jekyll-paginate-v2 1.9.2 → 1.9.4

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: f15ac980bc5f0d9247bc5c939e01b60817ac572d
4
- data.tar.gz: 2aba630fd12a6b32d4ab3df5efadb0b005590c8d
3
+ metadata.gz: 59ee73bfdddde665bfcac280629290ca03b809bc
4
+ data.tar.gz: a9534eca1fc37f499b33e8f4a4c6cefaf6b67adf
5
5
  SHA512:
6
- metadata.gz: 0eacf17144bd636451263625cc0c1ad9850d112070a69c0e6bcd3e37acc84095722bbfe469f04560ed17c619618ee4ed61667eb26b03110df0ca85066a0ce915
7
- data.tar.gz: 73a3e97b8db75f491f2b30294109c84c3839f52917e8e5f03010a6709053e9cf08151a889874a8210b8a7a1c8d0eb794d9dbbde558e8dacf1643609e3e85b63f
6
+ metadata.gz: 15f6a51f471f9950952f9ebbe45f4306dbd7c15ea70a95849d74f73c9b9905a44473d4284bd46aa30129ee13c71f630387326d97d7524f0ffeb8787f77d32ad1
7
+ data.tar.gz: 97299085a18024745768845f073e8d2a3d8df2ba41f6d07c3298dd15511d6dba6d7086cb603288b57fa424370b6de73ff52e42cc250dc80bd5f3e99d8820aada
@@ -508,6 +508,7 @@ Paginating content meets both of these requirements, but developers are limited
508
508
  First, create a new jekyll page and set its layout to `null` to avoid any extra html to show up.
509
509
 
510
510
  Next, use the `extension` and `indexpage` option to customize the output of the page and its paginated content as JSON files.
511
+ > Note that the `indexpage` field also supports the same macros as the permalink field
511
512
 
512
513
  Here's an example page:
513
514
  ```
@@ -515,10 +516,10 @@ Here's an example page:
515
516
  layout: null
516
517
  permalink: /api
517
518
  pagination:
518
- permalink: 'feed-:num'
519
+ permalink: ''
519
520
  enabled: true
520
- extension: json
521
- indexpage: 'feed-1'
521
+ extension: .json
522
+ indexpage: 'feed-:num'
522
523
  ---
523
524
 
524
525
  {
@@ -649,4 +650,4 @@ pagination:
649
650
  permalink: '/cars/:num/'
650
651
  ```
651
652
 
652
- 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.
653
+ 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.
data/README.md CHANGED
@@ -25,10 +25,6 @@ Reach me at the [project issues](https://github.com/sverrirs/jekyll-paginate-v2/
25
25
 
26
26
  :heart:
27
27
 
28
- <a target='_blank' rel='nofollow' href='https://app.codesponsor.io/link/zzB7QVjdsbLjtaFcQie3TDxC/sverrirs/jekyll-paginate-v2'>
29
- <img alt='Sponsor' width='888' height='68' src='https://app.codesponsor.io/embed/zzB7QVjdsbLjtaFcQie3TDxC/sverrirs/jekyll-paginate-v2.svg' />
30
- </a>
31
-
32
28
  ## Installation
33
29
 
34
30
  ```
@@ -2,9 +2,9 @@ module Jekyll
2
2
  module PaginateV2::AutoPages
3
3
 
4
4
  #
5
- # When the site has been read then go a head an generate the necessary extra pages
5
+ # This function is called right after the main generator is triggered by Jekyll
6
6
  # This code is adapted from Stephen Crosby's code https://github.com/stevecrozz
7
- Jekyll::Hooks.register :site, :post_read do |site|
7
+ def self.create_autopages(site)
8
8
 
9
9
  # Get the configuration for the auto pages
10
10
  autopage_config = Jekyll::Utils.deep_merge_hashes(DEFAULT, site.config['autopages'] || {})
@@ -13,7 +13,7 @@ module Jekyll
13
13
  # If disabled then don't do anything
14
14
  if !autopage_config['enabled'] || autopage_config['enabled'].nil?
15
15
  Jekyll.logger.info "AutoPages:","Disabled/Not configured in site.config."
16
- next ## Break the loop, could be an issue if the hook is called again though??
16
+ return
17
17
  end
18
18
 
19
19
  # TODO: Should I detect here and disable if we're running the legacy paginate code???!
@@ -45,7 +45,7 @@ module Jekyll
45
45
  end
46
46
  autopage_create(autopage_config, pagination_config,posts_to_use, 'collections', '__coll', createcolpage_lambda) # Call the actual function
47
47
 
48
- end # Jekyll::Hooks
48
+ end # create_autopages
49
49
 
50
50
 
51
51
  # STATIC: this function actually performs the steps to generate the autopages. It uses a lambda function to delegate the creation of the individual
@@ -74,4 +74,4 @@ module Jekyll
74
74
  end
75
75
 
76
76
  end # module PaginateV2
77
- end # module Jekyll
77
+ end # module Jekyll
@@ -8,20 +8,31 @@ module Jekyll
8
8
  'layouts' => ['autopage_tags.html'],
9
9
  'title' => 'Posts tagged with :tag',
10
10
  'permalink' => '/tag/:tag',
11
- 'enabled' => true
12
-
11
+ 'enabled' => true,
12
+ 'slugify' => {
13
+ 'mode' => 'none', # [raw default pretty ascii latin], none gives back the same string
14
+ 'cased'=> false # If cased is true, all uppercase letters in the result string are replaced with their lowercase counterparts.
15
+ }
13
16
  },
14
17
  'categories' => {
15
18
  'layouts' => ['autopage_category.html'],
16
19
  'title' => 'Posts in category :cat',
17
20
  'permalink' => '/category/:cat',
18
- 'enabled' => true
21
+ 'enabled' => true,
22
+ 'slugify' => {
23
+ 'mode' => 'none', # [raw default pretty ascii latin], none gives back the same string
24
+ 'cased'=> false # If cased is true, all uppercase letters in the result string are replaced with their lowercase counterparts.
25
+ }
19
26
  },
20
27
  'collections' => {
21
28
  'layouts' => ['autopage_collection.html'],
22
29
  'title' => 'Posts in collection :coll',
23
30
  'permalink' => '/collection/:coll',
24
- 'enabled' => true
31
+ 'enabled' => true,
32
+ 'slugify' => {
33
+ 'mode' => 'none', # [raw default pretty ascii latin], none gives back the same string
34
+ 'cased'=> false # If cased is true, all uppercase letters in the result string are replaced with their lowercase counterparts.
35
+ }
25
36
  }
26
37
  }
27
38
 
@@ -4,6 +4,9 @@ module Jekyll
4
4
  class CategoryAutoPage < BaseAutoPage
5
5
  def initialize(site, base, autopage_config, pagination_config, layout_name, category, category_name)
6
6
 
7
+ # Do we have a slugify configuration available
8
+ slugify_config = autopage_config.is_a?(Hash) && autopage_config.has_key?('slugify') ? autopage_config['slugify'] : nil
9
+
7
10
  # Construc the lambda function to set the config values
8
11
  # this function received the pagination config hash and manipulates it
9
12
  set_autopage_data_lambda = lambda do | in_config |
@@ -11,11 +14,11 @@ module Jekyll
11
14
  end
12
15
 
13
16
  get_autopage_permalink_lambda = lambda do |permalink_pattern|
14
- return Utils.format_cat_macro(permalink_pattern, category)
17
+ return Utils.format_cat_macro(permalink_pattern, category, slugify_config)
15
18
  end
16
19
 
17
20
  get_autopage_title_lambda = lambda do |title_pattern|
18
- return Utils.format_cat_macro(title_pattern, category)
21
+ return Utils.format_cat_macro(title_pattern, category, slugify_config)
19
22
  end
20
23
 
21
24
  # Call the super constuctor with our custom lambda
@@ -25,4 +28,4 @@ module Jekyll
25
28
 
26
29
  end #class CategoryAutoPage
27
30
  end # module PaginateV2
28
- end # module Jekyll
31
+ end # module Jekyll
@@ -4,6 +4,9 @@ module Jekyll
4
4
  class CollectionAutoPage < BaseAutoPage
5
5
  def initialize(site, base, autopage_config, pagination_config, layout_name, collection, collection_name)
6
6
 
7
+ # Do we have a slugify configuration available
8
+ slugify_config = autopage_config.is_a?(Hash) && autopage_config.has_key?('slugify') ? autopage_config['slugify'] : nil
9
+
7
10
  # Construc the lambda function to set the config values
8
11
  # this function received the pagination config hash and manipulates it
9
12
  set_autopage_data_lambda = lambda do | in_config |
@@ -11,11 +14,11 @@ module Jekyll
11
14
  end
12
15
 
13
16
  get_autopage_permalink_lambda = lambda do |permalink_pattern|
14
- return Utils.format_coll_macro(permalink_pattern, collection)
17
+ return Utils.format_coll_macro(permalink_pattern, collection, slugify_config)
15
18
  end
16
19
 
17
20
  get_autopage_title_lambda = lambda do |title_pattern|
18
- return Utils.format_coll_macro(title_pattern, collection)
21
+ return Utils.format_coll_macro(title_pattern, collection, slugify_config)
19
22
  end
20
23
 
21
24
  # Call the super constuctor with our custom lambda
@@ -25,4 +28,4 @@ module Jekyll
25
28
 
26
29
  end #class CollectionAutoPage
27
30
  end # module PaginateV2
28
- end # module Jekyll
31
+ end # module Jekyll
@@ -4,6 +4,9 @@ module Jekyll
4
4
  class TagAutoPage < BaseAutoPage
5
5
  def initialize(site, base, autopage_config, pagination_config, layout_name, tag, tag_name)
6
6
 
7
+ # Do we have a slugify configuration available
8
+ slugify_config = autopage_config.is_a?(Hash) && autopage_config.has_key?('slugify') ? autopage_config['slugify'] : nil
9
+
7
10
  # Construc the lambda function to set the config values,
8
11
  # this function received the pagination config hash and manipulates it
9
12
  set_autopage_data_lambda = lambda do | config |
@@ -11,11 +14,11 @@ module Jekyll
11
14
  end
12
15
 
13
16
  get_autopage_permalink_lambda = lambda do |permalink_pattern|
14
- return Utils.format_tag_macro(permalink_pattern, tag)
17
+ return Utils.format_tag_macro(permalink_pattern, tag, slugify_config)
15
18
  end
16
19
 
17
20
  get_autopage_title_lambda = lambda do |title_pattern|
18
- return Utils.format_tag_macro(title_pattern, tag)
21
+ return Utils.format_tag_macro(title_pattern, tag, slugify_config)
19
22
  end
20
23
 
21
24
  # Call the super constuctor with our custom lambda
@@ -25,4 +28,4 @@ module Jekyll
25
28
 
26
29
  end #class TagAutoPage
27
30
  end # module PaginateV2
28
- end # module Jekyll
31
+ end # module Jekyll
@@ -5,27 +5,33 @@ module Jekyll
5
5
 
6
6
  # Static: returns a fully formatted string with the tag macro (:tag) replaced
7
7
  #
8
- def self.format_tag_macro(toFormat, tag)
9
- return toFormat.sub(':tag', Jekyll::Utils.slugify(tag.to_s))
8
+ def self.format_tag_macro(toFormat, tag, slugify_config=nil)
9
+ slugify_mode = slugify_config.has_key?('mode') ? slugify_config['mode'] : nil
10
+ slugify_cased = slugify_config.has_key?('cased') ? slugify_config['cased'] : false
11
+ return toFormat.sub(':tag', Jekyll::Utils.slugify(tag.to_s, mode:slugify_mode, cased:slugify_cased))
10
12
  end #function format_tag_macro
11
13
 
12
14
  # Static: returns a fully formatted string with the category macro (:cat) replaced
13
15
  #
14
- def self.format_cat_macro(toFormat, category)
15
- return toFormat.sub(':cat', Jekyll::Utils.slugify(category.to_s))
16
+ def self.format_cat_macro(toFormat, category, slugify_config=nil)
17
+ slugify_mode = slugify_config.has_key?('mode') ? slugify_config['mode'] : nil
18
+ slugify_cased = slugify_config.has_key?('cased') ? slugify_config['cased'] : false
19
+ return toFormat.sub(':cat', Jekyll::Utils.slugify(category.to_s, mode:slugify_mode, cased:slugify_cased))
16
20
  end #function format_cat_macro
17
21
 
18
22
  # Static: returns a fully formatted string with the collection macro (:coll) replaced
19
23
  #
20
- def self.format_coll_macro(toFormat, collection)
21
- return toFormat.sub(':coll', Jekyll::Utils.slugify(collection.to_s))
24
+ def self.format_coll_macro(toFormat, collection, slugify_config=nil)
25
+ slugify_mode = slugify_config.has_key?('mode') ? slugify_config['mode'] : nil
26
+ slugify_cased = slugify_config.has_key?('cased') ? slugify_config['cased'] : false
27
+ return toFormat.sub(':coll', Jekyll::Utils.slugify(collection.to_s, mode:slugify_mode, cased:slugify_cased))
22
28
  end #function format_coll_macro
23
29
 
24
30
  # Static: returns all documents from all collections defined in the hash of collections passed in
25
31
  # excludes all pagination pages though
26
32
  def self.collect_all_docs(site_collections)
27
33
  coll = []
28
- for coll_name, coll_data in site_collections
34
+ site_collections.each do |coll_name, coll_data|
29
35
  if !coll_data.nil?
30
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
31
37
  end
@@ -37,7 +43,7 @@ module Jekyll
37
43
  return nil if all_posts.nil?
38
44
  return all_posts if index_key.nil?
39
45
  index = {}
40
- for post in all_posts
46
+ all_posts.each do |post|
41
47
  next if post.data.nil?
42
48
  next if !post.data.has_key?(index_key)
43
49
  next if post.data[index_key].nil?
@@ -51,11 +57,11 @@ module Jekyll
51
57
  post_data = post_data.split(/;|,|\s/)
52
58
  end
53
59
 
54
- for key in post_data
60
+ post_data.each do |key|
55
61
  key = key.strip
56
62
  # If the key is a delimetered list of values
57
63
  # (meaning the user didn't use an array but a string with commas)
58
- for raw_k_split in key.split(/;|,/)
64
+ key.split(/;|,/).each do |raw_k_split|
59
65
  k_split = raw_k_split.to_s.downcase.strip #Clean whitespace and junk
60
66
  if !index.has_key?(k_split)
61
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")
@@ -71,4 +77,4 @@ module Jekyll
71
77
  end # class Utils
72
78
 
73
79
  end # module PaginateV2
74
- end # module Jekyll
80
+ end # module Jekyll
@@ -20,6 +20,9 @@ module Jekyll
20
20
  # Returns nothing.
21
21
  def generate(site)
22
22
  #begin
23
+ # Generate the AutoPages first
24
+ PaginateV2::AutoPages.create_autopages(site)
25
+
23
26
  # Retrieve and merge the pagination configuration from the site yml file
24
27
  default_config = Jekyll::Utils.deep_merge_hashes(DEFAULT, site.config['pagination'] || {})
25
28
 
@@ -74,7 +77,7 @@ module Jekyll
74
77
  if collection_name == "all"
75
78
  # the 'all' collection_name is a special case and includes all collections in the site (except posts!!)
76
79
  # this is useful when you want to list items across multiple collections
77
- for coll_name, coll_data in site.collections
80
+ site.collections.each do |coll_name, coll_data|
78
81
  if( !coll_data.nil? && coll_name != 'posts')
79
82
  coll += coll_data.docs.select { |doc| !doc.data.has_key?('pagination') } # Exclude all pagination pages
80
83
  end
@@ -139,4 +142,4 @@ module Jekyll
139
142
  end # class PaginationGenerator
140
143
 
141
144
  end # module PaginateV2
142
- end # module Jekyll
145
+ end # module Jekyll
@@ -12,7 +12,7 @@ module Jekyll
12
12
  return nil if all_posts.nil?
13
13
  return all_posts if index_key.nil?
14
14
  index = {}
15
- for post in all_posts
15
+ all_posts.each do |post|
16
16
  next if post.data.nil?
17
17
  next if !post.data.has_key?(index_key)
18
18
  next if post.data[index_key].nil?
@@ -26,11 +26,11 @@ module Jekyll
26
26
  post_data = post_data.split(/;|,|\s/)
27
27
  end
28
28
 
29
- for key in post_data
29
+ post_data.each do |key|
30
30
  key = key.to_s.downcase.strip
31
31
  # If the key is a delimetered list of values
32
32
  # (meaning the user didn't use an array but a string with commas)
33
- for k_split in key.split(/;|,/)
33
+ key.split(/;|,/).each do |k_split|
34
34
  k_split = k_split.to_s.downcase.strip #Clean whitespace and junk
35
35
  if !index.has_key?(k_split)
36
36
  index[k_split.to_s] = []
@@ -79,7 +79,7 @@ module Jekyll
79
79
 
80
80
  # Now for all filter values for the config key, let's remove all items from the posts that
81
81
  # aren't common for all collections that the user wants to filter on
82
- for key in config_value
82
+ config_value.each do |key|
83
83
  key = key.to_s.downcase.strip
84
84
  posts = PaginationIndexer.intersect_arrays(posts, source_posts[key])
85
85
  end
@@ -31,7 +31,7 @@ module Jekyll
31
31
  end
32
32
 
33
33
  # Now for each template page generate the paginator for it
34
- for template in templates
34
+ templates.each do |template|
35
35
  # All pages that should be paginated need to include the pagination config element
36
36
  if template.data['pagination'].is_a?(Hash)
37
37
  template_config = Jekyll::Utils.deep_merge_hashes(default_config, template.data['pagination'] || {})
@@ -113,7 +113,7 @@ module Jekyll
113
113
 
114
114
  docs = []
115
115
  # Now for each of the collections get the docs
116
- for coll_name in collection_names
116
+ collection_names.each do |coll_name|
117
117
  # Request all the documents for the collection in question, and join it with the total collection
118
118
  docs += @collection_by_name_lambda.call(coll_name.downcase.strip)
119
119
  end
@@ -229,14 +229,14 @@ module Jekyll
229
229
  if @debug
230
230
  puts "Pagination: ".rjust(20) + "Rolling through the date fields for all documents"
231
231
  end
232
- for p in using_posts
233
- if p.respond_to?('date')
234
- tmp_date = p.date
232
+ using_posts.each do |u_post|
233
+ if u_post.respond_to?('date')
234
+ tmp_date = u_post.date
235
235
  if( !tmp_date || tmp_date.nil? )
236
236
  if @debug
237
- puts "Pagination: ".rjust(20) + "Explicitly assigning date for doc: #{p.data['title']} | #{p.path}"
237
+ puts "Pagination: ".rjust(20) + "Explicitly assigning date for doc: #{u_post.data['title']} | #{u_post.path}"
238
238
  end
239
- p.date = File.mtime(p.path)
239
+ u_post.date = File.mtime(u_post.path)
240
240
  end
241
241
  end
242
242
  end
@@ -80,16 +80,16 @@ module Jekyll
80
80
  # Handles Strings separately as we want a case-insenstive sorting
81
81
  #
82
82
  def self.sort_values(a, b)
83
- if a.is_a?(String)
84
- return a.downcase <=> b.downcase
85
- end
86
-
87
83
  if a.nil? && !b.nil?
88
84
  return -1
89
85
  elsif !a.nil? && b.nil?
90
86
  return 1
91
87
  end
92
88
 
89
+ if a.is_a?(String)
90
+ return a.downcase <=> b.downcase
91
+ end
92
+
93
93
  if a.respond_to?('to_datetime') && b.respond_to?('to_datetime')
94
94
  return a.to_datetime <=> b.to_datetime
95
95
  end
@@ -107,7 +107,7 @@ module Jekyll
107
107
  sort_split = sort_field.split(":")
108
108
  sort_value = post_data
109
109
 
110
- for r_key in sort_split
110
+ sort_split.each do |r_key|
111
111
  key = r_key.downcase.strip # Remove any erronious whitespace and convert to lower case
112
112
  if !sort_value.has_key?(key)
113
113
  return nil
@@ -1,8 +1,8 @@
1
1
  module Jekyll
2
2
  module PaginateV2
3
- VERSION = "1.9.2"
3
+ VERSION = "1.9.4"
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.2 -m "Gem v1.9.2"
5
+ # git tag -a v1.9.4 -m "Gem v1.9.4"
6
6
  # git push origin --tags
7
7
  # Yanking a published Gem
8
8
  # gem yank jekyll-paginate-v2 -v VERSION
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-paginate-v2
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.2
4
+ version: 1.9.4
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-01-11 00:00:00.000000000 Z
11
+ date: 2018-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll