jekyll-paginate-v2 2.0.0 → 3.0.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 5b1be5a3a418704b6d5798054c310cb0d1db73c8
4
- data.tar.gz: a0861fb2289e24c3ebc6d0047a9f4e55c7e8b866
2
+ SHA256:
3
+ metadata.gz: 87dc86f06aedb8e2c1e0b3d398a3580bb00d31569577ebb4ab6bfdefb45ad572
4
+ data.tar.gz: fd0c6a583189811309acd885c468eb2ed19555e8223743e285a7eecbd575c1a6
5
5
  SHA512:
6
- metadata.gz: 6ac0fae0864bed484368ce0dd83645e177809c0a90c0fb8a1b55536cb15ecd693bbe9dcd058d90c7e797f1ba834ba0ba7fa2c8ef6464f6ccf73929e1a4c2254f
7
- data.tar.gz: b7bf4594ed5718a301b49a118f4b040627f4705d601ef52cb0e79223c9b12436c900637a83048bdeb41bfaaca771618199eb2fe617b9f61c6f9f65baaac73d66
6
+ metadata.gz: 8bf26590ccba733825ab51cc305fdfb914d235983984d734ffdb9c5a95a97acb63c78ca6930c252431e81f8bffe25bb27fd10f87edb2c0915ef0a7e49d82c2ac
7
+ data.tar.gz: c51a21cb26af1df50f5fd26693828b09321bc556b986be7abdc10e26b333aa3251bf100fc6d059dfc8fc4025b8b511a87df7f9f62878d858de4910a80b2ea9cd
@@ -100,42 +100,5 @@ An example of this can be found in [examples/03-tags/_layouts/autopage_collectio
100
100
  ### Title should not contain pagination macros
101
101
  There is no need to include the pagination title macros `:num`, `:max` or `:title` in the title configuration. The autopages will use the title configuration from the pagination configuration itself.
102
102
 
103
- ### Categories and tags with spaces
104
- If you have category or tag names with spaces, make sure you use either
105
- 1. the singular forms (`tag`, `category`), or
106
- 2. the plural forms (`tags`, `categories`) using the YAML array syntax.
107
-
108
- See [Filtering categories](https://github.com/sverrirs/jekyll-paginate-v2/blob/master/README-GENERATOR.md#filtering-categories) for more information.
109
-
110
- ### Special characters
111
-
112
- As of v1.9.4, special characters are supported in category, tag, and collection names by default:
113
-
114
- ``` yml
115
- category: sports car, b+w
116
- ```
117
-
118
- If you need to support the previous behavior where special characters are replaced with hyphens in URLs, use the new `slugify` option:
119
-
120
- ``` yml
121
- autopages:
122
- categories:
123
- enabled: true
124
- slugify:
125
- mode: nil
126
- cased: true
127
- ```
128
-
129
- The following modes are available:
130
-
131
- | Value| Description |
132
- | --- | --- |
133
- | `none` | No conversion (default) |
134
- | `raw` | Replace sequences of spaces with a hyphen |
135
- | `nil` | Replace non-alphabetic characters with a hyphen |
136
- | `pretty` | Keep some non-alphabetic characters (._~!$&'()+,;=@) |
137
-
138
- If `cased` is set to `true`, all uppercase letters are replaced with their lowercase counterparts.
139
-
140
103
  ## Common issues
141
- _None reported so far_
104
+ _None reported so far_
@@ -21,6 +21,7 @@ The **Generator** forms the core of the pagination logic. It is responsible for
21
21
  + [Filtering locales](#filtering-locales)
22
22
  * [How to paginate on combination of filters](#paginate-on-combination-of-filters)
23
23
  * [Overriding site configuration](#configuration-overrides)
24
+ * [Offsetting posts (how to skip newest posts)](#offsetting-posts)
24
25
  * [Advanced Sorting](#advanced-sorting)
25
26
  * [Creating Pagination Trails](#creating-pagination-trails)
26
27
  * [How to detect auto-generated pages](#detecting-generated-pagination-pages)
@@ -271,36 +272,6 @@ pagination:
271
272
  category: software, ruby
272
273
  ```
273
274
 
274
- You may use also use `categories` instead:
275
-
276
- ``` yml
277
- pagination:
278
- enabled: true
279
- categories:
280
- - software
281
- - ruby
282
- ```
283
-
284
- **Note:** Do *not* use `categories` as follows:
285
-
286
- ``` yml
287
- categories: programming language, ruby
288
- ```
289
-
290
- i.e. with category names that have spaces in them. Jekyll will split the above using spaces as the delimiter, resulting in `programming`, `language,`, and `ruby` as categories. Instead, use
291
-
292
- ``` yml
293
- category: programming language, ruby
294
- ```
295
-
296
- or
297
-
298
- ``` yml
299
- categories:
300
- - programming language
301
- - ruby
302
- ```
303
-
304
275
  > To define categories you can either specify them in the front-matter or through the [directory structure](http://jekyllrb.com/docs/variables/#page-variables) of your jekyll site (Categories are derived from the directory structure above the \_posts directory). You can actually use both approaches to assign your pages to multiple categories.
305
276
 
306
277
  ### Filtering tags
@@ -321,16 +292,6 @@ pagination:
321
292
  tag: cool, life
322
293
  ```
323
294
 
324
- As with categories, you may also use the following syntax:
325
-
326
- ``` yml
327
- pagination:
328
- enabled: true
329
- tags:
330
- - cool
331
- - life
332
- ```
333
-
334
295
  > When specifying tags in your posts make sure that the values are not enclosed in single quotes (double quotes are fine). If they are you will get a cryptic error when generating your site that looks like _"Error: could not read file <FILE>: did not find expected key while parsing a block mapping at line 2 column 1"_
335
296
 
336
297
  ### Filtering locales
@@ -394,6 +355,20 @@ pagination:
394
355
  sort_reverse: false
395
356
  ```
396
357
 
358
+ ## Offsetting posts
359
+ The paging logic can be instructed to exclude the first _N_ number of newest posts from the pagination.
360
+ This can be useful in situations where your site treats the first N posts differently from the rest (e.g. a featured post that is always present).
361
+
362
+ The number of pages to skip is configured using the `offset` setting like so
363
+
364
+ ``` yml
365
+ pagination:
366
+ enabled: true
367
+ offset: 3
368
+ ```
369
+
370
+ This example skips the 3 newest posts from the pagination logic.
371
+
397
372
  ## Advanced Sorting
398
373
  Sorting can be done by any field that is available in the post front-matter. You can even sort by nested fields.
399
374
 
data/README.md CHANGED
@@ -2,10 +2,10 @@
2
2
 
3
3
  Pagination gem built specially for Jekyll 3 and newer that is fully backwards compatible and serves as an 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).
4
4
 
5
+ [![Code Shelter](https://www.codeshelter.co/static/badges/badge-flat.svg)](https://www.codeshelter.co/)
5
6
  [![Gem](https://img.shields.io/gem/v/jekyll-paginate-v2.svg)](https://rubygems.org/gems/jekyll-paginate-v2)
6
7
  [![Join the chat at https://gitter.im/jekyll-paginate-v2/Lobby](https://badges.gitter.im/jekyll-paginate-v2/Lobby.svg)](https://gitter.im/jekyll-paginate-v2/Lobby)
7
8
  [![Build Status](https://travis-ci.org/sverrirs/jekyll-paginate-v2.svg?branch=master)](https://travis-ci.org/sverrirs/jekyll-paginate-v2)
8
- [![Dependency Status](https://gemnasium.com/badges/github.com/sverrirs/jekyll-paginate-v2.svg)](https://gemnasium.com/github.com/sverrirs/jekyll-paginate-v2)
9
9
  [![Code Climate](https://codeclimate.com/github/sverrirs/jekyll-paginate-v2/badges/gpa.svg)](https://codeclimate.com/github/sverrirs/jekyll-paginate-v2)
10
10
  [![security](https://hakiri.io/github/sverrirs/jekyll-paginate-v2/master.svg)](https://hakiri.io/github/sverrirs/jekyll-paginate-v2/master)
11
11
  [![Gem](https://img.shields.io/gem/dt/jekyll-paginate-v2.svg)](https://rubygems.org/gems/jekyll-paginate-v2)
@@ -15,7 +15,7 @@ Gem::Specification.new do |spec|
15
15
  spec.homepage = "https://github.com/sverrirs/jekyll-paginate-v2"
16
16
  spec.license = "MIT"
17
17
 
18
- spec.summary = %q{Pagination Generator for Jekyll 3}
18
+ spec.summary = %q{Pagination Generator for Jekyll 3 and newer}
19
19
  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. Optional features include auto-generation of paginated collection, tag and category pages.}
20
20
 
21
21
  spec.files = Dir['CODE_OF_CONDUCT.md', 'README*.md', 'LICENSE', 'Rakefile', '*.gemspec', 'Gemfile', 'lib/**/*', 'spec/**/*']
@@ -24,10 +24,10 @@ Gem::Specification.new do |spec|
24
24
 
25
25
  # Gem requires Jekyll to work
26
26
  # ~> is the pessimistic operator and is equivalent to '>= 3.0', '< 4.0'
27
- spec.add_runtime_dependency "jekyll", "~> 3.0"
27
+ spec.add_runtime_dependency "jekyll", ">= 3.0", "< 5.0"
28
28
 
29
29
  # Development requires more
30
30
  spec.add_development_dependency "bundler", "~> 1.5"
31
31
  spec.add_development_dependency "rake", "~> 10.4"
32
32
  spec.add_development_dependency "minitest", '~> 5.4'
33
- end
33
+ end
@@ -11,7 +11,6 @@ module Jekyll
11
11
  # this function received the pagination config hash and manipulates it
12
12
  set_autopage_data_lambda = lambda do | in_config |
13
13
  in_config['category'] = category
14
- in_config['collection'] = site.collections.keys
15
14
  end
16
15
 
17
16
  get_autopage_permalink_lambda = lambda do |permalink_pattern|
@@ -11,7 +11,6 @@ module Jekyll
11
11
  # this function received the pagination config hash and manipulates it
12
12
  set_autopage_data_lambda = lambda do | config |
13
13
  config['tag'] = tag
14
- config['collection'] = site.collections.keys
15
14
  end
16
15
 
17
16
  get_autopage_permalink_lambda = lambda do |permalink_pattern|
@@ -32,7 +32,7 @@ module Jekyll
32
32
  def self.collect_all_docs(site_collections)
33
33
  coll = []
34
34
  site_collections.each do |coll_name, coll_data|
35
- if !coll_data.nil?
35
+ if !coll_data.nil?
36
36
  coll += coll_data.docs.select { |doc| !doc.data.has_key?('pagination') }.each{ |doc| doc.data['__coll'] = coll_name } # Exclude all pagination pages and then for every page store it's collection name
37
37
  end
38
38
  end
@@ -49,21 +49,25 @@ module Jekyll
49
49
  next if post.data[index_key].nil?
50
50
  next if post.data[index_key].size <= 0
51
51
  next if post.data[index_key].to_s.strip.length == 0
52
-
52
+
53
53
  # Only tags and categories come as premade arrays, locale does not, so convert any data
54
54
  # elements that are strings into arrays
55
55
  post_data = post.data[index_key]
56
56
  if post_data.is_a?(String)
57
57
  post_data = post_data.split(/;|,|\s/)
58
58
  end
59
-
59
+
60
60
  post_data.each do |key|
61
- key = key.to_s.strip
62
- processed_key = key.downcase #Clean whitespace and junk
63
- if !index.has_key?(processed_key)
64
- # Need to store the original key value here so that I can present it to the users as a page variable they can use (unmodified, e.g. tags not being 'sci-fi' but "Sci-Fi")
65
- # Also, only interested in storing all the keys not the pages in this case
66
- index[processed_key] = [processed_key, key]
61
+ key = key.strip
62
+ # If the key is a delimetered list of values
63
+ # (meaning the user didn't use an array but a string with commas)
64
+ key.split(/;|,/).each do |raw_k_split|
65
+ k_split = raw_k_split.to_s.downcase.strip #Clean whitespace and junk
66
+ if !index.has_key?(k_split)
67
+ # Need to store the original key value here so that I can present it to the users as a page variable they can use (unmodified, e.g. tags not being 'sci-fi' but "Sci-Fi")
68
+ # Also, only interested in storing all the keys not the pages in this case
69
+ index[k_split.to_s] = [k_split.to_s, raw_k_split.to_s]
70
+ end
67
71
  end
68
72
  end
69
73
  end
@@ -66,47 +66,24 @@ module Jekyll
66
66
  return nil if posts.nil?
67
67
  return nil if source_posts.nil? # If the source is empty then simply don't do anything
68
68
  return posts if config.nil?
69
-
70
- plural_key = Utils.plural(config_key)
71
-
72
- return posts if !config.has_key?(config_key) && !config.has_key?(plural_key)
73
- return posts if config[config_key].nil? && config[plural_key].nil?
69
+ return posts if !config.has_key?(config_key)
70
+ return posts if config[config_key].nil?
74
71
 
75
72
  # Get the filter values from the config (this is the cat/tag/locale values that should be filtered on)
73
+ config_value = config[config_key]
76
74
 
77
- if config[config_key].is_a?(Hash) || config[plural_key].is_a?(Hash)
78
- # { values: [..], matching: any|all }
79
- config_hash = config[config_key].is_a?(Hash) ? config[config_key] : config[plural_key]
80
- config_value = Utils.config_values(config_hash, 'value')
81
- matching = config_hash['matching'] || 'all'
82
- else
83
- # Default array syntax
84
- config_value = Utils.config_values(config, config_key)
85
- matching = 'all'
75
+ # If we're dealing with a delimitered string instead of an array then let's be forgiving
76
+ if( config_value.is_a?(String))
77
+ config_value = config_value.split(/;|,/)
86
78
  end
87
79
 
88
- matching = matching.to_s.downcase.strip
89
-
90
- # Filter on any/all specified categories, etc.
91
-
92
- if matching == "all"
93
- # Now for all filter values for the config key, let's remove all items from the posts that
94
- # aren't common for all collections that the user wants to filter on
95
- config_value.each do |key|
96
- key = key.to_s.downcase.strip
97
- posts = PaginationIndexer.intersect_arrays(posts, source_posts[key])
98
- end
99
-
100
- elsif matching == "any"
101
- # "or" filter: Remove posts that don't have at least one required key
102
- posts.delete_if { |post|
103
- post_config = Utils.config_values(post.data, config_key)
104
- (config_value & post_config).empty?
105
- }
106
-
107
- # else no filter
80
+ # Now for all filter values for the config key, let's remove all items from the posts that
81
+ # aren't common for all collections that the user wants to filter on
82
+ config_value.each do |key|
83
+ key = key.to_s.downcase.strip
84
+ posts = PaginationIndexer.intersect_arrays(posts, source_posts[key])
108
85
  end
109
-
86
+
110
87
  # The fully filtered final post list
111
88
  return posts
112
89
  end #function read_config_value_and_filter_posts
@@ -13,24 +13,12 @@ module Jekyll
13
13
  @site = page_to_copy.site
14
14
  @base = ''
15
15
  @url = ''
16
- if cur_page_nr == 1
17
- @dir = File.dirname(page_to_copy.dir)
18
- @name = page_to_copy.name
19
- else
20
- @name = index_pageandext.nil? ? 'index.html' : index_pageandext
21
- end
16
+ @name = index_pageandext.nil? ? 'index.html' : index_pageandext
22
17
 
23
18
  self.process(@name) # Creates the basename and ext member values
24
19
 
25
- # Copy page data over site defaults
26
- defaults = @site.frontmatter_defaults.all(page_to_copy.relative_path, type)
27
- self.data = Jekyll::Utils.deep_merge_hashes(defaults, page_to_copy.data)
28
-
29
- if defaults.has_key?('permalink')
30
- self.data['permalink'] = Jekyll::URL.new(:template => defaults['permalink'], :placeholders => self.url_placeholders).to_s
31
- @use_permalink_for_url = true
32
- end
33
-
20
+ # Only need to copy the data part of the page as it already contains the layout information
21
+ self.data = Jekyll::Utils.deep_merge_hashes( page_to_copy.data, {} )
34
22
  if !page_to_copy.data['autopage']
35
23
  self.content = page_to_copy.content
36
24
  else
@@ -53,7 +41,7 @@ module Jekyll
53
41
  end
54
42
 
55
43
  def set_url(url_value)
56
- @url = @use_permalink_for_url ? self.data['permalink'] : url_value
44
+ @url = url_value
57
45
  end
58
46
  end # class PaginationPage
59
47
 
@@ -135,27 +135,6 @@ module Jekyll
135
135
  return url
136
136
  end
137
137
 
138
- # Constructs the plural for a key
139
- def self.plural(config_key)
140
- (config_key =~ /s$/) ? config_key :
141
- (config_key.dup.sub!(/y$/, 'ies') || "#{config_key}s")
142
- end
143
-
144
- # Converts a string or array to a downcased, stripped array
145
- def self.config_array(config, key, keepcase = nil)
146
- [ config[key] ].flatten.compact.uniq.map { |c|
147
- c.split(/[,;]\s*/).map { |v|
148
- keepcase ? v.to_s.strip : v.to_s.downcase.strip
149
- }
150
- }.flatten.uniq
151
- end
152
-
153
- # Merges singular and plural config values into an array
154
- def self.config_values(config, key, keepcase = nil)
155
- singular = config_array(config, key, keepcase)
156
- plural = config_array(config, plural(key), keepcase)
157
- [ singular, plural ].flatten.uniq
158
- end
159
138
  end
160
139
 
161
140
  end # module PaginateV2
@@ -1,10 +1,12 @@
1
1
  module Jekyll
2
2
  module PaginateV2
3
- VERSION = "2.0.0"
3
+ VERSION = "3.0.0"
4
4
  # When modifying remember to issue a new tag command in git before committing, then push the new tag
5
- # git tag -a v2.0.0 -m "Gem v2.0.0"
5
+ # git tag -a v3.0.0 -m "Gem v3.0.0"
6
6
  # git push origin --tags
7
7
  # Yanking a published Gem
8
8
  # gem yank jekyll-paginate-v2 -v VERSION
9
+ # Building gem
10
+ # gem build jekyll-paginate-v2.gemspec
9
11
  end # module PaginateV2
10
12
  end # module Jekyll
metadata CHANGED
@@ -1,29 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-paginate-v2
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sverrir Sigmundarson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-29 00:00:00.000000000 Z
11
+ date: 2020-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '3.0'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '5.0'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
25
28
  - !ruby/object:Gem::Version
26
29
  version: '3.0'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '5.0'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: bundler
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -127,10 +133,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
127
133
  version: '0'
128
134
  requirements: []
129
135
  rubyforge_project:
130
- rubygems_version: 2.4.8
136
+ rubygems_version: 2.7.10
131
137
  signing_key:
132
138
  specification_version: 4
133
- summary: Pagination Generator for Jekyll 3
139
+ summary: Pagination Generator for Jekyll 3 and newer
134
140
  test_files:
135
141
  - spec/generator/defaults_spec.rb
136
142
  - spec/generator/paginationPage_spec.rb