Module: Spotlight::Controller

Extended by:
ActiveSupport::Concern
Includes:
Blacklight::Controller, Config
Included in:
Spotlight::Concerns::ApplicationController
Defined in:
app/controllers/concerns/spotlight/controller.rb

Overview

Spotlight controller helpers

Instance Method Summary collapse

Methods included from Config

#exhibit_specific_blacklight_config

Instance Method Details

#blacklight_configObject

overwrites Blacklight::Controller#blacklight_config



47
48
49
50
51
52
53
# File 'app/controllers/concerns/spotlight/controller.rb', line 47

def blacklight_config
  if current_exhibit
    exhibit_specific_blacklight_config
  else
    default_catalog_controller.blacklight_config
  end
end

#current_exhibitObject



17
18
19
# File 'app/controllers/concerns/spotlight/controller.rb', line 17

def current_exhibit
  @exhibit
end

#current_mastheadObject



21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/controllers/concerns/spotlight/controller.rb', line 21

def current_masthead
  @masthead ||= if resource_masthead?
                  # TODO: is there a way to get this generically, instead of requiring controllers
                  #  to override #current_masthead or set it explicitly?. In the meantime, `nil` is
                  #  hopefully less confusing than a wrong value.
                  nil
                elsif current_exhibit
                  current_exhibit.masthead if exhibit_masthead?
                else
                  current_site.masthead if current_site.masthead && current_site.masthead.display?
                end
end

#current_masthead=(masthead) ⇒ Object



34
35
36
# File 'app/controllers/concerns/spotlight/controller.rb', line 34

def current_masthead=(masthead)
  @masthead = masthead
end

#current_siteObject



13
14
15
# File 'app/controllers/concerns/spotlight/controller.rb', line 13

def current_site
  @current_site ||= Spotlight::Site.instance
end

#exhibit_masthead?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'app/controllers/concerns/spotlight/controller.rb', line 42

def exhibit_masthead?
  current_exhibit && current_exhibit.masthead && current_exhibit.masthead.display?
end

#exhibit_search_action_url(*args) ⇒ Object



71
72
73
74
75
76
77
78
79
80
81
# File 'app/controllers/concerns/spotlight/controller.rb', line 71

def exhibit_search_action_url(*args)
  options = args.extract_options!
  only_path = options[:only_path]
  options.except! :exhibit_id, :only_path

  if only_path
    spotlight.exhibit_catalog_index_path(current_exhibit, *args, options)
  else
    spotlight.exhibit_catalog_index_url(current_exhibit, *args, options)
  end
end

#exhibit_search_facet_url(*args) ⇒ Object



83
84
85
86
87
88
89
90
91
92
93
# File 'app/controllers/concerns/spotlight/controller.rb', line 83

def exhibit_search_facet_url(*args)
  options = args.extract_options!
  only_path = options[:only_path]
  options = params.merge(options).except(:exhibit_id, :only_path)

  if only_path
    spotlight.exhibit_catalog_facet_url(current_exhibit, *args, options)
  else
    spotlight.exhibit_catalog_facet_url(current_exhibit, *args, options)
  end
end

#resource_masthead?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'app/controllers/concerns/spotlight/controller.rb', line 38

def resource_masthead?
  false
end

#search_action_url(*args) ⇒ Object



55
56
57
58
59
60
61
# File 'app/controllers/concerns/spotlight/controller.rb', line 55

def search_action_url(*args)
  if current_exhibit
    exhibit_search_action_url(*args)
  else
    main_app.catalog_index_url(*args)
  end
end

#search_facet_url(*args) ⇒ Object



63
64
65
66
67
68
69
# File 'app/controllers/concerns/spotlight/controller.rb', line 63

def search_facet_url(*args)
  if current_exhibit
    exhibit_search_facet_url(*args)
  else
    main_app.catalog_facet_url(*args)
  end
end