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 +4 -4
- data/.rubocop.yml +0 -7
- data/lib/bridgetown-paginate/pagination_generator.rb +1 -1
- data/lib/bridgetown-paginate/pagination_indexer.rb +1 -1
- data/lib/bridgetown-paginate/pagination_model.rb +18 -15
- data/lib/bridgetown-paginate/pagination_page.rb +2 -0
- data/lib/bridgetown-paginate/paginator.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 634a074156ee472cd73b4649d7543306574ac5abe84f22b196212fbdb5600338
|
4
|
+
data.tar.gz: 915d9ddf67cf8f66ba9c10b1fd613a18652af6c134e00d3fd330cc84fbba09ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3666647fb444338b9cc1687494e05785c73110a821f4b90e26ccb4937b788aec416cd787e6b8f4c013369e25711848ce250f2da8e5fcdf7c90261859ab4b460e
|
7
|
+
data.tar.gz: '03795927374dcd4297c29c0cfe6e564ff07f6c686635c273590cb11a96f99887009f25df4bf448b704519f410a2ea60e81c5878d5e8cf732502461b46e985577'
|
data/.rubocop.yml
CHANGED
@@ -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 .
|
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
|
342
|
-
# page numbers, assign
|
343
|
-
|
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.
|
357
|
-
newpage.set_url(File.join(newpage.
|
358
|
-
elsif newpage.
|
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.
|
362
|
+
newpage.set_url(newpage.paginator.page_path)
|
361
363
|
else
|
362
364
|
# Support for extensionless permalinks
|
363
|
-
newpage.set_url(newpage.
|
365
|
+
newpage.set_url(newpage.paginator.page_path + index_page_ext.to_s)
|
364
366
|
end
|
365
367
|
|
366
|
-
newpage.data["permalink"] = newpage.
|
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.
|
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.
|
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.
|
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)
|
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.
|
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-
|
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.
|
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.
|
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.
|
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.
|