Module: Spotlight::MainAppHelpers

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

Instance Method Summary collapse

Methods included from NavbarHelper

#should_render_spotlight_search_bar?

Instance Method Details

#cache_key_for_spotlight_exhibitsObject



3
4
5
# File 'app/helpers/spotlight/main_app_helpers.rb', line 3

def cache_key_for_spotlight_exhibits
  Spotlight::Exhibit.maximum(:updated_at).try(:utc).try(:to_s, :number)
end

#enabled_in_spotlight_view_type_configuration?(config, *args) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
22
23
24
25
26
27
28
29
# File 'app/helpers/spotlight/main_app_helpers.rb', line 19

def enabled_in_spotlight_view_type_configuration? config, *args
  if config.respond_to? :upstream_if and !config.upstream_if.nil?
    return false unless evaluate_configuration_conditional(config.upstream_if, config, *args)
  end

  return true unless current_exhibit

  return true if controller.is_a? Spotlight::PagesController

  return current_exhibit.blacklight_configuration.document_index_view_types.include? config.key.to_s
end

#field_enabled?(field, *args) ⇒ Boolean

Returns:

  • (Boolean)


31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/helpers/spotlight/main_app_helpers.rb', line 31

def field_enabled? field, *args
  return false unless field.enabled

  if field.respond_to? :upstream_if and !field.upstream_if.nil?
    return false unless evaluate_configuration_conditional(field.upstream_if, field, *args)
  end

  if field.is_a? Blacklight::Configuration::SortField
    field.enabled
  elsif field.is_a?(Blacklight::Configuration::FacetField) or (controller.is_a?(Blacklight::Catalog) and ["edit", "show"].include?(action_name))
    field.show
  else
    field.send(document_index_view_type)
  end
end


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

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)


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

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

#on_browse_page?Boolean

Returns:

  • (Boolean)


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

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

#show_contact_form?Boolean

Returns:

  • (Boolean)


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

def show_contact_form?
  current_exhibit && current_exhibit.contact_emails.confirmed.any?
end