Commit 54b00182f9c26156a76c80a95f5092adf965239e
1 parent
889af32a
Exists in
master
and in
29 other branches
[pluginize-solr] Moving index back
Showing
6 changed files
with
62 additions
and
5 deletions
Show diff stats
app/controllers/public/search_controller.rb
... | ... | @@ -18,6 +18,25 @@ class SearchController < PublicController |
18 | 18 | |
19 | 19 | no_design_blocks |
20 | 20 | |
21 | + def index | |
22 | + @results = {} | |
23 | + @order = [] | |
24 | + @names = {} | |
25 | + @results_only = true | |
26 | + | |
27 | + @enabled_searches.select { |key,description| @searching[key] }.each do |key, description| | |
28 | + load_query | |
29 | + @asset = key | |
30 | + send(:get_results, key) | |
31 | + @order << key | |
32 | + @names[key] = getterm(description) | |
33 | + end | |
34 | + @asset = nil | |
35 | + | |
36 | + render :action => @results.keys.first if @results.keys.size == 1 | |
37 | + end | |
38 | + | |
39 | + | |
21 | 40 | def articles |
22 | 41 | if @search_engine && !@empty_query |
23 | 42 | full_text_search |
... | ... | @@ -127,7 +146,7 @@ class SearchController < PublicController |
127 | 146 | protected |
128 | 147 | |
129 | 148 | def load_query |
130 | - @asset = params[:action].to_sym | |
149 | + @asset = (params[:asset] || params[:action]).to_sym | |
131 | 150 | @order ||= [@asset] |
132 | 151 | params[:display] ||= 'list' |
133 | 152 | @results ||= {} |
... | ... | @@ -196,7 +215,7 @@ class SearchController < PublicController |
196 | 215 | @titles = {} |
197 | 216 | @enabled_searches.each do |key, name| |
198 | 217 | @titles[key] = _(name) |
199 | - @searching[key] = params[:action] == key.to_s | |
218 | + @searching[key] = params[:action] == 'index' || params[:action] == key.to_s | |
200 | 219 | end |
201 | 220 | @names = @titles if @names.nil? |
202 | 221 | end | ... | ... |
app/helpers/search_helper.rb
app/views/search/_display_results.rhtml
... | ... | @@ -4,7 +4,7 @@ |
4 | 4 | |
5 | 5 | <div class="search-results-<%= name %> search-results-box <%= "search-results-empty" if results.blank? %>"> |
6 | 6 | <% if !results.blank? %> |
7 | - <% partial = partial_for_class(results.first.class.class_name.constantize) %> | |
7 | + <% partial = partial_for_class(name.to_s.singularize.camelize.constantize) %> | |
8 | 8 | |
9 | 9 | <% if multiple_search? %> |
10 | 10 | <h3><%= @names[name] %></h3> | ... | ... |
... | ... | @@ -0,0 +1,29 @@ |
1 | +<div id="search-page" class="<%= "view-category" if @category %>"> | |
2 | + | |
3 | + <% if @category %> | |
4 | + <div id="category-image"><%= image_tag(@category.image.public_filename(:thumb), :id => 'category-image') if @category.image %></div> | |
5 | + <% end %> | |
6 | + | |
7 | + <%= search_page_title(_('Search Results'), @category) %> | |
8 | + <%= render :partial => 'search_form', :locals => { :hint => '' } if @search_engine %> | |
9 | + <%= category_context(@category, params) %> | |
10 | + <%= display_results(@asset) %> | |
11 | + | |
12 | + <div id="category-childs"> | |
13 | + <% if @category %> | |
14 | + <h2> <%= _('Sub-categories') %> </h2> | |
15 | + <% if @category.children.empty? %> | |
16 | + <strong id="cat-no-child"><%= _('No sub-categories') %></strong> | |
17 | + <% else %> | |
18 | + <ul> | |
19 | + <% @category.children.each do |c| %> | |
20 | + <li> <%= link_to_category c, false %> </li> | |
21 | + <% end %> | |
22 | + </ul> | |
23 | + <% end %> | |
24 | + <% end %> | |
25 | + </div> | |
26 | + | |
27 | +</div> | |
28 | + | |
29 | +<div style="clear: both"></div> | ... | ... |
plugins/solr/lib/solr_plugin.rb
... | ... | @@ -20,7 +20,12 @@ class SolrPlugin < Noosfero::Plugin |
20 | 20 | asset_class = asset_class(asset) |
21 | 21 | solr_options = solr_options(asset, category) |
22 | 22 | solr_options.merge!(products_options(context.send(:user))) if asset == :products && empty_query?(query, category) |
23 | - asset_class.find_by_contents(query, paginate_options, solr_options) | |
23 | + search = asset_class.find_by_contents(query, paginate_options, solr_options) | |
24 | + if context.params[:action] == 'index' | |
25 | + return search[:results] | |
26 | + else | |
27 | + return search | |
28 | + end | |
24 | 29 | end |
25 | 30 | |
26 | 31 | end | ... | ... |
plugins/solr/lib/solr_plugin/results_helper.rb