app/controllers/blog_controller.rb in spud_blog-0.9.11 vs app/controllers/blog_controller.rb in spud_blog-1.0.0.rc1

- old
+ new

@@ -1,27 +1,26 @@ class BlogController < ApplicationController - + # include ActionController::Caching::Sweeping respond_to :html, :xml, :json, :rss layout Spud::Blog.base_layout before_filter :find_post, :only => :show - caches_action :show, :index, - :expires => Spud::Blog.config.action_caching_duration, - :if => Proc.new{ |c| - Spud::Blog.cache_mode == :action && !(c.params[:page] && c.params[:page].to_i > 1) && (SpudPost.where(:is_news => false).future_posts.count == 0) - } + # caches_action :show, :index, + # :expires => Spud::Blog.config.action_caching_duration, + # :if => Proc.new{ |c| + # Spud::Blog.cache_mode == :action && !(c.params[:page] && c.params[:page].to_i > 1) && (SpudPost.where(:is_news => false).future_posts.count == 0) + # } - after_filter :only => [:show, :index] do |c| - if Spud::Blog.cache_mode == :full_page && !(c.params[:page] && c.params[:page].to_i > 1) - if (SpudPost.where(:is_news => false).future_posts.count == 0) - c.cache_page(nil, nil, false) - end - end - end + # after_filter :only => [:show, :index] do |c| + # if Spud::Blog.cache_mode == :full_page && !(c.params[:page] && c.params[:page].to_i > 1) + # if (SpudPost.where(:is_news => false).future_posts.count == 0) + # c.cache_page(nil, nil, false) + # end + # end + # end - cache_sweeper :spud_post_comment_sweeper, :only => [:create_comment] def index page = 1 if params[:page].blank? == false page = params[:page].to_i @@ -108,11 +107,11 @@ @post = SpudPost.find(params[:id]) if @post.blank? flash[:error] = "Post not found!" redirect_to blog_path and return false end - @comment = @post.comments.new(params[:spud_post_comment]) + @comment = @post.comments.new(comment_params) @comment.user_agent = request.env["HTTP_USER_AGENT"] @comment.user_ip = request.remote_ip @comment.referrer = request.referrer @comment.approved = true @comment.permalink = blog_post_url(@post.url_name) @@ -120,16 +119,20 @@ respond_with @comment do |format| format.html { redirect_to blog_post_path(@post.url_name, :anchor => 'spud_post_comment_form') } end end - private +private def find_post @post = SpudPost.find_by_url_name(params[:id]) if @post.blank? || @post.is_private? || (Spud::Core.config.multisite_mode_enabled && !@post.spud_site_ids.include?(current_site_id)) flash[:error] = "Post not found!" redirect_to blog_path and return false end + end + + def comment_params + params.require(:spud_post_comment).permit(:author,:content) end end