aboutsummaryrefslogtreecommitdiffstats
path: root/app/helpers/refinery/blog/controller_helper.rb
blob: 7235096f11bbf1540a294cf9df81f91aa233c7f7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
module Refinery
  module Blog
    module ControllerHelper

      protected

        def find_blog_post
          unless (@post = Refinery::Blog::Post.with_globalize.friendly.find(params[:id])).try(:live?)
            if refinery_user? and current_refinery_user.authorized_plugins.include?("refinerycms_blog")
              @post = Refinery::Blog::Post.friendly.find(params[:id])
            else
              error_404
            end
          end
        end

        def find_all_blog_posts
          @posts = Refinery::Blog::Post.live.includes(:comments, :categories).with_globalize.newest_first.page(params[:page])
        end

        def find_tags
          @tags = Refinery::Blog::Post.live.tag_counts_on(:tags)
        end

        def find_all_blog_categories
          @categories = Refinery::Blog::Category.translated
        end
    end
  end
end