diff --git a/app/controllers/public/search_controller.rb b/app/controllers/public/search_controller.rb
index 12b818b..7a9790b 100644
--- a/app/controllers/public/search_controller.rb
+++ b/app/controllers/public/search_controller.rb
@@ -144,7 +144,7 @@ class SearchController < PublicController
def load_query
@asset = (params[:asset] || params[:action]).to_sym
@order ||= [@asset]
- params[:display] ||= 'items'
+ params[:display] ||= DEFAULT_DISPLAY[@asset]
@searches ||= {}
@query = params[:query] || ''
diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb
index 69aee8c..85453db 100644
--- a/app/helpers/search_helper.rb
+++ b/app/helpers/search_helper.rb
@@ -14,11 +14,20 @@ module SearchHelper
:events, _('Events'),
]
+ DEFAULT_DISPLAY = {
+ :articles => 'full',
+ :communities => 'compact',
+ :enterprises => 'full',
+ :events => 'full',
+ :people => 'compact',
+ :products => 'full',
+ }
+
# FIXME remove it after search_controler refactored
include EventsHelper
def multiple_search?
- ['index', 'category_index'].include?(params[:action]) or @searches.size > 1
+ ['index', 'category_index'].include?(params[:action]) || @searches.size > 1
end
def map_search?
@@ -46,13 +55,12 @@ module SearchHelper
[:enterprises, :products].include?(asset)
end
- def display_items?(asset)
- puts "\n\n" + asset.inspect + "\n\n"
- ![:products, :events].include?(asset)
+ def display_compact?(asset)
+ [:communities, :enterprises, :people].include?(asset)
end
def display_full?(asset)
- [:enterprises, :products].include?(asset)
+ [:articles, :enterprises, :events, :products].include?(asset)
end
def display_results(asset = nil)
@@ -81,12 +89,12 @@ module SearchHelper
end
def display_selector(asset, display, float = 'right')
- if [display_map?(asset), display_items?(asset), display_full?(asset)].select {|option| option}.count > 1
- items_link = display_items?(asset) ? (display == 'items' ? _('Items') : link_to(_('Items'), params.merge(:display => 'items'))) : nil
+ if [display_map?(asset), display_compact?(asset), display_full?(asset)].select {|option| option}.count > 1
+ compact_link = display_compact?(asset) ? (display == 'compact' ? _('Compact') : link_to(_('Compact'), params.merge(:display => 'compact'))) : nil
map_link = display_map?(asset) ? (display == 'map' ? _('Map') : link_to(_('Map'), params.merge(:display => 'map'))) : nil
full_link = display_full?(asset) ? (display == 'full' ? _('Full') : link_to(_('Full'), params.merge(:display => 'full'))) : nil
content_tag('div',
- content_tag('strong', _('Display')) + ': ' + [items_link, map_link, full_link].compact.join(' | '),
+ content_tag('strong', _('Display')) + ': ' + [compact_link, map_link, full_link].compact.join(' | '),
:id => 'search-display-filter',
:style => "float: #{float}"
)
diff --git a/app/views/search/_article.rhtml b/app/views/search/_article.rhtml
deleted file mode 100644
index 25c2a41..0000000
--- a/app/views/search/_article.rhtml
+++ /dev/null
@@ -1,12 +0,0 @@
-
- <%= link_to(article.title, article.url, :class => "search-result-title") %>
-
- <%= render :partial => 'image', :object => article %>
-
-
- <%= render :partial => 'article_common', :object => article %>
-
- <%= render :partial => 'article_last_change', :object => article %>
-
-
-
diff --git a/app/views/search/_compact_profile.html.erb b/app/views/search/_compact_profile.html.erb
new file mode 100644
index 0000000..06c5f79
--- /dev/null
+++ b/app/views/search/_compact_profile.html.erb
@@ -0,0 +1,6 @@
+<% profile = item %>
+<% filter_label = profile.send(@filter + '_label') %>
+<% filter_label += show_date(profile.created_at) if @filter == 'more_recent' %>
+
+ <%= profile_image_link profile, :portrait, 'div', filter_label %>
+
diff --git a/app/views/search/_display_results.rhtml b/app/views/search/_display_results.rhtml
index b1f2793..da62323 100644
--- a/app/views/search/_display_results.rhtml
+++ b/app/views/search/_display_results.rhtml
@@ -4,19 +4,19 @@
">
<% if !search[:results].blank? %>
- <% partial = partial_for_class(name.to_s.singularize.camelize.constantize) %>
<% if multiple_search? %>
<%= @names[name] %>
<% if search[:results].total_entries > SearchController::MULTIPLE_SEARCH_LIMIT %>
<%= link_to(_('see all (%d)') % search[:results].total_entries, params.merge(:action => name), :class => 'see-more' ) %>
<% end %>
+ <% params[:display] = 'compact' %>
<% end %>
-
+
<% search[:results].each do |hit| %>
- <%= render :partial => partial_for_class(hit.class), :object => hit %>
+ <%= render :partial => partial_for_class(hit.class, params[:display]), :locals => {:item => hit} %>
<% end %>
diff --git a/app/views/search/_event.rhtml b/app/views/search/_event.rhtml
deleted file mode 100644
index eacbf2e..0000000
--- a/app/views/search/_event.rhtml
+++ /dev/null
@@ -1,25 +0,0 @@
-
-<%= link_to(event.title, event.url, :class => "search-result-title") %>
-
- <%= 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 %>
-
-<%= render :partial => 'article_last_change', :object => event %>
-
-
-
diff --git a/app/views/search/_full_article.html.erb b/app/views/search/_full_article.html.erb
new file mode 100644
index 0000000..8cbf5f7
--- /dev/null
+++ b/app/views/search/_full_article.html.erb
@@ -0,0 +1,13 @@
+<% article = item %>
+
+ <%= link_to(article.title, article.url, :class => "search-result-title") %>
+
+ <%= render :partial => 'image', :object => article %>
+
+
+ <%= render :partial => 'article_common', :object => article %>
+
+ <%= render :partial => 'article_last_change', :object => article %>
+
+
+
diff --git a/app/views/search/_full_enterprise.html.erb b/app/views/search/_full_enterprise.html.erb
new file mode 100644
index 0000000..fdea014
--- /dev/null
+++ b/app/views/search/_full_enterprise.html.erb
@@ -0,0 +1,39 @@
+<% profile = item %>
+
+
+
+ <%= profile_image_link profile, :portrait, 'div',
+ @filter == 'more_recent' ? profile.send(@filter + '_label') + show_date(profile.created_at) : profile.send(@filter + '_label') %>
+
+
+ <%= link_to_homepage(profile.name, profile.identifier, :class => "search-result-title") %>
+
+ <% if profile.description %>
+ <% body_stripped = strip_tags(profile.description) %>
+ <% elsif profile.home_page and profile.home_page.body %>
+ <% body_stripped = strip_tags(profile.home_page.body) %>
+ <% end %>
+ <%= excerpt(body_stripped, body_stripped.first(3), 200) if body_stripped %>
+
+
+ <%= _("City") %>
+ <% if profile.region %>
+ <%= city_with_state(profile.region) %>
+ <% end %>
+
+
+
+ <% profile.top_level_categorization.each do |parent, children| %>
+
+ <%= parent.name %>
+
+ <%= children.collect(&:name).join(', ') %>
+
+
+ <% end %>
+
+
+
+
+
+
diff --git a/app/views/search/_full_event.html.erb b/app/views/search/_full_event.html.erb
new file mode 100644
index 0000000..d63bac5
--- /dev/null
+++ b/app/views/search/_full_event.html.erb
@@ -0,0 +1,26 @@
+<% event = item %>
+
+<%= link_to(event.title, event.url, :class => "search-result-title") %>
+
+ <%= 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 %>
+
+<%= render :partial => 'article_last_change', :object => event %>
+
+
+
diff --git a/app/views/search/_full_product.rhtml b/app/views/search/_full_product.rhtml
new file mode 100644
index 0000000..680b15f
--- /dev/null
+++ b/app/views/search/_full_product.rhtml
@@ -0,0 +1,86 @@
+<% product = item %>
+<% extra_content = @plugins.dispatch(:asset_product_extras, product).collect { |content| instance_eval(&content) } %>
+<% extra_properties = @plugins.dispatch(:asset_product_properties, product)%>
+
+
+
+
+ <%= render :partial => 'search/image', :object => product %>
+
+ <% if product.available %>
+ <% if product.price && product.price > 0 %>
+ <% has_discount = product.discount && product.discount > 0 %>
+ <% if product.price %>
+
<%=_("from") if has_discount %><%= price_span(product.price, :class => "search-product-price " + (has_discount ? 'with-discount' : '')) %>
+ <% if has_discount %>
+
<%=_("by")%><%= price_span(product.price_with_discount, :class => "search-product-price") %>
+ <% end %>
+ <% if product.unit %>
+
<%= _('/') %> <%= product.unit.name %>
+ <% end %>
+ <% end %>
+
+ <% end %>
+ <% else %>
+
<%= _('Not available') %>
+ <% end %>
+
+
+
+ <%= link_to_product product, :class => 'search-result-title' %>
+
+ <%= _('Supplier') %> <%= link_to_homepage(product.enterprise.name, product.enterprise.identifier) %>
+
+
+ <% if product.description %>
+ <% desc_stripped = strip_tags(product.description) %>
+ <%= _('Description') %> <%= excerpt(desc_stripped, desc_stripped.first(3), 300) %>
+ <% end %>
+
+
+
+
+ <% if product.enterprise.region %>
+ <%= _('City') %>
+
<%= city_with_state(product.enterprise.region) %>
+ <% end %>
+
+
+ <% if product.product_qualifiers.count > 0 %>
+ <%= _('Qualifiers') %>
+ <% product.product_qualifiers.each do |pq| %>
+ <% if pq.qualifier %>
+ <%= pq.qualifier.name + (pq.certifier.nil? ? _(";") : '') %>
+ <% end %>
+ <% if pq.certifier %>
+ <%= _('cert. ') + pq.certifier.name + _(";") %>
+ <% end %>
+ <% end %>
+ <% end %>
+
+
+
+
+
+ <%= extra_content.join('\n') %>
+ <% extra_properties.each do |property| %>
+
<%= property[:name] + ': ' + instance_eval(&property[:content]) %>
+ <% end %>
+
+
diff --git a/app/views/search/_product.rhtml b/app/views/search/_product.rhtml
deleted file mode 100644
index dcbe8f1..0000000
--- a/app/views/search/_product.rhtml
+++ /dev/null
@@ -1,85 +0,0 @@
-<% extra_content = @plugins.dispatch(:asset_product_extras, product).collect { |content| instance_eval(&content) } %>
-<% extra_properties = @plugins.dispatch(:asset_product_properties, product)%>
-
-
-
-
- <%= render :partial => 'search/image', :object => product %>
-
- <% if product.available %>
- <% if product.price && product.price > 0 %>
- <% has_discount = product.discount && product.discount > 0 %>
- <% if product.price %>
-
<%=_("from") if has_discount %><%= price_span(product.price, :class => "search-product-price " + (has_discount ? 'with-discount' : '')) %>
- <% if has_discount %>
-
<%=_("by")%><%= price_span(product.price_with_discount, :class => "search-product-price") %>
- <% end %>
- <% if product.unit %>
-
<%= _('/') %> <%= product.unit.name %>
- <% end %>
- <% end %>
-
- <% end %>
- <% else %>
-
<%= _('Not available') %>
- <% end %>
-
-
-
- <%= link_to_product product, :class => 'search-result-title' %>
-
- <%= _('Supplier') %> <%= link_to_homepage(product.enterprise.name, product.enterprise.identifier) %>
-
-
- <% if product.description %>
- <% desc_stripped = strip_tags(product.description) %>
- <%= _('Description') %> <%= excerpt(desc_stripped, desc_stripped.first(3), 300) %>
- <% end %>
-
-
-
-
- <% if product.enterprise.region %>
- <%= _('City') %>
-
<%= city_with_state(product.enterprise.region) %>
- <% end %>
-
-
- <% if product.product_qualifiers.count > 0 %>
- <%= _('Qualifiers') %>
- <% product.product_qualifiers.each do |pq| %>
- <% if pq.qualifier %>
- <%= pq.qualifier.name + (pq.certifier.nil? ? _(";") : '') %>
- <% end %>
- <% if pq.certifier %>
- <%= _('cert. ') + pq.certifier.name + _(";") %>
- <% end %>
- <% end %>
- <% end %>
-
-
-
-
-
- <%= extra_content.join('\n') %>
- <% extra_properties.each do |property| %>
- <%= property[:name] + ': ' + instance_eval(&property[:content]) %>
- <% end %>
-
-
diff --git a/app/views/search/_profile.rhtml b/app/views/search/_profile.rhtml
deleted file mode 100644
index c363f94..0000000
--- a/app/views/search/_profile.rhtml
+++ /dev/null
@@ -1,43 +0,0 @@
-
-<% if @empty_query || multiple_search? || !profile.enterprise? %>
- <%= profile_image_link profile, :portrait, 'div',
- @filter == 'more_recent' ? profile.send(@filter + '_label') + show_date(profile.created_at) : profile.send(@filter + '_label') %>
-<% else %>
-
-
- <%= profile_image_link profile, :portrait, 'div',
- @filter == 'more_recent' ? profile.send(@filter + '_label') + show_date(profile.created_at) : profile.send(@filter + '_label') %>
-
-
- <%= link_to_homepage(profile.name, profile.identifier, :class => "search-result-title") %>
-
- <% if profile.description %>
- <% body_stripped = strip_tags(profile.description) %>
- <% elsif profile.home_page and profile.home_page.body %>
- <% body_stripped = strip_tags(profile.home_page.body) %>
- <% end %>
- <%= excerpt(body_stripped, body_stripped.first(3), 200) if body_stripped %>
-
-
- <%= _("City") %>
- <% if profile.region %>
- <%= city_with_state(profile.region) %>
- <% end %>
-
-
-
- <% profile.top_level_categorization.each do |parent, children| %>
-
- <%= parent.name %>
-
- <%= children.collect(&:name).join(', ') %>
-
-
- <% end %>
-
-
-
-
-
-<% end %>
-
diff --git a/app/views/search/_results_header.rhtml b/app/views/search/_results_header.rhtml
index 790e92b..59bd7a1 100644
--- a/app/views/search/_results_header.rhtml
+++ b/app/views/search/_results_header.rhtml
@@ -1,5 +1,5 @@
--
libgit2 0.21.2