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
    module ClassMethods
      def controls(klass)
        @klass = klass
      end

      def klass
        @klass
      end

      def blog_title(title)
        @title = title
      end

      def title
        @title
      end
    end

    def self.included(base)
      base.extend ClassMethods
      base.before_filter :find_recent_posts,
                         :find_archive_months,
                         :find_all_tags
    end

    def index
      @title = "Blog"
      @blog_posts = self.class.klass.published
    end

    def show
      @blog_post = self.class.klass.find(params[:id])
    end

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

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

    private
    def find_recent_posts
      @recent_posts = self.class.klass.limit(3)
    end

    def find_archive_months
      @blog_archive_months = self.class.klass.archive_months
    end

    def find_all_tags
      @tags = self.class.klass.tag_counts_on(:tags)
    end
  end
end