Commit ab66aa9b5951b748156bb9dc20b1e4820645e89d
1 parent
c6b33ac3
Exists in
master
and in
29 other branches
[search-improvements] Use dispatch_first already builtin default action
Showing
2 changed files
with
5 additions
and
16 deletions
Show diff stats
app/controllers/application_controller.rb
... | ... | @@ -165,24 +165,10 @@ class ApplicationController < ActionController::Base |
165 | 165 | end |
166 | 166 | |
167 | 167 | def find_by_contents(asset, scope, query, paginate_options={:page => 1}, options={}) |
168 | - plugins.dispatch_first(:find_by_contents, asset, scope, query, paginate_options, options) || | |
169 | - fallback_find_by_contents(asset, scope, query, paginate_options, options) | |
168 | + plugins.dispatch_first(:find_by_contents, asset, scope, query, paginate_options, options) | |
170 | 169 | end |
171 | 170 | |
172 | 171 | def find_suggestions(asset, query, options={}) |
173 | - plugins.dispatch_first(:find_suggestions, asset, query, options) || | |
174 | - fallback_find_suggestions(asset, query, options) | |
175 | - end | |
176 | - | |
177 | - private | |
178 | - | |
179 | - def fallback_find_by_contents(asset, scope, query, paginate_options, options) | |
180 | - scope = scope.like_search(query) unless query.blank? | |
181 | - scope = scope.send(options[:filter]) unless options[:filter].blank? | |
182 | - {:results => scope.paginate(paginate_options)} | |
183 | - end | |
184 | - | |
185 | - def fallback_find_suggestions(asset, query, options) | |
186 | - #TODO Implement fallback suggestions solution | |
172 | + plugins.dispatch_first(:find_suggestions, asset, query, options) | |
187 | 173 | end |
188 | 174 | end | ... | ... |
lib/noosfero/plugin.rb
... | ... | @@ -505,6 +505,9 @@ class Noosfero::Plugin |
505 | 505 | # P.S.: The plugin might add other informations on the return hash for its |
506 | 506 | # own use in specific views |
507 | 507 | def find_by_contents(asset, scope, query, paginate_options={}, options={}) |
508 | + scope = scope.like_search(query) unless query.blank? | |
509 | + scope = scope.send(options[:filter]) unless options[:filter].blank? | |
510 | + {:results => scope.paginate(paginate_options)} | |
508 | 511 | end |
509 | 512 | |
510 | 513 | # -> Suggests terms based on asset and query | ... | ... |