Module: Spotlight::Controller
Overview
Spotlight controller helpers
Instance Method Summary
collapse
Methods included from Config
#exhibit_specific_blacklight_config
Instance Method Details
#add_breadcrumb(name, path = nil, _current = nil) ⇒ Object
30
31
32
|
# File 'app/controllers/concerns/spotlight/controller.rb', line 30
def add_breadcrumb(name, path = nil, _current = nil)
breadcrumbs << Breadcrumb.new(name, path)
end
|
#blacklight_config ⇒ Object
overwrites Blacklight::Controller#blacklight_config
72
73
74
75
76
77
78
|
# File 'app/controllers/concerns/spotlight/controller.rb', line 72
def blacklight_config
if current_exhibit
exhibit_specific_blacklight_config
else
default_catalog_controller.blacklight_config
end
end
|
#breadcrumbs ⇒ Object
26
27
28
|
# File 'app/controllers/concerns/spotlight/controller.rb', line 26
def breadcrumbs
@breadcrumbs ||= []
end
|
#current_exhibit ⇒ Object
34
35
36
|
# File 'app/controllers/concerns/spotlight/controller.rb', line 34
def current_exhibit
@exhibit || (Spotlight::Exhibit.find(params[:exhibit_id]) if params[:exhibit_id].present?)
end
|
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'app/controllers/concerns/spotlight/controller.rb', line 38
def current_masthead
@masthead ||= if resource_masthead?
nil
elsif current_exhibit
current_exhibit.masthead if exhibit_masthead?
elsif current_site.masthead&.display?
current_site.masthead
end
end
|
51
52
53
|
# File 'app/controllers/concerns/spotlight/controller.rb', line 51
def current_masthead=(masthead)
@masthead = masthead
end
|
#current_site ⇒ Object
22
23
24
|
# File 'app/controllers/concerns/spotlight/controller.rb', line 22
def current_site
@current_site ||= Spotlight::Site.instance
end
|
#default_url_options ⇒ Object
67
68
69
|
# File 'app/controllers/concerns/spotlight/controller.rb', line 67
def default_url_options
super.merge(locale: (I18n.locale if I18n.locale != I18n.default_locale))
end
|
59
60
61
|
# File 'app/controllers/concerns/spotlight/controller.rb', line 59
def exhibit_masthead?
current_exhibit&.masthead && current_exhibit.masthead.display?
end
|
#exhibit_search_action_url(*args, **kwargs) ⇒ Object
104
105
106
107
108
109
110
111
112
113
114
115
|
# File 'app/controllers/concerns/spotlight/controller.rb', line 104
def exhibit_search_action_url(*args, **kwargs)
options = args.
options = options.merge(kwargs)
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_path(*args, **kwargs) ⇒ Object
117
118
119
120
121
|
# File 'app/controllers/concerns/spotlight/controller.rb', line 117
def exhibit_search_facet_path(*args, **kwargs)
options = args.
options = Blacklight::Parameters.sanitize(params.to_unsafe_h.with_indifferent_access).merge(options).merge(kwargs).except(:exhibit_id, :only_path)
spotlight.facet_exhibit_catalog_url(current_exhibit, *args, **options&.symbolize_keys)
end
|
55
56
57
|
# File 'app/controllers/concerns/spotlight/controller.rb', line 55
def resource_masthead?
false
end
|
#search_action_url(*args, **kwargs) ⇒ Object
88
89
90
91
92
93
94
|
# File 'app/controllers/concerns/spotlight/controller.rb', line 88
def search_action_url(*args, **kwargs)
if current_exhibit
exhibit_search_action_url(*args, **kwargs)
else
main_app.search_catalog_url(*args, **kwargs)
end
end
|
#search_facet_path(*args, **kwargs) ⇒ Object
96
97
98
99
100
101
102
|
# File 'app/controllers/concerns/spotlight/controller.rb', line 96
def search_facet_path(*args, **kwargs)
if current_exhibit
exhibit_search_facet_path(*args, **kwargs)
else
main_app.facet_catalog_url(*args, **kwargs)
end
end
|
#search_state ⇒ Object
80
81
82
83
84
85
86
|
# File 'app/controllers/concerns/spotlight/controller.rb', line 80
def search_state
if current_exhibit
@search_state ||= Spotlight::SearchState.new(super, current_exhibit)
else
super
end
end
|
#set_exhibit_locale_scope ⇒ Object
18
19
20
|
# File 'app/controllers/concerns/spotlight/controller.rb', line 18
def set_exhibit_locale_scope
Translation.current_exhibit = current_exhibit
end
|
#set_locale ⇒ Object
63
64
65
|
# File 'app/controllers/concerns/spotlight/controller.rb', line 63
def set_locale
I18n.locale = params[:locale] || I18n.default_locale
end
|