Module: Spotlight::MainAppHelpers

Includes:
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 NavbarHelper

#should_render_spotlight_search_bar?

Instance Method Details

#cache_key_for_spotlight_exhibitsObject



8
9
10
# File 'app/helpers/spotlight/main_app_helpers.rb', line 8

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

#current_exhibit_themeObject



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

def current_exhibit_theme
  current_exhibit.theme if current_exhibit && current_exhibit.theme.present? && Spotlight::Engine.config.exhibit_themes.include?(current_exhibit.theme)
end


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

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 white-list of available themes: #{Spotlight::Engine.config.exhibit_themes}"
    stylesheet_link_tag(tag)
  end
end


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

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

Returns:

  • (Boolean)


16
17
18
# File 'app/helpers/spotlight/main_app_helpers.rb', line 16

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

#on_browse_page?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'app/helpers/spotlight/main_app_helpers.rb', line 12

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

#presenter(document) ⇒ Object



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

def presenter(document)
  case action_name
  when 'index'
    super
  else
    show_presenter(document)
  end
end

#show_contact_form?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'app/helpers/spotlight/main_app_helpers.rb', line 20

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