Module: Atrium::AtriumHelperBehavior
- Includes:
- BlacklightHelper, FacetsHelper
- Included in:
- BaseController, BaseHelper
- Defined in:
- lib/atrium/atrium_helper_behavior.rb
Instance Method Summary collapse
- #application_name ⇒ Object
-
#extra_head_content ⇒ Object
An array of strings to be added to HTML HEAD section of view.
-
#facet_limit_for(facet_field) ⇒ Object
If collection is defined and in an collection browse view then do not set limit on facet values displayed.
- #get_start_over_path ⇒ Object
-
#javascript_includes ⇒ Object
Array, where each element is an array of arguments to Rails javascript_include_tag helper.
-
#link_back_to_catalog(opts = {:label=>'Back to Search'}) ⇒ Object
Override this from BlacklightHelper so we can have a link back to browsing a collection Create a link back to the index screen, keeping the user’s facet, query and paging choices intact by using session.
-
#link_to_document(doc, opts = {:label=>blacklight_config.index.show_link.to_sym, :counter => nil, :results_view => true}) ⇒ Object
link_to_document(doc, :label=>‘VIEW’, :counter => 3) Use the catalog_path RESTful route to create a link to the show page for a specific item.
-
#render_constraints(localized_params = params) ⇒ Object
Overriding so that it will not show facet constraints if selecting featured items because we should not be able to remove facet selections that are setting proper search scope for a browse page.
-
#render_facet_limit(display_facet, options = {}) ⇒ Object
used in the catalog/_facets partial def facet_field_names if params && params == ‘catalog’ && params = ‘index’ logger.debug(“Into get facets”) collection = @atrium_collection? @atrium_collection : Atrium::Collection.find(params) if collection collection.search_facets.collect {|f| f.name} end else super end end.
- #save_collection_id_in_session(collection_id) ⇒ Object
- #save_exhibit_id_in_session(exhibit_id) ⇒ Object
- #set_edit_showcase_in_session ⇒ Object
-
#stylesheet_links ⇒ Object
Array, where each element is an array of arguments to Rails stylesheet_link_tag helper.
Instance Method Details
#application_name ⇒ Object
7 8 9 |
# File 'lib/atrium/atrium_helper_behavior.rb', line 7 def application_name 'Atrium Application' end |
#extra_head_content ⇒ Object
An array of strings to be added to HTML HEAD section of view.
12 13 14 |
# File 'lib/atrium/atrium_helper_behavior.rb', line 12 def extra_head_content @extra_head_content ||= [] end |
#facet_limit_for(facet_field) ⇒ Object
If collection is defined and in an collection browse view then do not set limit on facet values displayed. Otherwise use code lifted from catalog controller in blacklight plugin
104 105 106 107 108 109 110 111 112 |
# File 'lib/atrium/atrium_helper_behavior.rb', line 104 def facet_limit_for(facet_field) #if (params[:collection_id] && !params[:render_search].blank?) if params[:controller] == "catalog" super else nil end end |
#get_start_over_path ⇒ Object
151 152 153 154 155 156 157 |
# File 'lib/atrium/atrium_helper_behavior.rb', line 151 def get_start_over_path if (params[:collection_id]) atrium_collection_home_path(params[:collection_id]) else catalog_index_path end end |
#javascript_includes ⇒ Object
Array, where each element is an array of arguments to Rails javascript_include_tag helper. See ApplicationHelper#render_head_content for details.
27 28 29 |
# File 'lib/atrium/atrium_helper_behavior.rb', line 27 def javascript_includes @javascript_includes ||= [] end |
#link_back_to_catalog(opts = {:label=>'Back to Search'}) ⇒ Object
Override this from BlacklightHelper so we can have a link back to browsing a collection Create a link back to the index screen, keeping the user’s facet, query and paging choices intact by using session.
127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/atrium/atrium_helper_behavior.rb', line 127 def link_back_to_catalog(opts={:label=>'Back to Search'}) if params[:atrium_collection_browse] params[:controller] == "atrium_collections" ? collection_id = params[:id] : collection_id = params[:collection_id] link_to "Back to Browse Collection", atrium_collection_path(collection_id) elsif params[:atrium_exhibit_browse] params[:controller] == "atrium_exhibits" ? exhibit_id = params[:id] : exhibit_id = params[:exhibit_id] link_to "Back to Browse Exhibit", atrium_exhibit_path(exhibit_id,:f=>params[:f]) else super end end |
#link_to_document(doc, opts = {:label=>blacklight_config.index.show_link.to_sym, :counter => nil, :results_view => true}) ⇒ Object
link_to_document(doc, :label=>‘VIEW’, :counter => 3) Use the catalog_path RESTful route to create a link to the show page for a specific item. catalog_path accepts a HashWithIndifferentAccess object. The solr query params are stored in the session, so we only need the counter
param here. We also need to know if we are viewing to document as part of search results.
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/atrium/atrium_helper_behavior.rb', line 68 def link_to_document(doc, opts={:label=>blacklight_config.index.show_link.to_sym, :counter => nil, :results_view => true}) collection_id = params[:controller] == "atrium/collections" ? params[:id] : params[:collection_id] exhibit_id = params[:controller] == "atrium/exhibits" ? params[:id] : params[:exhibit_id] label = render_document_index_label doc, opts args = {} args.merge!(:f=>params[:f]) if params[:f] #&& params[:controller] != "catalog" #try to retrieve collection id if not set if exhibit_id && !collection_id begin exhibit = Atrium::Exhibit.find(exhibit_id) collection_id = exhibit.collection.id if exhibit && exhibit.collection rescue end end args.merge!(:'data-counter' => opts[:counter]) if exhibit_id && collection_id #link_to_with_data(label, atrium_collection_exhibit_browse_path(collection_id, exhibit_id, doc.id, args), {:method => :put, :class => label.parameterize, :data => opts}).html_safe label = render_document_index_label doc, opts link_to label, atrium_collection_exhibit_browse_path(collection_id, exhibit_id, doc.id, args) #elsif exhibit_id # link_to_with_data(label, atrium_exhibit_browse_path(exhibit_id, doc.id, args), {:method => :put, :class => label.parameterize, :data => opts}).html_safe elsif collection_id params[:controller] == "catalog" ? current_path = atrium_collection_catalog_path(collection_id, doc.id, args) : current_path = atrium_collection_browse_path(collection_id, doc.id, args) label = render_document_index_label doc, opts link_to label, current_path, :'data-counter' => opts[:counter] #link_to_with_data(label, current_path, {:method => :put, :class => label.parameterize, :data => opts}).html_safe else super end end |
#render_constraints(localized_params = params) ⇒ Object
Overriding so that it will not show facet constraints if selecting featured items because we should not be able to remove facet selections that are setting proper search scope for a browse page
117 118 119 120 121 122 123 |
# File 'lib/atrium/atrium_helper_behavior.rb', line 117 def render_constraints(localized_params = params) if params[:add_featured] (render_constraints_query(localized_params)).html_safe else (render_constraints_query(localized_params) + render_constraints_filters(localized_params)).html_safe end end |
#render_facet_limit(display_facet, options = {}) ⇒ Object
used in the catalog/_facets partial def facet_field_names
if params[:collection_id] && params[:controller] == 'catalog' && params[:action] = 'index'
logger.debug("Into get facets")
collection = @atrium_collection? @atrium_collection : Atrium::Collection.find(params[:collection_id])
if collection
collection.search_facets.collect {|f| f.name}
end
else
super
end
end
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/atrium/atrium_helper_behavior.rb', line 44 def render_facet_limit(display_facet, = {}) if params[:edit_exhibit_filter] || params[:edit_collection_filter] || params[:edit_browse_level_filter] || params[:add_featured] || params[:exclude_browse_level_filter] if display_facet.is_a? String or display_facet.is_a? Symbol $stderr.puts "............... DEPRECATION WARNING: Blacklight::FacetsHelper#render_facet_limit: use #render_facet_partials to render facets by field name" return render_facet_partials([display_facet]) end = .dup [:partial] ||= facet_partial_name(display_facet) [:layout] ||= "facet_layout" unless .has_key?(:layout) [:locals] ||= {} [:locals][:solr_field] ||= display_facet.name [:locals][:solr_fname] ||= display_facet.name # DEPRECATED [:locals][:facet_field] ||= facet_configuration_for_field(display_facet.name) [:locals][:display_facet] ||= display_facet render() else super end end |
#save_collection_id_in_session(collection_id) ⇒ Object
139 140 141 |
# File 'lib/atrium/atrium_helper_behavior.rb', line 139 def save_collection_id_in_session(collection_id) session[:collection_id] = collection_id end |
#save_exhibit_id_in_session(exhibit_id) ⇒ Object
143 144 145 |
# File 'lib/atrium/atrium_helper_behavior.rb', line 143 def save_exhibit_id_in_session(exhibit_id) session[:exhibit_id] = exhibit_id end |
#set_edit_showcase_in_session ⇒ Object
147 148 149 |
# File 'lib/atrium/atrium_helper_behavior.rb', line 147 def set_edit_showcase_in_session session[:edit_showcase] = true end |
#stylesheet_links ⇒ Object
Array, where each element is an array of arguments to Rails stylesheet_link_tag helper. See ApplicationHelper#render_head_content for details.
20 21 22 |
# File 'lib/atrium/atrium_helper_behavior.rb', line 20 def stylesheet_links @stylesheet_links ||= [] end |