Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions app/controllers/concerns/blacklight/controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,7 @@ module Blacklight::Controller
helper_method :has_user_authentication_provider?
helper_method :blacklight_config, :blacklight_configuration_context # move to Catalog
helper_method :search_action_url, :search_action_path
helper_method :search_state
end

# Which class to use for the search state. You can subclass SearchState if you
# want to override any of the methods (e.g. SearchState#url_for_document)
# TODO: move to Searchable
class_attribute :search_state_class
self.search_state_class = Blacklight::SearchState
end

# @private
Expand All @@ -55,13 +48,6 @@ def render_bookmarks_control?
has_user_authentication_provider? && current_or_guest_user.present?
end

# This must be on every controller that uses the layout, because it is used in
# the header to draw Blacklight::SearchNavbarComponent
# @return [Blacklight::SearchState] a memoized instance of the parameter state.
def search_state
@search_state ||= search_state_class.new(params, blacklight_config, self)
end

# Default route to the search action (used e.g. in global partials). Override this method
# in a controller or in your ApplicationController to introduce custom logic for choosing
# which action the search form should use
Expand Down
14 changes: 14 additions & 0 deletions app/controllers/concerns/blacklight/searchable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ module Blacklight::Searchable
# want to override any of the methods (e.g. SearchService#fetch)
class_attribute :search_service_class
self.search_service_class = Blacklight::SearchService

# Which class to use for the search state. You can subclass SearchState if you
# want to override any of the methods (e.g. SearchState#url_for_document)
class_attribute :search_state_class
self.search_state_class = Blacklight::SearchState

helper_method :search_state if respond_to? :helper_method
end

# @return [Blacklight::SearchService]
Expand All @@ -36,4 +43,11 @@ def search_service_context
def suggestions_service
Blacklight::SuggestSearch.new(params, search_service.repository).suggestions
end

# This must be on every controller that uses the layout, because it is used in
# the header to draw Blacklight::SearchNavbarComponent
# @return [Blacklight::SearchState] a memoized instance of the parameter state.
def search_state
@search_state ||= search_state_class.new(params, blacklight_config, self)
end
end
Loading