Commit 34496635bedb7eff88a46f809375258de18b9b91

Authored by Rodrigo Souto
2 parents 1b7634a3 c44a4256

Merge branch 'full-blog-posts' into stable

app/models/blog.rb
... ... @@ -81,4 +81,8 @@ class Blog < Folder
81 81 posts.empty?
82 82 end
83 83  
  84 + def last_posts(limit=3)
  85 + posts.where("type != 'RssFeed'").order(:updated_at).limit(limit)
  86 + end
  87 +
84 88 end
... ...
app/views/search/_full_blog.html.erb
... ... @@ -7,12 +7,12 @@
7 7 <tr class="search-blog-items">
8 8 <td class="search-field-label"><%= _("Last posts") %></td>
9 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) %>
  10 + <% last_posts = blog.last_posts %>
  11 + <td class="<%= "search-field-none" if last_posts.empty? %>">
  12 + <% last_posts.each do |post| %>
  13 + <%= link_to post.title, post.view_url, :class => 'search-blog-sample-item '+icon_for_article(post) %>
14 14 <% end %>
15   - <%= _('None') if r.empty? %>
  15 + <%= _('None') if last_posts.empty? %>
16 16 </td>
17 17 </tr>
18 18  
... ...