jekyll-paginate-v2 1.9.1 → 1.9.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
  SHA1:
3
- metadata.gz: 24170ee95f3de77a471c81f08e58f83c034221be
4
- data.tar.gz: e3b5f53cdac7ed6bb44765a8f0f1521e137fdb26
3
+ metadata.gz: f15ac980bc5f0d9247bc5c939e01b60817ac572d
4
+ data.tar.gz: 2aba630fd12a6b32d4ab3df5efadb0b005590c8d
5
5
  SHA512:
6
- metadata.gz: c0fa098d8199206b2ca2b5764149e9647c70cfc0e5d2cdf261ffbcb0ec17734772f618730bd3e9fe04a3a70905b34b8139af512c4495fa21a0b9c8d83696f94f
7
- data.tar.gz: a04720418e0ce53f02ece44f3cac28723bc66c759367d0d5c3d49b803a9bd85f8bbd70f0412f2cdb22b0f13619f571d36cad59659db7ca20706cfca10bb7b17e
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' => 'index', # The default name of the index pages
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
- # Adjust the first index page url
35
- if( first_index_page_url.end_with?('/'))
36
- first_index_page_url = first_index_page_url + default_indexpage + default_ext
37
- puts "Appending default index+ext: #{first_index_page_url}"
38
- elsif !first_index_page_url.include?('.')
39
- first_index_page_url = first_index_page_url + default_indexpage
40
- puts "Appending default index only: #{first_index_page_url}"
41
- end
42
-
43
- # Adjust the paginated pages as well
44
- if( paginated_page_url.end_with?('/'))
45
- paginated_page_url = paginated_page_url + default_indexpage + default_ext
46
- puts "Appending default paginated index+ext: #{paginated_page_url}"
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 = @page == 1 ? first_index_page_url : Utils.format_page_number(paginated_page_url, cur_page_nr, @total_pages)
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 != 1 ? @page == 2 ? first_index_page_url : Utils.format_page_number(paginated_page_url, @previous_page, @total_pages) : nil
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.1"
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.1 -m "Gem v1.9.1"
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, "/", "/feed:num", posts, 2, 5, 'feed', '.json')
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 '/feed.json'
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-paginate-v2
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.1
4
+ version: 1.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sverrir Sigmundarson