Sha256: c78b86ba293629679d343c4159a7a2dc1e7679988dc14f6172cdde5a896fc546

Contents?: true

Size: 1.84 KB

Versions: 11

Compression:

Stored size: 1.84 KB

Contents

module Spotlight
  ##
  # Index and read actions for browse (see {Spotlight::SearchesController}
  # for the curator's create-update-delete actions)
  class BrowseController < Spotlight::ApplicationController
    load_and_authorize_resource :exhibit, class: 'Spotlight::Exhibit'
    include Spotlight::Base

    load_and_authorize_resource :search, except: :index, through: :exhibit, parent: false
    before_action :attach_breadcrumbs
    record_search_parameters only: :show

    helper_method :should_render_spotlight_search_bar?

    def index
      @searches = @exhibit.searches.published
    end

    def show
      blacklight_config.index.document_actions = blacklight_config.browse.document_actions

      add_breadcrumb @search.title, exhibit_browse_path(@exhibit, @search)
      (@response, @document_list) = search_results(@search.query_params.with_indifferent_access.merge(params))
    end

    protected

    ##
    # Browsing an exhibit should start a new search session
    def start_new_search_session?
      params[:action] == 'show'
    end

    # WARNING: Blacklight::Catalog::SearchContext sets @searches in history_session in a before_filter
    # See https://github.com/projectblacklight/blacklight/pull/780
    def history_session
      # nop
    end

    def attach_breadcrumbs
      add_breadcrumb t(:'spotlight.exhibits.breadcrumb', title: @exhibit.title), @exhibit
      add_breadcrumb(@exhibit.main_navigations.browse.label_or_default, exhibit_browse_index_path(@exhibit))
    end

    def _prefixes
      @_prefixes ||= super + ['catalog']
    end

    def current_masthead
      if resource_masthead?
        @search.masthead
      else
        super
      end
    end

    def resource_masthead?
      @search && @search.masthead && @search.masthead.display?
    end

    def should_render_spotlight_search_bar?
      !resource_masthead?
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
blacklight-spotlight-0.23.0 app/controllers/spotlight/browse_controller.rb
blacklight-spotlight-0.22.0 app/controllers/spotlight/browse_controller.rb
blacklight-spotlight-0.21.0 app/controllers/spotlight/browse_controller.rb
blacklight-spotlight-0.20.3 app/controllers/spotlight/browse_controller.rb
blacklight-spotlight-0.20.2 app/controllers/spotlight/browse_controller.rb
blacklight-spotlight-0.20.1 app/controllers/spotlight/browse_controller.rb
blacklight-spotlight-0.20.0 app/controllers/spotlight/browse_controller.rb
blacklight-spotlight-0.19.2 app/controllers/spotlight/browse_controller.rb
blacklight-spotlight-0.19.1 app/controllers/spotlight/browse_controller.rb
blacklight-spotlight-0.19.0 app/controllers/spotlight/browse_controller.rb
blacklight-spotlight-0.18.0 app/controllers/spotlight/browse_controller.rb