diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/refinery/blog/posts_controller.rb | 23 | ||||
-rw-r--r-- | app/controllers/refinery/blog_controller.rb | 7 | ||||
-rw-r--r-- | app/helpers/refinery/blog_controller_helper.rb | 28 |
3 files changed, 32 insertions, 26 deletions
diff --git a/app/controllers/refinery/blog/posts_controller.rb b/app/controllers/refinery/blog/posts_controller.rb index 3041439..a885d18 100644 --- a/app/controllers/refinery/blog/posts_controller.rb +++ b/app/controllers/refinery/blog/posts_controller.rb @@ -1,6 +1,8 @@ module Refinery module Blog class PostsController < BlogController + + include BlogControllerHelper caches_page :index @@ -71,27 +73,6 @@ module Refinery @tag_name = @tag.name @blog_posts = Refinery::BlogPost.tagged_with(@tag_name).page(params[:page]) end - - protected - - def find_blog_post - unless (@blog_post = Refinery::BlogPost.find(params[:id])).try(:live?) - if refinery_user? and current_user.authorized_plugins.include?("refinerycms_blog") - @blog_post = Refinery::BlogPost.find(params[:id]) - else - error_404 - end - end - end - - def find_all_blog_posts - @blog_posts = Refinery::BlogPost.live.includes(:comments, :categories).page(params[:page]) - end - - def find_tags - @tags = Refinery::BlogPost.tag_counts_on(:tags) - end - end end end diff --git a/app/controllers/refinery/blog_controller.rb b/app/controllers/refinery/blog_controller.rb index cbafdeb..b875b44 100644 --- a/app/controllers/refinery/blog_controller.rb +++ b/app/controllers/refinery/blog_controller.rb @@ -1,5 +1,7 @@ module Refinery class BlogController < ::ApplicationController + + include BlogControllerHelper helper :'refinery/blog_posts' before_filter :find_page, :find_all_blog_categories @@ -9,10 +11,5 @@ module Refinery def find_page @page = Refinery::Page.find_by_link_url("/blog") end - - def find_all_blog_categories - @blog_categories = Refinery::BlogCategory.all - end - end end diff --git a/app/helpers/refinery/blog_controller_helper.rb b/app/helpers/refinery/blog_controller_helper.rb new file mode 100644 index 0000000..2edc2f6 --- /dev/null +++ b/app/helpers/refinery/blog_controller_helper.rb @@ -0,0 +1,28 @@ +module Refinery + module BlogControllerHelper + + protected + + def find_blog_post + unless (@blog_post = Refinery::BlogPost.find(params[:id])).try(:live?) + if refinery_user? and current_user.authorized_plugins.include?("refinerycms_blog") + @blog_post = Refinery::BlogPost.find(params[:id]) + else + error_404 + end + end + end + + def find_all_blog_posts + @blog_posts = Refinery::BlogPost.live.includes(:comments, :categories).page(params[:page]) + end + + def find_tags + @tags = Refinery::BlogPost.tag_counts_on(:tags) + end + + def find_all_blog_categories + @blog_categories = Refinery::BlogCategory.all + end + end +end |