app/controllers/spotlight/solr_controller.rb in blacklight-spotlight-0.4.1 vs app/controllers/spotlight/solr_controller.rb in blacklight-spotlight-0.5.0
- old
+ new
@@ -1,19 +1,26 @@
-class Spotlight::SolrController < Spotlight::ApplicationController
- before_filter :authenticate_user!
- load_and_authorize_resource :exhibit, class: Spotlight::Exhibit
+module Spotlight
+ ##
+ # Proxy update requests to Solr and inject spotlight's exhibit
+ # specific fields.
+ #
+ # This is an example of how you could integrate external indexing
+ # workflows with exhibit-specific content
+ class SolrController < Spotlight::ApplicationController
+ before_action :authenticate_user!
+ load_and_authorize_resource :exhibit, class: Spotlight::Exhibit
- def update
- authorize! :update_solr, @exhibit
+ def update
+ authorize! :update_solr, @exhibit
- req = ActiveSupport::JSON.decode(request.body.read)
+ req = ActiveSupport::JSON.decode(request.body.read)
- docs = Array.wrap(req).map do |r|
- SolrDocument.new(r).to_solr.merge(@exhibit.solr_data).merge(r)
- end
+ docs = Array.wrap(req).map do |r|
+ blacklight_config.document_model.new(r).to_solr.merge(@exhibit.solr_data).merge(r)
+ end
- blacklight_solr.update docs
+ blacklight_solr.update docs
- render nothing: true
+ render nothing: true
+ end
end
-
-end
\ No newline at end of file
+end