Module: Spotlight::Controller
Overview
Spotlight controller helpers
Instance Method Summary
collapse
Methods included from Config
#exhibit_specific_blacklight_config
Instance Method Details
#blacklight_config ⇒ Object
overwrites Blacklight::Controller#blacklight_config
60
61
62
63
64
65
66
|
# File 'app/controllers/concerns/spotlight/controller.rb', line 60
def blacklight_config
if current_exhibit
exhibit_specific_blacklight_config
else
default_catalog_controller.blacklight_config
end
end
|
#current_exhibit ⇒ Object
22
23
24
|
# File 'app/controllers/concerns/spotlight/controller.rb', line 22
def current_exhibit
@exhibit || (Spotlight::Exhibit.find(params[:exhibit_id]) if params[:exhibit_id].present?)
end
|
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'app/controllers/concerns/spotlight/controller.rb', line 26
def current_masthead
@masthead ||= if resource_masthead?
nil
elsif current_exhibit
current_exhibit.masthead if exhibit_masthead?
elsif current_site.masthead && current_site.masthead.display?
current_site.masthead
end
end
|
39
40
41
|
# File 'app/controllers/concerns/spotlight/controller.rb', line 39
def current_masthead=(masthead)
@masthead = masthead
end
|
#current_site ⇒ Object
18
19
20
|
# File 'app/controllers/concerns/spotlight/controller.rb', line 18
def current_site
@current_site ||= Spotlight::Site.instance
end
|
#default_url_options ⇒ Object
55
56
57
|
# File 'app/controllers/concerns/spotlight/controller.rb', line 55
def default_url_options
super.merge(locale: (I18n.locale if I18n.locale != I18n.default_locale))
end
|
47
48
49
|
# File 'app/controllers/concerns/spotlight/controller.rb', line 47
def exhibit_masthead?
current_exhibit && current_exhibit.masthead && current_exhibit.masthead.display?
end
|
#exhibit_search_action_url(*args) ⇒ Object
84
85
86
87
88
89
90
91
92
93
94
|
# File 'app/controllers/concerns/spotlight/controller.rb', line 84
def exhibit_search_action_url(*args)
options = args.
only_path = options[:only_path]
options.except! :exhibit_id, :only_path
if only_path
spotlight.search_exhibit_catalog_path(current_exhibit, *args, options)
else
spotlight.search_exhibit_catalog_url(current_exhibit, *args, options)
end
end
|
#exhibit_search_facet_url(*args) ⇒ Object
96
97
98
99
100
|
# File 'app/controllers/concerns/spotlight/controller.rb', line 96
def exhibit_search_facet_url(*args)
options = args.
options = Blacklight::Parameters.sanitize(params.to_unsafe_h.with_indifferent_access).merge(options).except(:exhibit_id, :only_path)
spotlight.facet_exhibit_catalog_url(current_exhibit, *args, options)
end
|
43
44
45
|
# File 'app/controllers/concerns/spotlight/controller.rb', line 43
def resource_masthead?
false
end
|
#search_action_url(*args) ⇒ Object
68
69
70
71
72
73
74
|
# File 'app/controllers/concerns/spotlight/controller.rb', line 68
def search_action_url(*args)
if current_exhibit
exhibit_search_action_url(*args)
else
main_app.search_catalog_url(*args)
end
end
|
#search_facet_url(*args) ⇒ Object
76
77
78
79
80
81
82
|
# File 'app/controllers/concerns/spotlight/controller.rb', line 76
def search_facet_url(*args)
if current_exhibit
exhibit_search_facet_url(*args)
else
main_app.catalog_facet_url(*args)
end
end
|
#set_exhibit_locale_scope ⇒ Object
14
15
16
|
# File 'app/controllers/concerns/spotlight/controller.rb', line 14
def set_exhibit_locale_scope
Translation.current_exhibit = current_exhibit
end
|
#set_locale ⇒ Object
51
52
53
|
# File 'app/controllers/concerns/spotlight/controller.rb', line 51
def set_locale
I18n.locale = params[:locale] || I18n.default_locale
end
|