Sha256: 3c701ccfd4c57bb6435aecd6dd8f72ce1aba3620ae5a1c1cd2820388edecc920

Contents?: true

Size: 681 Bytes

Versions: 2

Compression:

Stored size: 681 Bytes

Contents

module Staticpress::Content
  class Index < Base
    include CollectionContent
    extend CollectionContent

    def optional_param_defaults
      { :number => pages_count }
    end

    def pages_count
      (self.class.all_posts.count / config.posts_per_page.to_f).ceil
    end

    def sub_content
      paginate(self.class.all_posts.sort)[params[:number] - 1]
    end

    def template_path
      self.class.template_path
    end

    def self.all
      (1..paginate(all_posts).count).map do |number|
        new(:number => number)
      end
    end

    def self.published
      all
    end

    def self.all_posts
      Staticpress::Content::Post.published
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
staticpress-0.6.2 lib/staticpress/content/index.rb
staticpress-0.6.1 lib/staticpress/content/index.rb