jekyll-paginate-v2 1.5.0 → 1.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +41 -43
  3. data/Rakefile +2 -2
  4. data/jekyll-paginate-v2.gemspec +3 -1
  5. data/lib/jekyll-paginate-v2.rb +12 -8
  6. data/lib/jekyll-paginate-v2/autopages/autoTagPages.rb +66 -0
  7. data/lib/jekyll-paginate-v2/autopages/defaults.rb +26 -0
  8. data/lib/jekyll-paginate-v2/autopages/utils.rb +21 -0
  9. data/lib/jekyll-paginate-v2/{compatibilityUtils.rb → generator/compatibilityUtils.rb} +4 -2
  10. data/lib/jekyll-paginate-v2/{defaults.rb → generator/defaults.rb} +3 -2
  11. data/lib/jekyll-paginate-v2/{paginationGenerator.rb → generator/paginationGenerator.rb} +14 -9
  12. data/lib/jekyll-paginate-v2/generator/paginationIndexer.rb +93 -0
  13. data/lib/jekyll-paginate-v2/{paginationModel.rb → generator/paginationModel.rb} +99 -120
  14. data/lib/jekyll-paginate-v2/{paginationPage.rb → generator/paginationPage.rb} +1 -1
  15. data/lib/jekyll-paginate-v2/{paginator.rb → generator/paginator.rb} +1 -1
  16. data/lib/jekyll-paginate-v2/{utils.rb → generator/utils.rb} +11 -4
  17. data/lib/jekyll-paginate-v2/version.rb +4 -4
  18. data/spec/{defaults_spec.rb → generator/defaults_spec.rb} +5 -3
  19. data/spec/generator/paginationPage_spec.rb +12 -0
  20. data/spec/{paginator_spec.rb → generator/paginator_spec.rb} +21 -18
  21. data/spec/generator/utils_spec.rb +90 -0
  22. data/spec/spec_helper.rb +8 -30
  23. metadata +41 -87
  24. data/examples/01-typicalblog/Gemfile +0 -28
  25. data/examples/01-typicalblog/README.md +0 -91
  26. data/examples/01-typicalblog/_config.yml +0 -51
  27. data/examples/01-typicalblog/_includes/header.html +0 -31
  28. data/examples/01-typicalblog/_layouts/home.html +0 -52
  29. data/examples/01-typicalblog/_posts/2016-11-20-geography-of-minneapolis.md +0 -29
  30. data/examples/01-typicalblog/_posts/2016-11-21-sailing-summer-olympics-1988.md +0 -15
  31. data/examples/01-typicalblog/_posts/2016-11-22-rotary-engine.md +0 -27
  32. data/examples/01-typicalblog/_posts/2016-11-23-luft-fahrzeug-gesellschaft.md +0 -27
  33. data/examples/01-typicalblog/_posts/2016-11-24-narcisse-snake-pits.md +0 -18
  34. data/examples/01-typicalblog/_posts/2016-11-25-tele7jours.md +0 -43
  35. data/examples/01-typicalblog/_posts/2016-11-26-columbia-river.md +0 -41
  36. data/examples/01-typicalblog/_posts/2016-11-27-welcome-to-jekyll-paginate-v2.md +0 -33
  37. data/examples/01-typicalblog/about.md +0 -15
  38. data/examples/01-typicalblog/index.html +0 -8
  39. data/examples/02-category/Gemfile +0 -28
  40. data/examples/02-category/README.md +0 -119
  41. data/examples/02-category/_config.yml +0 -47
  42. data/examples/02-category/_includes/header.html +0 -31
  43. data/examples/02-category/_layouts/home.html +0 -52
  44. data/examples/02-category/_posts/2016-10-27-welcome-to-jekyll-paginate-v2.md +0 -32
  45. data/examples/02-category/about.md +0 -15
  46. data/examples/02-category/cars/_posts/2016-10-18-Porsche-918-Spyder.md +0 -13
  47. data/examples/02-category/cars/_posts/2016-10-19-Porsche-964.md +0 -12
  48. data/examples/02-category/cars/_posts/2016-10-20-porsche-911-gt3.md +0 -13
  49. data/examples/02-category/cars/_posts/2016-10-21-porsche-911.md +0 -13
  50. data/examples/02-category/cars/_posts/2016-10-22-porsche-962.md +0 -18
  51. data/examples/02-category/cars/_posts/2016-10-23-Toyota-GT-One.md +0 -20
  52. data/examples/02-category/cars/_posts/2016-10-24-Mercedes-Benz-CLK-GTR.md +0 -40
  53. data/examples/02-category/cars/_posts/2016-10-25-rolls-royce-silver-ghost.md +0 -31
  54. data/examples/02-category/categories/byname.md +0 -11
  55. data/examples/02-category/categories/porsche.md +0 -10
  56. data/examples/02-category/index.md +0 -13
  57. data/examples/02-category/toyota/index.md +0 -7
  58. data/examples/03-tags/Gemfile +0 -28
  59. data/examples/03-tags/README.md +0 -67
  60. data/examples/03-tags/_biography/all/born-to-run.md +0 -26
  61. data/examples/03-tags/_biography/all/forty-autumns.md +0 -26
  62. data/examples/03-tags/_biography/all/life-in-questions-a.md +0 -27
  63. data/examples/03-tags/_biography/all/not-dead-yet.md +0 -24
  64. data/examples/03-tags/_biography/all/princess-diarist-the.md +0 -26
  65. data/examples/03-tags/_biography/all/when-breath-becomes-air.md +0 -24
  66. data/examples/03-tags/_biography/biography-musicians.md +0 -13
  67. data/examples/03-tags/_biography/index.md +0 -12
  68. data/examples/03-tags/_config.yml +0 -57
  69. data/examples/03-tags/_fantasy/all/harry-potter-deathly-hallows.md +0 -24
  70. data/examples/03-tags/_fantasy/all/harry-potter-philosophers-stone.md +0 -24
  71. data/examples/03-tags/_fantasy/all/mistborn-trilogy.md +0 -24
  72. data/examples/03-tags/_fantasy/all/ready-player-one.md +0 -24
  73. data/examples/03-tags/_fantasy/all/sword-of-destiny.md +0 -24
  74. data/examples/03-tags/_fantasy/all/terry-pratchet-diary-2017.md +0 -24
  75. data/examples/03-tags/_includes/header.html +0 -31
  76. data/examples/03-tags/_layouts/home.html +0 -51
  77. data/examples/03-tags/_layouts/post.html +0 -20
  78. data/examples/03-tags/_romance/all/breath-of-snow-and-ashes-a.md +0 -25
  79. data/examples/03-tags/_romance/all/dressmaker-the.md +0 -24
  80. data/examples/03-tags/_romance/all/fiery-cross-the.md +0 -26
  81. data/examples/03-tags/_romance/all/it-ends-with-us.md +0 -28
  82. data/examples/03-tags/_romance/all/outlander-novel.md +0 -34
  83. data/examples/03-tags/_romance/all/virgins-outlander-short-story.md +0 -26
  84. data/examples/03-tags/_romance/romance-historical.md +0 -14
  85. data/examples/03-tags/blog/_posts/2016-09-30-welcome-to-jekyll-paginate-v2.md +0 -32
  86. data/examples/03-tags/byisbn.md +0 -14
  87. data/examples/03-tags/index.md +0 -19
  88. data/examples/03-tags/tags/contemporary.md +0 -11
  89. data/examples/03-tags/tags/fantasy.md +0 -13
  90. data/examples/03-tags/tags/sci-fi.md +0 -16
  91. data/examples/README.md +0 -23
  92. data/examples/img/01-example-screenshot-main.png +0 -0
  93. data/examples/img/02-example-screenshot-main.png +0 -0
  94. data/examples/img/03-example-screenshot-main.png +0 -0
  95. data/spec/utils_spec.rb +0 -65
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5815a5929c866dd11ae6f027f4f3d58bbd584f3f
4
- data.tar.gz: 7d261bcb4d2089d8f196f0ddc71a7961992bbc5d
3
+ metadata.gz: 9254e3f2a00c883968a4d9c511541c99a768e9c4
4
+ data.tar.gz: b65e829454c441a37f427a29642c6a4ee1f17a0c
5
5
  SHA512:
6
- metadata.gz: c18ad4a94390fd030c278ca84beceffe32643926775ca7596679278658ab7665a19f55fffe76662261f88f1e4d725ab6482f5d2e86ddd0d681ec939f9e1f8c1c
7
- data.tar.gz: 823ab882ae1fa5342fd8eca1554b6b921c29abecd585967224c77717edd5e2ab6162b254a6d72fbe791893c3d879cade61d3d611690346285122f48240edd52d
6
+ metadata.gz: b886d5e8cada5d00c0fb94617bcb12c46ac6237e155eef36763f7dfdb489b4efd4356429f476764a7555169d7a3fd0e44b14d7132df1a345cfb5aad9fcab12b5
7
+ data.tar.gz: 2073fa3f77170a1a76ec41bb7ed0f64016143ca5a00b30d3b93b06b491922045a41288f0014d2fb9b06e1b0d17c493c48130db8dc5720603d3a9be79e83187fb
data/README.md CHANGED
@@ -1,21 +1,24 @@
1
1
  # Jekyll::Paginate V2
2
2
 
3
- Pagination gem built specially for Jekyll 3 and newer.
4
- https://rubygems.org/gems/jekyll-paginate-v2
3
+ Pagination gem built specially for Jekyll 3 and newer and is a fully backwards compatable and enhanced replacement for the previously built-in [jekyll-paginate gem](https://github.com/jekyll/jekyll-paginate). View it on [rubygems.org](https://rubygems.org/gems/jekyll-paginate-v2).
5
4
 
6
- Fully backwards compatable and enhanced replacement for the previously built-in [jekyll-paginate gem](https://github.com/jekyll/jekyll-paginate).
5
+ [![Build Status](https://travis-ci.org/sverrirs/jekyll-paginate-v2.svg?branch=master)](https://travis-ci.org/sverrirs/jekyll-paginate-v2)
6
+ [![Gem Version](https://badge.fury.io/rb/jekyll-paginate-v2.svg)](https://badge.fury.io/rb/jekyll-paginate-v2)
7
+ [![Dependency Status](https://gemnasium.com/badges/github.com/sverrirs/jekyll-paginate-v2.svg)](https://gemnasium.com/github.com/sverrirs/jekyll-paginate-v2)
7
8
 
8
- The code was based on the original design of [jekyll-paginate](https://github.com/jekyll/jekyll-paginate) and features were mostly drawn from discussions from the issues pages (especially [#27](https://github.com/jekyll/jekyll-paginate/issues/27)) and some from the excellent [Octopress::Paginate code](https://github.com/octopress/paginate).
9
-
10
- :heart:
9
+ Reach me at the [project issues](https://github.com/sverrirs/jekyll-paginate-v2/issues) section or via email at [jekyll@sverrirs.com](mailto:jekyll@sverrirs.com).
11
10
 
11
+ > The code was based on the original design of [jekyll-paginate](https://github.com/jekyll/jekyll-paginate) and features were sourced discussions such as [#27](https://github.com/jekyll/jekyll-paginate/issues/27) (thanks [Günter Kits](https://github.com/gynter)).
12
12
 
13
13
  * [Installation](#installation)
14
- * [Examples](https://github.com/sverrirs/jekyll-paginate-v2/tree/master/examples)
15
- * [Features](#features)
16
- * [New site configuration](#site-configuration)
17
- * [New page configuration](#page-configuration)
14
+ * [Example Sites](https://github.com/sverrirs/jekyll-paginate-v2/tree/master/examples)
15
+ * [Site configuration](#site-configuration)
16
+ * [Page configuration](#page-configuration)
18
17
  * [Backwards compatibility](#backwards-compatibility-with-jekyll-paginate)
18
+ * [Paginating collections](#paginating-collections)
19
+ + [Single collection](#paginating-a-single-collection)
20
+ + [Multiple collection](#paginating-multiple-collections)
21
+ + [The special 'all' collection](#the-special-all-collection)
19
22
  * [How to paginate categories, tags, locales](#paginate-categories-tags-locales)
20
23
  + [Filtering categories](#filtering-categories)
21
24
  + [Filtering tags](#filtering-tags)
@@ -33,6 +36,10 @@ The code was based on the original design of [jekyll-paginate](https://github.co
33
36
  * [Issues / to-be-completed](#issues--to-be-completed)
34
37
  * [How to Contribute](#contributing)
35
38
 
39
+ > _"Be excellent to each other"_
40
+
41
+ :heart:
42
+
36
43
  ## Installation
37
44
 
38
45
  ```
@@ -45,23 +52,7 @@ Update your [_config.yml](#site-configuration) and [pages](#page-configuration).
45
52
 
46
53
  Now you're ready to run `jekyll serve` and your paginated files should be generated.
47
54
 
48
- Please see the [Examples](https://github.com/sverrirs/jekyll-paginate-v2/tree/master/examples) for more information on how to configure the pagination logic.
49
-
50
-
51
- ## Features
52
-
53
- In addition to all the features offered by the older [jekyll-paginate gem](https://github.com/jekyll/jekyll-paginate) this new pagination plugin features include
54
-
55
- 1. Works with any type of file ending (HTML, Markdown, etc) as long as the file has front-matter and the minimum page level pagination meta (see [page-configuration](#page-configuration)).
56
- 2. Paginated files can have any file name (not just index.html).
57
- 3. Supports category, tag and locale filtering.
58
- 4. Supports any combination of category, tag and locale filtering (e.g. _all posts in the 'ruby' category written for 'en\_US'_ or _all posts in 'car' and 'cycle' category tagged with 'cool' written for 'fr\_FR'_)
59
- 5. Sorting of posts by any field. Decending or Ascending.
60
- 6. Optional limits of number of pagenated pages (e.g. _only produce 15 pages_)
61
- 7. Fully customizable permalink format. E.g `/page:num/` or `/page/:num/` or `/:num/` or really anything you want.
62
- 8. Optional title suffix for paginated pages (e.g. _Index - Page 2_)
63
-
64
- All this while being fully backwards compatible with the old [jekyll-paginate](https://github.com/jekyll/jekyll-paginate) gem.
55
+ Please see the [Examples](https://github.com/sverrirs/jekyll-paginate-v2/tree/master/examples) for tips and tricks on how to configure the pagination logic.
65
56
 
66
57
  ## Site configuration
67
58
 
@@ -76,6 +67,9 @@ pagination:
76
67
  # Site-wide kill switch, disabled here it doesn't run at all
77
68
  enabled: true
78
69
 
70
+ # Set to 'true' to enable pagination debugging. This can be enabled in the site config or only for individual pagination pages
71
+ debug: false
72
+
79
73
  # The default document collection to paginate if nothing is specified ('posts' is default)
80
74
  collection: 'posts'
81
75
 
@@ -85,8 +79,8 @@ pagination:
85
79
  # The permalink structure for the paginated pages (this can be any level deep)
86
80
  permalink: '/page/:num/'
87
81
 
88
- # Optional additional suffix for the title of the paginated pages (the prefix is inherited from the original page)
89
- title_suffix: ' - page :num'
82
+ # Optional the title format for the paginated pages (supports :title for original page title, :num for pagination page number)
83
+ title: ':title - page :num'
90
84
 
91
85
  # Limit how many pagenated pages to create (default: 0, means all)
92
86
  limit: 0
@@ -97,15 +91,15 @@ pagination:
97
91
  # Optional, sorts the posts in reverse order (omit to default decending or sort_reverse: true)
98
92
  sort_reverse: true
99
93
 
100
- # The default category to use, just leave this as 'posts' to get a backwards-compatible behavior (all posts)
94
+ # Optional, the default category to use, omit or just leave this as 'posts' to get a backwards-compatible behavior (all posts)
101
95
  category: 'posts'
102
96
 
103
97
  # Optional, the default tag to use, omit to disable
104
- tag: 'cool'
98
+ tag: ''
105
99
 
106
100
  # Optional, the default locale to use, omit to disable (depends on a field 'locale' to be specified in the posts,
107
101
  # in reality this can be any value, suggested are the Microsoft locale-codes (e.g. en_US, en_GB) or simply the ISO-639 language code )
108
- locale: 'en_US'
102
+ locale: ''
109
103
 
110
104
  ############################################################
111
105
  ```
@@ -161,7 +155,7 @@ The code is fully backwards compatible and you will have access to all the norma
161
155
 
162
156
  Neat!
163
157
 
164
- Please see the [Examples](https://github.com/sverrirs/jekyll-paginate-v2/tree/master/examples) for more detailed information and working site configurations.
158
+ Don't delay, go see the [Examples](https://github.com/sverrirs/jekyll-paginate-v2/tree/master/examples), they're way more useful than read-me docs at this point :)
165
159
 
166
160
  ## Backwards compatibility with jekyll-paginate
167
161
  This gem is fully backwards compatible with the old [jekyll-paginate](https://github.com/jekyll/jekyll-paginate) gem and can be used as a zero-configuration replacement for it. If the old site config is detected then the gem will fall back to the old logic of pagination.
@@ -359,7 +353,7 @@ author:
359
353
  ---
360
354
  ```
361
355
 
362
- You can define pagination sorting on the nested `last` field like so
356
+ You can define pagination sorting on the nested `first` field like so
363
357
 
364
358
  ``` yml
365
359
  ---
@@ -417,15 +411,18 @@ end
417
411
 
418
412
  > bundler/spec_set.rb:95:in `block in materialize': Could not find jekyll-paginate-v2-1.0.0 in any of the sources (Bundler::GemNotFound)
419
413
 
420
- When running `jekyll serve` if you ever get an error similar to the one above the solution is to delete your `Gemfile.lock` file and try again.
414
+ Delete your `Gemfile.lock` file and try again.
421
415
 
422
416
  ### My pagination pages are not being found (Couldn't find any pagination page. Skipping pagination)
423
417
 
424
418
  > Pagination: Is enabled, but I couldn't find any pagination page. Skipping pagination...
425
419
 
426
- Pagination only works inside **pages** they are not supported in the liquid templates. Those are the files that live in the folders prefixed by the underscore (i.e. files under `_layouts/`, `_includes/`, `_posts/` etc ).
427
-
428
- Create a normal page with a `layout:page` in it's front-matter and place the pagination logic there.
420
+ * Ensure that you have the correct minimum front-matter in the pagination pages
421
+ ``` yml
422
+ pagination:
423
+ enabled: true
424
+ ```
425
+ * You can place pagination logic into either the pages or liquid templates (templates are stored under the `_layouts/` and `_includes/` folders).
429
426
 
430
427
  ### My pages are being nested multiple levels deep
431
428
 
@@ -449,15 +446,16 @@ pagination:
449
446
  Make absolutely sure that your pagination permalink paths do not clash with any other paths in your final site. For simplicity it is recommended that you keep all custom pagination (non root index.html) in a single or multiple separate sub folders under your site root.
450
447
 
451
448
  ## Issues / to-be-completed
452
- * Incomplete unit-tests
453
- * No integration tests [#2](https://github.com/jekyll/jekyll-paginate/pull/2)
449
+ * A few missing unit-tests
450
+ * No integration tests yet [#2](https://github.com/jekyll/jekyll-paginate/pull/2)
454
451
  * _Exclude_ filter not implemented [#6](https://github.com/jekyll/jekyll-paginate/issues/6)
455
- * Pagination for [Collections](http://ben.balter.com/2015/02/20/jekyll-collections/) not implemented yet
456
- * Feature being considered is to auto-generate category/tag/language pagination pages. Project still requires programmer to specify the pages him/herself.
452
+ * Considering adding a feature to auto-generate collection/category/tag/locale pagination pages. In cases where projects have hundreds of tags creating the pages by hand is not a feasible option.
457
453
 
458
454
  ## Contributing
459
455
 
460
- I currently need testers and people willing to give me feedback and code reviews.
456
+ I currently really need testers for the gem and people willing to give me feedback and code reviews.
457
+
458
+ If you don't want to open issues here on Github, you can also send me your feedback by email at [jekyll@sverrirs.com](mailto:jekyll@sverrirs.com).
461
459
 
462
460
  1. Fork it ( https://github.com/sverrirs/jekyll-paginate-v2/fork )
463
461
  2. Create your feature branch (`git checkout -b my-new-feature`)
data/Rakefile CHANGED
@@ -8,8 +8,8 @@ Rake::TestTask.new do |t|
8
8
  t.libs.push 'lib'
9
9
  t.libs.push 'specs'
10
10
  t.verbose = true
11
- t.pattern = "spec/*_spec.rb"
12
- t.test_files = FileList['spec/*_spec.rb']
11
+ t.pattern = "spec/**/*_spec.rb"
12
+ t.test_files = FileList['spec/**/*_spec.rb']
13
13
  end
14
14
 
15
15
  desc "Run tests"
@@ -16,7 +16,8 @@ Gem::Specification.new do |spec|
16
16
  spec.summary = %q{Pagination Generator for Jekyll 3}
17
17
  spec.description = %q{An enhanced zero-configuration in-place replacement for the now decomissioned built-in jekyll-paginate gem. This pagination gem offers full backwards compatability as well as a slew of new frequently requested features with minimal additional site and page configuration.}
18
18
 
19
- spec.files = `git ls-files -z`.split("\x0")
19
+ #spec.files = `git ls-files -z`.split("\x0")
20
+ spec.files = Dir['CODE_OF_CONDUCT.md', 'README.md', 'LICENSE', 'Rakefile', '*.gemspec', 'Gemfile', 'lib/**/*', 'spec/**/*']
20
21
  #spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
21
22
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
22
23
  spec.require_paths = ["lib"]
@@ -24,4 +25,5 @@ Gem::Specification.new do |spec|
24
25
  spec.add_development_dependency "jekyll", ">= 3.0"
25
26
  spec.add_development_dependency "bundler", "~> 1.5"
26
27
  spec.add_development_dependency "rake"
28
+ spec.add_development_dependency "minitest", '~> 5.4', '>= 5.4.3'
27
29
  end
@@ -1,4 +1,4 @@
1
- # Jekyll::Paginate V2 is a gem built for Jekyll 3 that generates pagiatation for posts, categories and tags.
1
+ # Jekyll::Paginate V2 is a gem built for Jekyll 3 that generates pagiatation for posts, collections, categories and tags.
2
2
  #
3
3
  # It is based on https://github.com/jekyll/jekyll-paginate, the original Jekyll paginator
4
4
  # which was decommissioned in Jekyll 3 release onwards. This code is currently not officially
@@ -10,13 +10,17 @@
10
10
  # - https://opensource.org/licenses/MIT
11
11
 
12
12
  require "jekyll-paginate-v2/version"
13
- require "jekyll-paginate-v2/defaults"
14
- require "jekyll-paginate-v2/compatibilityUtils"
15
- require "jekyll-paginate-v2/utils"
16
- require "jekyll-paginate-v2/paginator"
17
- require "jekyll-paginate-v2/paginationPage"
18
- require "jekyll-paginate-v2/paginationModel"
19
- require "jekyll-paginate-v2/paginationGenerator"
13
+ # Files needed for the pagination generator
14
+ require "jekyll-paginate-v2/generator/defaults"
15
+ require "jekyll-paginate-v2/generator/compatibilityUtils"
16
+ require "jekyll-paginate-v2/generator/utils"
17
+ require "jekyll-paginate-v2/generator/paginationIndexer"
18
+ require "jekyll-paginate-v2/generator/paginator"
19
+ require "jekyll-paginate-v2/generator/paginationPage"
20
+ require "jekyll-paginate-v2/generator/paginationModel"
21
+ require "jekyll-paginate-v2/generator/paginationGenerator"
22
+ # Files needed for the auto category and tag pages
23
+
20
24
 
21
25
  module Jekyll
22
26
  module PaginateV2
@@ -0,0 +1,66 @@
1
+ #module Jekyll
2
+ # module PaginateV2::AutoPages
3
+ #
4
+ # #
5
+ # # This code is adapted from Stephen Crosby's code https://github.com/stevecrozz
6
+ # Jekyll::Hooks.register :site, :post_read do |site|
7
+ #
8
+ # # Get the configuration for the auto pages
9
+ # default_config = DEFAULT.merge(site.config['autopages'] || {})
10
+ #
11
+ # # If disabled then don't do anything
12
+ # if !default_config['enabled'] || !default_config['tags']
13
+ # Jekyll.logger.debug "AutoPages:","Disabled/Not configured in site.config."
14
+ # return
15
+ # end
16
+ #
17
+ # # TODO: Should I detect here and disable if we're running the legacy paginate code???!
18
+ #
19
+ # # Roll through all documents in the posts collection and extract the tags
20
+ # # construct the paginated tag page for each
21
+ # site.posts.docs.map { |p| p.data['tags'] }.reduce(&:|).each do |tag|
22
+ # site.pages << PaginatedTagPage.new(site, site.source, '', tag, default_config['tags'])
23
+ # end
24
+ # end
25
+ #
26
+ # class PaginatedTagPage < Jekyll::Page
27
+ # def initialize(site, base, dir, tag, tags_config)
28
+ # @site = site
29
+ # @base = base
30
+ # @dir = dir
31
+ # @name = 'index.html'
32
+ # @ext = '.html'
33
+ # @url = Utils.format_tag_macro(tags_config['permalink'], tag)
34
+ #
35
+ # self.read_yaml(File.join(base, '_layouts'), tags_config['layout'])
36
+ # self.data['layout'] = File.basename(tags_config['layout'], File.extname(tags_config['layout']))
37
+ # self.data['title'] = Utils.format_tag_macro(tags_config['title'], tag)
38
+ # self.data['pagination'] = {
39
+ # 'enabled' => true,
40
+ # 'collection' => 'posts',
41
+ # 'sort_field' => 'date',
42
+ # 'sort_reverse' => true,
43
+ # 'tag' => tag
44
+ # }
45
+ #
46
+ # 'enabled' => false,
47
+ # 'collection' => 'posts',
48
+ # 'per_page' => 10,
49
+ # 'permalink' => '/page:num/', # Supports :num as customizable elements
50
+ # 'title_suffix' => ' - page :num', # Supports :num as customizable elements
51
+ # 'page_num' => 1,
52
+ # 'sort_reverse' => false,
53
+ # 'sort_field' => 'date',
54
+ # 'limit' => 0, # Limit how many content objects to paginate (default: 0, means all)
55
+ #
56
+ # self.process(@name)
57
+ #
58
+ # data.default_proc = proc do |_, key|
59
+ # site.frontmatter_defaults.find(File.join(dir, name), type, key)
60
+ # end
61
+ #
62
+ # Jekyll::Hooks.trigger :pages, :post_init, self
63
+ # end
64
+ # end
65
+ # end # module PaginateV2
66
+ #end # module Jekyll
@@ -0,0 +1,26 @@
1
+ module Jekyll
2
+ module PaginateV2::AutoPages
3
+
4
+ # Construct an extended version of the pagination config for the tag pages
5
+ tagDefaults = Jekyll::PaginateV2::Generator::DEFAULT.merge({
6
+ 'layout' => 'autopage_tags.html',
7
+ 'title' => 'Posts tagged with :tag',
8
+ 'permalink' => '/tags/:tag'
9
+ })
10
+
11
+ # Extend the pagination config for the categories as well
12
+ catDefaults = Jekyll::PaginateV2::Generator::DEFAULT.merge({
13
+ 'layout' => 'autopage_category.html',
14
+ 'title' => 'Posts in category :cat',
15
+ 'permalink' => '/category/:cat'
16
+ })
17
+
18
+ # The default configuration for the AutoPages
19
+ DEFAULT = {
20
+ 'enabled' => false,
21
+ 'tags' => tagDefaults,
22
+ 'category'=> catDefaults
23
+ }
24
+
25
+ end # module PaginateV2
26
+ end # module Jekyll
@@ -0,0 +1,21 @@
1
+ module Jekyll
2
+ module PaginateV2::AutoPages
3
+
4
+ class Utils
5
+
6
+ # Static: returns a fully formatted string with the tag macro (:tag) replaced
7
+ #
8
+ def self.format_tag_macro(toFormat, tag)
9
+ return toFormat.sub(':tag', Jekyll::Utils.slugify(tag.to_s)
10
+ end #function format_tag_macro
11
+
12
+ # Static: returns a fully formatted string with the category macro (:cat) replaced
13
+ #
14
+ def self.format_cat_macro(toFormat, category)
15
+ return toFormat.sub(':cat', Jekyll::Utils.slugify(category.to_s))
16
+ end #function format_tag_macro
17
+
18
+ end # class Utils
19
+
20
+ end # module PaginateV2
21
+ end # module Jekyll
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
- module PaginateV2
2
+ module PaginateV2::Generator
3
3
 
4
4
  #
5
5
  # Static utility functions that provide backwards compatibility with the old
@@ -7,6 +7,8 @@ module Jekyll
7
7
  # that sites still running the old gem work without problems
8
8
  # (REMOVE AFTER 2018-01-01)
9
9
  #
10
+ # THIS CLASS IS ADAPTED FROM THE ORIGINAL IMPLEMENTATION AND WILL BE REMOVED, THERE ARE DELIBERATELY NO TESTS FOR THIS CLASS
11
+ #
10
12
  class CompatibilityUtils
11
13
 
12
14
  # Public: Find the Jekyll::Page which will act as the pager template
@@ -48,7 +50,7 @@ module Jekyll
48
50
  # directories, e.g.: page2/index.html, page3/index.html, etc and adds more
49
51
  # site-wide data.
50
52
  #
51
- def self.paginate(legacy_config, all_posts, page, page_create_lambda, logging_lambda )
53
+ def self.paginate(legacy_config, all_posts, page, page_create_lambda )
52
54
  pages = Utils.calculate_number_of_pages(all_posts, legacy_config['per_page'].to_i)
53
55
  (1..pages).each do |num_page|
54
56
  pager = Paginator.new( legacy_config['per_page'], legacy_config['permalink'], all_posts, num_page, pages, page.url, page.path )
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
- module PaginateV2
2
+ module PaginateV2::Generator
3
3
 
4
4
  # The default configuration for the Paginator
5
5
  DEFAULT = {
@@ -7,11 +7,12 @@ module Jekyll
7
7
  'collection' => 'posts',
8
8
  'per_page' => 10,
9
9
  'permalink' => '/page:num/', # Supports :num as customizable elements
10
- 'title_suffix' => ' - page :num', # Supports :num as customizable elements
10
+ 'title' => ':title - page :num', # Supports :num as customizable elements
11
11
  'page_num' => 1,
12
12
  'sort_reverse' => false,
13
13
  'sort_field' => 'date',
14
14
  'limit' => 0, # Limit how many content objects to paginate (default: 0, means all)
15
+ 'debug' => false, # Turns on debug output for the gem
15
16
  'legacy' => false # Internal value, do not use (will be removed after 2018-01-01)
16
17
  }
17
18
 
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
- module PaginateV2
2
+ module PaginateV2::Generator
3
3
 
4
4
  #
5
5
  # The main entry point into the generator, called by Jekyll
@@ -48,7 +48,12 @@ module Jekyll
48
48
  Jekyll.logger.info "Pagination:","Disabled in site.config."
49
49
  return
50
50
  end
51
-
51
+
52
+ # Handle deprecation of settings and features
53
+ if( !default_config['title_suffix' ].nil? )
54
+ Jekyll.logger.warn "Pagination:", "The 'title_suffix' configuration has been deprecated. Please use 'title'. See https://github.com/sverrirs/jekyll-paginate-v2#site-configuration"
55
+ end
56
+
52
57
  Jekyll.logger.debug "Pagination:","Starting"
53
58
 
54
59
  ################ 0 ####################
@@ -108,24 +113,24 @@ module Jekyll
108
113
  # Decoupling Jekyll specific logging
109
114
  logging_lambda = lambda do | message, type="info" |
110
115
  if type == 'debug'
111
- Jekyll.logger.debug "Pagination:", message
116
+ Jekyll.logger.debug "Pagination:","#{message}"
112
117
  elsif type == 'error'
113
- Jekyll.logger.error "Pagination:", message
118
+ Jekyll.logger.error "Pagination:", "#{message}"
114
119
  elsif type == 'warn'
115
- Jekyll.logger.warn "Pagination:", message
120
+ Jekyll.logger.warn "Pagination:", "#{message}"
116
121
  else
117
- Jekyll.logger.info "Pagination:", message
122
+ Jekyll.logger.info "Pagination:", "#{message}"
118
123
  end
119
124
  end
120
125
 
121
126
  ################ 4 ####################
122
127
  # Now create and call the model with the real-life page creation proc and site data
123
- model = PaginationModel.new()
128
+ model = PaginationModel.new(logging_lambda, page_create_lambda, page_remove_lambda, collection_by_name_lambda)
124
129
  if( default_config['legacy'] ) #(REMOVE AFTER 2018-01-01)
125
130
  all_posts = site.site_payload['site']['posts'].reject { |post| post['hidden'] }
126
- model.run_compatability(default_config, all_pages, site_title, all_posts, page_create_lambda, logging_lambda) #(REMOVE AFTER 2018-01-01)
131
+ model.run_compatability(default_config, all_pages, site_title, all_posts) #(REMOVE AFTER 2018-01-01)
127
132
  else
128
- model.run(default_config, all_pages, site_title, page_create_lambda, logging_lambda, page_remove_lambda, collection_by_name_lambda)
133
+ model.run(default_config, all_pages, site_title)
129
134
  end
130
135
 
131
136
  end