app/controllers/blog_controller.rb in spud_blog-0.6.3 vs app/controllers/blog_controller.rb in spud_blog-0.7.0
- old
+ new
@@ -1,18 +1,24 @@
class BlogController < ApplicationController
-
- respond_to :html, :xml, :json,:rss
-
+ respond_to :html, :xml, :json, :rss
layout Spud::Blog.base_layout
caches_action :show, :index,
- :expires => Spud::Blog.config.caching_expires_in,
+ :expires => Spud::Blog.config.action_caching_duration,
:if => Proc.new{ |c|
- Spud::Blog.config.caching_enabled && !(c.params[:page] && c.params[:page].to_i > 1)
+ Spud::Blog.config.enable_action_caching && !(c.params[:page] && c.params[:page].to_i > 1)
}
+ after_filter :only => [:show, :index] do |c|
+ if Spud::Blog.enable_full_page_caching && !(c.params[:page] && c.params[:page].to_i > 1)
+ c.cache_page(nil, nil, false)
+ end
+ end
+
+ cache_sweeper :spud_post_comment_sweeper, :only => [:create_comment]
+
def index
@posts = SpudPost.public_blog_posts(params[:page], Spud::Blog.config.posts_per_page)
respond_with @posts
end
@@ -63,13 +69,10 @@
flash[:error] = "Post not found!"
redirect_to blog_path and return false
end
@comment = @post.comments.new(params[:spud_post_comment])
@comment.approved = true
- if @comment.save
- flash[:notice] = 'Your comment has been posted, however it will not appear until it is approved.'
- expire_action blog_post_url(@post.url_name)
- end
+ flash[:notice] = 'Your comment has been posted, however it will not appear until it is approved.' if @comment.save
respond_with @comment do |format|
format.html { redirect_to blog_post_path(@post.url_name, :anchor => 'spud_post_comment_form') }
end
end
\ No newline at end of file