Module: Spotlight::Concerns::ApplicationController

Extended by:
ActiveSupport::Concern
Includes:
Spotlight::Controller
Included in:
ApplicationController, Spotlight::CatalogController
Defined in:
app/controllers/spotlight/concerns/application_controller.rb

Overview

Inherit from the host app’s ApplicationController This will configure e.g. the layout used by the host

Instance Method Summary collapse

Methods included from Spotlight::Controller

#blacklight_config, #current_exhibit, #current_masthead, #current_masthead=, #current_site, #exhibit_masthead?, #exhibit_search_action_url, #exhibit_search_facet_url, #resource_masthead?, #search_action_url, #search_facet_url

Methods included from Spotlight::Config

#exhibit_specific_blacklight_config

Instance Method Details

#enabled_in_spotlight_view_type_configuration?(config, *args) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
32
33
34
35
36
37
38
39
# File 'app/controllers/spotlight/concerns/application_controller.rb', line 29

def enabled_in_spotlight_view_type_configuration?(config, *args)
  if config.respond_to?(:upstream_if) &&
     !config.upstream_if.nil? &&
     !blacklight_configuration_context.evaluate_configuration_conditional(config.upstream_if, config, *args)
    false
  elsif current_exhibit.nil? || 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

Returns:

  • (Boolean)


42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'app/controllers/spotlight/concerns/application_controller.rb', line 42

def field_enabled?(field, *args)
  if !field.enabled
    false
  elsif field.respond_to?(:upstream_if) &&
        !field.upstream_if.nil? &&
        !blacklight_configuration_context.evaluate_configuration_conditional(field.upstream_if, field, *args)
    false
  elsif field.is_a?(Blacklight::Configuration::SortField) || field.is_a?(Blacklight::Configuration::SearchField)
    field.enabled
  elsif field.is_a?(Blacklight::Configuration::FacetField) || (is_a?(Blacklight::Catalog) && %w(edit show).include?(action_name))
    field.show
  else
    field.send(document_index_view_type)
  end
end