aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilip Arndt <parndt@gmail.com>2011-09-19 19:06:25 -0700
committerPhilip Arndt <parndt@gmail.com>2011-09-19 19:06:25 -0700
commit8a69c623bb8a3fa9c03d25b8253fd710da081198 (patch)
tree863d62228de1f2e3b45e44bd7a618c60664630e6
parent7fe5fe5de6a0e7ef8ac011d7d6b85c61a2f6be96 (diff)
parent1b51e2343d477d2065c016d77ef73d527cb37b0e (diff)
downloadrefinerycms-blog-8a69c623bb8a3fa9c03d25b8253fd710da081198.tar.gz
refinerycms-blog-8a69c623bb8a3fa9c03d25b8253fd710da081198.tar.bz2
refinerycms-blog-8a69c623bb8a3fa9c03d25b8253fd710da081198.zip
Merge pull request #139 from resolve/abstract-filters-into-controller-helper
Abstract filters into controller helper
-rw-r--r--app/controllers/refinery/blog/base_controller.rb17
-rw-r--r--app/controllers/refinery/blog/categories_controller.rb2
-rw-r--r--app/controllers/refinery/blog/posts_controller.rb23
-rw-r--r--app/controllers/refinery/blog_controller.rb18
-rw-r--r--app/helpers/refinery/blog/controller_helper.rb30
5 files changed, 49 insertions, 41 deletions
diff --git a/app/controllers/refinery/blog/base_controller.rb b/app/controllers/refinery/blog/base_controller.rb
new file mode 100644
index 0000000..01892d1
--- /dev/null
+++ b/app/controllers/refinery/blog/base_controller.rb
@@ -0,0 +1,17 @@
+module Refinery
+ module Blog
+ class BaseController < ::ApplicationController
+
+ include ControllerHelper
+
+ helper :'refinery/blog_posts'
+ before_filter :find_page, :find_all_blog_categories
+
+ protected
+
+ def find_page
+ @page = Refinery::Page.find_by_link_url("/blog")
+ end
+ end
+ end
+end
diff --git a/app/controllers/refinery/blog/categories_controller.rb b/app/controllers/refinery/blog/categories_controller.rb
index 57196c3..80e54d9 100644
--- a/app/controllers/refinery/blog/categories_controller.rb
+++ b/app/controllers/refinery/blog/categories_controller.rb
@@ -1,6 +1,6 @@
module Refinery
module Blog
- class CategoriesController < BlogController
+ class CategoriesController < BaseController
def show
@category = Refinery::BlogCategory.find(params[:id])
diff --git a/app/controllers/refinery/blog/posts_controller.rb b/app/controllers/refinery/blog/posts_controller.rb
index 3041439..7b09329 100644
--- a/app/controllers/refinery/blog/posts_controller.rb
+++ b/app/controllers/refinery/blog/posts_controller.rb
@@ -1,6 +1,6 @@
module Refinery
module Blog
- class PostsController < BlogController
+ class PostsController < BaseController
caches_page :index
@@ -71,27 +71,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
deleted file mode 100644
index cbafdeb..0000000
--- a/app/controllers/refinery/blog_controller.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-module Refinery
- class BlogController < ::ApplicationController
-
- helper :'refinery/blog_posts'
- before_filter :find_page, :find_all_blog_categories
-
- protected
-
- 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..74a189b
--- /dev/null
+++ b/app/helpers/refinery/blog/controller_helper.rb
@@ -0,0 +1,30 @@
+module Refinery
+ module Blog
+ module ControllerHelper
+
+ 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
+end