lib/enjoy/search/controllers/search.rb in enjoy_cms_search-0.4.0 vs lib/enjoy/search/controllers/search.rb in enjoy_cms_search-0.4.0.1
- old
+ new
@@ -2,33 +2,29 @@
module Controllers
module Search
extend ActiveSupport::Concern
def index
- if search_redirecter
- return redirect_to url_for(params)
- end
+ return redirect_to url_for(params) if search_redirecter
- if defined?(BreadcrumbsOnRails)
- add_breadcrumb "search", [:enjoy_search]
+ if Enjoy::Search.config.breadcrumbs_on_rails_support
+ add_breadcrumb "search", [:enjoy_search], if: :insert_breadcrumbs
+ add_breadcrumb "results", [:enjoy_search, {q: params[:q]}], if: :insert_breadcrumbs
end
if params[:q].blank?
@results = []
else
- query = params[:q].to_s.gsub(/\P{Word}+/, ' ').gsub(/ +/, ' ').strip
- @results = search_model_class.page(params[:page]).per(10).send(fts_method, query)
+ @results = search_model_class.page(params[:page]).per(per_page).send(fts_method, query)
end
-
- if defined?(BreadcrumbsOnRails)
- add_breadcrumb "results", [:enjoy_search, {q: params[:q]}]
- end
end
private
def search_model_class
- Enjoy::Catalog::Item
+ if Enjoy::Search.config.pages_support
+ Enjoy::Pages::Page
+ end
end
def fts_method
:fts
end
@@ -39,9 +35,21 @@
params.delete(:submit)
params.delete(:commit)
return true
end
false
+ end
+
+ def insert_breadcrumbs
+ true
+ end
+
+ def per_page
+ 10
+ end
+
+ def query
+ params[:q].to_s.gsub(/\P{Word}+/, ' ').gsub(/ +/, ' ').strip
end
end
end
end