Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
neoteric-blog / app / controllers / neoteric / blog_posts_controller.rb
Size: Mime:
module Neoteric
  module BlogPostsController
    def self.included(base)
      base.before_filter :find_recent_posts,
                         :find_archive_months,
                         :find_all_tags
    end

    def index
      @title = "Blog"
      @blog_posts = BLOG_POST_CLASS.published
    end

    def show
      @blog_post = BLOG_POST_CLASS.find(params[:id])
    end

    def archive
      @title = "Posted in #{Date::MONTHNAMES[params[:month].to_i]} #{params[:year]}"
      @blog_posts = BLOG_POST_CLASS.by_month(params[:year], params[:month])
      render :template => 'blog_posts/index'
    end

    def tagged
      @tag = params[:tag]
      @title = "Posts tagged '#{@tag}'"
      @blog_posts = BLOG_POST_CLASS.tagged_with(@tag)
      render :template => 'blog_posts/index'
    end

    private
    def find_recent_posts
      @recent_posts = BLOG_POST_CLASS.limit(3)
    end

    def find_archive_months
      @blog_archive_months = BLOG_POST_CLASS.archive_months
    end

    def find_all_tags
      @tags = BLOG_POST_CLASS.tag_counts_on(:tags)
    end
  end
end