Module: Spotlight::MainAppHelpers

Includes:
MastheadHelper, NavbarHelper
Included in:
SpotlightHelper
Defined in:
app/helpers/spotlight/main_app_helpers.rb

Overview

Helpers that are injected into the main application (because they used in layouts)

Instance Method Summary collapse

Methods included from MastheadHelper

#masthead_heading_content, #masthead_subheading_content

Methods included from NavbarHelper

#should_render_spotlight_search_bar?

Instance Method Details

#cache_key_for_spotlight_exhibitsObject



10
11
12
# File 'app/helpers/spotlight/main_app_helpers.rb', line 10

def cache_key_for_spotlight_exhibits
  "#{Spotlight::Exhibit.count}/#{Spotlight::Exhibit.maximum(:updated_at).try(:utc)}"
end

#current_exhibit_themeObject



48
49
50
# File 'app/helpers/spotlight/main_app_helpers.rb', line 48

def current_exhibit_theme
  current_exhibit.theme if current_exhibit && current_exhibit.theme.present? && current_exhibit.themes.include?(current_exhibit.theme)
end

#document_presenter_class(_document) ⇒ Object



31
32
33
34
35
36
37
# File 'app/helpers/spotlight/main_app_helpers.rb', line 31

def document_presenter_class(_document)
  if action_name == 'index'
    super
  else
    blacklight_config.view_config(action_name: :show).document_presenter_class
  end
end


39
40
41
42
43
44
45
46
# File 'app/helpers/spotlight/main_app_helpers.rb', line 39

def exhibit_stylesheet_link_tag(tag)
  if current_exhibit_theme && current_exhibit&.theme != 'default'
    stylesheet_link_tag "#{tag}_#{current_exhibit_theme}"
  else
    Rails.logger.warn "Exhibit theme '#{current_exhibit_theme}' not in the list of available themes: #{current_exhibit&.themes}"
    stylesheet_link_tag(tag)
  end
end


26
27
28
29
# File 'app/helpers/spotlight/main_app_helpers.rb', line 26

def link_back_to_catalog(opts = { label: nil })
  opts[:route_set] ||= spotlight if (current_search_session&.query_params || {}).fetch(:controller, '').starts_with? 'spotlight'
  super
end

#on_about_page?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'app/helpers/spotlight/main_app_helpers.rb', line 18

def on_about_page?
  params[:controller] == 'spotlight/about_pages'
end

#on_browse_page?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'app/helpers/spotlight/main_app_helpers.rb', line 14

def on_browse_page?
  params[:controller] == 'spotlight/browse'
end

#show_contact_form?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'app/helpers/spotlight/main_app_helpers.rb', line 22

def show_contact_form?
  current_exhibit && (Spotlight::Engine.config.default_contact_email || current_exhibit.contact_emails.confirmed.any?)
end