app/views/blog/index.html.erb in tb_blog-1.0.4 vs app/views/blog/index.html.erb in tb_blog-1.1.0
- old
+ new
@@ -1,35 +1,37 @@
-<% content_for :title do %>
- Blog | <%=current_site_name%>
-<% end %>
+<% @page_title = 'Blog' %>
<% content_for :head do %>
- <%= spud_blog_rss_link %>
+ <%= spud_blog_rss_link %>
<% end %>
-<div id="spud_blog_filters">
- <%= form_tag blog_path, :class => 'spud_blog_filter_form' do %>
- <label>Category:</label>
- <%= spud_post_category_select %>
- <label>Month:</label>
- <%= spud_post_archive_select %>
- <input type="submit" value="Submit" />
- <% end %>
-</div>
+<% cache(cache_key_for_spud_collection(@posts, :cache_params => [:category_url_name, :archive_date, :page], :for_user => true)) do %>
+ <div id="spud_blog_filters">
+ <%= form_tag blog_path, :class => 'spud_blog_filter_form' do %>
+ <label>Category:</label>
+ <%= spud_post_category_select %>
+ <label>Month:</label>
+ <%= spud_post_archive_select %>
+ <input type="submit" value="Submit" />
+ <% end %>
+ </div>
-<div id="spud_blog_posts">
- <% if @posts.length > 0 %>
- <% @posts.each do |post| %>
- <div class="spud_blog_post">
- <h3><%= link_to post.title, blog_post_path(post.url_name) %></h3>
- <h4>Posted by <%= post.author.full_name %> on <%= post.display_date %></h4>
- <div class="spud_blog_post_content">
- <%= truncate_html post.content_processed.html_safe, :length => 250 %>
- </div>
- </div>
- <% end %>
- <% else %>
- <p>No posts were found in this category</p>
- <% end %>
-</div>
+ <div id="spud_blog_posts">
+ <% if @posts.length > 0 %>
+ <% @posts.includes(:categories, :author).each do |post| %>
+ <% cache(post) do %>
+ <div class="spud_blog_post">
+ <h3><%= link_to post.title, blog_post_path(post.url_name) %></h3>
+ <h4>Posted by <%= post.author.full_name %> on <%= post.display_date %></h4>
+ <div class="spud_blog_post_content">
+ <%= truncate_html post.content_processed.html_safe, :length => 250 %>
+ </div>
+ </div>
+ <% end %>
+ <% end %>
+ <% else %>
+ <p>No posts were found in this category</p>
+ <% end %>
+ </div>
+<% end %>
<%= will_paginate @posts %>