bridgetown-paginate 0.16.0.beta2 → 0.18.1

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: f32ff429d1555611db0b29ff2f0d84b88c4ce1a25c1bb4dc2c9abd46067d3b19
4
- data.tar.gz: 946fe3525d9340e55c31678b77e31505ccefe6258bb010fddb8801074c64ceac
3
+ metadata.gz: 81d942a88662c16dcd180fc5f01c010fe1aa6a97111c5a8fd309470b5f57c84d
4
+ data.tar.gz: 77a3231ca1e7e2ef4032875f7e8b875f942094c1857f3ced49ef327f0c7eb91d
5
5
  SHA512:
6
- metadata.gz: 5e77b90c872453ff8ee825011e4b83a2e64e44cc95599f40026cf39efb8c49d1b146a8b3b6c6f07e0c7b5f977891d84feb328968fe1ad28f65d254cda745dd96
7
- data.tar.gz: 31707297fa5794470ee771beea16a8c802e746bd32f545af9a4ecc7b767819522a2d3cfc2b696fff0a6caa522dc0f86fc91c67dedd4825a679ff484cca478a1e
6
+ metadata.gz: 81e453d78b03ec03fe1d671c6ed584514e09fcf3d90720e738224e6d4bd7564c27916cd9282c6db875661078c82a38f406949342674c497e86a3514a597d73ea
7
+ data.tar.gz: 97d345ccd0e38c5c890e4bf43dfe08e9fbcb4f4363ec9da1dd8c589ac2b75e7f75f0462188fe67e9aef74116c6e4f2a8b2af0a688f745e91304eed4272a0f793
@@ -12,13 +12,6 @@ Bridgetown/NoPutsAllowed:
12
12
  Layout/CommentIndentation:
13
13
  Exclude:
14
14
  - lib/bridgetown-paginate/defaults.rb
15
- Metrics/AbcSize:
16
- Exclude:
17
- - lib/bridgetown-paginate/pagination_generator.rb
18
- - lib/bridgetown-paginate/pagination_indexer.rb
19
- - lib/bridgetown-paginate/pagination_model.rb
20
- - lib/bridgetown-paginate/pagination_page.rb
21
- - lib/bridgetown-paginate/paginator.rb
22
15
  Metrics/BlockNesting:
23
16
  Exclude:
24
17
  - lib/bridgetown-paginate/pagination_model.rb
@@ -27,7 +27,7 @@ module Bridgetown
27
27
  # site - The Site.
28
28
  #
29
29
  # Returns nothing.
30
- def generate(site)
30
+ def generate(site) # rubocop:todo Metrics/AbcSize
31
31
  # Retrieve and merge the pagination configuration from the site yml file
32
32
  default_config = Bridgetown::Utils.deep_merge_hashes(
33
33
  DEFAULT,
@@ -17,7 +17,7 @@ module Bridgetown
17
17
  # Create a hash index for all documents based on a key in the
18
18
  # document.data table
19
19
  #
20
- def self.index_documents_by(all_documents, index_key)
20
+ def self.index_documents_by(all_documents, index_key) # rubocop:todo Metrics/AbcSize
21
21
  return nil if all_documents.nil?
22
22
  return all_documents if index_key.nil?
23
23
 
@@ -30,7 +30,7 @@ module Bridgetown
30
30
  end
31
31
 
32
32
  # rubocop:disable Metrics/BlockLength
33
- def run(default_config, templates, site_title)
33
+ def run(default_config, templates, site_title) # rubocop:todo Metrics/AbcSize
34
34
  if templates.size.to_i <= 0
35
35
  @logging_lambda.call "is enabled in the config, but no paginated pages found." \
36
36
  " Add 'pagination:\\n enabled: true' to the front-matter of a page.", "warn"
@@ -142,7 +142,7 @@ module Bridgetown
142
142
  end
143
143
 
144
144
  # rubocop:disable Layout/LineLength
145
- def _debug_print_config_info(config, page_path)
145
+ def _debug_print_config_info(config, page_path) # rubocop:todo Metrics/AbcSize
146
146
  r = 20
147
147
  f = "Pagination: ".rjust(20)
148
148
  # Debug print the config
@@ -185,6 +185,7 @@ module Bridgetown
185
185
  # template - The index.html Page that requires pagination.
186
186
  # config - The configuration settings that should be used
187
187
  #
188
+ # rubocop:todo Metrics/AbcSize
188
189
  def paginate(template, config, site_title, documents_payload)
189
190
  # By default paginate on all posts in the site
190
191
  using_posts = documents_payload[:posts]
@@ -311,7 +312,7 @@ module Bridgetown
311
312
 
312
313
  # Now for each pagination page create it and configure the ranges for
313
314
  # the collection
314
- # The .pager member is a built in thing in Bridgetown and references the
315
+ # The .paginator member is a built in thing in Bridgetown and references the
315
316
  # paginator implementation
316
317
  # rubocop:disable Metrics/BlockLength
317
318
  (1..total_pages).each do |cur_page_nr|
@@ -338,9 +339,10 @@ module Bridgetown
338
339
  end
339
340
  paginated_page_url = File.join(first_index_page_url, paginated_page_url)
340
341
 
341
- # 3. Create the pager logic for this page, pass in the prev and next
342
- # page numbers, assign pager to in-memory page
343
- newpage.pager = Paginator.new(
342
+ # 3. Create the paginator logic for this page, pass in the prev and next
343
+ # page numbers, assign paginator to in-memory page
344
+ # TODO: remove .pager by v1.0, deprecated
345
+ newpage.paginator = newpage.pager = Paginator.new(
344
346
  config["per_page"],
345
347
  first_index_page_url,
346
348
  paginated_page_url,
@@ -353,17 +355,17 @@ module Bridgetown
353
355
 
354
356
  # Create the url for the new page, make sure we prepend any permalinks
355
357
  # that are defined in the template page before
356
- if newpage.pager.page_path.end_with? "/"
357
- newpage.set_url(File.join(newpage.pager.page_path, index_page_with_ext))
358
- elsif newpage.pager.page_path.end_with? index_page_ext.to_s
358
+ if newpage.paginator.page_path.end_with? "/"
359
+ newpage.set_url(File.join(newpage.paginator.page_path, index_page_with_ext))
360
+ elsif newpage.paginator.page_path.end_with? index_page_ext.to_s
359
361
  # Support for direct .html files
360
- newpage.set_url(newpage.pager.page_path)
362
+ newpage.set_url(newpage.paginator.page_path)
361
363
  else
362
364
  # Support for extensionless permalinks
363
- newpage.set_url(newpage.pager.page_path + index_page_ext.to_s)
365
+ newpage.set_url(newpage.paginator.page_path + index_page_ext.to_s)
364
366
  end
365
367
 
366
- newpage.data["permalink"] = newpage.pager.page_path if template.data["permalink"]
368
+ newpage.data["permalink"] = newpage.paginator.page_path if template.data["permalink"]
367
369
 
368
370
  # Transfer the title across to the new page
369
371
  tmp_title = if !template.data["title"]
@@ -416,7 +418,7 @@ module Bridgetown
416
418
  if trail_before.positive? || trail_after.positive?
417
419
  newpages.select do |npage|
418
420
  # Selecting the beginning of the trail
419
- idx_start = [npage.pager.page - trail_before - 1, 0].max
421
+ idx_start = [npage.paginator.page - trail_before - 1, 0].max
420
422
  # Selecting the end of the trail
421
423
  idx_end = [idx_start + trail_length, newpages.size.to_i].min
422
424
 
@@ -433,11 +435,11 @@ module Bridgetown
433
435
 
434
436
  # Convert the newpages array into a two dimensional array that has
435
437
  # [index, page_url] as items
436
- npage.pager.page_trail = newpages[idx_start...idx_end] \
438
+ npage.paginator.page_trail = newpages[idx_start...idx_end] \
437
439
  .each_with_index.map do |ipage, idx|
438
440
  PageTrail.new(
439
441
  idx_start + idx + 1,
440
- ipage.pager.page_path,
442
+ ipage.paginator.page_path,
441
443
  ipage.data["title"]
442
444
  )
443
445
  end
@@ -445,6 +447,7 @@ module Bridgetown
445
447
  end
446
448
  end
447
449
  end
450
+ # rubocop:enable Metrics/AbcSize
448
451
  end
449
452
  end
450
453
  end
@@ -11,6 +11,7 @@ module Bridgetown
11
11
  # not read from disk
12
12
  #
13
13
  class PaginationPage < Bridgetown::Page
14
+ # rubocop:todo Metrics/AbcSize
14
15
  def initialize(page_to_copy, cur_page_nr, total_pages, index_pageandext, template_ext)
15
16
  @site = page_to_copy.site
16
17
  @base = ""
@@ -44,6 +45,7 @@ module Bridgetown
44
45
 
45
46
  Bridgetown::Hooks.trigger :pages, :post_init, self
46
47
  end
48
+ # rubocop:enable Metrics/AbcSize
47
49
 
48
50
  # rubocop:disable Naming/AccessorMethodName
49
51
  def set_url(url_value)
@@ -13,7 +13,7 @@ module Bridgetown
13
13
 
14
14
  # Initialize a new Paginator.
15
15
  #
16
- def initialize(
16
+ def initialize( # rubocop:todo Metrics/AbcSize
17
17
  config_per_page,
18
18
  first_index_page_url,
19
19
  paginated_page_url,
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: 0.16.0.beta2
4
+ version: 0.18.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bridgetown Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-24 00:00:00.000000000 Z
11
+ date: 2020-10-30 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: 0.16.0.beta2
19
+ version: 0.18.1
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: 0.16.0.beta2
26
+ version: 0.18.1
27
27
  description:
28
28
  email: maintainers@bridgetownrb.com
29
29
  executables: []
@@ -57,11 +57,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
57
57
  version: '0'
58
58
  required_rubygems_version: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - ">"
60
+ - - ">="
61
61
  - !ruby/object:Gem::Version
62
- version: 1.3.1
62
+ version: '0'
63
63
  requirements: []
64
- rubygems_version: 3.0.6
64
+ rubygems_version: 3.1.4
65
65
  signing_key:
66
66
  specification_version: 4
67
67
  summary: A Bridgetown plugin to add pagination support for posts and collection indices.