Commit 71494e1cea0c8bf0852dfd62712b4c55d4349b92
1 parent
bc76afad
Exists in
master
and in
23 other branches
[pluginize-solr] File that were missing from other commits... =P
Showing
5 changed files
with
84 additions
and
0 deletions
Show diff stats
plugins/solr/controllers/public/solr_plugin_public_controller.rb
0 → 100644
| ... | ... | @@ -0,0 +1,22 @@ |
| 1 | +# TODO This controller was created to remove the solr dependencies from | |
| 2 | +# noosfero controllers. All actions here might not be working as they're | |
| 3 | +# supposed to. Everything here must be reviewed! | |
| 4 | + | |
| 5 | +class SolrPluginPublicController < MyProfileController | |
| 6 | + | |
| 7 | + include SolrPlugin::ResultsHelper | |
| 8 | + | |
| 9 | + | |
| 10 | + def facets_browse | |
| 11 | + @asset = params[:asset].to_sym | |
| 12 | + @asset_class = asset_class(@asset) | |
| 13 | + | |
| 14 | + @facets_only = true | |
| 15 | + send(@asset) | |
| 16 | + | |
| 17 | + @facet = @asset_class.map_facets_for(environment).find { |facet| facet[:id] == params[:facet_id] } | |
| 18 | + raise 'Facet not found' if @facet.nil? | |
| 19 | + | |
| 20 | + render :layout => false | |
| 21 | + end | |
| 22 | +end | ... | ... |
| ... | ... | @@ -0,0 +1,37 @@ |
| 1 | +<div class='search-form'> | |
| 2 | + | |
| 3 | + <% form_tag( { :controller => 'search', :action => @asset ? @asset : 'index', :asset => nil, :category_path => ( @category ? @category.explode_path : [] ) }, | |
| 4 | + :method => 'get', :class => 'search_form' ) do %> | |
| 5 | + | |
| 6 | + <%= hidden_field_tag :display, params[:display] %> | |
| 7 | + | |
| 8 | + <% params_uri = CGI::unescape(request.request_uri) %> | |
| 9 | + <% if params_uri.index('?') %> | |
| 10 | + <% params_uri[(params_uri.index('?')+1)..-1].to_s.split("&").each do |part| %> | |
| 11 | + <% if part.start_with? "facet" %> | |
| 12 | + <% name_value = part.split("=") %> | |
| 13 | + <%= hidden_field_tag name_value[0], name_value[1] %> | |
| 14 | + <% end %> | |
| 15 | + <% end %> | |
| 16 | + <% end %> | |
| 17 | + | |
| 18 | + <div class="search-field"> | |
| 19 | + <span class="formfield"> | |
| 20 | + <%= text_field_tag 'query', @query, :id => 'search-input', :size => 50 %> | |
| 21 | + <%= javascript_tag "jQuery('#search-input').attr('title', \"#{hint}\").hint()" if defined?(hint) %> | |
| 22 | + </span> | |
| 23 | + | |
| 24 | + <%= submit_button(:search, _('Search')) %> | |
| 25 | + </div> | |
| 26 | + | |
| 27 | + <% end %> | |
| 28 | + | |
| 29 | + <% if @empty_query %> | |
| 30 | + <% hint = environment.search_hints[@asset] %> | |
| 31 | + <% if hint and !hint.blank? %> | |
| 32 | + <div class="search-hint"><%= hint %></div> | |
| 33 | + <% end %> | |
| 34 | + <% end %> | |
| 35 | + | |
| 36 | + <div style="clear: both"></div> | |
| 37 | +</div> | ... | ... |
plugins/solr/views/solr_plugin_public/facets_browse.rhtml
0 → 100644
| ... | ... | @@ -0,0 +1,14 @@ |
| 1 | +<% | |
| 2 | + # TODO This view was created to remove the solr dependencies from | |
| 3 | + # noosfero views. All code here might not be working as they're | |
| 4 | + # supposed to. Everything must be reviewed! | |
| 5 | +%> | |
| 6 | + | |
| 7 | +<% results = @asset_class.map_facet_results(@facet, params[:facet], @facets, @all_facets) %> | |
| 8 | + | |
| 9 | +<% array = [] %> | |
| 10 | +<% @asset_class.facet_result_sort(@facet, results, :alphabetically).each do |id, label, count| %> | |
| 11 | + <% array << {:id => id, :name => facet_link_html(@facet, params.merge(:controller => 'search', :action => @asset), id, label, count)} %> | |
| 12 | +<% end %> | |
| 13 | + | |
| 14 | +<%= facet_javascript('facet-input-'+@facet[:id].to_s, @facet, array) %> | ... | ... |