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.



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

def initialize chapter
  @page = chapter
end

Instance Method Details

#duplicate(original) ⇒ Object



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

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



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

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

#num_pages(site) ⇒ Object



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

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


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

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



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

def source_page site
  @page
end