Commit 9ceae77bcdbf548cbde2666a03635fcbcb37e71a
1 parent
16c36447
Exists in
master
and in
29 other branches
[search-improvements] Use only enabled assets
Showing
2 changed files
with
24 additions
and
14 deletions
Show diff stats
app/controllers/public/search_controller.rb
... | ... | @@ -173,13 +173,22 @@ class SearchController < PublicController |
173 | 173 | end |
174 | 174 | end |
175 | 175 | |
176 | + AVAILABLE_SEARCHES = ActiveSupport::OrderedHash[ | |
177 | + :articles, _('Contents'), | |
178 | + :enterprises, _('Enterprises'), | |
179 | + :people, _('People'), | |
180 | + :communities, _('Communities'), | |
181 | + :products, _('Products and Services'), | |
182 | + :events, _('Events'), | |
183 | + ] | |
184 | + | |
176 | 185 | def load_search_assets |
177 | - if SEARCHES.keys.include?(params[:action].to_sym) && environment.enabled?("disable_asset_#{params[:action]}") | |
186 | + if AVAILABLE_SEARCHES.keys.include?(params[:action].to_sym) && environment.enabled?("disable_asset_#{params[:action]}") | |
178 | 187 | render_not_found |
179 | 188 | return |
180 | 189 | end |
181 | 190 | |
182 | - @enabled_searches = SEARCHES.select {|key, name| environment.disabled?("disable_asset_#{key}") } | |
191 | + @enabled_searches = AVAILABLE_SEARCHES.select {|key, name| environment.disabled?("disable_asset_#{key}") } | |
183 | 192 | @searching = {} |
184 | 193 | @titles = {} |
185 | 194 | @enabled_searches.each do |key, name| |
... | ... | @@ -191,7 +200,7 @@ class SearchController < PublicController |
191 | 200 | |
192 | 201 | def load_order |
193 | 202 | @order = 'more_recent' |
194 | - if SEARCHES.keys.include?(@asset.to_sym) | |
203 | + if AVAILABLE_SEARCHES.keys.include?(@asset.to_sym) | |
195 | 204 | available_orders = asset_class(@asset)::SEARCH_FILTERS[:order] |
196 | 205 | @order = params[:order] if available_orders.include?(params[:order]) |
197 | 206 | end |
... | ... | @@ -232,4 +241,14 @@ class SearchController < PublicController |
232 | 241 | 20 |
233 | 242 | end |
234 | 243 | |
244 | + def available_assets | |
245 | + assets = ActiveSupport::OrderedHash[ | |
246 | + :articles, _('Contents'), | |
247 | + :enterprises, _('Enterprises'), | |
248 | + :people, _('People'), | |
249 | + :communities, _('Communities'), | |
250 | + :products, _('Products and Services'), | |
251 | + ] | |
252 | + end | |
253 | + | |
235 | 254 | end | ... | ... |
app/helpers/search_helper.rb
... | ... | @@ -5,15 +5,6 @@ module SearchHelper |
5 | 5 | BLOCKS_SEARCH_LIMIT = 24 |
6 | 6 | MULTIPLE_SEARCH_LIMIT = 8 |
7 | 7 | |
8 | - SEARCHES = ActiveSupport::OrderedHash[ | |
9 | - :articles, _('Contents'), | |
10 | - :enterprises, _('Enterprises'), | |
11 | - :people, _('People'), | |
12 | - :communities, _('Communities'), | |
13 | - :products, _('Products and Services'), | |
14 | - :events, _('Events'), | |
15 | - ] | |
16 | - | |
17 | 8 | FILTERS_TRANSLATIONS = { |
18 | 9 | :order => _('Order'), |
19 | 10 | :display => _('Display') |
... | ... | @@ -118,7 +109,7 @@ module SearchHelper |
118 | 109 | end |
119 | 110 | |
120 | 111 | def assets_menu(selected) |
121 | - assets = SEARCHES.keys | |
112 | + assets = @enabled_searches.keys | |
122 | 113 | content_tag('ul', |
123 | 114 | assets.map do |asset| |
124 | 115 | options = {} |
... | ... | @@ -129,7 +120,7 @@ module SearchHelper |
129 | 120 | end |
130 | 121 | |
131 | 122 | def asset_link(asset) |
132 | - link_to(SEARCHES[asset], "/search/#{asset}") | |
123 | + link_to(@enabled_searches[asset], "/search/#{asset}") | |
133 | 124 | end |
134 | 125 | |
135 | 126 | end | ... | ... |