Class: Jekyll::J1Paginator::Generator::PaginationPage
- Inherits:
-
Page
- Object
- Page
- Jekyll::J1Paginator::Generator::PaginationPage
- Defined in:
- lib/j1-paginator/generator/paginationPage.rb
Overview
This page handles the creation of the fake pagination pages based on the original page configuration. The code does the same things as the default Jekyll/page.rb code but just forces the code to look into the template instead of the (currently non-existing) pagination page.
NOTE: This page exists purely in memory and is not read from disk
Instance Attribute Summary collapse
-
#relative_path ⇒ Object
readonly
Returns the value of attribute relative_path.
Instance Method Summary collapse
-
#initialize(page_to_copy, cur_page_nr, total_pages, index_pageandext) ⇒ PaginationPage
constructor
A new instance of PaginationPage.
- #url=(url_value) ⇒ Object (also: #set_url)
Constructor Details
#initialize(page_to_copy, cur_page_nr, total_pages, index_pageandext) ⇒ PaginationPage
Returns a new instance of PaginationPage.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/j1-paginator/generator/paginationPage.rb', line 16 def initialize(page_to_copy, cur_page_nr, total_pages, index_pageandext) @site = page_to_copy.site @base = '' @url = '' @relative_path = page_to_copy.relative_path if cur_page_nr == 1 @dir = File.dirname(page_to_copy.dir) @name = page_to_copy.name else @name = index_pageandext.nil? ? 'index.html' : index_pageandext end self.process(@name) # Creates the basename and ext member values # Copy page data over site defaults defaults = @site.frontmatter_defaults.all(page_to_copy.relative_path, type) self.data = Jekyll::Utils.deep_merge_hashes(defaults, page_to_copy.data) if defaults.has_key?('permalink') self.data['permalink'] = Jekyll::URL.new(:template => defaults['permalink'], :placeholders => self.url_placeholders).to_s @use_permalink_for_url = true end if !page_to_copy.data['autopage'] self.content = page_to_copy.content else # If the page is an auto page then migrate the necessary autopage # info across into the new pagination page (so that users can get # the correct keys etc) if( page_to_copy.data['autopage'].has_key?('display_name') ) self.data['autopages'] = Jekyll::Utils.deep_merge_hashes( page_to_copy.data['autopage'], {} ) end end # Store the current page and total page numbers in the pagination_info # construct self.data['pagination_info'] = {"curr_page" => cur_page_nr, 'total_pages' => total_pages } # Perform some validation that is also performed in Jekyll::Page validate_data! page_to_copy.path validate_permalink! page_to_copy.path # Trigger a page event #Jekyll::Hooks.trigger :pages, :post_init, self end |
Instance Attribute Details
#relative_path ⇒ Object (readonly)
Returns the value of attribute relative_path.
14 15 16 |
# File 'lib/j1-paginator/generator/paginationPage.rb', line 14 def relative_path @relative_path end |
Instance Method Details
#url=(url_value) ⇒ Object Also known as: set_url
63 64 65 |
# File 'lib/j1-paginator/generator/paginationPage.rb', line 63 def url=(url_value) @url = @use_permalink_for_url ? self.data['permalink'] : url_value end |