Skip to content

Commit

Permalink
Fix for issue with lucene query parser missing from VM
Browse files Browse the repository at this point in the history
  • Loading branch information
cjcolvar committed Sep 18, 2015
1 parent ce78ba7 commit 5d52708
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions app/controllers/bookmarks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@

class BookmarksController < CatalogController
include Blacklight::Bookmarks

#HACK next two lines are a hack for problems in the puppet VM tomcat/solr
BookmarksController.search_params_logic -= [:add_query_to_solr]
BookmarksController.search_params_logic += [:rewrite_bookmarks_search]

blacklight_config.show.document_actions[:email].if = false if blacklight_config.show.document_actions[:email]
blacklight_config.show.document_actions[:citation].if = false if blacklight_config.show.document_actions[:citation]
Expand All @@ -30,6 +34,23 @@ class BookmarksController < CatalogController

before_filter :verify_permissions, only: :index

#HACK next two methods are a hack for problems in the puppet VM tomcat/solr
def rewrite_bookmarks_search(solr_parameters, user_parameters)
solr_parameters[:q] = "id:(#{ Array(user_parameters[:q][:id]).map { |x| solr_escape(x) }.join(' OR ')})"
end

def solr_escape val, options={}
options[:quote] ||= '"'
unless val =~ /^[a-zA-Z0-9$_\-\^]+$/
val = options[:quote] +
# Yes, we need crazy escaping here, to deal with regexp esc too!
val.gsub("'", "\\\\\'").gsub('"', "\\\\\"") +
options[:quote]
end
return val
end


def user_can? action
@valid_user_actions.include? action
end
Expand Down

0 comments on commit 5d52708

Please sign in to comment.