bridgetown-paginate 1.3.4 → 2.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1dfcdfe9b3b335307c35319f0f7b62d11d7d2c45a720dbb09191861decdca205
4
- data.tar.gz: 2a658541e86b51b67344f2f45535d1deb554cde298e43c25cb49d249eba4e6a1
3
+ metadata.gz: 36836aba528fdfc833dec9c1a6d90659e202837472fde5c22873a74095b3cdc9
4
+ data.tar.gz: c5d27698eee4d9e9ebc5c5e86d523ceb5de5c379a852e3a2387b12c13471be55
5
5
  SHA512:
6
- metadata.gz: 8bc3100ec50fd65a3459716043abb82f427a035ea81cc6aa65bef866ec729fe0348046197eeaa6b526f9b8fad497fad83749322622fa1f38d959dc95cf00154d
7
- data.tar.gz: 99740ec5f2229cd4587faf0567578b4aa5ed56b13b86d881417167579868327e0ec37203852851e53127bb26e834919ad91b52595bedc261de4cc545e77f21b5
6
+ metadata.gz: d03c6b845a094ac6163133f89bd510b0501f73fb02c2944678cf2053b754cc6b5e7ddb60243d5b2fae55f833f9f950d6c7e62cb5b5e8f6542087f5f01e8aca55
7
+ data.tar.gz: a893f3dc381b98458b0dc6bbe66033b3a5569fe65644567f26d259d9374f7306f762c214a60e3af4d49a659cc6b187acdc8ac4da2140eaa4608a72ff8130073d
@@ -3,20 +3,19 @@
3
3
  # Handles Generated Pages
4
4
  Bridgetown::Hooks.register_one :generated_pages, :post_init, reloadable: false do |page|
5
5
  if page.class != Bridgetown::Paginate::PaginationPage &&
6
- page.site.config.dig("pagination", "enabled")
7
- data = page.data.with_dot_access
8
- if (data.pagination.present? && data.pagination.enabled != false) ||
9
- (data.paginate.present? && data.paginate.enabled != false)
10
- Bridgetown::Paginate::PaginationGenerator.add_matching_template(page)
11
- end
6
+ page.site.config.dig("pagination", "enabled") && (
7
+ page.data.dig(:pagination, :enabled) != false ||
8
+ page.data.dig(:paginate, :enabled) != false
9
+ )
10
+ Bridgetown::Paginate::PaginationGenerator.add_matching_template(page)
12
11
  end
13
12
  end
14
13
 
15
14
  # Handles Resources
16
15
  Bridgetown::Hooks.register_one :resources, :post_read, reloadable: false do |page|
17
16
  if page.site.config.dig("pagination", "enabled") && (
18
- (page.data.pagination.present? && page.data.pagination.enabled != false) ||
19
- (page.data.paginate.present? && page.data.paginate.enabled != false)
17
+ page.data.dig(:pagination, :enabled) != false ||
18
+ page.data.dig(:paginate, :enabled) != false
20
19
  )
21
20
  Bridgetown::Paginate::PaginationGenerator.add_matching_template(page)
22
21
  end
@@ -97,6 +97,7 @@ module Bridgetown
97
97
  else
98
98
  site.generated_pages.delete(page_to_remove)
99
99
  end
100
+ page_to_remove.unmark_for_fast_refresh!
100
101
  end
101
102
 
102
103
  # Create a proc that will delegate logging
@@ -11,7 +11,15 @@ module Bridgetown
11
11
  # not read from disk
12
12
  #
13
13
  class PaginationPage < Bridgetown::GeneratedPage
14
+ attr_reader :page_to_copy
15
+
14
16
  def initialize(page_to_copy, cur_page_nr, total_pages, index_pageandext, template_ext) # rubocop:disable Lint/MissingSuper
17
+ self.original_resource = if page_to_copy.is_a?(Bridgetown::Resource::Base)
18
+ page_to_copy
19
+ elsif page_to_copy.original_resource
20
+ page_to_copy.original_resource
21
+ end
22
+ @page_to_copy = page_to_copy
15
23
  @site = page_to_copy.site
16
24
  @base = ""
17
25
  @url = ""
@@ -19,6 +27,8 @@ module Bridgetown
19
27
  @path = page_to_copy.path
20
28
  @basename = File.basename(@path, ".*")
21
29
  @ext = File.extname(@name)
30
+ @cur_page_r = cur_page_nr
31
+ @total_pages = total_pages
22
32
 
23
33
  # Only need to copy the data part of the page as it already contains the
24
34
  # layout information
@@ -31,6 +41,20 @@ module Bridgetown
31
41
  Bridgetown::Hooks.trigger :generated_pages, :post_init, self
32
42
  end
33
43
 
44
+ def fast_refresh!
45
+ page_to_copy.fast_refresh! if page_to_copy.respond_to?(:fast_refresh!)
46
+
47
+ self.data = Bridgetown::Utils.deep_merge_hashes page_to_copy.data, {}
48
+ self.content = page_to_copy.content
49
+ # Store the current page and total page numbers in the pagination_info construct
50
+ data["pagination_info"] = { "curr_page" => @cur_page_nr, "total_pages" => @total_pages }
51
+ end
52
+
53
+ def unmark_for_fast_refresh!
54
+ super
55
+ page_to_copy.unmark_for_fast_refresh! if page_to_copy.is_a?(Bridgetown::GeneratedPage)
56
+ end
57
+
34
58
  # rubocop:disable Naming/AccessorMethodName
35
59
  def set_url(url_value)
36
60
  @path = url_value.delete_prefix "/"
@@ -41,7 +65,9 @@ module Bridgetown
41
65
 
42
66
  def destination(dest)
43
67
  path = site.in_dest_dir(
44
- dest, URL.unescape_path(url).delete_prefix(site.base_path(strip_slash_only: true))
68
+ dest, Bridgetown::Utils
69
+ .unencode_uri(url)
70
+ .delete_prefix(site.base_path(strip_slash_only: true))
45
71
  )
46
72
  path = File.join(path, "index") if url.end_with?("/")
47
73
  path << output_ext unless path.end_with? output_ext
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bridgetown-paginate
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.4
4
+ version: 2.0.0.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bridgetown Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-28 00:00:00.000000000 Z
11
+ date: 2024-08-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bridgetown-core
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 1.3.4
19
+ version: 2.0.0.beta1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 1.3.4
26
+ version: 2.0.0.beta1
27
27
  description:
28
28
  email: maintainers@bridgetownrb.com
29
29
  executables: []
@@ -61,11 +61,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
61
61
  version: '0'
62
62
  required_rubygems_version: !ruby/object:Gem::Requirement
63
63
  requirements:
64
- - - ">="
64
+ - - ">"
65
65
  - !ruby/object:Gem::Version
66
- version: '0'
66
+ version: 1.3.1
67
67
  requirements: []
68
- rubygems_version: 3.2.33
68
+ rubygems_version: 3.3.26
69
69
  signing_key:
70
70
  specification_version: 4
71
71
  summary: A Bridgetown plugin to add pagination support for posts and collection indices.