jekyll-paginate-v2 1.9.1 → 1.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/jekyll-paginate-v2/generator/defaults.rb +2 -2
- data/lib/jekyll-paginate-v2/generator/paginationModel.rb +2 -2
- data/lib/jekyll-paginate-v2/generator/paginator.rb +19 -20
- data/lib/jekyll-paginate-v2/generator/utils.rb +11 -0
- data/lib/jekyll-paginate-v2/version.rb +2 -2
- data/spec/generator/paginator_spec.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f15ac980bc5f0d9247bc5c939e01b60817ac572d
|
4
|
+
data.tar.gz: 2aba630fd12a6b32d4ab3df5efadb0b005590c8d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0eacf17144bd636451263625cc0c1ad9850d112070a69c0e6bcd3e37acc84095722bbfe469f04560ed17c619618ee4ed61667eb26b03110df0ca85066a0ce915
|
7
|
+
data.tar.gz: 73a3e97b8db75f491f2b30294109c84c3839f52917e8e5f03010a6709053e9cf08151a889874a8210b8a7a1c8d0eb794d9dbbde558e8dacf1643609e3e85b63f
|
@@ -16,8 +16,8 @@ module Jekyll
|
|
16
16
|
'before' => 0, # Limits how many links to show before the current page in the pagination trail (0, means off, default: 0)
|
17
17
|
'after' => 0, # Limits how many links to show after the current page in the pagination trail (0 means off, default: 0)
|
18
18
|
},
|
19
|
-
'indexpage' =>
|
20
|
-
'extension' => 'html', # The default extension for the output pages
|
19
|
+
'indexpage' => nil, # The default name of the index pages
|
20
|
+
'extension' => 'html', # The default extension for the output pages (ignored if indexpage is nil)
|
21
21
|
'debug' => false, # Turns on debug output for the gem
|
22
22
|
'legacy' => false # Internal value, do not use (will be removed after 2018-01-01)
|
23
23
|
}
|
@@ -263,8 +263,8 @@ module Jekyll
|
|
263
263
|
newpages = []
|
264
264
|
|
265
265
|
# Consider the default index page name and extension
|
266
|
-
indexPageName = config['indexpage'].split('.')[0]
|
267
|
-
indexPageExt = Utils.ensure_leading_dot(config['extension'])
|
266
|
+
indexPageName = config['indexpage'].nil? ? '' : config['indexpage'].split('.')[0]
|
267
|
+
indexPageExt = config['extension'].nil? ? '' : Utils.ensure_leading_dot(config['extension'])
|
268
268
|
indexPageWithExt = indexPageName + indexPageExt
|
269
269
|
|
270
270
|
# In case there are no (visible) posts, generate the index file anyway
|
@@ -31,34 +31,33 @@ module Jekyll
|
|
31
31
|
init = (@page - 1) * @per_page
|
32
32
|
offset = (init + @per_page - 1) >= posts.size ? posts.size : (init + @per_page - 1)
|
33
33
|
|
34
|
-
#
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
paginated_page_url = paginated_page_url
|
46
|
-
|
47
|
-
elsif !paginated_page_url.include?('.')
|
48
|
-
paginated_page_url = paginated_page_url + default_ext
|
49
|
-
puts "Appending default paginated ext only: #{paginated_page_url}"
|
50
|
-
end
|
34
|
+
# Ensure that the current page has correct extensions if needed
|
35
|
+
this_page_url = Utils.ensure_full_path(@page == 1 ? first_index_page_url : paginated_page_url,
|
36
|
+
!default_indexpage || default_indexpage.length == 0 ? 'index' : default_indexpage,
|
37
|
+
!default_ext || default_ext.length == 0 ? '.html' : default_ext)
|
38
|
+
|
39
|
+
# To support customizable pagination pages we attempt to explicitly append the page name to
|
40
|
+
# the url incase the user is using extensionless permalinks.
|
41
|
+
if default_indexpage && default_indexpage.length > 0
|
42
|
+
# Adjust first page url
|
43
|
+
first_index_page_url = Utils.ensure_full_path(first_index_page_url, default_indexpage, default_ext)
|
44
|
+
# Adjust the paginated pages as well
|
45
|
+
paginated_page_url = Utils.ensure_full_path(paginated_page_url, default_indexpage, default_ext)
|
46
|
+
end
|
51
47
|
|
52
48
|
@total_posts = posts.size
|
53
49
|
@posts = posts[init..offset]
|
54
|
-
@page_path =
|
50
|
+
@page_path = Utils.format_page_number(this_page_url, cur_page_nr, @total_pages)
|
51
|
+
|
55
52
|
@previous_page = @page != 1 ? @page - 1 : nil
|
56
|
-
@previous_page_path = @page
|
53
|
+
@previous_page_path = @page == 1 ? nil :
|
54
|
+
@page == 2 ? Utils.format_page_number(first_index_page_url, 1, @total_pages) :
|
55
|
+
Utils.format_page_number(paginated_page_url, @previous_page, @total_pages)
|
57
56
|
@next_page = @page != @total_pages ? @page + 1 : nil
|
58
57
|
@next_page_path = @page != @total_pages ? Utils.format_page_number(paginated_page_url, @next_page, @total_pages) : nil
|
59
58
|
|
60
59
|
@first_page = 1
|
61
|
-
@first_page_path = first_index_page_url
|
60
|
+
@first_page_path = Utils.format_page_number(first_index_page_url, 1, @total_pages)
|
62
61
|
@last_page = @total_pages
|
63
62
|
@last_page_path = Utils.format_page_number(paginated_page_url, @total_pages, @total_pages)
|
64
63
|
end
|
@@ -124,6 +124,17 @@ module Jekyll
|
|
124
124
|
end
|
125
125
|
end
|
126
126
|
|
127
|
+
# Ensures that the passed in url has a index and extension applied
|
128
|
+
def self.ensure_full_path(url, default_index, default_ext)
|
129
|
+
if( url.end_with?('/'))
|
130
|
+
return url + default_index + default_ext
|
131
|
+
elsif !url.include?('.')
|
132
|
+
return url + default_index
|
133
|
+
end
|
134
|
+
# Default
|
135
|
+
return url
|
136
|
+
end
|
137
|
+
|
127
138
|
end
|
128
139
|
|
129
140
|
end # module PaginateV2
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module Jekyll
|
2
2
|
module PaginateV2
|
3
|
-
VERSION = "1.9.
|
3
|
+
VERSION = "1.9.2"
|
4
4
|
# When modifying remember to issue a new tag command in git before committing, then push the new tag
|
5
|
-
# git tag -a v1.9.
|
5
|
+
# git tag -a v1.9.2 -m "Gem v1.9.2"
|
6
6
|
# git push origin --tags
|
7
7
|
# Yanking a published Gem
|
8
8
|
# gem yank jekyll-paginate-v2 -v VERSION
|
@@ -135,7 +135,7 @@ module Jekyll::PaginateV2::Generator
|
|
135
135
|
# Initialize a pager with
|
136
136
|
# 5 posts per page
|
137
137
|
# at page 2 out of 5 pages
|
138
|
-
pager = Paginator.new(5, "/", "/
|
138
|
+
pager = Paginator.new(5, "/", "/", posts, 2, 5, 'feed:num', '.json')
|
139
139
|
|
140
140
|
pager.page.must_equal 2
|
141
141
|
pager.per_page.must_equal 5
|
@@ -148,7 +148,7 @@ module Jekyll::PaginateV2::Generator
|
|
148
148
|
pager.posts[4].must_equal '10'
|
149
149
|
|
150
150
|
pager.previous_page.must_equal 1
|
151
|
-
pager.previous_page_path.must_equal '/
|
151
|
+
pager.previous_page_path.must_equal '/feed1.json'
|
152
152
|
pager.next_page.must_equal 3
|
153
153
|
pager.next_page_path.must_equal '/feed3.json'
|
154
154
|
end
|