bridgetown-paginate 0.8.0 → 0.8.1

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: 7af8a59db674148dbfbb66a2ade0333ceb589917f22eef04533cde1cd097d65d
4
- data.tar.gz: e75a96fc01a65161609c90923a222883dfcf500102dc9f36d7924468545fc04f
3
+ metadata.gz: ece4df58f98cea6fa950bb3c3ca63cb89c6dbbac4bf00a0b2e12eed31cf91b8e
4
+ data.tar.gz: b967004c16729ed3f95bd07902774e6435b4740d9e4444734dd356b61ae35d7e
5
5
  SHA512:
6
- metadata.gz: b261fecd3cbae9ac8e8f0dfd3e5232e1fc516cd6a667cba3467e23152109d3e5a07364cfee7f694b36cd35f524532f0a01db79415649a9e999faa67c3aceb81a
7
- data.tar.gz: 2a1d1d909a289a7f0578792b11b9eb2d1b2fc30d6cf39de4c52313f0d7eb4237fc8540ad23d994820f3d9fc03355222344bdc5c397cf1ccd3b5657b875d9606b
6
+ metadata.gz: 53e202734aaaa86f82443da095b490f9d2b92cd96778d6329c78537dbdace78b9b7b062257ee3db4dabe030fcd9d33ce97b3c950a8208b9d34d25c898b5526b7
7
+ data.tar.gz: 37abe6427f2ceeac8bbc2c3c38e372ad1de4cfad4b425709aa5420fd356a2f9fef9d84d79ac5ea9f2da6f888c000a03b5385f3818a9b6543bc5153aca6095ad2
@@ -40,6 +40,7 @@ Metrics/MethodLength:
40
40
  Metrics/ParameterLists:
41
41
  Exclude:
42
42
  - lib/bridgetown-paginate/pagination_model.rb
43
+ - lib/bridgetown-paginate/pagination_page.rb
43
44
  - lib/bridgetown-paginate/paginator.rb
44
45
  Metrics/PerceivedComplexity:
45
46
  Exclude:
@@ -13,7 +13,7 @@ module Bridgetown
13
13
  "permalink" => "/page/:num/", # Supports :num as customizable elements
14
14
  "title" => ":title (Page :num)", # Supports :num as customizable elements
15
15
  "page_num" => 1,
16
- "sort_reverse" => false,
16
+ "sort_reverse" => true,
17
17
  "sort_field" => "date",
18
18
  "limit" => 0, # Limit how many content objects to paginate (default: 0, means all)
19
19
  "trail" => {
@@ -271,18 +271,14 @@ module Bridgetown
271
271
  # list of all newly created pages
272
272
  newpages = []
273
273
 
274
- # Consider the default index page name and extension
275
- index_page_name = if config["indexpage"].nil?
276
- ""
277
- else
278
- config["indexpage"].split(".")[0]
279
- end
280
- index_page_ext = if config["extension"].nil?
281
- ""
282
- else
274
+ # Consider the index page name and extension
275
+ # By default, they will be nil and the Page object will infer
276
+ # it from the template used
277
+ index_page_name = config["indexpage"].split(".")[0] unless config["indexpage"].nil?
278
+ index_page_ext = unless index_page_name.nil? || config["extension"].nil?
283
279
  Utils.ensure_leading_dot(config["extension"])
284
280
  end
285
- index_page_with_ext = index_page_name + index_page_ext
281
+ index_page_with_ext = index_page_name + index_page_ext if index_page_name
286
282
 
287
283
  # In case there are no (visible) posts, generate the index file anyway
288
284
  total_pages = 1 if total_pages.zero?
@@ -296,7 +292,13 @@ module Bridgetown
296
292
  # 1. Create the in-memory page
297
293
  # External Proc call to create the actual page for us (this is
298
294
  # passed in when the pagination is run)
299
- newpage = PaginationPage.new template, cur_page_nr, total_pages, index_page_with_ext
295
+ newpage = PaginationPage.new(
296
+ template,
297
+ cur_page_nr,
298
+ total_pages,
299
+ index_page_with_ext,
300
+ template.ext
301
+ )
300
302
 
301
303
  # 2. Create the url for the in-memory page (calc permalink etc),
302
304
  # construct the title, set all page.data values needed
@@ -327,12 +329,12 @@ module Bridgetown
327
329
  # that are defined in the template page before
328
330
  if newpage.pager.page_path.end_with? "/"
329
331
  newpage.set_url(File.join(newpage.pager.page_path, index_page_with_ext))
330
- elsif newpage.pager.page_path.end_with? index_page_ext
332
+ elsif newpage.pager.page_path.end_with? index_page_ext.to_s
331
333
  # Support for direct .html files
332
334
  newpage.set_url(newpage.pager.page_path)
333
335
  else
334
336
  # Support for extensionless permalinks
335
- newpage.set_url(newpage.pager.page_path + index_page_ext)
337
+ newpage.set_url(newpage.pager.page_path + index_page_ext.to_s)
336
338
  end
337
339
 
338
340
  newpage.data["permalink"] = newpage.pager.page_path if template.data["permalink"]
@@ -12,11 +12,11 @@ module Bridgetown
12
12
  # not read from disk
13
13
  #
14
14
  class PaginationPage < Bridgetown::Page
15
- def initialize(page_to_copy, cur_page_nr, total_pages, index_pageandext)
15
+ def initialize(page_to_copy, cur_page_nr, total_pages, index_pageandext, template_ext)
16
16
  @site = page_to_copy.site
17
17
  @base = ""
18
18
  @url = ""
19
- @name = index_pageandext.nil? ? "index.html" : index_pageandext
19
+ @name = index_pageandext.nil? ? "index#{template_ext}" : index_pageandext
20
20
  @path = page_to_copy.path
21
21
 
22
22
  # Creates the basename and ext member values
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.8.0
4
+ version: 0.8.1
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-04-14 00:00:00.000000000 Z
11
+ date: 2020-04-15 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.8.0
19
+ version: 0.8.1
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.8.0
26
+ version: 0.8.1
27
27
  description:
28
28
  email: maintainers@bridgetownrb.com
29
29
  executables: []