Module: Spotlight::MainAppHelpers
Overview
Helpers that are injected into the main application (because they used in layouts)
Instance Method Summary
collapse
#should_render_spotlight_search_bar?
Instance Method Details
#cache_key_for_spotlight_exhibits ⇒ Object
6
7
8
|
# File 'app/helpers/spotlight/main_app_helpers.rb', line 6
def cache_key_for_spotlight_exhibits
"#{Spotlight::Exhibit.count}/#{Spotlight::Exhibit.maximum(:updated_at).try(:utc)}"
end
|
#enabled_in_spotlight_view_type_configuration?(config, *args) ⇒ Boolean
22
23
24
25
26
27
28
29
30
31
|
# File 'app/helpers/spotlight/main_app_helpers.rb', line 22
def enabled_in_spotlight_view_type_configuration?(config, *args)
case
when config.respond_to?(:upstream_if) && !config.upstream_if.nil? && !evaluate_configuration_conditional(config.upstream_if, config, *args)
false
when current_exhibit.nil? || controller.is_a?(Spotlight::PagesController)
true
else
current_exhibit.blacklight_configuration.document_index_view_types.include? config.key.to_s
end
end
|
#field_enabled?(field, *args) ⇒ Boolean
rubocop:disable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/MethodLength
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'app/helpers/spotlight/main_app_helpers.rb', line 34
def field_enabled?(field, *args)
case
when !field.enabled
false
when (field.respond_to?(:upstream_if) && !field.upstream_if.nil? && !evaluate_configuration_conditional(field.upstream_if, field, *args))
false
when field.is_a?(Blacklight::Configuration::SortField) || field.is_a?(Blacklight::Configuration::SearchField)
field.enabled
when field.is_a?(Blacklight::Configuration::FacetField) || (controller.is_a?(Blacklight::Catalog) && %w(edit show).include?(action_name))
field.show
else
field.send(document_index_view_type)
end
end
|
#link_back_to_catalog(opts = { label: nil }) ⇒ Object
rubocop:enable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/MethodLength
50
51
52
53
54
55
|
# File 'app/helpers/spotlight/main_app_helpers.rb', line 50
def link_back_to_catalog(opts = { label: nil })
if (current_search_session.try(:query_params) || {}).fetch(:controller, '').starts_with? 'spotlight'
opts[:route_set] ||= spotlight
end
super
end
|
#on_about_page? ⇒ Boolean
14
15
16
|
# File 'app/helpers/spotlight/main_app_helpers.rb', line 14
def on_about_page?
params[:controller] == 'spotlight/about_pages'
end
|
#on_browse_page? ⇒ Boolean
10
11
12
|
# File 'app/helpers/spotlight/main_app_helpers.rb', line 10
def on_browse_page?
params[:controller] == 'spotlight/browse'
end
|
18
19
20
|
# File 'app/helpers/spotlight/main_app_helpers.rb', line 18
def show_contact_form?
current_exhibit && current_exhibit.contact_emails.confirmed.any?
end
|