bridgetown-paginate 0.16.0 → 0.18.2

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: a305aede852429eb5dfb62d357d10af0ed09b1832eff26d6d9780406a4bd60f7
4
- data.tar.gz: c4d3ea6922b7b1df77408e661fafe52d790f5156fdbde7111d0ff07d7a8f69f2
3
+ metadata.gz: 79988105e12d918a177756e2fbdf261d79e009c0179a20afcc7cdc3bf2f57508
4
+ data.tar.gz: eaa59a37bc9ba68517bfed43196f15c445cf72ef298a82ec42d869f19a6982c6
5
5
  SHA512:
6
- metadata.gz: 2e77bfb929332576ac68f7251a31d8b165427aa39031a2cdc8fe867260b8311152624aa8ae4e26445f6bad42757526c9224861ece72564dc0764a77b4cb6270b
7
- data.tar.gz: cee9ed878040eff24e79a5fa228d64512091dacae6f4adc532cc23208ead2b20807dd311f197125d62a43a675f4c13eff73306ee6f57e3f627d536826a685f5c
6
+ metadata.gz: ba8930be7efa2f26864bbc88176856031a3c4df79c9ef00ee4ac318e1993c8c7584b96b07993bcb3c9b9cbf2a20c586386f00a1ef325f9c8c36acb107a9a3b78
7
+ data.tar.gz: b28fba4508804a8c1b77d1cbc360beea1c4bd649cc7103c5b17a60976ab865768f38fd43b284757a503f7e365f758299ca51a858978564a828242b5661447167
@@ -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
4
+ version: 0.18.2
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-28 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
19
+ version: 0.18.2
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
26
+ version: 0.18.2
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.