diff --git a/app/controllers/public/search_controller.rb b/app/controllers/public/search_controller.rb index 84774f8..7f1dcd7 100644 --- a/app/controllers/public/search_controller.rb +++ b/app/controllers/public/search_controller.rb @@ -4,7 +4,7 @@ class SearchController < PublicController include SearchHelper include ActionView::Helpers::NumberHelper - before_filter :redirect_asset_param, :except => [:facets_browse, :assets] + before_filter :redirect_asset_param, :except => :assets before_filter :load_category before_filter :load_search_assets before_filter :load_query @@ -18,19 +18,6 @@ class SearchController < PublicController no_design_blocks - 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 - def articles if @search_engine && !@empty_query full_text_search @@ -54,21 +41,10 @@ class SearchController < PublicController end def products - if @search_engine && !@empty_query + if @search_engine full_text_search else - @geosearch = logged_in? && current_user.person.lat && current_user.person.lng - - extra_limit = LIST_SEARCH_LIMIT*5 - sql_options = {:limit => LIST_SEARCH_LIMIT, :order => 'random()'} - if @geosearch - full_text_search :sql_options => sql_options, :extra_limit => extra_limit, - :alternate_query => "{!boost b=recip(geodist(),#{"%e" % (1.to_f/DistBoost)},1,1)}", - :radius => DistFilt, :latitude => current_user.person.lat, :longitude => current_user.person.lng - else - full_text_search :sql_options => sql_options, :extra_limit => extra_limit, - :boost_functions => ['recip(ms(NOW/HOUR,updated_at),1.3e-10,1,1)'] - end + @results[@asset] = @environment.products.send(@filter).paginate(paginate_options) end render :template => 'search/search_page' end @@ -120,52 +96,12 @@ class SearchController < PublicController @next_calendar = populate_calendar(date + 1.month, events) end - def index - @results = {} - @order = [] - @names = {} - @results_only = true - - @enabled_searches.select { |key,description| @searching[key] }.each do |key, description| - load_query - @asset = key - send(key) - @order << key - @names[key] = getterm(description) - end - @asset = nil - @facets = {} - - render :action => @results.keys.first if @results.keys.size == 1 - end - # keep old URLs workings def assets params[:action] = params[:asset].is_a?(Array) ? :index : params.delete(:asset) redirect_to params end - # view the summary of one category - def category_index - @results = {} - @order = [] - @names = {} - limit = MULTIPLE_SEARCH_LIMIT - [ - [ :people, _('People'), :recent_people ], - [ :enterprises, _('Enterprises'), :recent_enterprises ], - [ :products, _('Products'), :recent_products ], - [ :events, _('Upcoming events'), :upcoming_events ], - [ :communities, _('Communities'), :recent_communities ], - [ :articles, _('Contents'), :recent_articles ] - ].each do |asset, name, filter| - @order << asset - @results[asset] = @category.send(filter, limit) - raise "No total_entries for: #{asset}" unless @results[asset].respond_to?(:total_entries) - @names[asset] = name - end - end - def tags @tags_cache_key = "tags_env_#{environment.id.to_s}" if is_cache_expired?(@tags_cache_key) @@ -260,7 +196,7 @@ class SearchController < PublicController @titles = {} @enabled_searches.each do |key, name| @titles[key] = _(name) - @searching[key] = params[:action] == 'index' || params[:action] == key.to_s + @searching[key] = params[:action] == key.to_s end @names = @titles if @names.nil? end diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb index aac7d45..18910e0 100644 --- a/app/helpers/search_helper.rb +++ b/app/helpers/search_helper.rb @@ -4,8 +4,6 @@ module SearchHelper LIST_SEARCH_LIMIT = 20 BLOCKS_SEARCH_LIMIT = 24 MULTIPLE_SEARCH_LIMIT = 8 - DistFilt = 200 - DistBoost = 50 Searches = ActiveSupport::OrderedHash[ :articles, _('Contents'), @@ -16,37 +14,11 @@ module SearchHelper :events, _('Events'), ] - SortOptions = { - :products => ActiveSupport::OrderedHash[ :none, {:label => _('Relevance')}, - :more_recent, {:label => _('More recent'), :solr_opts => {:sort => 'updated_at desc, score desc'}}, - :name, {:label => _('Name'), :solr_opts => {:sort => 'solr_plugin_name_sortable asc'}}, - :closest, {:label => _('Closest to me'), :if => proc{ logged_in? && (profile=current_user.person).lat && profile.lng }, - :solr_opts => {:sort => "geodist() asc", - :latitude => proc{ current_user.person.lat }, :longitude => proc{ current_user.person.lng }}}, - ], - :events => ActiveSupport::OrderedHash[ :none, {:label => _('Relevance')}, - :name, {:label => _('Name'), :solr_opts => {:sort => 'solr_plugin_name_sortable asc'}}, - ], - :articles => ActiveSupport::OrderedHash[ :none, {:label => _('Relevance')}, - :name, {:label => _('Name'), :solr_opts => {:sort => 'solr_plugin_name_sortable asc'}}, - :more_recent, {:label => _('More recent'), :solr_opts => {:sort => 'updated_at desc, score desc'}}, - ], - :enterprises => ActiveSupport::OrderedHash[ :none, {:label => _('Relevance')}, - :name, {:label => _('Name'), :solr_opts => {:sort => 'solr_plugin_name_sortable asc'}}, - ], - :people => ActiveSupport::OrderedHash[ :none, {:label => _('Relevance')}, - :name, {:label => _('Name'), :solr_opts => {:sort => 'solr_plugin_name_sortable asc'}}, - ], - :communities => ActiveSupport::OrderedHash[ :none, {:label => _('Relevance')}, - :name, {:label => _('Name'), :solr_opts => {:sort => 'solr_plugin_name_sortable asc'}}, - ], - } - # FIXME remove it after search_controler refactored include EventsHelper def multiple_search? - ['index', 'category_index'].include?(params[:action]) or @results.size > 1 + @results.size > 1 end def map_search? @@ -95,23 +67,6 @@ module SearchHelper end end - def facet_javascript(input_id, facet, array) - array = [] if array.nil? - hintText = _('Type in an option') - text_field_tag('facet['+input_id+']', '', :id => input_id) + - javascript_tag("jQuery.TokenList(jQuery('##{input_id}'), #{array.to_json}, - {searchDelay: 0, permanentDropdown: true, theme: 'facet', dontAdd: true, preventDuplicates: true, - #{jquery_token_input_messages_json(hintText)}});") - end - - def asset_class(asset) - asset.to_s.singularize.camelize.constantize - end - - def asset_table(asset) - asset_class(asset).table_name - end - def display_filter(asset, display, float = 'right') if map_capable?(asset) list_link = display == 'list' ? _('List') : link_to(_('List'), params.merge(:display => 'list')) diff --git a/app/models/article.rb b/app/models/article.rb index 1ce2dc2..cbd0389 100644 --- a/app/models/article.rb +++ b/app/models/article.rb @@ -2,12 +2,6 @@ require 'hpricot' class Article < ActiveRecord::Base - # use for internationalizable human type names in search facets - # reimplement on subclasses - def self.type_name - _('Content') - end - track_actions :create_article, :after_create, :keep_params => [:name, :url, :lead, :first_image], :if => Proc.new { |a| a.is_trackable? && !a.image? } # xss_terminate plugin can't sanitize array fields diff --git a/app/models/environment.rb b/app/models/environment.rb index 9e36191..7714dea 100644 --- a/app/models/environment.rb +++ b/app/models/environment.rb @@ -266,8 +266,6 @@ class Environment < ActiveRecord::Base settings_items :search_hints, :type => Hash, :default => {} - settings_items :top_level_category_as_facet_ids, :type => Array, :default => [] - def news_amount_by_folder=(amount) settings[:news_amount_by_folder] = amount.to_i end diff --git a/app/models/profile.rb b/app/models/profile.rb index f14d666..4d3524c 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -3,12 +3,6 @@ # which by default is the one returned by Environment:default. class Profile < ActiveRecord::Base - # use for internationalizable human type names in search facets - # reimplement on subclasses - def self.type_name - _('Profile') - end - module Roles def self.admin(env_id) find_role('admin', env_id) diff --git a/app/views/search/_facets_unselect_menu.rhtml b/app/views/search/_facets_unselect_menu.rhtml deleted file mode 100644 index db1393b..0000000 --- a/app/views/search/_facets_unselect_menu.rhtml +++ /dev/null @@ -1,6 +0,0 @@ -