diff --git a/plugins/solr/controllers/public/solr_plugin_public_controller.rb b/plugins/solr/controllers/public/solr_plugin_public_controller.rb new file mode 100644 index 0000000..9e9af04 --- /dev/null +++ b/plugins/solr/controllers/public/solr_plugin_public_controller.rb @@ -0,0 +1,22 @@ +# TODO This controller was created to remove the solr dependencies from +# noosfero controllers. All actions here might not be working as they're +# supposed to. Everything here must be reviewed! + +class SolrPluginPublicController < MyProfileController + + include SolrPlugin::ResultsHelper + + + def facets_browse + @asset = params[:asset].to_sym + @asset_class = asset_class(@asset) + + @facets_only = true + send(@asset) + + @facet = @asset_class.map_facets_for(environment).find { |facet| facet[:id] == params[:facet_id] } + raise 'Facet not found' if @facet.nil? + + render :layout => false + end +end diff --git a/plugins/solr/lib/ext/environment.rb b/plugins/solr/lib/ext/environment.rb new file mode 100644 index 0000000..8c69c80 --- /dev/null +++ b/plugins/solr/lib/ext/environment.rb @@ -0,0 +1,5 @@ +require_dependency 'environment' + +class Environment + settings_items :solr_plugin_top_level_category_as_facet_ids, :type => Array, :default => [] +end diff --git a/plugins/solr/views/search/_facets_unselect_menu.rhtml b/plugins/solr/views/search/_facets_unselect_menu.rhtml new file mode 100644 index 0000000..db1393b --- /dev/null +++ b/plugins/solr/views/search/_facets_unselect_menu.rhtml @@ -0,0 +1,6 @@ +
+ <% if params[:facet] and params[:facet].count > 0 %> + <%= _("Applied filters") %> + <%= facet_selecteds_html_for(environment, asset_class(@asset), params) %> + <% end %> +
diff --git a/plugins/solr/views/search/_search_form.rhtml b/plugins/solr/views/search/_search_form.rhtml new file mode 100644 index 0000000..e298996 --- /dev/null +++ b/plugins/solr/views/search/_search_form.rhtml @@ -0,0 +1,37 @@ +
+ + <% form_tag( { :controller => 'search', :action => @asset ? @asset : 'index', :asset => nil, :category_path => ( @category ? @category.explode_path : [] ) }, + :method => 'get', :class => 'search_form' ) do %> + + <%= hidden_field_tag :display, params[:display] %> + + <% params_uri = CGI::unescape(request.request_uri) %> + <% if params_uri.index('?') %> + <% params_uri[(params_uri.index('?')+1)..-1].to_s.split("&").each do |part| %> + <% if part.start_with? "facet" %> + <% name_value = part.split("=") %> + <%= hidden_field_tag name_value[0], name_value[1] %> + <% end %> + <% end %> + <% end %> + +
+ + <%= text_field_tag 'query', @query, :id => 'search-input', :size => 50 %> + <%= javascript_tag "jQuery('#search-input').attr('title', \"#{hint}\").hint()" if defined?(hint) %> + + + <%= submit_button(:search, _('Search')) %> +
+ + <% end %> + + <% if @empty_query %> + <% hint = environment.search_hints[@asset] %> + <% if hint and !hint.blank? %> +
<%= hint %>
+ <% end %> + <% end %> + +
+
diff --git a/plugins/solr/views/solr_plugin_public/facets_browse.rhtml b/plugins/solr/views/solr_plugin_public/facets_browse.rhtml new file mode 100644 index 0000000..946d234 --- /dev/null +++ b/plugins/solr/views/solr_plugin_public/facets_browse.rhtml @@ -0,0 +1,14 @@ +<% + # TODO This view was created to remove the solr dependencies from + # noosfero views. All code here might not be working as they're + # supposed to. Everything must be reviewed! +%> + +<% results = @asset_class.map_facet_results(@facet, params[:facet], @facets, @all_facets) %> + +<% array = [] %> +<% @asset_class.facet_result_sort(@facet, results, :alphabetically).each do |id, label, count| %> + <% array << {:id => id, :name => facet_link_html(@facet, params.merge(:controller => 'search', :action => @asset), id, label, count)} %> +<% end %> + +<%= facet_javascript('facet-input-'+@facet[:id].to_s, @facet, array) %> -- libgit2 0.21.2