Class: Spotlight::BlacklightConfigurationsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- Spotlight::BlacklightConfigurationsController
- Includes:
- Blacklight::SearchHelper
- Defined in:
- app/controllers/spotlight/blacklight_configurations_controller.rb
Instance Method Summary collapse
-
#alternate_count ⇒ Object
the luke request handler can return document counts, but the seem to be incorrect.
- #available_search_views ⇒ Object
-
#edit_facet_fields ⇒ Object
Edit the index and show view metadata fields.
-
#edit_metadata_fields ⇒ Object
Edit the index and show view metadata fields.
-
#edit_sort_fields ⇒ Object
Edit the index and show view metadata fields.
- #metadata_fields ⇒ Object
- #update ⇒ Object
Methods included from Controller
#blacklight_config, #current_exhibit, #current_masthead, #current_masthead=, #default_masthead?, #exhibit_masthead?, #exhibit_search_action_url, #exhibit_search_facet_url, #search_action_url, #search_facet_url
Methods included from Config
#exhibit_specific_blacklight_config
Instance Method Details
#alternate_count ⇒ Object
the luke request handler can return document counts, but the seem to be incorrect. They seem to be for the whole index and they decrease after optimizing. This method finds those counts by doing regular facet queries
65 66 67 68 69 70 71 72 73 |
# File 'app/controllers/spotlight/blacklight_configurations_controller.rb', line 65 def alternate_count @alt_count ||= begin facet_query = @blacklight_configuration.blacklight_config.facet_fields.reject { |k, v| v.pivot || v.query }.map { |key, fields| "#{fields.field}:[* TO *]" } solr_resp = repository.search('facet.query' => facet_query, 'rows' =>0, 'facet' => true) @alt_count = solr_resp['facet_counts']['facet_queries'].each_with_object({}) do |(key, val), alt_count| alt_count[key.split(/:/).first] = val end end end |
#available_search_views ⇒ Object
30 31 32 33 34 |
# File 'app/controllers/spotlight/blacklight_configurations_controller.rb', line 30 def available_search_views respond_to do |format| format.json { render json: @blacklight_configuration.default_blacklight_config.view.to_h.reject { |k,v| v.if === false}.keys } end end |
#edit_facet_fields ⇒ Object
Edit the index and show view metadata fields
46 47 48 49 50 51 |
# File 'app/controllers/spotlight/blacklight_configurations_controller.rb', line 46 def edit_facet_fields t(:'spotlight.exhibits.breadcrumb', title: @exhibit.title), @exhibit t(:'spotlight.curation.sidebar.header'), exhibit_dashboard_path(@exhibit) t(:'spotlight.curation.sidebar.search_facets'), exhibit_edit_facets_path(@exhibit) @fields = repository.send_and_receive('admin/luke', fl: '*', 'json.nl' => 'map')['fields'] end |
#edit_metadata_fields ⇒ Object
Edit the index and show view metadata fields
38 39 40 41 42 |
# File 'app/controllers/spotlight/blacklight_configurations_controller.rb', line 38 def t(:'spotlight.exhibits.breadcrumb', title: @exhibit.title), @exhibit t(:'spotlight.curation.sidebar.header'), exhibit_dashboard_path(@exhibit) t(:'spotlight.curation.sidebar.metadata'), (@exhibit) end |
#edit_sort_fields ⇒ Object
Edit the index and show view metadata fields
55 56 57 58 59 |
# File 'app/controllers/spotlight/blacklight_configurations_controller.rb', line 55 def edit_sort_fields t(:'spotlight.exhibits.breadcrumb', title: @exhibit.title), @exhibit t(:'spotlight.curation.sidebar.header'), exhibit_dashboard_path(@exhibit) t(:'spotlight.curation.sidebar.sort_fields'), exhibit_edit_sort_fields_path(@exhibit) end |
#metadata_fields ⇒ Object
24 25 26 27 28 |
# File 'app/controllers/spotlight/blacklight_configurations_controller.rb', line 24 def respond_to do |format| format.json { render json: @blacklight_configuration.blacklight_config.index_fields.as_json } end end |
#update ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/controllers/spotlight/blacklight_configurations_controller.rb', line 8 def update if @blacklight_configuration.update(exhibit_params) flash[:notice] = t(:'helpers.submit.blacklight_configuration.updated', model: @blacklight_configuration.class.model_name.human.downcase) end if params[:blacklight_configuration][:index_fields] redirect_to (@exhibit) elsif params[:blacklight_configuration][:facet_fields] redirect_to exhibit_edit_facets_path(@exhibit) elsif params[:blacklight_configuration][:sort_fields] redirect_to exhibit_edit_sort_fields_path(@exhibit) else redirect_to exhibit_dashboard_path(@exhibit) end end |