Class: Bridgetown::Paginate::Generator::PaginationPage
- Inherits:
-
Bridgetown::Page
- Object
- Bridgetown::Page
- Bridgetown::Paginate::Generator::PaginationPage
- Defined in:
- lib/bridgetown-paginate/pagination_page.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 Bridgetown page.rb code but just forces the code to look into the template instead of the (currently non-existing) pagination page. This page exists purely in memory and is not read from disk
Instance Method Summary collapse
-
#initialize(page_to_copy, cur_page_nr, total_pages, index_pageandext, template_ext) ⇒ PaginationPage
constructor
A new instance of PaginationPage.
-
#set_url(url_value) ⇒ Object
rubocop:disable Naming/AccessorMethodName.
Constructor Details
#initialize(page_to_copy, cur_page_nr, total_pages, index_pageandext, template_ext) ⇒ PaginationPage
Returns a new instance of PaginationPage.
15 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 |
# File 'lib/bridgetown-paginate/pagination_page.rb', line 15 def initialize(page_to_copy, cur_page_nr, total_pages, index_pageandext, template_ext) @site = page_to_copy.site @base = "" @url = "" @name = index_pageandext.nil? ? "index#{template_ext}" : index_pageandext @path = page_to_copy.path # Creates the basename and ext member values process(@name) # Only need to copy the data part of the page as it already contains the # layout information self.data = Bridgetown::Utils.deep_merge_hashes page_to_copy.data, {} if !page_to_copy.data["autopage"] self.content = page_to_copy.content elsif page_to_copy.data["autopage"].key?("display_name") # 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) data["autopages"] = Bridgetown::Utils.deep_merge_hashes( page_to_copy.data["autopage"], {} ) end # Store the current page and total page numbers in the pagination_info construct data["pagination_info"] = { "curr_page" => cur_page_nr, "total_pages" => total_pages } # Perform some validation that is also performed in Bridgetown::Page validate_data! page_to_copy.path validate_permalink! page_to_copy.path # TODO: Trigger a page event # Bridgetown::Hooks.trigger :pages, :post_init, self end |
Instance Method Details
#set_url(url_value) ⇒ Object
rubocop:disable Naming/AccessorMethodName
51 52 53 54 55 |
# File 'lib/bridgetown-paginate/pagination_page.rb', line 51 def set_url(url_value) @path = url_value.delete_prefix "/" @dir = File.dirname(@path) @url = url_value end |