Class: Bridgetown::Paginate::PaginationPage

Inherits:
GeneratedPage
  • Object
show all
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

Constructor Details

#initialize(page_to_copy, cur_page_nr, total_pages, index_pageandext, template_ext) ⇒ PaginationPage

Returns a new instance of PaginationPage.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/bridgetown-paginate/pagination_page.rb', line 14

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, {}
  self.content = page_to_copy.content

  # 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

  Bridgetown::Hooks.trigger :pages, :post_init, self
end

Instance Method Details

#set_url(url_value) ⇒ Object

rubocop:disable Naming/AccessorMethodName



40
41
42
43
44
# File 'lib/bridgetown-paginate/pagination_page.rb', line 40

def set_url(url_value)
  @path = url_value.delete_prefix "/"
  @dir  = File.dirname(@path)
  @url = url_value
end