class PlainSite::Data::PostListPage
PostList
Pagination
Attributes
These attributes' accessors are auto generated by OpenStruct attr_reader(
:slug,:display_num, :posts,:prev_page,:next_page, :total_pages_count,:total_posts_count,:page_size,:all_pages, :revert_nos,:site
)
These attributes' accessors are auto generated by OpenStruct attr_reader(
:slug,:display_num, :posts,:prev_page,:next_page, :total_pages_count,:total_posts_count,:page_size,:all_pages, :revert_nos,:site
)
These attributes' accessors are auto generated by OpenStruct attr_reader(
:slug,:display_num, :posts,:prev_page,:next_page, :total_pages_count,:total_posts_count,:page_size,:all_pages, :revert_nos,:site
)
Public Class Methods
Options: slug - The String page name suggested to used in url,first page is 'index',others are 'a'…'zzz' string display_num - The Integer always be ascending,first page is 1,second page is 2 posts - The PostList
prev_page
- The previous PostListPage
next_page
- The next PostListPage
total_pages_count - The Integer of total count in this pagination total_posts_count - The Integer of total count in this pagination page_size - The Integer of preset page size revert_nos - The Boolean indicate if this post list page use revert nos.
When false case,it's html page must be regenerated every time.
site - The Site
belongs to
# File lib/PlainSite/Data/PostListPage.rb, line 28 def initialize(opts) super opts end
Public Instance Methods
# File lib/PlainSite/Data/PostListPage.rb, line 38 def include?(a) posts.include? a end
Pop posts Return Post[]
# File lib/PlainSite/Data/PostListPage.rb, line 57 def pop_multi(n) ret=posts.slice(-n,n) posts=posts.slice(0,-n-1) ret end
Remove posts,resort all previous pages list - The String[] of post's path list
# File lib/PlainSite/Data/PostListPage.rb, line 47 def remove(list) posts=posts.select do |p| list.include? p.path end try_pad_from_other_page end
# File lib/PlainSite/Data/PostListPage.rb, line 63 def try_pad_from_other_page n=page_size-posts.length return [] unless n>0 related_pages=[self] if prev_page posts=prev_page.posts.pop_multi(n)+posts related_pages.concat prev_page.try_pad_from_other_page elsif next_page posts+=next_page.posts.take n end related_pages end
The String url of self
# File lib/PlainSite/Data/PostListPage.rb, line 33 def url site.url_for self end