blob: 10accb0eb08dbe2b1e0b28c7e0c8492c18d62ecd (
plain) (
tree)
|
|
ApplicationController.class_eval do
include Refinery::Blog::ControllerHelper
before_filter :populate_sidebars
before_filter :populate_home_page, :only => [:home]
protected
def populate_sidebars
@sidebar_modules = []
Refinery::Blog::Category.all.each do |c|
@sidebar_modules << SidebarBlogCategory.new(c)
end
#
# The blog categories and tags are listed in the right sidebar
# on every page.
#
find_all_blog_categories
#find_tags
calc_tags
end
def populate_home_page
@posts = Refinery::Blog::Post
.live
.includes(:comments, :categories)
.where(:refinery_blog_categories => { :sidebar_position => 0 })
.page(params[:page])
end
def calc_tags
# Limit the number of tags to show:
# This should show the 50 most popular tags from the past 30 days.
# I think this is a fair compromise between most popular and recent.
opts = {
:order => 'count DESC',
:start_at => 30.days.ago,
:limit => 50
}
@tags = Refinery::Blog::Post.tag_counts_on(:tags, opts)
if @tags.empty?
opts.delete(:start_at)
@tags = Refinery::Blog::Post.tag_counts_on(:tags, opts)
end
end
end
|