diff --git a/app/controllers/public/search_controller.rb b/app/controllers/public/search_controller.rb index afe9b34..2a7c82e 100644 --- a/app/controllers/public/search_controller.rb +++ b/app/controllers/public/search_controller.rb @@ -1,10 +1,5 @@ class SearchController < PublicController - MAP_SEARCH_LIMIT = 2000 - LIST_SEARCH_LIMIT = 20 - BLOCKS_SEARCH_LIMIT = 18 - MULTIPLE_SEARCH_LIMIT = 8 - helper TagsHelper include SearchHelper include ActionView::Helpers::NumberHelper @@ -33,7 +28,6 @@ class SearchController < PublicController full_text_search ['public:true'] else @results[@asset] = @environment.articles.public.send(@filter).paginate(paginate_options) - facets = {} end end @@ -46,7 +40,6 @@ class SearchController < PublicController full_text_search ['public:true'] else @results[@asset] = @environment.people.visible.send(@filter).paginate(paginate_options) - @facets = {} end end @@ -54,8 +47,19 @@ class SearchController < PublicController if !@empty_query full_text_search ['public:true'] else - @results[@asset] = @environment.products.send(@filter).paginate(paginate_options) - @facets = {} + @one_page = true + @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 ['public:true', "{!geofilt}"], :sql_options => sql_options, :extra_limit => extra_limit, + :alternate_query => "{!boost b=recip(geodist(),#{1/DistBoost},1,1)}", + :radius => DistFilt, :latitude => current_user.person.lat, :longitude => current_user.person.lng + else + full_text_search ['public:true'], :sql_options => sql_options, :extra_limit => extra_limit, + :boost_functions => ['recip(ms(NOW/HOUR,updated_at),1.3e-10,1,1)'] + end end end @@ -77,40 +81,25 @@ class SearchController < PublicController end def events - @category_id = @category ? @category.id : nil - year = (params[:year] ? params[:year].to_i : Date.today.year) month = (params[:month] ? params[:month].to_i : Date.today.month) day = (params[:day] ? params[:day].to_i : Date.today.day) - date = Date.new(year, month, day) + date = build_date(params[:year], params[:month], params[:day]) date_range = (date - 1.month)..(date + 1.month).at_end_of_month - if @query.blank? - # Ignore pagination for asset events - if date_range - @results[@asset] = Event.send('find', :all, - :conditions => [ - 'start_date BETWEEN :start_day AND :end_day OR end_date BETWEEN :start_day AND :end_day', - {:start_day => date_range.first, :end_day => date_range.last} - ]) - else - @results[@asset] = Event.send('find', :all) - end - else - full_text_search - end - @selected_day = nil @events_of_the_day = [] - date = build_date(params[:year], params[:month], params[:day]) - if params[:day] || !params[:year] && !params[:month] @selected_day = date - if @category_id and Category.exists?(@category_id) - @events_of_the_day = environment.events.by_day(@selected_day).in_category(Category.find(@category_id)) - else - @events_of_the_day = environment.events.by_day(@selected_day) - end + @events_of_the_day = @category ? + environment.events.by_day(@selected_day).in_category(Category.find(@category_id)) : + environment.events.by_day(@selected_day) + end + + if !@empty_query + full_text_search + else + @results[@asset] = date_range ? environment.events.by_range(date_range) : environment.events end events = @results[@asset] @@ -135,17 +124,10 @@ class SearchController < PublicController @asset = nil @facets = {} - if @results.keys.size == 1 - specific_action = @results.keys.first - if respond_to?(specific_action) - @asset_name = getterm(@names[@results.keys.first]) - send(specific_action) - render :action => specific_action - return - end - end + 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 @@ -167,6 +149,7 @@ class SearchController < PublicController ].each do |asset, name, filter| @order << asset @results[asset] = @category.send(filter, limit) + raise "nao total #{asset}" unless @results[asset].respond_to?(:total_entries) @names[asset] = name end end @@ -182,7 +165,8 @@ class SearchController < PublicController @tag = params[:tag] @tag_cache_key = "tag_#{CGI.escape(@tag.to_s)}_env_#{environment.id.to_s}_page_#{params[:npage]}" if is_cache_expired?(@tag_cache_key) - @tagged = environment.articles.find_tagged_with(@tag).paginate(:per_page => 10, :page => params[:npage]) + @asset = :articles + @results[@asset] = environment.articles.find_tagged_with(@tag).paginate(paginate_options) end end @@ -241,7 +225,7 @@ class SearchController < PublicController 'communities_more_recent' => _('More recent communities from network'), 'communities_more_active' => _('More active communities from network'), 'communities_more_popular' => _('More popular communities from network'), - 'products_more_recent' => _('More recent products from network'), + 'products_more_recent' => _('Highlights'), }[asset.to_s + '_' + filter] end @@ -284,21 +268,30 @@ class SearchController < PublicController { :per_page => limit, :page => page } end - def full_text_search(filters = []) + def full_text_search(filters = [], options = {}) paginate_options = paginate_options(params[:page]) asset_class = asset_class(@asset) - solr_options = {} - if !@results_only and asset_class.methods.include?('facets') + solr_options = options + if !@results_only and asset_class.respond_to? :facets solr_options.merge! asset_class.facets_find_options(params[:facet]) solr_options[:all_facets] = true solr_options[:limit] = 0 if @facets_only - #solr_options[:facets][:browse] << asset_class.facet_category_query.call(@category) if @category and asset_class.facet_category_query end - solr_options[:order] = params[:order_by] if params[:order_by] solr_options[:filter_queries] ||= [] solr_options[:filter_queries] += filters solr_options[:filter_queries] << "environment_id:#{environment.id}" + solr_options[:filter_queries] << asset_class.facet_category_query.call(@category) if @category + + solr_options[:boost_functions] ||= [] + params[:order_by] = nil if params[:order_by] == 'none' + if params[:order_by] + order = SortOptions[@asset][params[:order_by].to_sym] + raise "Unknown order by" if order.nil? + order[:solr_opts].each do |opt, value| + solr_options[opt] = value.is_a?(Proc) ? instance_eval(&value) : value + end + end ret = asset_class.find_by_contents(@query, paginate_options, solr_options) @results[@asset] = ret[:results] diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb index 966c387..db59d20 100644 --- a/app/helpers/search_helper.rb +++ b/app/helpers/search_helper.rb @@ -1,5 +1,37 @@ module SearchHelper + MAP_SEARCH_LIMIT = 2000 + LIST_SEARCH_LIMIT = 20 + BLOCKS_SEARCH_LIMIT = 18 + MULTIPLE_SEARCH_LIMIT = 8 + DistFilt = 200 + DistBoost = 50 + 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 => '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 => 'name_sortable asc'}}, + ], + :articles => ActiveSupport::OrderedHash[ :none, {:label => _('Relevance')}, + :name, {:label => _('Name'), :solr_opts => {:sort => 'name_sortable asc'}}, + :name, {:label => _('Most recent'), :solr_opts => {:sort => 'updated_at desc, score desc'}}, + ], + :enterprises => ActiveSupport::OrderedHash[ :none, {:label => _('Relevance')}, + :name, {:label => _('Name'), :solr_opts => {:sort => 'name_sortable asc'}}, + ], + :people => ActiveSupport::OrderedHash[ :none, {:label => _('Relevance')}, + :name, {:label => _('Name'), :solr_opts => {:sort => 'name_sortable asc'}}, + ], + :communities => ActiveSupport::OrderedHash[ :none, {:label => _('Relevance')}, + :name, {:label => _('Name'), :solr_opts => {:sort => 'name_sortable asc'}}, + ], + } + # FIXME remove it after search_controler refactored include EventsHelper @@ -130,18 +162,14 @@ module SearchHelper end def order_by(asset) - options = { - :products => [[_('Relevance'), ''], [_('More Recent'), 'updated_at desc'], [_('Name'), 'name_or_category_sort asc']], - :events => [[_('Relevance'), ''], [_('Name'), 'name_sort asc']], - :articles => [[_('Relevance'), ''], [_('Name'), 'name_sort asc'], [_('Most recent'), 'updated_at desc']], - :enterprises => [[_('Relevance'), ''], [_('Name'), 'name_sort asc']], - :people => [[_('Relevance'), ''], [_('Name'), 'name_sort asc']], - :communities => [[_('Relevance'), ''], [_('Name'), 'name_sort asc']], - } + options = SortOptions[asset].map do |name, options| + next if options[:if] and ! instance_eval(&options[:if]) + [_(options[:label]), name.to_s] + end.compact content_tag('div', _('Sort results by ') + - select_tag(asset.to_s + '[order]', options_for_select(options[asset], params[:order_by]), - {:onchange => "window.location=jQuery.param.querystring(window.location.href, { 'order_by' : this.options[this.selectedIndex].value})"}), + select_tag(asset.to_s + '[order]', options_for_select(options, params[:order_by] || 'none'), + {:onchange => "window.location = jQuery.param.querystring(window.location.href, { 'order_by' : this.options[this.selectedIndex].value})"}), :class => "search-ordering") end diff --git a/app/models/article.rb b/app/models/article.rb index 27325d3..94016f7 100644 --- a/app/models/article.rb +++ b/app/models/article.rb @@ -618,15 +618,14 @@ class Article < ActiveRecord::Base def f_category self.categories.collect(&:name) end - def name_sort + + delegate :region, :region_id, :environment, :environment_id, :to => :profile + def name_sortable # give a different name for solr name end def public self.public? end - def environment_id - profile.environment_id - end public acts_as_faceted :fields => { @@ -639,16 +638,24 @@ class Article < ActiveRecord::Base :category_query => proc { |c| "f_category:\"#{c.name}\"" }, :order => [:f_type, :f_published_at, :f_profile_type, :f_category] - acts_as_searchable :additional_fields => [ - {:name_sort => {:type => :string}}, - {:public => {:type => :boolean}}, - {:environment_id => {:type => :integer}}, - ] + facets_fields_for_solr, - :exclude_fields => [:setting], - :include => [:profile, :comments, :categories], - :facets => facets_option_for_solr, - :boost => proc {|a| 10 if a.profile.enabled}, - :if => proc{|a| ! ['RssFeed'].include?(a.class.name)} + acts_as_searchable :fields => facets_fields_for_solr + [ + # searched fields + {:name => {:type => :text, :boost => 2.0}}, + {:slug => :text}, {:body => :text}, + {:abstract => :text}, {:filename => :text}, + # filtered fields + {:public => :boolean}, {:environment_id => :integer}, + :language, :published, + # ordered/query-boosted fields + {:name_sortable => :string}, :last_changed_by_id, :published_at, :is_image, + :updated_at, :created_at, + ], :include => [ + {:profile => {:fields => [:name, :identifier, :address, :nickname, :region_id, :lat, :lng]}}, + {:comments => {:fields => [:title, :body, :author_name, :author_email]}}, + {:categories => {:fields => [:name, :path, :slug, :lat, :lng, :acronym, :abbreviation]}}, + ], :facets => facets_option_for_solr, + :boost => proc { |a| 10 if a.profile.enabled }, + :if => proc{ |a| ! ['RssFeed'].include?(a.class.name) } handle_asynchronously :solr_save private diff --git a/app/models/category.rb b/app/models/category.rb index ab48d18..b0b16fc 100644 --- a/app/models/category.rb +++ b/app/models/category.rb @@ -15,9 +15,6 @@ class Category < ActiveRecord::Base acts_as_filesystem - acts_as_searchable :additional_fields => [{:name => {:boost => 2.0}}] - handle_asynchronously :solr_save - has_many :article_categorizations, :dependent => :destroy has_many :articles, :through => :article_categorizations has_many :comments, :through => :articles @@ -68,7 +65,7 @@ class Category < ActiveRecord::Base end def upcoming_events(limit = 10) - self.events.find(:all, :conditions => [ 'start_date >= ?', Date.today ], :order => 'start_date') + self.events.paginate(:conditions => [ 'start_date >= ?', Date.today ], :order => 'start_date', :page => 1, :per_page => limit) end def display_in_menu? @@ -92,4 +89,23 @@ class Category < ActiveRecord::Base self.children.find(:all, :conditions => {:display_in_menu => true}).empty? end + private + def name_sortable # give a different name for solr + name + end + public + + acts_as_searchable :fields => [ + # searched fields + {:name => {:type => :text, :boost => 2.0}}, + {:path => :text}, {:slug => :text}, + {:abbreviation => :text}, {:acronym => :text}, + # filtered fields + :parent_id, + # ordered/query-boosted fields + {:name_sortable => :string}, + ] + after_save_reindex [:articles, :profiles], :with => :delayed_job + handle_asynchronously :solr_save + end diff --git a/app/models/certifier.rb b/app/models/certifier.rb index 1db7984..a5e0974 100644 --- a/app/models/certifier.rb +++ b/app/models/certifier.rb @@ -24,4 +24,6 @@ class Certifier < ActiveRecord::Base self.name.downcase.transliterate <=> b.name.downcase.transliterate end + after_save_reindex [:products], :with => :delayed_job + end diff --git a/app/models/image.rb b/app/models/image.rb index a88bc0c..2182d25 100644 --- a/app/models/image.rb +++ b/app/models/image.rb @@ -23,4 +23,9 @@ class Image < ActiveRecord::Base postgresql_attachment_fu + alias_method :public_filename_old, :public_filename + def public_filename(*args) + "http://cirandas.net#{public_filename_old(args)}" + end + end diff --git a/app/models/product_category.rb b/app/models/product_category.rb index d37bf57..37ef4c5 100644 --- a/app/models/product_category.rb +++ b/app/models/product_category.rb @@ -1,4 +1,5 @@ class ProductCategory < Category + # FIXME: do not allow category with products or inputs to be destroyed has_many :products has_many :inputs @@ -9,4 +10,7 @@ class ProductCategory < Category def self.menu_categories(top_category, env) top_category ? top_category.children : top_level_for(env).select{|c|c.kind_of?(ProductCategory)} end + + after_save_reindex [:products], :with => :delayed_job + end diff --git a/app/models/profile.rb b/app/models/profile.rb index 138c9f9..29bccfd 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -87,7 +87,7 @@ class Profile < ActiveRecord::Base named_scope :more_popular named_scope :more_active - named_scope :more_recent, :order => "updated_at DESC" + named_scope :more_recent, :order => "created_at DESC" acts_as_trackable :dependent => :destroy @@ -125,8 +125,6 @@ class Profile < ActiveRecord::Base validates_length_of :description, :maximum => 550, :allow_nil => true - acts_as_mappable :default_units => :kms - # Valid identifiers must match this format. IDENTIFIER_FORMAT = /^#{Noosfero.identifier_format}$/ @@ -859,7 +857,8 @@ private :generate_url, :url_options c.name end end - def name_sort + + def name_sortable # give a different name for solr name end def public @@ -875,13 +874,24 @@ private :generate_url, :url_options :category_query => proc { |c| "f_categories:#{c.id}" }, :order => [:f_region, :f_categories] - acts_as_searchable :additional_fields => [ - {:name_sort => {:type => :string}}, - {:public => {:type => :boolean}}, - :extra_data_for_index ] + facets.keys.map{|i| {i => :facet}}, - :boost => proc {|p| 10 if p.enabled}, - :include => [:categories, :region], - :facets => facets.keys + acts_as_searchable :fields => facets_fields_for_solr + [:extra_data_for_index, + # searched fields + {:name => {:type => :text, :boost => 2.0}}, + {:identifier => :text}, {:address => :text}, {:nickname => :text}, + # filtered fields + {:public => :boolean}, {:environment_id => :integer}, + # ordered/query-boosted fields + {:name_sortable => :string}, {:user_id => :integer}, + :enabled, :active, :validated, :public_profile, + {:lat => :float}, {:lng => :float}, + :updated_at, :created_at, + ], + :include => [ + {:region => {:fields => [:name, :path, :slug, :lat, :lng]}}, + {:categories => {:fields => [:name, :path, :slug, :lat, :lng, :acronym, :abbreviation]}}, + ], :facets => facets_option_for_solr, + :boost => proc{ |p| 10 if p.enabled } + after_save_reindex [:articles], :with => :delayed_job handle_asynchronously :solr_save def control_panel_settings_button diff --git a/app/models/qualifier.rb b/app/models/qualifier.rb index 3852dc7..378527b 100644 --- a/app/models/qualifier.rb +++ b/app/models/qualifier.rb @@ -15,4 +15,6 @@ class Qualifier < ActiveRecord::Base self.name.downcase.transliterate <=> b.name.downcase.transliterate end + after_save_reindex [:products], :with => :delayed_job + end diff --git a/app/views/search/_article.rhtml b/app/views/search/_article.rhtml index 3648fd8..25c2a41 100644 --- a/app/views/search/_article.rhtml +++ b/app/views/search/_article.rhtml @@ -3,9 +3,10 @@
<%= render :partial => 'image', :object => article %>
-
- -
+ + <%= render :partial => 'article_common', :object => article %> +
+ <%= render :partial => 'article_last_change', :object => article %>
diff --git a/app/views/search/_article_author.rhtml b/app/views/search/_article_author.rhtml index 41ab926..9e9b1f6 100644 --- a/app/views/search/_article_author.rhtml +++ b/app/views/search/_article_author.rhtml @@ -1,8 +1,8 @@ <% article = article_author %> -
-
- <%= _("Author") %> + + <%= _("Author") %> + <%= link_to_profile article.profile.name, article.profile.identifier %> -
-
+ + diff --git a/app/views/search/_article_categories.rhtml b/app/views/search/_article_categories.rhtml index 4a0a940..325f971 100644 --- a/app/views/search/_article_categories.rhtml +++ b/app/views/search/_article_categories.rhtml @@ -1,9 +1,9 @@ -
- <%= _('Categories') %> - + + <%= _('Categories') %> + "> <% article_categories.each do |category| %> <%= link_to_category category, false, :class => "search-article-category" %> <% end %> - <%= _('None') if article_categories.empty? %> - -
+ <%= _('None') if article_categories.empty? %> + + diff --git a/app/views/search/_article_common.rhtml b/app/views/search/_article_common.rhtml index 952ec0a..43e2a5f 100644 --- a/app/views/search/_article_common.rhtml +++ b/app/views/search/_article_common.rhtml @@ -5,4 +5,3 @@ <%= render :partial => 'article_description', :object => article if show_description %> <%= render :partial => 'article_tags', :object => article.tags %> <%= render :partial => 'article_categories', :object => article.categories %> -<%= render :partial => 'article_last_change', :object => article %> diff --git a/app/views/search/_article_description.rhtml b/app/views/search/_article_description.rhtml index e0655d2..9df30c8 100644 --- a/app/views/search/_article_description.rhtml +++ b/app/views/search/_article_description.rhtml @@ -1,11 +1,13 @@ <% article = article_description %> -
- <%= _("Description") %> + + <%= _("Description") %> + <% if !article.body.blank? %> - <% body_stripped = strip_tags(article.body.to_s) %> - <%= excerpt(body_stripped, body_stripped.first(3), 200) %> + <% description = strip_tags(article.body.to_s) %> + <% description = excerpt(description, description.first(3), 200).gsub!(/\s{2,}/, ' ') %> + <%= description %> <% else %> - <%= _('None') %> + <%= _('None') %> <% end %> -
+ diff --git a/app/views/search/_article_last_change.rhtml b/app/views/search/_article_last_change.rhtml index f504551..d0203a3 100644 --- a/app/views/search/_article_last_change.rhtml +++ b/app/views/search/_article_last_change.rhtml @@ -1,8 +1,9 @@ <% article = article_last_change %>
- <% if article.last_changed_by && article.last_changed_by != article.profile %> - <%= _('by %s') % link_to(article.last_changed_by.name, article.last_changed_by.url) %> <%= _(' at %s.') % show_date(article.updated_at) %> + <% if article.last_changed_by and article.last_changed_by != article.profile %> + <%= _('by %{name} at %{date}') % {:name => link_to(article.last_changed_by.name, article.last_changed_by.url), + :date => show_date(article.updated_at) } %> <% else %> <%= _('Last update: %s.') % show_date(article.updated_at) %> <% end %> diff --git a/app/views/search/_article_tags.rhtml b/app/views/search/_article_tags.rhtml index 057703a..2d9c923 100644 --- a/app/views/search/_article_tags.rhtml +++ b/app/views/search/_article_tags.rhtml @@ -1,9 +1,9 @@ -
- <%= _('Tags') %> - -
+ <%= _('None') if article_tags.empty? %> + + diff --git a/app/views/search/_blog.rhtml b/app/views/search/_blog.rhtml index da5558b..c155bca 100644 --- a/app/views/search/_blog.rhtml +++ b/app/views/search/_blog.rhtml @@ -3,21 +3,22 @@
<%= render :partial => 'image', :object => blog %>
-
-
- <%= _("Last posts") %> + + + + <% r = blog.children.find(:all, :order => :updated_at, :conditions => ['type != ?', 'RssFeed']).last(3) %> - <% r.each do |a| %> - <%= link_to a.title, a.view_url, :class => 'search-blog-sample-item '+icon_for_article(a) %> - <% end %> - <%= _('None') if r.empty? %> - + + - <%= render :partial => 'article_author', :object => blog %> - <%= render :partial => 'article_tags', :object => blog.tags %> - <%= render :partial => 'article_categories', :object => blog.categories %> - <%= render :partial => 'article_last_change', :object => blog %> - + <%= render :partial => 'article_common', :object => blog %> +
<%= _("Last posts") %>"> + <% r.each do |a| %> + <%= link_to a.title, a.view_url, :class => 'search-blog-sample-item '+icon_for_article(a) %> + <% end %> + <%= _('None') if r.empty? %> +
+ <%= render :partial => 'article_last_change', :object => blog %>
diff --git a/app/views/search/_display_results.rhtml b/app/views/search/_display_results.rhtml index 9615f64..526bc10 100644 --- a/app/views/search/_display_results.rhtml +++ b/app/views/search/_display_results.rhtml @@ -1,44 +1,39 @@
- <% @order.each do |name| %> <% results = @results[name] %> - <% if !results.nil? and !results.empty? %> -
- + <% empty = results.nil? || results.empty? %> + +
"> + <% if not empty %> + <% partial = partial_for_class(results.first.class.class_name.constantize) %> + <% if @results.size > 1 %>

<%= @names[name] %>

- <%= link_to(results.respond_to?(:total_entries) ? _('see all (%d)') % results.total_entries : _('see all...'), - params.merge(:action => name), :class => 'see-more' ) %> + <% if results.total_entries > SearchController::MULTIPLE_SEARCH_LIMIT %> + <%= link_to(_('see all (%d)') % results.total_entries, params.merge(:action => name), :class => 'see-more' ) %> + <% end %> <% end %> - - <% partial = partial_for_class(results.first.class.class_name.constantize) %> +
-
-
    - <% results.each do |hit| %> - <%= render :partial => partial_for_class(hit.class), :object => hit %> - <% end %> -
-
-
-
- -
- <% else %> -
+
    + <% results.each do |hit| %> + <%= render :partial => partial_for_class(hit.class), :object => hit %> + <% end %> +
+
+ <% else %> <% if @results.size > 1 %>

<%= @names[name] %>

<% end %>
<%= _('None') %>
-
-
-
- <% end %> +
+ <% end %> +
<% end %>
<%= add_zoom_to_images %> -
+
diff --git a/app/views/search/_event.rhtml b/app/views/search/_event.rhtml index aaf96dd..a95dfb1 100644 --- a/app/views/search/_event.rhtml +++ b/app/views/search/_event.rhtml @@ -3,22 +3,23 @@
<%= render :partial => 'image', :object => event %>
-
+ <% if event.start_date %> -
- <%= _('Start date') %> - <%= event.start_date %> -
+ + + + <% end %> <% if event.end_date %> -
- <%= _('End date') %> - <%= event.end_date %> -
+ + + + <% end %> <%= render :partial => 'article_common', :object => event %> - +
<%= _('Start date') %><%= event.start_date %>
<%= _('End date') %><%= event.end_date %>
+ <%= render :partial => 'article_last_change', :object => event %>
diff --git a/app/views/search/_folder.rhtml b/app/views/search/_folder.rhtml index 35866da..a322481 100644 --- a/app/views/search/_folder.rhtml +++ b/app/views/search/_folder.rhtml @@ -3,18 +3,22 @@
<%= render :partial => 'image', :object => folder %>
-
-
- <%= _("Last items") %> + + + + <% r = folder.children.last(3) %> - <% r.each do |a| %> - <%= link_to a.title, a.view_url, :class => 'search-folder-sample-item '+icon_for_article(a) %> - <% end %> - <%= _('None') if r.empty? %> - + + <%= render :partial => 'article_common', :object => folder %> - +
<%= _("Last items") %>"> + <% r.each do |a| %> + <%= link_to a.title, a.view_url, :class => 'search-folder-sample-item '+icon_for_article(a) %> + <% end %> + <%= _('None') if r.empty? %> +
+ <%= render :partial => 'article_last_change', :object => folder %>
diff --git a/app/views/search/_forum.rhtml b/app/views/search/_forum.rhtml index a6caa85..54df4a2 100644 --- a/app/views/search/_forum.rhtml +++ b/app/views/search/_forum.rhtml @@ -3,18 +3,22 @@
<%= render :partial => 'image', :object => forum %>
-
-
- <%= _("Last topics") %> + + + + <% r = forum.children.find(:all, :order => :updated_at, :conditions => ['type != ?', 'RssFeed']).last(3) %> - <% r.each do |a| %> - <%= link_to a.title, a.view_url, :class => 'search-forum-sample-item '+icon_for_article(a) %> - <% end %> - <%= _('None') if r.empty? %> - + + <%= render :partial => 'article_common', :object => forum %> - +
<%= _("Last topics") %>"> + <% r.each do |a| %> + <%= link_to a.title, a.view_url, :class => 'search-forum-sample-item '+icon_for_article(a) %> + <% end %> + <%= _('None') if r.empty? %> +
+ <%= render :partial => 'article_last_change', :object => forum %>
diff --git a/app/views/search/_gallery.rhtml b/app/views/search/_gallery.rhtml index 7b50c86..28e2e66 100644 --- a/app/views/search/_gallery.rhtml +++ b/app/views/search/_gallery.rhtml @@ -3,9 +3,10 @@
<%= render :partial => 'image', :object => gallery %>
-
+ <%= render :partial => 'article_common', :object => gallery %> - +
+ <%= render :partial => 'article_last_change', :object => gallery %>
diff --git a/app/views/search/_image.rhtml b/app/views/search/_image.rhtml index ed5d004..ae82a05 100644 --- a/app/views/search/_image.rhtml +++ b/app/views/search/_image.rhtml @@ -1,6 +1,6 @@
- <% if image.is_a? UploadedFile %> + <% if image.is_a? UploadedFile and image.filename %> <% extension = image.filename[(image.filename.rindex('.')+1)..-1].downcase %> <% if ['jpg', 'jpeg', 'gif', 'png', 'tiff', 'svg'].include? extension %> <%= link_to '', image.view_url, :class => "search-image-pic", :style => 'background-image: url(%s)'% image.public_filename(:thumb) %> diff --git a/app/views/search/_product.rhtml b/app/views/search/_product.rhtml index fc42d9d..25b4f91 100644 --- a/app/views/search/_product.rhtml +++ b/app/views/search/_product.rhtml @@ -2,6 +2,7 @@ <% extra_properties = @plugins.dispatch(:asset_product_properties, product)%>
  • +
    <%= render :partial => 'search/image', :object => product %> @@ -18,17 +19,9 @@ <% end %> <% end %>
    - <% if product.inputs.count > product.inputs.collect(&:is_from_solidarity_economy).count(nil) %> - <% se_i = t_i = 0 %> - <% product.inputs.each{ |i| t_i += 1; se_i += 1 if i.is_from_solidarity_economy } %> - <% p = case (se_i.to_f/t_i)*100 - when 0..24.999 then ["0", _("")]; - when 25..49.999 then ["25", _("25%")]; - when 50..74.999 then ["50", _("50%")]; - when 75..99.999 then ["75", _("75%")]; - when 100 then ["100", _("100%")]; - end %> -
    + <% if p = product.percentage_from_solidarity_economy %> +
    <%= p[1] %>
    <% end %> diff --git a/app/views/search/_profile.rhtml b/app/views/search/_profile.rhtml index 1b0940e..26f4720 100644 --- a/app/views/search/_profile.rhtml +++ b/app/views/search/_profile.rhtml @@ -39,6 +39,7 @@ <% end %>
    +
    <% end %> diff --git a/app/views/search/_search_form.rhtml b/app/views/search/_search_form.rhtml index ccb475e..7bc7a6e 100644 --- a/app/views/search/_search_form.rhtml +++ b/app/views/search/_search_form.rhtml @@ -5,10 +5,13 @@ <%= hidden_field_tag :display, params[:display] %> - <% CGI::unescape(request.request_uri).split("&").each do |part| %> - <% if part.start_with? "facet" %> - <% name_value = part.split("=") %> - <%= hidden_field_tag name_value[0], name_value[1] %> + <% 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 %> @@ -16,19 +19,9 @@ <%= text_field_tag 'query', @query, :id => 'search-input', :size => 50 %> <%= javascript_tag "jQuery('#search-input').attr('title', \"#{hint}\").hint()" if defined?(hint) %> - <%= javascript_tag "jQuery('.search_form').submit(function() { - if (jQuery('#search-input').val().length < 3) { - jQuery('#search-empty-query-error').slideDown(200).delay(2500).slideUp(200); - return false; - } - });" %> <%= submit_button(:search, _('Search')) %> - -
    - <%= _("Type more than 2 characters to start a search") %> -
  • <% end %> diff --git a/app/views/search/_text_article.rhtml b/app/views/search/_text_article.rhtml index 8b76f44..0f1b746 100644 --- a/app/views/search/_text_article.rhtml +++ b/app/views/search/_text_article.rhtml @@ -1,11 +1,13 @@
  • <%= link_to(text_article.title, text_article.url, :class => "search-result-title") %> +
    <%= render :partial => 'image', :object => text_article %>
    -
    + <%= render :partial => 'article_common', :object => text_article %> - +
    + <%= render :partial => 'article_last_change', :object => text_article %>
  • diff --git a/app/views/search/_uploaded_file.rhtml b/app/views/search/_uploaded_file.rhtml index 16717dd..b8aa1d4 100644 --- a/app/views/search/_uploaded_file.rhtml +++ b/app/views/search/_uploaded_file.rhtml @@ -1,37 +1,25 @@
  • <%= link_to uploaded_file.filename, uploaded_file.view_url, :class => 'search-result-title' %> -
    <%= render :partial => 'image', :object => uploaded_file %>
    -
    + <%= render :partial => 'article_author', :object => uploaded_file %> + <%= render :partial => 'article_description', :object => uploaded_file %> -
    - <% if !uploaded_file.body.blank? %> - <%= _("Description") %> - <% body = strip_tags(uploaded_file.body.to_s) %> - <%= excerpt(body, body.first(3), 200) %> - <% end %> -
    - -
    - <% if uploaded_file.parent && uploaded_file.parent.published? %> - <% if uploaded_file.parent.gallery? %> - <%= _("Gallery") %> - <% else %> - <%= _("Folder") %> - <% end %> - <%= link_to uploaded_file.parent.name, {:controller => 'content_viewer', :profile => uploaded_file.profile.identifier, :action => 'view_page', :page => [uploaded_file.parent.slug]} %> - <% end %> -
    + <% if uploaded_file.parent and uploaded_file.parent.published? %> + + + + + <% end %> <%= render :partial => 'article_tags', :object => uploaded_file.tags %> <%= render :partial => 'article_categories', :object => uploaded_file.categories %> - <%= render :partial => 'article_last_change', :object => uploaded_file %> - +
    <%= uploaded_file.parent.gallery? ? _("Gallery") : _("Folder") %><%= link_to uploaded_file.parent.name, uploaded_file.parent.url %>
    + <%= render :partial => 'article_last_change', :object => uploaded_file %>
  • diff --git a/app/views/search/products.rhtml b/app/views/search/products.rhtml index 2ba06af..6babe53 100644 --- a/app/views/search/products.rhtml +++ b/app/views/search/products.rhtml @@ -14,7 +14,7 @@ <%= render :partial => 'results_header' %> <%= display_results(true) %> - <% if params[:display] != 'map' %> + <% if !@one_page and params[:display] != 'map' %> <%= pagination_links @results[:products] %> <% end %>
    diff --git a/app/views/search/tag.rhtml b/app/views/search/tag.rhtml index e9881dd..2540146 100644 --- a/app/views/search/tag.rhtml +++ b/app/views/search/tag.rhtml @@ -7,16 +7,7 @@ <% end %> <% cache_timeout(@tag_cache_key, 4.hour) do %> -
    - <% @tagged.each do |hit| %> -
      - <%= render :partial => partial_for_class(hit.class), :object => hit %> -
    -
    - <% end %> - -
    - <%= pagination_links @tagged, :param_name => 'npage' %> + <%= display_results %>
    <% end %> diff --git a/public/designs/themes/base/style.css b/public/designs/themes/base/style.css index ad25da6..00238ed 100644 --- a/public/designs/themes/base/style.css +++ b/public/designs/themes/base/style.css @@ -872,30 +872,6 @@ X.sep { border-top: 1px solid #CCC; } -#content .search-results-box a.see-more { - z-index: 10; - position: absolute; - bottom: 20px; - right: 20px; - background: transparent url(imgs/arrow-right-p.png) 100% 55% no-repeat; - border: none; - padding-right: 15px; - color: #000; - text-decoration: none; - font-weight: bold; -} -#content .search-results-box a.see-more:hover { - background: transparent url(imgs/arrow-right-p.png) 100% 55% no-repeat; - color: #888; -} - - -.search-results-type-article.search-results-innerbox { - padding: 5px 0px 5px 10px; - max-height: 215px; - height: 225px; -} - #content .search-results-type-article li, #content .search-results-type-event li { padding: 5px 0px; @@ -1207,12 +1183,6 @@ table.profile th { /**************************** Browse *******************************/ -.search-results-type-article.search-results-innerbox { - padding: 5px 0px 5px 10px; - max-height: 215px; - height: 225px; -} - #content .search-results-type-article li { padding: 5px 0px; } diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 50fbfd3..4911484 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -3216,7 +3216,7 @@ div#article-parent { #agenda .calendar-day-out.selected { background: none; } -#agenda td { +#agenda .agenda-calendar td { vertical-align: middle; } #agenda .agenda-calendar .current-month caption { diff --git a/public/stylesheets/search.css b/public/stylesheets/search.css index 5cb8f61..0fb027f 100644 --- a/public/stylesheets/search.css +++ b/public/stylesheets/search.css @@ -91,7 +91,8 @@ margin: 0px; padding: 0px; } -.controller-search #product-categories-menu .sub-opening, .controller-search #product-categories-menu .sub-closeing { +.controller-search #product-categories-menu .sub-opening, +.controller-search #product-categories-menu .sub-closeing { background-color: #FF8; } .controller-search #product-categories-menu .sub-opened { @@ -101,9 +102,13 @@ float: right; } .controller-search #content .search-results-box a.see-more { + z-index: 10; position: absolute; bottom: 0px; right: 25px; + color: black; + text-decoration: none; + font-weight: bold; font-size: 11px; line-height: 11px; background: #B8CFE7; @@ -116,10 +121,14 @@ color: #FFF; text-decoration: none; } +.controller-search .search-results-innerbox.common-profile-list-block { + overflow: hidden; +} .controller-search .search-results-innerbox { - padding: 8px 0px 10px 10px; + padding: 8px 10px 10px 10px; + overflow: auto; + overflow-x: hidden; height: 230px; - overflow: visible; position: relative; /* work-arround-bug fo MSIE */ } .controller-search .search-results-innerbox hr { @@ -138,7 +147,10 @@ height: 0px; visibility: hidden; } -.controller-search #content .search-results-type-article ul, .controller-search #content .search-results-type-article li, .controller-search #content .search-results-type-event ul, .controller-search #content .search-results-type-event li { +.search-results-type-article ul, +.controller-search #content .search-results-type-article li, +.controller-search #content .search-results-type-event ul, +.controller-search #content .search-results-type-event li { margin: 0px; padding: 0px; list-style: none; @@ -146,21 +158,19 @@ .controller-search #content .search-results-type-event li { padding: 2px 0px 4px 0px; } -.controller-search #content .search-results-type-article li, .controller-search #content .search-results-type-event li { - padding: 0px 0px 4px 20px; +.controller-search #content .search-results-type-article li { + padding: 10px 0; background-repeat: no-repeat; - border-color: transparent; } -.controller-search #content .search-results-type-article li:hover, .controller-search #content .search-results-type-event li:hover { +.controller-search #content .search-results-type-article li:hover, +.controller-search #content .search-results-type-event li:hover { background-color: transparent; } -.controller-search .search-results-type-article .item_meta, .controller-search .search-results-type-event .item_meta { +.controller-search .search-results-type-article .item_meta, +.controller-search .search-results-type-event .item_meta { font-size: 10px; color: #888; } -.search-results-type-article.search-results-innerbox { - overflow: auto; -} #content .only-one-result-box .search-results-enterprises li.vcard { margin: 4.5px; } @@ -171,19 +181,14 @@ min-height: 16px; overflow: hidden; } -.controller-search #content .search-results-type-article ul { +.search-results-type-article ul { margin: 0; - padding:0; -} -.controller-search #content .search-results-type-article li.article-item, -.controller-search .search-tagged-items li.article-item, -.controller-search #content .only-one-result-box li.search-product-item { - padding:0; - border-bottom:1px solid #000; - margin: 0 0 10px 0; - padding: 0 0 10px 0; - font-size: 11px; - height: auto; + padding: 0; +} +.search-results-type-article li.article-item, +.search-tagged-items li.article-item, +.only-one-result-box li.search-product-item { + border-bottom: 1px solid #000; } .search-result-title { display:inline-block; @@ -199,8 +204,6 @@ } li.article-item .search-result-title { color: #007788; - clear:both; - float:left; } .search-article-tags, .search-uploaded-file-description, @@ -216,37 +219,24 @@ li.article-item .search-result-title { clear: both; } .search-article-body { - float: right; width: 80%; margin-bottom: 7px; } .search-field-none { color: #ccc; } -.search-forum-items .search-field-label { - height: 36px; -} .search-field-label { - display: block; - float: left; font-size: 10px; font-weight: bold; - height: 18px; - line-height: 18px; - margin: 0 5px 0 0; text-transform: uppercase; width: 110px; + display: block; } .search-product-item-third-column .search-field-label { width: 150px; } -li.article-item .search-article-tags-container, -li.article-item .search-article-categories-container { - display: block; - min-height: 18px; - line-height: 18px; -} -.search-article-tags .search-article-tag, .search-article-categories .search-article-category { +.search-article-tags .search-article-tag, +.search-article-categories .search-article-category { background: #BBB; padding:0 2px; -moz-border-radius: 3px; @@ -260,10 +250,12 @@ li.article-item .search-article-categories-container { color: #FFF; font-size: 10px; } -.search-article-tags a.search-article-tag, .search-article-categories a.search-article-category { +.search-article-tags a.search-article-tag, +.search-article-categories a.search-article-category { text-decoration:none; } -.search-article-tags a:hover.search-article-tag, .search-article-categories a:hover.search-article-category { +.search-article-tags a:hover.search-article-tag, +.search-article-categories a:hover.search-article-category { background: #555753; text-decoration:none; } @@ -292,7 +284,8 @@ li.article-item .search-article-categories-container { .search-results-innerbox .menu-submenu { bottom: 107px; } -.controller-search .search-results-type-product, .controller-search .search-results-type-event { +.controller-search .search-results-type-product, +.controller-search .search-results-type-event { overflow: auto; } li.search-product-item { @@ -364,8 +357,8 @@ li.search-product-item { float: left; font-size: 70%; background-repeat: no-repeat; - height: 18px; - line-height: 18px; + height: 21px; + line-height: 21px; } .search-product-ecosol-percentage-icon-0 { background-image: none; @@ -376,7 +369,8 @@ li.search-product-item { .search-product-ecosol-percentage-icon-50 { background-position: 0px -42px; } -.search-product-ecosol-percentage-icon-75 { +.search-product-ecosol-percentage-icon-75, +.search-product-ecosol-percentage-icon-100 { background-position: 0px -63px; } .search-product-price-details { @@ -388,18 +382,23 @@ li.search-product-item { .controller-search #category-comments { margin-left: 55%; } -.controller-search #content .search-results-comments ul, .controller-search #content .search-results-comments li, .controller-search #content #category-comments ul, .controller-search #content #category-comments li { +.controller-search #content .search-results-comments ul, +.controller-search #content .search-results-comments li, +.controller-search #content #category-comments ul, +.controller-search #content #category-comments li { margin: 0px; padding: 0px; list-style: none; color: #888; } -.controller-search .search-results-comments .comment-picture, .controller-search #category-comments .comment-picture { +.controller-search .search-results-comments .comment-picture, +.controller-search #category-comments .comment-picture { width: 20px; height: 20px; margin: -2px 5px 0px 0px; } -.controller-search #content .search-results-type-product ul, .controller-search #content .search-results-type-product li { +.controller-search #content .search-results-type-product ul, +.controller-search #content .search-results-type-product li { margin: 0px; padding: 0px; list-style: none; @@ -572,7 +571,9 @@ li.search-product-item hr { border: none; background: none; } -.search-product-item-first-column, .search-product-item-second-column, .search-product-item-third-column { +.search-product-item-first-column, +.search-product-item-second-column, +.search-product-item-third-column { float: left; margin:0 !important; } @@ -600,7 +601,6 @@ li.search-product-item hr { } .only-one-result-box .common-profile-list-block { float: left; - margin: 10px; } .search-enterprise-item { border-bottom: 1px solid #ccc; @@ -760,30 +760,41 @@ form .search-field input:hover.button.submit { background-repeat: no-repeat; padding: 0 0 0 20px; } -.facet-menu a.facet-options-toggle.facet-more-options, .facet-menu a.facet-options-toggle { +.facet-menu a.facet-options-toggle.facet-more-options, +.facet-menu a.facet-options-toggle { background-position: 0 0; } .facet-menu a.facet-options-toggle.facet-less-options { background-position: 0 -32px; } -.search-uploaded-file-first-column, -.search-text-article-first-column, .search-content-first-column { - clear: both; - float: left; - margin: 0 10px 0 0; width: 130px; - min-height:98px; + min-height: 98px; + position: absolute; } -.search-uploaded-file-second-column, -.search-text-article-second-column, .search-content-second-column { - float: left; - width: 570px; + margin-left: 140px; + width: auto; +} +.search-content-second-column tr:hover { + background-color: none; +} +.search-content-second-column td { + height: auto; +} +.search-results-articles li { + position: relative; +} + +a.search-blog-sample-item.icon, +.search-folder-items a, +.search-forum-items a, +.search-blog-items a { + border: none; + margin-bottom: 3px; + display: block; } -ul.clean-list .search-uploaded-file-second-column, -ul.clean-list .search-text-article-second-column, ul.clean-list .search-content-second-column { width:795px; } @@ -864,10 +875,7 @@ a.search-image-pic { } .search-content-first-column .icon-application-vnd-oasis-opendocument-text, .search-content-first-column .icon-application-vnd-oasis-opendocument-spreadsheet, -.search-content-first-column .icon-text-content, -.search-uploaded-file-first-column .icon-application-vnd-oasis-opendocument-text, -.search-uploaded-file-first-column .icon-application-vnd-oasis-opendocument-spreadsheet, -.search-text-article-first-column .icon-text-content { +.search-content-first-column .icon-text-content { display:block; width: 16px; height: 16px; @@ -879,18 +887,6 @@ a.search-image-pic { margin: auto; } -.search-content-first-column .icon-application-vnd-oasis-opendocument-spreadsheet, -.search-content-first-column .icon-application-vnd-oasis-opendocument-spreadsheet { - -} -.search-content-first-column .icon-application-opendocument-spreadsheet, -.search-uploaded-file-first-column .icon-application-opendocument-spreadsheet { - -} -.search-content-first-column .icon-text-content, -.search-text-article-first-column .icon-text-content { - -} .search-uploaded-file-line { clear: both; float: left; @@ -904,7 +900,6 @@ a.search-image-pic { width: 130px; height: 130px; display: block; - } #search-input { font-size: 140%; @@ -933,7 +928,8 @@ a.search-image-pic { font-style: italic; color: gray; } -.search-relevance, .search-result-text { +.search-relevance, +.search-result-text { margin-left: 40px; } -- libgit2 0.21.2