Class: RageRender::ChapterArchivePaginator

Inherits:
Object
  • Object
show all
Includes:
PaginationGenerator
Defined in:
lib/ragerender/jekyll/archive.rb

Overview

Note that this one doesn’t descend from Jekyll::Generator, because we don’t want it to be invoked automatically, only when we create a chapter page.

Instance Method Summary collapse

Methods included from PaginationGenerator

#generate

Constructor Details

#initialize(chapter) ⇒ ChapterArchivePaginator

Returns a new instance of ChapterArchivePaginator.



69
70
71
# File 'lib/ragerender/jekyll/archive.rb', line 69

def initialize chapter
  @page = chapter
end

Instance Method Details

#duplicate(original) ⇒ Object



77
78
79
80
81
# File 'lib/ragerender/jekyll/archive.rb', line 77

def duplicate original
  page = Jekyll::Document.new(original.path, site: original.site, collection: original.collection)
  page.merge_data! original.data, source: 'original document'
  page
end

#handle_page(page) ⇒ Object



95
96
97
# File 'lib/ragerender/jekyll/archive.rb', line 95

def handle_page page
  page.collection.docs << page
end

#num_pages(site) ⇒ Object



83
84
85
86
87
# File 'lib/ragerender/jekyll/archive.rb', line 83

def num_pages site
  site.collections['comics'].docs.select do |c|
    c.data['chapter'] == @page.data['slug']
  end.each_slice(COMICS_PER_PAGE).size
end


89
90
91
92
93
# File 'lib/ragerender/jekyll/archive.rb', line 89

def permalink
  path = Pathname.new(@page.url)
  path = path.dirname unless @page.url.end_with?('/')
  path.join('page/:number/index.html').to_path
end

#source_page(site) ⇒ Object



73
74
75
# File 'lib/ragerender/jekyll/archive.rb', line 73

def source_page site
  @page
end