Class: Staticpress::Content::Index

Inherits:
Base
  • Object
show all
Includes:
CollectionContent, ResourceContent
Defined in:
lib/staticpress/content/index.rb

Instance Attribute Summary

Attributes inherited from Base

#params, #template_types

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ResourceContent

#find_supported_extensions, #gather_resources_from, #load_resource

Methods included from CollectionContent

#template_path, #template_types

Methods inherited from Base

#==, #content, #content_type, #exist?, find_by_url_path, #full_title, #initialize, #layout, #markup_template?, #meta, #output_path, #published?, #raw, #render, #render_partial, #save, #save!, #template_context, #template_engine_options, #template_extension, #template_path_content, #theme, theme, #title, #to_s, type, #url_path

Methods included from Helpers

#config, #extensionless_basename, #extensionless_path, #hash_from_array, #hash_from_match_data, #paginate, #settings, #spider_map, #titleize

Constructor Details

This class inherits a constructor from Staticpress::Content::Base

Class Method Details

.allObject



25
26
27
28
29
# File 'lib/staticpress/content/index.rb', line 25

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

.all_postsObject



35
36
37
# File 'lib/staticpress/content/index.rb', line 35

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

.publishedObject



31
32
33
# File 'lib/staticpress/content/index.rb', line 31

def self.published
  all
end

Instance Method Details

#optional_param_defaultsObject



6
7
8
# File 'lib/staticpress/content/index.rb', line 6

def optional_param_defaults
  { :number => pages_count }
end

#pages_countObject



10
11
12
# File 'lib/staticpress/content/index.rb', line 10

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

#preferred_layout_namesObject



18
19
20
21
22
23
# File 'lib/staticpress/content/index.rb', line 18

def preferred_layout_names
  reply = []
  reply << :post_index if params[:number].nil?
  reply << :post_paged
  reply
end

#sub_contentObject



14
15
16
# File 'lib/staticpress/content/index.rb', line 14

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