Module: Blacklight::CatalogHelper
- Included in:
- AssetsController, CatalogController
- Defined in:
- lib/blacklight/catalog_helper.rb
Overview
Note: not sure we’re still using this in hydrangea… This is a replica of some methods that are in Blacklight’s CatalogController that we wanted to re-use in other controllers
Instance Method Summary (collapse)
-
- (Object) history_session
sets up the session[:history] hash if it doesn’t already exist.
-
- (Object) search_session
sets up the session[:search] hash if it doesn’t already exist.
-
- (Object) setup_document_by_counter(counter)
gets a document based on its position within a resultset.
-
- (Object) setup_next_and_previous_documents
calls setup_previous_document then setup_next_document.
- - (Object) setup_next_document
- - (Object) setup_previous_document
Instance Method Details
- (Object) history_session
sets up the session[:history] hash if it doesn’t already exist. assigns all Search objects (that match the searches in session[:history]) to a variable @searches.
39 40 41 42 |
# File 'lib/blacklight/catalog_helper.rb', line 39 def history_session session[:history] ||= [] @searches = searches_from_history # <- in ApplicationController end |
- (Object) search_session
sets up the session[:search] hash if it doesn’t already exist
33 34 35 |
# File 'lib/blacklight/catalog_helper.rb', line 33 def search_session session[:search] ||= {} end |
- (Object) setup_document_by_counter(counter)
gets a document based on its position within a resultset
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/blacklight/catalog_helper.rb', line 12 def setup_document_by_counter(counter) return if counter < 1 || session[:search].blank? # need to duplicate search session hash so we aren't modifying the original (and don't get the qt in the Back to search results link) search = session[:search].dup || {} # enforcing search restrictions # if the user is not a reader then use the pulic qt, otherwise use the default qt (using logic from enforce_search_permissions method) if !reader? search[:qt] = Blacklight.config[:public_qt] end get_single_doc_via_search(search.merge({:page => counter})) end |
- (Object) setup_next_and_previous_documents
calls setup_previous_document then setup_next_document. used in the show action for single view pagination.
6 7 8 9 |
# File 'lib/blacklight/catalog_helper.rb', line 6 def setup_next_and_previous_documents setup_previous_document setup_next_document end |
- (Object) setup_next_document
28 29 30 |
# File 'lib/blacklight/catalog_helper.rb', line 28 def setup_next_document @next_document = session[:search][:counter] ? setup_document_by_counter(session[:search][:counter].to_i + 1) : nil end |
- (Object) setup_previous_document
24 25 26 |
# File 'lib/blacklight/catalog_helper.rb', line 24 def setup_previous_document @previous_document = session[:search][:counter] ? setup_document_by_counter(session[:search][:counter].to_i - 1) : nil end |