bridgetown-paginate 0.17.0 → 0.18.3

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: 6e1361d6ef9ab7a62d2bd9e120ea5a8575df45e672653c0ef0d0ef08886b1e1c
4
- data.tar.gz: 6dc5d22a0b3ae30a961d152d9874893309270ace5cda0bec22cffe01ce414389
3
+ metadata.gz: 634a074156ee472cd73b4649d7543306574ac5abe84f22b196212fbdb5600338
4
+ data.tar.gz: 915d9ddf67cf8f66ba9c10b1fd613a18652af6c134e00d3fd330cc84fbba09ee
5
5
  SHA512:
6
- metadata.gz: d8afb3866ea19f069eff38325eb9418d3d3dbab85752973d5eaf8126f1c39d964520ee986bad141e40382ea62935f1438cc62be91e409ae514e572dcdca74811
7
- data.tar.gz: 59a35d4fef872ed87299e58f2e25f32dfd40559e636632f15c9c9184e3c757222eaf0e6f327d1d1e96a4b629077f3ca4dd662efd4bd888020a004e7d7b7871bf
6
+ metadata.gz: 3666647fb444338b9cc1687494e05785c73110a821f4b90e26ccb4937b788aec416cd787e6b8f4c013369e25711848ce250f2da8e5fcdf7c90261859ab4b460e
7
+ data.tar.gz: '03795927374dcd4297c29c0cfe6e564ff07f6c686635c273590cb11a96f99887009f25df4bf448b704519f410a2ea60e81c5878d5e8cf732502461b46e985577'
@@ -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.17.0
4
+ version: 0.18.3
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-09-17 00:00:00.000000000 Z
11
+ date: 2020-11-01 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.17.0
19
+ version: 0.18.3
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.17.0
26
+ version: 0.18.3
27
27
  description:
28
28
  email: maintainers@bridgetownrb.com
29
29
  executables: []
@@ -61,7 +61,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
61
61
  - !ruby/object:Gem::Version
62
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.