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



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

#current_exhibit_themeObject



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

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


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

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


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

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)


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

Returns:

  • (Boolean)


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

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

#presenter(document) ⇒ Object



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

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

#show_contact_form?Boolean

Returns:

  • (Boolean)


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

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