Commit bf580965a39ee357ddd34ec6bb226efeaef213c4

Authored by Rodrigo Souto
1 parent e80e4028

Renaming search partials

app/views/search/_blog.rhtml
... ... @@ -1,24 +0,0 @@
1   -<li class="search-blog article-item">
2   - <%= link_to blog.title, blog.view_url, :class => 'search-result-title' %>
3   - <div class="search-content-first-column">
4   - <%= render :partial => 'image', :object => blog %>
5   - </div>
6   - <table class="noborder search-content-second-column">
7   - <tr class="search-blog-items">
8   - <td class="search-field-label"><%= _("Last posts") %></td>
9   -
10   - <% r = blog.children.find(:all, :order => :updated_at, :conditions => ['type != ?', 'RssFeed']).last(3) %>
11   - <td class="<%= "search-field-none" if r.empty? %>">
12   - <% r.each do |a| %>
13   - <%= link_to a.title, a.view_url, :class => 'search-blog-sample-item '+icon_for_article(a) %>
14   - <% end %>
15   - <%= _('None') if r.empty? %>
16   - </td>
17   - </tr>
18   -
19   - <%= render :partial => 'article_common', :object => blog %>
20   - </table>
21   - <%= render :partial => 'article_last_change', :object => blog %>
22   -
23   - <div style="clear: both;"/></div>
24   -</li>
app/views/search/_display_results.rhtml
... ... @@ -15,7 +15,9 @@
15 15 <div class="search-results-innerbox search-results-type-<%= name.to_s %> <%= 'common-profile-list-block' if [:enterprises, :people, :communities].include?(name) %>">
16 16 <ul>
17 17 <% search[:results].each do |hit| %>
18   - <%= render :partial => partial_for_class(hit.class, params[:display]), :locals => {:item => hit} %>
  18 + <% partial = partial_for_class(hit.class, params[:display]) %>
  19 + <% variable_name = partial.gsub("#{params[:display]}_", '').to_sym %>
  20 + <%= render :partial => partial, :locals => {variable_name => hit} %>
19 21 <% end %>
20 22 </ul>
21 23 </div>
... ...
app/views/search/_folder.rhtml
... ... @@ -1,24 +0,0 @@
1   -<li class="search-folder-item article-item">
2   - <%= link_to folder.title, folder.view_url, :class => 'search-result-title' %>
3   - <div class="search-content-first-column">
4   - <%= render :partial => 'image', :object => folder %>
5   - </div>
6   - <table class="noborder search-content-second-column">
7   - <tr class="search-folder-items">
8   - <td class="search-field-label"><%= _("Last items") %></td>
9   -
10   - <% r = folder.children.last(3) %>
11   - <td class="<%= "search-field-none" if r.empty? %>">
12   - <% r.each do |a| %>
13   - <%= link_to a.title, a.view_url, :class => 'search-folder-sample-item '+icon_for_article(a) %>
14   - <% end %>
15   - <%= _('None') if r.empty? %>
16   - </td>
17   - </tr>
18   -
19   - <%= render :partial => 'article_common', :object => folder %>
20   - </table>
21   - <%= render :partial => 'article_last_change', :object => folder %>
22   -
23   - <div style="clear:both"></div>
24   -</li>
app/views/search/_forum.rhtml
... ... @@ -1,24 +0,0 @@
1   -<li class="search-forum-item article-item">
2   - <%= link_to forum.title, forum.view_url, :class => 'search-result-title' %>
3   - <div class="search-content-first-column">
4   - <%= render :partial => 'image', :object => forum %>
5   - </div>
6   - <table class="noborder search-content-second-column">
7   - <tr class="search-forum-items">
8   - <td class="search-field-label"><%= _("Last topics") %></td>
9   -
10   - <% r = forum.children.find(:all, :order => :updated_at, :conditions => ['type != ?', 'RssFeed']).last(3) %>
11   - <td class="<%= "search-field-none" if r.empty? %>">
12   - <% r.each do |a| %>
13   - <%= link_to a.title, a.view_url, :class => 'search-forum-sample-item '+icon_for_article(a) %>
14   - <% end %>
15   - <%= _('None') if r.empty? %>
16   - </td>
17   - </tr>
18   -
19   - <%= render :partial => 'article_common', :object => forum %>
20   - </table>
21   - <%= render :partial => 'article_last_change', :object => forum %>
22   -
23   - <div style="clear:both"></div>
24   -</li>
app/views/search/_full_article.html.erb
1   -<% article = item %>
2 1 <li class="search-article-item article-item">
3 2 <%= link_to(article.title, article.url, :class => "search-result-title") %>
4 3 <div class="search-content-first-column">
... ...
app/views/search/_full_blog.html.erb 0 → 100644
... ... @@ -0,0 +1,24 @@
  1 +<li class="search-blog article-item">
  2 + <%= link_to blog.title, blog.view_url, :class => 'search-result-title' %>
  3 + <div class="search-content-first-column">
  4 + <%= render :partial => 'image', :object => blog %>
  5 + </div>
  6 + <table class="noborder search-content-second-column">
  7 + <tr class="search-blog-items">
  8 + <td class="search-field-label"><%= _("Last posts") %></td>
  9 +
  10 + <% r = blog.children.find(:all, :order => :updated_at, :conditions => ['type != ?', 'RssFeed']).last(3) %>
  11 + <td class="<%= "search-field-none" if r.empty? %>">
  12 + <% r.each do |a| %>
  13 + <%= link_to a.title, a.view_url, :class => 'search-blog-sample-item '+icon_for_article(a) %>
  14 + <% end %>
  15 + <%= _('None') if r.empty? %>
  16 + </td>
  17 + </tr>
  18 +
  19 + <%= render :partial => 'article_common', :object => blog %>
  20 + </table>
  21 + <%= render :partial => 'article_last_change', :object => blog %>
  22 +
  23 + <div style="clear: both;"/></div>
  24 +</li>
... ...
app/views/search/_full_enterprise.html.erb
1   -<% profile = item %>
2 1 <li class="search-profile-item">
3 2 <div class="search-enterprise-item">
4 3 <div class="search-enterprise-item-column-left">
... ...
app/views/search/_full_event.html.erb
1   -<% event = item %>
2 1 <li class="search-event-item article-item">
3 2 <%= link_to(event.title, event.url, :class => "search-result-title") %>
4 3 <div class="search-content-first-column">
... ...
app/views/search/_full_folder.html.erb 0 → 100644
... ... @@ -0,0 +1,24 @@
  1 +<li class="search-folder-item article-item">
  2 + <%= link_to folder.title, folder.view_url, :class => 'search-result-title' %>
  3 + <div class="search-content-first-column">
  4 + <%= render :partial => 'image', :object => folder %>
  5 + </div>
  6 + <table class="noborder search-content-second-column">
  7 + <tr class="search-folder-items">
  8 + <td class="search-field-label"><%= _("Last items") %></td>
  9 +
  10 + <% r = folder.children.last(3) %>
  11 + <td class="<%= "search-field-none" if r.empty? %>">
  12 + <% r.each do |a| %>
  13 + <%= link_to a.title, a.view_url, :class => 'search-folder-sample-item '+icon_for_article(a) %>
  14 + <% end %>
  15 + <%= _('None') if r.empty? %>
  16 + </td>
  17 + </tr>
  18 +
  19 + <%= render :partial => 'article_common', :object => folder %>
  20 + </table>
  21 + <%= render :partial => 'article_last_change', :object => folder %>
  22 +
  23 + <div style="clear:both"></div>
  24 +</li>
... ...
app/views/search/_full_forum.html.erb 0 → 100644
... ... @@ -0,0 +1,24 @@
  1 +<li class="search-forum-item article-item">
  2 + <%= link_to forum.title, forum.view_url, :class => 'search-result-title' %>
  3 + <div class="search-content-first-column">
  4 + <%= render :partial => 'image', :object => forum %>
  5 + </div>
  6 + <table class="noborder search-content-second-column">
  7 + <tr class="search-forum-items">
  8 + <td class="search-field-label"><%= _("Last topics") %></td>
  9 +
  10 + <% r = forum.children.find(:all, :order => :updated_at, :conditions => ['type != ?', 'RssFeed']).last(3) %>
  11 + <td class="<%= "search-field-none" if r.empty? %>">
  12 + <% r.each do |a| %>
  13 + <%= link_to a.title, a.view_url, :class => 'search-forum-sample-item '+icon_for_article(a) %>
  14 + <% end %>
  15 + <%= _('None') if r.empty? %>
  16 + </td>
  17 + </tr>
  18 +
  19 + <%= render :partial => 'article_common', :object => forum %>
  20 + </table>
  21 + <%= render :partial => 'article_last_change', :object => forum %>
  22 +
  23 + <div style="clear:both"></div>
  24 +</li>
... ...
app/views/search/_full_gallery.html.erb 0 → 100644
... ... @@ -0,0 +1,13 @@
  1 +<li class="search-gallery article-item">
  2 + <%= link_to gallery.title, gallery.view_url, :class => 'search-result-title' %>
  3 + <div class="search-content-first-column">
  4 + <%= render :partial => 'image', :object => gallery %>
  5 + </div>
  6 + <table class="noborder search-content-second-column">
  7 + <%= render :partial => 'article_common', :object => gallery %>
  8 + </table>
  9 + <%= render :partial => 'article_last_change', :object => gallery %>
  10 +
  11 + <div style="clear: both"></div>
  12 +</li>
  13 +
... ...
app/views/search/_full_product.rhtml
1   -<% product = item %>
2 1 <% extra_content = @plugins.dispatch(:asset_product_extras, product).collect { |content| instance_eval(&content) } %>
3 2 <% extra_properties = @plugins.dispatch(:asset_product_properties, product)%>
4 3  
... ...
app/views/search/_full_text_article.html.erb 0 → 100644
... ... @@ -0,0 +1,13 @@
  1 +<li class="search-text-article-item article-item">
  2 + <%= link_to(text_article.title, text_article.url, :class => "search-result-title") %>
  3 +
  4 + <div class="search-content-first-column">
  5 + <%= render :partial => 'image', :object => text_article %>
  6 + </div>
  7 + <table class="noborder search-content-second-column">
  8 + <%= render :partial => 'article_common', :object => text_article %>
  9 + </table>
  10 + <%= render :partial => 'article_last_change', :object => text_article %>
  11 +
  12 + <div style="clear: both"></div>
  13 +</li>
... ...
app/views/search/_full_uploaded_file.html.erb 0 → 100644
... ... @@ -0,0 +1,25 @@
  1 +<li class="search-uploaded-file-item article-item">
  2 + <%= link_to uploaded_file.filename, uploaded_file.view_url, :class => 'search-result-title' %>
  3 +
  4 + <div class="search-content-first-column">
  5 + <%= render :partial => 'image', :object => uploaded_file %>
  6 + </div>
  7 +
  8 + <table class="noborder search-content-second-column">
  9 + <%= render :partial => 'article_author', :object => uploaded_file %>
  10 + <%= render :partial => 'article_description', :object => uploaded_file %>
  11 +
  12 + <% if uploaded_file.parent and uploaded_file.parent.published? %>
  13 + <tr class="search-uploaded-file-parent">
  14 + <td class="search-field-label"><%= uploaded_file.parent.gallery? ? _("Gallery") : _("Folder") %></td>
  15 + <td><%= link_to uploaded_file.parent.name, uploaded_file.parent.url %></td>
  16 + </tr>
  17 + <% end %>
  18 +
  19 + <%= render :partial => 'article_tags', :object => uploaded_file.tags %>
  20 + <%= render :partial => 'article_categories', :object => uploaded_file.categories %>
  21 + </table>
  22 + <%= render :partial => 'article_last_change', :object => uploaded_file %>
  23 +
  24 + <div style="clear:both"></div>
  25 +</li>
... ...
app/views/search/_gallery.rhtml
... ... @@ -1,13 +0,0 @@
1   -<li class="search-gallery article-item">
2   - <%= link_to gallery.title, gallery.view_url, :class => 'search-result-title' %>
3   - <div class="search-content-first-column">
4   - <%= render :partial => 'image', :object => gallery %>
5   - </div>
6   - <table class="noborder search-content-second-column">
7   - <%= render :partial => 'article_common', :object => gallery %>
8   - </table>
9   - <%= render :partial => 'article_last_change', :object => gallery %>
10   -
11   - <div style="clear: both"></div>
12   -</li>
13   -
app/views/search/_image.html.erb 0 → 100644
... ... @@ -0,0 +1,52 @@
  1 +<div class="search-image-container">
  2 +
  3 + <% if image.is_a? UploadedFile and image.filename %>
  4 + <% extension = image.extension %>
  5 + <% if ['jpg', 'jpeg', 'gif', 'png', 'tiff', 'svg'].include? extension %>
  6 + <%= link_to '', image.view_url, :class => "search-image-pic", :style => 'background-image: url(%s)'% image.public_filename(:thumb) %>
  7 + <% if image.width && image.height %>
  8 + <% javascript_tag do %>
  9 + image = jQuery('script').last().parent().find('.search-image-pic');
  10 + des_width = parseInt(image.css('width'));
  11 + des_height = parseInt(image.css('height'));
  12 +
  13 + width = <%= image.width %>;
  14 + height = <%= image.height %>;
  15 + scale_factor = width > height ? des_width/width : des_height/height;
  16 +
  17 + image.css({'width' : scale_factor*width +'px', 'height' : scale_factor*height+'px'});
  18 + <% end %>
  19 + <% end %>
  20 + <% elsif ['pdf'].include? extension %>
  21 + <%= link_to '', image.view_url, :class => 'search-image-pic icon-application-pdf' %>
  22 + <% elsif ['doc', 'docx', 'odt', 'rtf', 'txt', 'html', 'htm'].include? extension %>
  23 + <%= link_to '', image.view_url, :class => 'search-image-pic icon-application-vnd-oasis-opendocument-text' %>
  24 + <% elsif ['xls', 'xlsx', 'ods', 'csv', 'tsv', 'tab'].include? extension %>
  25 + <%= link_to '', image.view_url, :class => 'search-image-pic icon-application-vnd-oasis-opendocument-spreadsheet' %>
  26 + <% end %>
  27 + <% elsif image.is_a? Gallery %>
  28 + <div class="search-gallery-items">
  29 + <% r = image.children.find(:all, :order => :updated_at, :conditions => ['type = ?', 'UploadedFile']).last(3) %>
  30 + <% if r.length > 0 %>
  31 + <% r.each do |i| %>
  32 + <%= link_to '', i.view_url, :class => "search-image-pic", :style => 'background-image: url(%s)'% i.public_filename(:thumb) %>
  33 + <% end %>
  34 + <% else %>
  35 + <div class="search-no-image"><span><%= _('No image') %></span></div>
  36 + <% end %>
  37 + </div>
  38 + <% elsif image.is_a? Product %>
  39 + <% if image.image %>
  40 + <div class="zoomable-image">
  41 + <%= link_to '', product_path(image), :class => "search-image-pic",
  42 + :style => 'background-image: url(%s)'% image.default_image(:thumb) %>
  43 + <%= link_to content_tag(:span, _('Zoom in')), image.image.public_filename,
  44 + :class => 'zoomify-image' %>
  45 + </div>
  46 + <% else %>
  47 + <div class="search-no-image"><span><%= _('No image') %></span></div>
  48 + <% end %>
  49 + <% else %>
  50 + <div class="search-content-type-icon icon-content-<%=image.class.to_s.underscore.dasherize%>"></div>
  51 + <% end %>
  52 +</div>
... ...
app/views/search/_image.rhtml
... ... @@ -1,52 +0,0 @@
1   -<div class="search-image-container">
2   -
3   - <% if image.is_a? UploadedFile and image.filename %>
4   - <% extension = image.extension %>
5   - <% if ['jpg', 'jpeg', 'gif', 'png', 'tiff', 'svg'].include? extension %>
6   - <%= link_to '', image.view_url, :class => "search-image-pic", :style => 'background-image: url(%s)'% image.public_filename(:thumb) %>
7   - <% if image.width && image.height %>
8   - <% javascript_tag do %>
9   - image = jQuery('script').last().parent().find('.search-image-pic');
10   - des_width = parseInt(image.css('width'));
11   - des_height = parseInt(image.css('height'));
12   -
13   - width = <%= image.width %>;
14   - height = <%= image.height %>;
15   - scale_factor = width > height ? des_width/width : des_height/height;
16   -
17   - image.css({'width' : scale_factor*width +'px', 'height' : scale_factor*height+'px'});
18   - <% end %>
19   - <% end %>
20   - <% elsif ['pdf'].include? extension %>
21   - <%= link_to '', image.view_url, :class => 'search-image-pic icon-application-pdf' %>
22   - <% elsif ['doc', 'docx', 'odt', 'rtf', 'txt', 'html', 'htm'].include? extension %>
23   - <%= link_to '', image.view_url, :class => 'search-image-pic icon-application-vnd-oasis-opendocument-text' %>
24   - <% elsif ['xls', 'xlsx', 'ods', 'csv', 'tsv', 'tab'].include? extension %>
25   - <%= link_to '', image.view_url, :class => 'search-image-pic icon-application-vnd-oasis-opendocument-spreadsheet' %>
26   - <% end %>
27   - <% elsif image.is_a? Gallery %>
28   - <div class="search-gallery-items">
29   - <% r = image.children.find(:all, :order => :updated_at, :conditions => ['type = ?', 'UploadedFile']).last(3) %>
30   - <% if r.length > 0 %>
31   - <% r.each do |i| %>
32   - <%= link_to '', i.view_url, :class => "search-image-pic", :style => 'background-image: url(%s)'% i.public_filename(:thumb) %>
33   - <% end %>
34   - <% else %>
35   - <div class="search-no-image"><span><%= _('No image') %></span></div>
36   - <% end %>
37   - </div>
38   - <% elsif image.is_a? Product %>
39   - <% if image.image %>
40   - <div class="zoomable-image">
41   - <%= link_to '', product_path(image), :class => "search-image-pic",
42   - :style => 'background-image: url(%s)'% image.default_image(:thumb) %>
43   - <%= link_to content_tag(:span, _('Zoom in')), image.image.public_filename,
44   - :class => 'zoomify-image' %>
45   - </div>
46   - <% else %>
47   - <div class="search-no-image"><span><%= _('No image') %></span></div>
48   - <% end %>
49   - <% else %>
50   - <div class="search-content-type-icon icon-content-<%=image.class.to_s.underscore.dasherize%>"></div>
51   - <% end %>
52   -</div>
app/views/search/_text_article.rhtml
... ... @@ -1,13 +0,0 @@
1   -<li class="search-text-article-item article-item">
2   - <%= link_to(text_article.title, text_article.url, :class => "search-result-title") %>
3   -
4   - <div class="search-content-first-column">
5   - <%= render :partial => 'image', :object => text_article %>
6   - </div>
7   - <table class="noborder search-content-second-column">
8   - <%= render :partial => 'article_common', :object => text_article %>
9   - </table>
10   - <%= render :partial => 'article_last_change', :object => text_article %>
11   -
12   - <div style="clear: both"></div>
13   -</li>
app/views/search/_uploaded_file.rhtml
... ... @@ -1,25 +0,0 @@
1   -<li class="search-uploaded-file-item article-item">
2   - <%= link_to uploaded_file.filename, uploaded_file.view_url, :class => 'search-result-title' %>
3   -
4   - <div class="search-content-first-column">
5   - <%= render :partial => 'image', :object => uploaded_file %>
6   - </div>
7   -
8   - <table class="noborder search-content-second-column">
9   - <%= render :partial => 'article_author', :object => uploaded_file %>
10   - <%= render :partial => 'article_description', :object => uploaded_file %>
11   -
12   - <% if uploaded_file.parent and uploaded_file.parent.published? %>
13   - <tr class="search-uploaded-file-parent">
14   - <td class="search-field-label"><%= uploaded_file.parent.gallery? ? _("Gallery") : _("Folder") %></td>
15   - <td><%= link_to uploaded_file.parent.name, uploaded_file.parent.url %></td>
16   - </tr>
17   - <% end %>
18   -
19   - <%= render :partial => 'article_tags', :object => uploaded_file.tags %>
20   - <%= render :partial => 'article_categories', :object => uploaded_file.categories %>
21   - </table>
22   - <%= render :partial => 'article_last_change', :object => uploaded_file %>
23   -
24   - <div style="clear:both"></div>
25   -</li>