jekyll-paginate-v2 1.3.1 → 1.3.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: e40078ff1d6e37ea3e12e5c00a6d19918532cc9f
4
- data.tar.gz: 5b48bf3d7056f77ffe6a5644127bd8f48460d75c
3
+ metadata.gz: 0d7de5f8ddc3857991231c6f4a76ef803728a164
4
+ data.tar.gz: 6c516cc6e012ecbea06f9a859401d36cc99cae71
5
5
  SHA512:
6
- metadata.gz: 4b30be9bf65547b50bb37bbb088e3f6836efcae6f0e5ea44c44109502b38b1f078f89f5676afdef1555a852cfe6c8efc8f6f04f31a90eeaed164272445a8c31f
7
- data.tar.gz: 84286d55555990445f81c14245e7371277ad12d6d1867f32129f709f4f51dd9a4792619e5268b3761de80f757bee72c905b13e157d81a2da2d1f76eb65b0cfd9
6
+ metadata.gz: 7858c9b171488a7a956ec3bc226ca7ee8f0ea2467866bcb74ddb4f9db57bcf1b0efa8427cd2f76c98e5aa96185d0bb50648faf39ab5554182a8c70a97aa9213e
7
+ data.tar.gz: 46de0b546ff6bb11a1848535685710bc6b6eb6260f726602f74fe842da038f60efca60fc1b0b9a623183892b161524832830bfdcf3e1af45a8390061a18542e5
data/README.md CHANGED
@@ -10,6 +10,22 @@ The code was based on the original design of [jekyll-paginate](https://github.co
10
10
  :heart:
11
11
 
12
12
 
13
+ * [Installation](#installation)
14
+ * [Features](#features)
15
+ * [New site configuration](#site-configuration)
16
+ * [New page configuration](#page-configuration)
17
+ * [Backwards compatibility](#backwards-compatibility-with-jekyll-paginate)
18
+ * [How to paginate categories, tags, locales](#paginate-categories-tags-locales)
19
+ + [Filtering categories](#filtering-categories)
20
+ + [Filtering tags](#filtering-tags)
21
+ + [Filtering locales](#filtering-locales)
22
+ * [How to paginate on combination of filters](#paginate-on-combination-of-filters)
23
+ * [Specifying configuration overrides](#configuration-overrides)
24
+ * [Common issues](#common-issues)
25
+ - [Bundler error upgrading gem (Bundler::GemNotFound)](#im-getting-a-bundler-error-after-upgrading-the-gem-bundlergemnotfound)
26
+ * [Issues / to-be-completed](#issues--to-be-completed)
27
+ * [How to Contribute](#contributing)
28
+
13
29
  ## Installation
14
30
 
15
31
  ```
@@ -38,28 +54,6 @@ In addition to all the features offered by the older [jekyll-paginate gem](https
38
54
 
39
55
  All this while being fully backwards compatible with the old [jekyll-paginate](https://github.com/jekyll/jekyll-paginate) gem.
40
56
 
41
- ## Issues / to-be-completed
42
- * Incomplete unit-tests
43
- * Missing integration tests [#2](https://github.com/jekyll/jekyll-paginate/pull/2)
44
- * Missing more detailed examples
45
- * Unable to auto-generate category/tag/language pagination pages. Still requires programmer to specify the pages him/herself.
46
- * _Exclude_ filter not implemented [#6](https://github.com/jekyll/jekyll-paginate/issues/6)
47
-
48
- ## Contributing
49
-
50
- I currently need testers and people willing to give me feedback and code reviews.
51
-
52
- 1. Fork it ( https://github.com/sverrirs/jekyll-paginate-v2/fork )
53
- 2. Create your feature branch (`git checkout -b my-new-feature`)
54
- 3. Run the unit tests (`rake`)
55
- 4. Commit your changes (`git commit -am 'Add some feature'`)
56
- 5. Build the gem locally (`gem build jekyll-paginate-v2.gemspec`)
57
- 6. Test and verify the gem locally (`gem install ./jekyll-paginate-v2-x.x.x.gem`)
58
- 7. Push to the branch (`git push origin my-new-feature`)
59
- 8. Create new Pull Request
60
-
61
- Note: This project uses [semantic versioning](http://semver.org/).
62
-
63
57
  ## Site configuration
64
58
 
65
59
  The plugin can be configured in the site's `_config.yml` file by including the `pagination` configuration element
@@ -104,20 +98,6 @@ pagination:
104
98
  ############################################################
105
99
  ```
106
100
 
107
- ### Backwards compatibility with jekyll-paginate
108
- 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.
109
-
110
- > You cannot run both the new pagination logic and the old one at the same time
111
-
112
- The following `_config.yml` settings are honored when running this gem in compatability mode
113
-
114
- ``` yml
115
- paginate: 8
116
- paginate_path: "/legacy/page:num/"
117
- ```
118
-
119
- See more about the old style of pagination at the [jekyll-paginate](https://github.com/jekyll/jekyll-paginate) page.
120
-
121
101
  ## Page configuration
122
102
 
123
103
  To enable pagination on a page (i.e. make that page a template for pagination) then simply include the minimal pagination configuration in the page front-matter:
@@ -163,6 +143,23 @@ The code is fully backwards compatible and you will have access to all the norma
163
143
 
164
144
  Neat!
165
145
 
146
+ ## Backwards compatibility with jekyll-paginate
147
+ 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.
148
+
149
+ > You cannot run both the new pagination logic and the old one at the same time
150
+
151
+ The following `_config.yml` settings are honored when running this gem in compatability mode
152
+
153
+ ``` yml
154
+ paginate: 8
155
+ paginate_path: "/legacy/page:num/"
156
+ ```
157
+
158
+ See more about the old style of pagination at the [jekyll-paginate](https://github.com/jekyll/jekyll-paginate) page.
159
+
160
+ > :bangbang: **Warning** Backwards compatibility with the old jekyll-paginate gem is currently scheduled to be removed after **1st January 2018**. Users will start receiving warning log messages when running jekyll two months before this date.
161
+
162
+
166
163
  ## Paginate categories, tags, locales
167
164
 
168
165
  Enabling pagination for specific categories, tags or locales is as simple as adding values to the pagination template front-matter and corresponding values in the posts.
@@ -276,3 +273,25 @@ pagination:
276
273
  > 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)
277
274
 
278
275
  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.
276
+
277
+ ## Issues / to-be-completed
278
+ * Incomplete unit-tests
279
+ * Missing integration tests [#2](https://github.com/jekyll/jekyll-paginate/pull/2)
280
+ * Missing more detailed examples
281
+ * Unable to auto-generate category/tag/language pagination pages. Still requires programmer to specify the pages him/herself.
282
+ * _Exclude_ filter not implemented [#6](https://github.com/jekyll/jekyll-paginate/issues/6)
283
+
284
+ ## Contributing
285
+
286
+ I currently need testers and people willing to give me feedback and code reviews.
287
+
288
+ 1. Fork it ( https://github.com/sverrirs/jekyll-paginate-v2/fork )
289
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
290
+ 3. Run the unit tests (`rake`)
291
+ 4. Commit your changes (`git commit -am 'Add some feature'`)
292
+ 5. Build the gem locally (`gem build jekyll-paginate-v2.gemspec`)
293
+ 6. Test and verify the gem locally (`gem install ./jekyll-paginate-v2-x.x.x.gem`)
294
+ 7. Push to the branch (`git push origin my-new-feature`)
295
+ 8. Create new Pull Request
296
+
297
+ Note: This project uses [semantic versioning](http://semver.org/).
@@ -48,12 +48,12 @@ module Jekyll
48
48
  # directories, e.g.: page2/index.html, page3/index.html, etc and adds more
49
49
  # site-wide data.
50
50
  #
51
- def self.paginate(legacy_config, all_posts, page, &page_create_proc )
51
+ def self.paginate(legacy_config, all_posts, page, page_create_lambda, logging_lambda )
52
52
  pages = Utils.calculate_number_of_pages(all_posts, legacy_config['per_page'].to_i)
53
53
  (1..pages).each do |num_page|
54
54
  pager = Paginator.new( legacy_config['per_page'], legacy_config['permalink'], all_posts, num_page, pages, page.url )
55
55
  if num_page > 1
56
- newpage = page_create_proc.call( page.dir, page.name )
56
+ newpage = page_create_lambda.call( page.dir, page.name )
57
57
  newpage.pager = pager
58
58
  newpage.dir = Utils.paginate_path(page.url, num_page, legacy_config['permalink'])
59
59
  else
@@ -65,6 +65,7 @@ module Jekyll
65
65
 
66
66
  ################ 2 ####################
67
67
  # Create the proc that constructs the real-life site page
68
+ # This is necessary to decouple the code from the Jekyll site object
68
69
  page_create_lambda = lambda do | template_dir, template_name |
69
70
  # Create the new page
70
71
  newpage = Page.new( site, site.source, template_dir, template_name)
@@ -75,12 +76,27 @@ module Jekyll
75
76
  end
76
77
 
77
78
  ################ 3 ####################
79
+ # Create a proc that will delegate logging
80
+ # Decoupling Jekyll specific logging
81
+ logging_lambda = lambda do | message, type="info" |
82
+ if type == 'debug'
83
+ Jekyll.logger.debug "Pagination:", message
84
+ elsif type == 'error'
85
+ Jekyll.logger.error "Pagination:", message
86
+ elsif type == 'warn'
87
+ Jekyll.logger.warn "Pagination:", message
88
+ else
89
+ Jekyll.logger.info "Pagination:", message
90
+ end
91
+ end
92
+
93
+ ################ 4 ####################
78
94
  # Now create and call the model with the real-life page creation proc and site data
79
95
  model = PaginationModel.new()
80
96
  if( default_config['legacy'] ) #(REMOVE AFTER 2018-01-01)
81
- model.run_compatability(default_config, all_pages, site_title, all_posts, &page_create_lambda) #(REMOVE AFTER 2018-01-01)
97
+ model.run_compatability(default_config, all_pages, site_title, all_posts, page_create_lambda, logging_lambda) #(REMOVE AFTER 2018-01-01)
82
98
  else
83
- model.run(default_config, all_pages, site_title, all_posts, &page_create_lambda)
99
+ model.run(default_config, all_pages, site_title, all_posts, page_create_lambda, logging_lambda)
84
100
  end
85
101
 
86
102
  end
@@ -3,12 +3,13 @@ module Jekyll
3
3
 
4
4
  class PaginationModel
5
5
 
6
- def run(default_config, site_pages, site_title, all_posts, &page_create_proc)
6
+ def run(default_config, site_pages, site_title, all_posts, page_create_lambda, logging_lambda)
7
7
  # By default if pagination is enabled we attempt to find all index.html pages in the site
8
8
  templates = self.discover_paginate_templates(site_pages)
9
9
  if( templates.size.to_i <= 0 )
10
- Jekyll.logger.warn "Pagination:","is enabled, but I couldn't find " +
11
- "any index.html page to use as the pagination template. Skipping pagination."
10
+ logging_lambda.call "Is enabled, but I couldn't find any pagination template page "+
11
+ "to use as the pagination template. Skipping pagination. "+
12
+ "Templates must have 'paginate: enabled: true' in their front-matter.", "warn"
12
13
  return
13
14
  end
14
15
 
@@ -29,10 +30,10 @@ module Jekyll
29
30
  # requiring this makes the logic simpler as I don't need to determine which index pages
30
31
  # were generated automatically and which weren't
31
32
  if( template_config['enabled'] )
32
- Jekyll.logger.info "Pagination:","found template: "+template.path
33
+ logging_lambda.call "found template: "+template.path
33
34
  # Now construct the pagination data for this template page
34
35
  #self.paginate(site, template, template_config, all_posts, all_tags, all_categories, all_locales)
35
- self.paginate(template, template_config, site_title, all_posts, all_tags, all_categories, all_locales, &page_create_proc)
36
+ self.paginate(template, template_config, site_title, all_posts, all_tags, all_categories, all_locales, page_create_lambda, logging_lambda)
36
37
  end
37
38
  end
38
39
  end #for
@@ -43,21 +44,27 @@ module Jekyll
43
44
  # no changes should be made to this function and it should be retired and deleted after 2018-01-01
44
45
  # (REMOVE AFTER 2018-01-01)
45
46
  #
46
- def run_compatability(legacy_config, site_pages, site_title, all_posts, &page_create_proc)
47
+ def run_compatability(legacy_config, site_pages, site_title, all_posts, page_create_lambda, logging_lambda)
47
48
 
49
+ # Decomissioning error
48
50
  if( date = Date.strptime("20180101","%Y%m%d") <= Date.today )
49
51
  raise ArgumentError.new("Legacy jekyll-paginate configuration compatibility mode has expired. Please upgrade to jekyll-paginate-v2 configuration.")
50
52
  end
51
53
 
52
- Jekyll.logger.warn "Pagination:", "Detected legacy jekyll-paginate logic being run. "+
54
+ # Two month warning or general notification
55
+ if( date = Date.strptime("20171101","%Y%m%d") <= Date.today )
56
+ logging_lambda.call "Legacy pagination logic will stop working on Jan 1st 2018, update your configs before that time.", "warn"
57
+ else
58
+ logging_lambda.call "Detected legacy jekyll-paginate logic being run. "+
53
59
  "Please update your configs to use the new pagination logic (gem jekyll-paginate-v2). This compatibility function "+
54
60
  "will stop working after Jan 1st 2018 and your site build will throw an error."
55
-
61
+ end
62
+
56
63
  if template = CompatibilityUtils.template_page(site_pages, legacy_config['legacy_source'], legacy_config['permalink'])
57
- CompatibilityUtils.paginate(legacy_config, all_posts, template, &page_create_proc)
64
+ CompatibilityUtils.paginate(legacy_config, all_posts, template, page_create_lambda, logging_lambda)
58
65
  else
59
- Jekyll.logger.warn "Pagination:", "Legacy pagination is enabled, but I couldn't find " +
60
- "an index.html page to use as the pagination template. Skipping pagination."
66
+ logging_lambda.call "Legacy pagination is enabled, but I couldn't find " +
67
+ "an index.html page to use as the pagination template. Skipping pagination.", "warn"
61
68
  end
62
69
  end # function run_compatability (REMOVE AFTER 2018-01-01)
63
70
 
@@ -182,7 +189,7 @@ module Jekyll
182
189
  # template - The index.html Page that requires pagination.
183
190
  # config - The configuration settings that should be used
184
191
  #
185
- def paginate(template, config, site_title, all_posts, all_tags, all_categories, all_locales, &page_create_proc)
192
+ def paginate(template, config, site_title, all_posts, all_tags, all_categories, all_locales, page_create_lambda, logging_lambda)
186
193
  # By default paginate on all posts in the site
187
194
  using_posts = all_posts
188
195
 
@@ -216,7 +223,7 @@ module Jekyll
216
223
  pager = Paginator.new( config['per_page'], config['permalink'], using_posts, cur_page_nr, total_pages, template.url )
217
224
  if( cur_page_nr > 1)
218
225
  # External Proc call to create the actual page for us (this is passed in when the pagination is run)
219
- newpage = page_create_proc.call( template.dir, template.name )
226
+ newpage = page_create_lambda.call( template.dir, template.name )
220
227
  newpage.pager = pager
221
228
  newpage.dir = Utils.paginate_path(template.url, cur_page_nr, config['permalink'])
222
229
  if( config.has_key?('title_suffix'))
@@ -1,5 +1,8 @@
1
1
  module Jekyll
2
2
  module PaginateV2
3
- VERSION = "1.3.1"
3
+ VERSION = "1.3.2"
4
+ # When modifying remember to issue a new tag command in git before committing, then push the new tag
5
+ # git tag -a v1.3.1 -m "Gem v1.3.1"
6
+ # git push origin --tags
4
7
  end
5
8
  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.3.1
4
+ version: 1.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sverrir Sigmundarson