jekyll-paginate-v2 1.7.0 → 1.7.2

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
2
  SHA1:
3
- metadata.gz: 520aefbd27b59fcb86fcaca7871c693295bafb16
4
- data.tar.gz: 3e45a7ccc457134a43ee81520dc0f32971c9989d
3
+ metadata.gz: 9ce2b9e1db9613c363b49bd85abcde999a711f92
4
+ data.tar.gz: 4e1437c8cf70f5bc127db725e3b3ddb8b3993aac
5
5
  SHA512:
6
- metadata.gz: 31e6855bc99cd94c7160da6e5926046f7cb32b783bd177c9b5ef1d3d38b989063746df296a3909159e3fbc43d9285202d424d165ef639c0187c002828b8ff332
7
- data.tar.gz: 734e0a050c950f4535c49eb115009f65c509ecd20ce8c1c95b99b27fa535bef19f8a990457edd8a9e1207184004f617d84e416385bf1602c73af28470af51532
6
+ metadata.gz: bf461c4d569da1753e223721f06092d6f54c1fefe59910531bcaab16daa39af8494278527d984cb5c34e4ec4e1bf3da1a0f8869cdac364a75a0063e52da7afd1
7
+ data.tar.gz: 88df86ce35916323d5caf29f23bcb15e8a10f5607f91bc46a2f2de94823cc6a3957bfd1449bd55f3ab0da9e7774bfc80a6d30c9669a1d0312b6916e0fa9466cb
@@ -62,6 +62,23 @@ Example of a simple autopage layout can be seen in Example 3 [examples/03-tags/_
62
62
 
63
63
  The layout does not need anything special beyond the normal pagination logic (e.g. `for post in paginator.posts` and then the next/prev arrows). You can either name the layouts by the default names (see site configuration section above) or give them a custom name and add them to the `layouts:` configuration for the relevant type of autopage.
64
64
 
65
+ ### Obtaining the original Tag or Category name
66
+ Internally the autopage system will trim and downcase the indexing key (tag, category or collection name). To retrieve the original name of the index key you can use the `autopages.display_name` liquid variable.
67
+
68
+ ``` html
69
+ <h1 class="page-heading">All pages tagged with <b>{% if page.autopages %}{{page.autopages.display_name}}{% endif %}</b></h1>
70
+ ```
71
+
72
+ This variable returns the untouched key value. As an example if your site uses the tag `Science-Fiction` then
73
+
74
+ ```
75
+ page.tag = "science-fiction"
76
+ page.autopages.display_name = "Science-Fiction"
77
+ ```
78
+
79
+ See [#6](https://github.com/sverrirs/jekyll-paginate-v2/issues/6) for more information.
80
+
81
+
65
82
  ## Advanced configuration
66
83
  You can customize the look an feel of the permalink structure and the title for the auto-pages. You can also add front-matter `pagination` configuration to the layout pages you're using to specify things like sorting, filtering and all the other configuration options that are available in the normal pagination generator.
67
84
 
@@ -82,8 +82,6 @@ pagination:
82
82
 
83
83
  # Optional,omit or set both before and after to zero to disable.
84
84
  # Controls how the pagination trail for the paginated pages look like.
85
- # this feature enables the user to display a <prev, 1, 2, 3, 4, 5, next> pagination trail on their page
86
- # By default this feature produces two pages before and two pages after the current page (total of 5 pages)
87
85
  trail:
88
86
  before: 2
89
87
  after: 2
@@ -368,7 +366,7 @@ pagination:
368
366
  ## Creating Pagination Trails
369
367
 
370
368
  <p align="center">
371
- <img src="https://raw.githubusercontent.com/sverrirs/jekyll-paginate-v2/master/res/pagination-trails.png" width="59" />
369
+ <img src="https://raw.githubusercontent.com/sverrirs/jekyll-paginate-v2/master/res/pagination-trails.png" />
372
370
  </p>
373
371
 
374
372
  Creating a trail structure for your pagination as shown above can be achieved by enabling the `trail` configuration and including a little extra code in your liquid templates.
@@ -385,26 +383,27 @@ Your layout file would then have to include code similar to the following to gen
385
383
  ``` HTML
386
384
  {% if paginator.page_trail %}
387
385
  {% for trail in paginator.page_trail %}
388
- <li>
386
+ <li {% if page.url == trail.path %}class="selected"{% endif %}>
389
387
  <a href="{{ trail.path | prepend: site.baseurl }}" title="{{trail.title}}">{{ trail.num }}</a>
390
388
  </li>
391
389
  {% endfor %}
392
390
  {% endif %}
393
391
  ```
392
+ _See [example 3](https://github.com/sverrirs/jekyll-paginate-v2/tree/master/examples/03-tags) for a demo of a pagination trail_
394
393
 
395
- The `trail` value exposes three properties:
394
+ The `trail` object exposes three properties:
396
395
  * `num`: The number of the page
397
396
  * `path`: The path to the page
398
397
  * `title`: The title of the page
399
398
 
400
399
  The algorithm will always attempt to keep the same trail length for all pages (`trail length = before + after + 1`).
401
- Example when on page 4 the trail for the configuration above would look like this
400
+ As an example if we have only 7 pagination pages in total and the user is currently on page 6 then the trail would look like this
402
401
 
403
402
  <p align="center">
404
- <img src="https://raw.githubusercontent.com/sverrirs/jekyll-paginate-v2/master/res/pagination-trails-p4.png" />
403
+ <img src="https://raw.githubusercontent.com/sverrirs/jekyll-paginate-v2/master/res/pagination-trails-p6.png" />
405
404
  </p>
406
405
 
407
- Different number of before and after trail links can be specified. Below is an example of how this yml config would look like when on the same page 4
406
+ Different number of before and after trail links can be specified. Below is an example of how the yml config below would look like when on the same page 4
408
407
 
409
408
  ``` yml
410
409
  pagination:
data/README.md CHANGED
@@ -11,7 +11,7 @@ Pagination gem built specially for Jekyll 3 and newer that is fully backwards co
11
11
 
12
12
  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).
13
13
 
14
- > 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)).
14
+ > The code was based on the original design of [jekyll-paginate](https://github.com/jekyll/jekyll-paginate) and features were sourced from discussions such as [#27](https://github.com/jekyll/jekyll-paginate/issues/27) (thanks [Günter Kits](https://github.com/gynter)).
15
15
 
16
16
  * [Installation](#installation)
17
17
  * [Example Sites](https://github.com/sverrirs/jekyll-paginate-v2/tree/master/examples)
@@ -25,23 +25,23 @@ module Jekyll
25
25
 
26
26
  ###############################################
27
27
  # Generate the Tag pages if enabled
28
- createtagpage_lambda = lambda do | autopage_tag_config, pagination_config, layout_name, tag |
29
- site.pages << TagAutoPage.new(site, site.dest, autopage_tag_config, pagination_config, layout_name, tag)
28
+ createtagpage_lambda = lambda do | autopage_tag_config, pagination_config, layout_name, tag, tag_original_name |
29
+ site.pages << TagAutoPage.new(site, site.dest, autopage_tag_config, pagination_config, layout_name, tag, tag_original_name)
30
30
  end
31
31
  autopage_create(autopage_config, pagination_config, posts_to_use, 'tags', 'tags', createtagpage_lambda) # Call the actual function
32
32
 
33
33
 
34
34
  ###############################################
35
35
  # Generate the category pages if enabled
36
- createcatpage_lambda = lambda do | autopage_cat_config, pagination_config, layout_name, category |
37
- site.pages << CategoryAutoPage.new(site, site.dest, autopage_cat_config, pagination_config, layout_name, category)
36
+ createcatpage_lambda = lambda do | autopage_cat_config, pagination_config, layout_name, category, category_original_name |
37
+ site.pages << CategoryAutoPage.new(site, site.dest, autopage_cat_config, pagination_config, layout_name, category, category_original_name)
38
38
  end
39
39
  autopage_create(autopage_config, pagination_config,posts_to_use, 'categories', 'categories', createcatpage_lambda) # Call the actual function
40
40
 
41
41
  ###############################################
42
42
  # Generate the Collection pages if enabled
43
- createcolpage_lambda = lambda do | autopage_col_config, pagination_config, layout_name, coll_name |
44
- site.pages << CollectionAutoPage.new(site, site.dest, autopage_col_config, pagination_config, layout_name, coll_name)
43
+ createcolpage_lambda = lambda do | autopage_col_config, pagination_config, layout_name, coll_name, coll_original_name |
44
+ site.pages << CollectionAutoPage.new(site, site.dest, autopage_col_config, pagination_config, layout_name, coll_name, coll_original_name)
45
45
  end
46
46
  autopage_create(autopage_config, pagination_config,posts_to_use, 'collections', '__coll', createcolpage_lambda) # Call the actual function
47
47
 
@@ -58,13 +58,13 @@ module Jekyll
58
58
  Jekyll.logger.info "AutoPages:","Generating #{configkey_name} pages"
59
59
 
60
60
  # Roll through all documents in the posts collection and extract the tags
61
- index_keys = Utils.index_posts_by(posts_to_use, indexkey_name).keys # Cannot use just the posts here, must use all things.. posts, collections...
61
+ index_keys = Utils.ap_index_posts_by(posts_to_use, indexkey_name) # Cannot use just the posts here, must use all things.. posts, collections...
62
62
 
63
- index_keys.each do |index_key|
63
+ index_keys.each do |index_key, value|
64
64
  # Iterate over each layout specified in the config
65
65
  ap_sub_config ['layouts'].each do | layout_name |
66
66
  # Use site.dest here as these pages are never created in the actual source but only inside the _site folder
67
- createpage_lambda.call(ap_sub_config, pagination_config, layout_name, index_key)
67
+ createpage_lambda.call(ap_sub_config, pagination_config, layout_name, index_key, value[-1]) # the last item in the value array will be the display name
68
68
  end
69
69
  end
70
70
  else
@@ -2,7 +2,7 @@ module Jekyll
2
2
  module PaginateV2::AutoPages
3
3
 
4
4
  class BaseAutoPage < Jekyll::Page
5
- def initialize(site, base, autopage_config, pagination_config, layout_name, set_autopage_data_lambda, get_autopage_permalink_lambda, get_autopage_title_lambda)
5
+ def initialize(site, base, autopage_config, pagination_config, layout_name, set_autopage_data_lambda, get_autopage_permalink_lambda, get_autopage_title_lambda, display_name)
6
6
  @site = site
7
7
  @base = base
8
8
  @name = 'index.html'
@@ -46,7 +46,7 @@ module Jekyll
46
46
 
47
47
  # Add the auto page flag in there to be able to detect the page (necessary when figuring out where to load it from)
48
48
  # TODO: Need to re-think this variable!!!
49
- self.data['autopage'] = {"layout_path" => File.join( layout_dir, layout_name ) }
49
+ self.data['autopage'] = {"layout_path" => File.join( layout_dir, layout_name ), 'display_name' => display_name.to_s }
50
50
 
51
51
  data.default_proc = proc do |_, key|
52
52
  site.frontmatter_defaults.find(File.join(layout_dir, layout_name), type, key)
@@ -2,7 +2,7 @@ module Jekyll
2
2
  module PaginateV2::AutoPages
3
3
 
4
4
  class CategoryAutoPage < BaseAutoPage
5
- def initialize(site, base, autopage_config, pagination_config, layout_name, category)
5
+ def initialize(site, base, autopage_config, pagination_config, layout_name, category, category_name)
6
6
 
7
7
  # Construc the lambda function to set the config values
8
8
  # this function received the pagination config hash and manipulates it
@@ -19,7 +19,7 @@ module Jekyll
19
19
  end
20
20
 
21
21
  # Call the super constuctor with our custom lambda
22
- super(site, base, autopage_config, pagination_config, layout_name, set_autopage_data_lambda, get_autopage_permalink_lambda, get_autopage_title_lambda)
22
+ super(site, base, autopage_config, pagination_config, layout_name, set_autopage_data_lambda, get_autopage_permalink_lambda, get_autopage_title_lambda, category_name)
23
23
 
24
24
  end #function initialize
25
25
 
@@ -2,7 +2,7 @@ module Jekyll
2
2
  module PaginateV2::AutoPages
3
3
 
4
4
  class CollectionAutoPage < BaseAutoPage
5
- def initialize(site, base, autopage_config, pagination_config, layout_name, collection)
5
+ def initialize(site, base, autopage_config, pagination_config, layout_name, collection, collection_name)
6
6
 
7
7
  # Construc the lambda function to set the config values
8
8
  # this function received the pagination config hash and manipulates it
@@ -19,7 +19,7 @@ module Jekyll
19
19
  end
20
20
 
21
21
  # Call the super constuctor with our custom lambda
22
- super(site, base, autopage_config, pagination_config, layout_name, set_autopage_data_lambda, get_autopage_permalink_lambda, get_autopage_title_lambda)
22
+ super(site, base, autopage_config, pagination_config, layout_name, set_autopage_data_lambda, get_autopage_permalink_lambda, get_autopage_title_lambda, collection_name)
23
23
 
24
24
  end #function initialize
25
25
 
@@ -2,7 +2,7 @@ module Jekyll
2
2
  module PaginateV2::AutoPages
3
3
 
4
4
  class TagAutoPage < BaseAutoPage
5
- def initialize(site, base, autopage_config, pagination_config, layout_name, tag)
5
+ def initialize(site, base, autopage_config, pagination_config, layout_name, tag, tag_name)
6
6
 
7
7
  # Construc the lambda function to set the config values,
8
8
  # this function received the pagination config hash and manipulates it
@@ -19,7 +19,7 @@ module Jekyll
19
19
  end
20
20
 
21
21
  # Call the super constuctor with our custom lambda
22
- super(site, base, autopage_config, pagination_config, layout_name, set_autopage_data_lambda, get_autopage_permalink_lambda, get_autopage_title_lambda)
22
+ super(site, base, autopage_config, pagination_config, layout_name, set_autopage_data_lambda, get_autopage_permalink_lambda, get_autopage_title_lambda, tag_name)
23
23
 
24
24
  end #function initialize
25
25
 
@@ -33,7 +33,7 @@ module Jekyll
33
33
  return coll
34
34
  end
35
35
 
36
- def self.index_posts_by(all_posts, index_key)
36
+ def self.ap_index_posts_by(all_posts, index_key)
37
37
  return nil if all_posts.nil?
38
38
  return all_posts if index_key.nil?
39
39
  index = {}
@@ -52,16 +52,16 @@ module Jekyll
52
52
  end
53
53
 
54
54
  for key in post_data
55
- key = key.downcase.strip
55
+ key = key.strip
56
56
  # If the key is a delimetered list of values
57
57
  # (meaning the user didn't use an array but a string with commas)
58
- for k_split in key.split(/;|,/)
59
- k_split = k_split.downcase.strip #Clean whitespace and junk
58
+ for raw_k_split in key.split(/;|,/)
59
+ k_split = raw_k_split.to_s.downcase.strip #Clean whitespace and junk
60
60
  if !index.has_key?(k_split)
61
- index[k_split.to_s] = []
61
+ # 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")
62
+ # Also, only interested in storing all the keys not the pages in this case
63
+ index[k_split.to_s] = [k_split.to_s, raw_k_split.to_s]
62
64
  end
63
- # TODO: 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")
64
- index[k_split.to_s] << post
65
65
  end
66
66
  end
67
67
  end
@@ -22,6 +22,12 @@ module Jekyll
22
22
  self.data = Jekyll::Utils.deep_merge_hashes( page_to_copy.data, {} )
23
23
  if !page_to_copy.data['autopage']
24
24
  self.content = page_to_copy.content
25
+ else
26
+ # If the page is an auto page then migrate the necessary autopage info across into the
27
+ # new pagination page (so that users can get the correct keys etc)
28
+ if( page_to_copy.data['autopage'].has_key?('display_name') )
29
+ self.data['autopages'] = Jekyll::Utils.deep_merge_hashes( page_to_copy.data['autopage'], {} )
30
+ end
25
31
  end
26
32
 
27
33
  # Perform some validation that is also performed in Jekyll::Page
@@ -1,8 +1,8 @@
1
1
  module Jekyll
2
2
  module PaginateV2
3
- VERSION = "1.7.0"
3
+ VERSION = "1.7.2"
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.7.0 -m "Gem v1.7.0"
5
+ # git tag -a v1.7.2 -m "Gem v1.7.2"
6
6
  # git push origin --tags
7
7
  end # module PaginateV2
8
8
  end # module Jekyll
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.7.0
4
+ version: 1.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sverrir Sigmundarson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-29 00:00:00.000000000 Z
11
+ date: 2017-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll