jekyll-paginate-v2 1.4.0 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/CODE_OF_CONDUCT.md +74 -0
  3. data/README.md +59 -3
  4. data/examples/03-tags/README.md +12 -5
  5. data/examples/03-tags/{biography/_posts/2016-10-27-born-to-run.md → _biography/all/born-to-run.md} +0 -0
  6. data/examples/03-tags/{biography/_posts/2016-10-27-forty-autumns.md → _biography/all/forty-autumns.md} +0 -0
  7. data/examples/03-tags/{biography/_posts/2016-10-27-life-in-questions-a.md → _biography/all/life-in-questions-a.md} +0 -0
  8. data/examples/03-tags/{biography/_posts/2016-10-27-not-dead-yet.md → _biography/all/not-dead-yet.md} +0 -0
  9. data/examples/03-tags/{biography/_posts/2016-10-27-princess-diarist-the.md → _biography/all/princess-diarist-the.md} +1 -1
  10. data/examples/03-tags/{biography/_posts/2016-10-27-when-breath-becomes-air.md → _biography/all/when-breath-becomes-air.md} +0 -0
  11. data/examples/03-tags/{biography → _biography}/biography-musicians.md +1 -1
  12. data/examples/03-tags/{biography/biography.md → _biography/index.md} +1 -1
  13. data/examples/03-tags/_config.yml +12 -0
  14. data/examples/03-tags/{fantasy/_posts/2016-10-27-harry-potter-deathly-hallows.md → _fantasy/all/harry-potter-deathly-hallows.md} +0 -0
  15. data/examples/03-tags/{fantasy/_posts/2016-10-27-harry-potter-philosophers-stone.md → _fantasy/all/harry-potter-philosophers-stone.md} +0 -0
  16. data/examples/03-tags/{fantasy/_posts/2016-10-27-mistborn-trilogy.md → _fantasy/all/mistborn-trilogy.md} +0 -0
  17. data/examples/03-tags/{fantasy/_posts/2016-10-27-ready-player-one.md → _fantasy/all/ready-player-one.md} +0 -0
  18. data/examples/03-tags/{fantasy/_posts/2016-10-27-sword-of-destiny.md → _fantasy/all/sword-of-destiny.md} +0 -0
  19. data/examples/03-tags/{fantasy/_posts/2016-10-27-terry-pratchet-diary-2017.md → _fantasy/all/terry-pratchet-diary-2017.md} +0 -0
  20. data/examples/03-tags/_layouts/home.html +1 -1
  21. data/examples/03-tags/_layouts/post.html +1 -1
  22. data/examples/03-tags/{romance/_posts/2016-10-27-breath-of-snow-and-ashes-a.md → _romance/all/breath-of-snow-and-ashes-a.md} +0 -0
  23. data/examples/03-tags/{romance/_posts/2016-10-27-dressmaker-the.md → _romance/all/dressmaker-the.md} +0 -0
  24. data/examples/03-tags/{romance/_posts/2016-10-27-fiery-cross-the.md → _romance/all/fiery-cross-the.md} +0 -0
  25. data/examples/03-tags/{romance/_posts/2016-10-27-it-ends-with-us.md → _romance/all/it-ends-with-us.md} +0 -0
  26. data/examples/03-tags/{romance/_posts/2016-10-27-outlander-novel.md → _romance/all/outlander-novel.md} +0 -0
  27. data/examples/03-tags/{romance/_posts/2016-10-27-virgins-outlander-short-story.md → _romance/all/virgins-outlander-short-story.md} +0 -0
  28. data/examples/03-tags/{romance → _romance}/romance-historical.md +1 -1
  29. data/examples/03-tags/byisbn.md +1 -0
  30. data/examples/03-tags/index.md +1 -0
  31. data/examples/03-tags/tags/contemporary.md +1 -0
  32. data/examples/03-tags/tags/fantasy.md +1 -0
  33. data/examples/03-tags/tags/sci-fi.md +4 -1
  34. data/examples/README.md +4 -2
  35. data/lib/jekyll-paginate-v2/paginationGenerator.rb +29 -7
  36. data/lib/jekyll-paginate-v2/paginationModel.rb +33 -8
  37. data/lib/jekyll-paginate-v2/version.rb +2 -2
  38. metadata +24 -23
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d2151298586fb30e325abf19b2f4f2feb050581d
4
- data.tar.gz: d01e27f2e65eaa820a194e4a261f1668839d75be
3
+ metadata.gz: 5815a5929c866dd11ae6f027f4f3d58bbd584f3f
4
+ data.tar.gz: 7d261bcb4d2089d8f196f0ddc71a7961992bbc5d
5
5
  SHA512:
6
- metadata.gz: 15b28be37affd98b4b18709747afaf3d7e4ab85cc22541b5549c6b34bedd1e3f531c7e52fc3b20937643371e99fcaa0f15f056a37295d778925342045fc5aef7
7
- data.tar.gz: 422190d1e73563def30150c4a4173e4cbbc267b9e123c3bd93cc74da93f99c8b98e2f3c5f22b4be492d3f27169143c0568e5749690e7bf81786efa9eaead52a7
6
+ metadata.gz: c18ad4a94390fd030c278ca84beceffe32643926775ca7596679278658ab7665a19f55fffe76662261f88f1e4d725ab6482f5d2e86ddd0d681ec939f9e1f8c1c
7
+ data.tar.gz: 823ab882ae1fa5342fd8eca1554b6b921c29abecd585967224c77717edd5e2ab6162b254a6d72fbe791893c3d879cade61d3d611690346285122f48240edd52d
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at [jekyll@sverrirs.com](mailto:jekyll@sverrirs.com). All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/README.md CHANGED
@@ -76,6 +76,9 @@ pagination:
76
76
  # Site-wide kill switch, disabled here it doesn't run at all
77
77
  enabled: true
78
78
 
79
+ # The default document collection to paginate if nothing is specified ('posts' is default)
80
+ collection: 'posts'
81
+
79
82
  # How many objects per paginated page, used to be `paginate` (default: 0, means all)
80
83
  per_page: 10
81
84
 
@@ -176,6 +179,59 @@ See more about the old style of pagination at the [jekyll-paginate](https://gith
176
179
 
177
180
  > :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.
178
181
 
182
+ ## Paginating collections
183
+ By default the pagination system only paginates `posts`. If you only have `posts` and `pages` in your site you don't need to worry about a thing, everything will work as intended without you configuring anything.
184
+
185
+ However if you use document collections, or would like to, then this pagination gem offers extensive support for paginating documents in one or more collections at the same time.
186
+
187
+ > Collections are groups of documents that belong together but should not be grouped by date.
188
+ > See more about ['collections'](http://ben.balter.com/2015/02/20/jekyll-collections/) on Ben Balters blog.
189
+
190
+ ### Paginating a single collection
191
+
192
+ Lets expand on Ben's collection discussion (linked above). Let's say that you have hundreds of cupcake pages in your cupcake collection. To create a pagination page for only documents from the cupcake collection you would do this
193
+
194
+ ``` yml
195
+ ---
196
+ layout: page
197
+ title: All Cupcakes
198
+ pagination:
199
+ enabled: true
200
+ collection: cupcakes
201
+ ---
202
+ ```
203
+
204
+ ### Paginating multiple collections
205
+
206
+ Lets say that you want to create a single pagination page for only small cakes on your page (you have both cupcakes and cookies to sell). You could do that like this
207
+
208
+ ``` yml
209
+ ---
210
+ layout: page
211
+ title: Lil'bits
212
+ pagination:
213
+ enabled: true
214
+ collection: cupcakes, cookies
215
+ ---
216
+ ```
217
+
218
+ ### The special 'all' collection
219
+
220
+ Now your site has grown and you have multiple cake collections on it and you want to have a single page that paginates all of your collections at the same time.
221
+ You can use the special `all` collection name for this.
222
+
223
+ ``` yml
224
+ ---
225
+ layout: page
226
+ title: All the Cakes!
227
+ pagination:
228
+ enabled: true
229
+ collection: all
230
+ ---
231
+ ```
232
+
233
+ > Note: Due to the `all` keyword being reserved for this feature, you cannot have a collection called `all` in your site configuration. Sorry.
234
+
179
235
 
180
236
  ## Paginate categories, tags, locales
181
237
 
@@ -394,10 +450,10 @@ Make absolutely sure that your pagination permalink paths do not clash with any
394
450
 
395
451
  ## Issues / to-be-completed
396
452
  * Incomplete unit-tests
397
- * Missing integration tests [#2](https://github.com/jekyll/jekyll-paginate/pull/2)
398
- * Missing more detailed examples
399
- * Unable to auto-generate category/tag/language pagination pages. Still requires programmer to specify the pages him/herself.
453
+ * No integration tests [#2](https://github.com/jekyll/jekyll-paginate/pull/2)
400
454
  * _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.
401
457
 
402
458
  ## Contributing
403
459
 
@@ -1,6 +1,8 @@
1
- # Example 03::Tag pagination
1
+ # Example 03::Tag and Collection pagination
2
2
 
3
- This example bookshop website expands on the category example and adds pagination by both category and tags. The site uses the pretty permalink structure. It also demonstrates advanced sorting features such as nested fields.
3
+ This example bookshop website uses collections to organize its books^*. The site relies on pagination of its books by both collections and tags. The site shows how to paginate by single, multiple or all collections at the same time.
4
+
5
+ The site uses the pretty permalink structure. It also demonstrates advanced sorting features such as nested fields.
4
6
 
5
7
  <p align="center">
6
8
  <img src="https://raw.githubusercontent.com/sverrirs/jekyll-paginate-v2/master/examples/img/03-example-screenshot-main.png" />
@@ -13,11 +15,13 @@ After generating the pagination gem was installed using
13
15
  gem install jekyll-paginate-v2
14
16
  ```
15
17
 
18
+ ^* _It could be argued that the bookstore should have just used categories here and collections were better suited to separate things into 'books', 'DVDs', 'Games' etc..._
19
+
16
20
  ## Structure
17
21
 
18
- The site has four types of post categories `biography/_posts`, `blog/_posts`, `fantasy/_posts`, `romance/_posts`.
22
+ The site has three types of document collections `_biography/`, `_fantasy/`, `_romance/`. In addition to that the bookstore also has a blog and those posts are stored under `blog/_posts`.
19
23
 
20
- All book posts have assigned multiple tags to them.
24
+ All books have multiple tags assigned to them.
21
25
 
22
26
  Permalinks are configured to the `pretty` format site-wide. The pagination logic handles this configuration without problems and constructs the correct sub url structure.
23
27
 
@@ -34,9 +38,12 @@ Pagination pages are:
34
38
 
35
39
  Most pages are self explanatory and most sort books by the nested attribute `rank`.
36
40
 
37
- ### byisbn.md
41
+ ### Page: byisbn.md
38
42
  Demonstrates how to have multiple pagination pages defined in the root of the site without their pagination pages clashing. Uses permalinks to achieve this.
39
43
 
44
+ ### Page: Under tags/
45
+ Demonstrate how to paginate across multiple collections by using the `collections: all` front matter configuration
46
+
40
47
  ## Setup Configuration
41
48
  The gem is added to the `_config.yml` file under
42
49
  ``` yml
@@ -14,7 +14,7 @@ book:
14
14
  price:
15
15
  usd: 22.19
16
16
  eur: 20.97
17
- tags: Memoirs,Films,Autobiography,Actors
17
+ tags: Memoirs,Films,Autobiography,Actors,Science Fiction
18
18
  ---
19
19
 
20
20
  The Princess Diarist is Carrie Fisher's intimate, hilarious and revealing recollection of what happened behind the scenes on one of the most famous film sets of all time, the first Star Wars movie.
@@ -3,7 +3,7 @@ layout: home
3
3
  title: Biographies by Musicians
4
4
  pagination:
5
5
  enabled: true
6
- category: biography
6
+ collection: biography
7
7
  tag: Musicians
8
8
  permalink: /:num/
9
9
  sort_field: 'book:rank'
@@ -3,7 +3,7 @@ layout: home
3
3
  title: Biographies by Rank
4
4
  pagination:
5
5
  enabled: true
6
- category: biography
6
+ collection: biography
7
7
  permalink: /:num/
8
8
  sort_field: 'book:rank'
9
9
  sort_reverse: false
@@ -30,6 +30,18 @@ exclude:
30
30
  - Gemfile
31
31
  - Gemfile.lock
32
32
 
33
+ # Collection configurations
34
+ collections:
35
+ biography:
36
+ output: true
37
+ permalink: /biography/:path/
38
+ fantasy:
39
+ output: true
40
+ permalink: /fantasy/:path/
41
+ romance:
42
+ output: true
43
+ permalink: /romance/:path/
44
+
33
45
  # This site uses the pretty permalink structure, this renders all urls with a slash / at the end and
34
46
  # no file endings, I guess that is considered pretty :)
35
47
  permalink: pretty
@@ -20,7 +20,7 @@ layout: default
20
20
  -->
21
21
  {% for post in paginator.posts %}
22
22
  <li>
23
- <span class="post-meta">{{ post.date | date: "%b %-d, %Y" }}{% if post.book.rank %} | Rank: {{ post.book.rank }}{% endif %}{% if post.categories %} | {{ post.categories }}{% endif %}{% if post.tags %}<br>Tags: {{ post.tags }}{% endif %}</span>
23
+ <span class="post-meta">{{ post.date | date: "%b %-d, %Y" }}{% if post.book.rank %} | Rank: {{ post.book.rank }}{% endif %}{% if post.collection %} | {{ post.collection }}{% endif %}{% if post.tags %}<br>Tags: {{ post.tags }}{% endif %}</span>
24
24
  <h2>
25
25
  <a class="post-link" href="{{ post.url | relative_url }}">{{ post.title | escape }}</a>
26
26
  </h2>
@@ -6,7 +6,7 @@ layout: default
6
6
  <header class="post-header">
7
7
  <h1 class="post-title" itemprop="name headline">{{ page.title | escape }}</h1>
8
8
  <p class="post-meta"><time datetime="{{ page.date | date_to_xmlschema }}" itemprop="datePublished">{{ page.date | date: "%b %-d, %Y" }}</time>{% if page.author %} • <span itemprop="author" itemscope itemtype="http://schema.org/Person"><span itemprop="name">{{ page.author }}</span></span>{% endif %}
9
- {% if page.book.rank %} • Rank: {{ page.book.rank }}{% endif %}{% if page.categories %}<br>Category: {{ page.categories }}{% endif %}{% if page.tags %}<br>Tags: {{ page.tags }}{% endif %}</p>
9
+ {% if page.book.rank %} • Rank: {{ page.book.rank }}{% endif %}{% if page.collection %}<br>Collection: {{ page.collection }}{% endif %}{% if page.tags %}<br>Tags: {{ page.tags }}{% endif %}</p>
10
10
  </header>
11
11
 
12
12
  <div class="post-content" itemprop="articleBody">
@@ -3,7 +3,7 @@ layout: home
3
3
  title: Historical Romance
4
4
  pagination:
5
5
  enabled: true
6
- category: romance
6
+ collection: romance
7
7
  tag: historical, fiction
8
8
  per_page: 2
9
9
  permalink: /:num/
@@ -4,6 +4,7 @@ title: By ISBN
4
4
  permalink: /isbn/
5
5
  pagination:
6
6
  enabled: true
7
+ collection: all
7
8
  permalink: '/:num/'
8
9
  sort_field: 'book:ISBN13'
9
10
  sort_reverse: false
@@ -6,6 +6,7 @@ layout: home
6
6
  title: Home
7
7
  pagination:
8
8
  enabled: true
9
+ collection: biography, fantasy, romance
9
10
  sort_field: 'title'
10
11
  sort_reverse: false
11
12
  ---
@@ -3,6 +3,7 @@ layout: home
3
3
  title: Contemporary
4
4
  pagination:
5
5
  enabled: true
6
+ collection: all
6
7
  tag: contemporary
7
8
  permalink: /:num/
8
9
  ---
@@ -3,6 +3,7 @@ layout: home
3
3
  title: Fantasy
4
4
  pagination:
5
5
  enabled: true
6
+ collection: all
6
7
  tag: fantasy
7
8
  permalink: /:num/
8
9
  sort_field: 'book:rank'
@@ -3,6 +3,7 @@ layout: home
3
3
  title: Sci-Fi
4
4
  pagination:
5
5
  enabled: true
6
+ collection: fantasy,romance
6
7
  tag: Science, Fiction
7
8
  per_page: 2
8
9
  permalink: /:num/
@@ -10,4 +11,6 @@ pagination:
10
11
  sort_reverse: false
11
12
  ---
12
13
 
13
- All books tagged with _science_ and _fiction_
14
+ All books in the _fantasy_ and _romance_ collections that are tagged with _science_ and _fiction_
15
+
16
+ This should exclude the Biography "The Princess Diarist"
data/examples/README.md CHANGED
@@ -14,8 +14,10 @@ This example also demonstrates how the page can operate as a zero-config replace
14
14
  ## Example 2: Category Pagination
15
15
  Car site that has multiple paginated pages and multiple post categories.
16
16
 
17
- ## Example 3: Tag Pagination
18
- Book review site that organizes its content by tags and categories. Uses the `pretty` permalink structure for the site.
17
+ ## Example 3: Tag and Collection Pagination
18
+ Book review site that organizes its content into collections and by tags. Uses the `pretty` permalink structure for the site.
19
+
20
+ This site demonstrates how the pagination logic handles paginating across one or more collections at the same time. The pagination can also paginate over all collections.
19
21
 
20
22
  This site also demonstrates how to sort posts by nested front-matter attributes.
21
23
 
@@ -51,18 +51,39 @@ module Jekyll
51
51
 
52
52
  Jekyll.logger.debug "Pagination:","Starting"
53
53
 
54
- ################# 1 ###################
55
- # Extract the necessary information out of the site object and then instantiate the model
56
-
57
- # Get all posts that will be generated (excluding hidden posts that have hidden:true in the front matter)
58
- all_posts = site.site_payload['site']['posts'].reject { |post| post['hidden'] }
59
-
54
+ ################ 0 ####################
60
55
  # Get all pages in the site (this will be used to find the pagination templates)
61
56
  all_pages = site.pages
62
57
 
63
58
  # Get the default title of the site (used as backup when there is no title available for pagination)
64
59
  site_title = site.config['title']
65
60
 
61
+ ################ 1 ####################
62
+ # Specify the callback function that returns the correct docs/posts based on the collection name
63
+ # "posts" are just another collection in Jekyll but a specialized version that require timestamps
64
+ # This collection is the default and if the user doesn't specify a collection in their front-matter then that is the one we load
65
+ # If the collection is not found then empty array is returned
66
+ collection_by_name_lambda = lambda do |collection_name|
67
+ coll = []
68
+ if collection_name == "all"
69
+ # the 'all' collection_name is a special case and includes all collections in the site (except posts!!)
70
+ # this is useful when you want to list items across multiple collections
71
+ for coll_name, coll_data in site.collections
72
+ if( !coll_data.nil? && coll_name != 'posts')
73
+ coll += coll_data.docs.select { |doc| !doc.data.has_key?('pagination') } # Exclude all pagination pages
74
+ end
75
+ end
76
+ else
77
+ # Just the one collection requested
78
+ if !site.collections.has_key?(collection_name)
79
+ return []
80
+ end
81
+
82
+ coll = site.collections[collection_name].docs.select { |doc| !doc.data.has_key?('pagination') } # Exclude all pagination pages
83
+ end
84
+ return coll
85
+ end
86
+
66
87
  ################ 2 ####################
67
88
  # Create the proc that constructs the real-life site page
68
89
  # This is necessary to decouple the code from the Jekyll site object
@@ -101,9 +122,10 @@ module Jekyll
101
122
  # Now create and call the model with the real-life page creation proc and site data
102
123
  model = PaginationModel.new()
103
124
  if( default_config['legacy'] ) #(REMOVE AFTER 2018-01-01)
125
+ all_posts = site.site_payload['site']['posts'].reject { |post| post['hidden'] }
104
126
  model.run_compatability(default_config, all_pages, site_title, all_posts, page_create_lambda, logging_lambda) #(REMOVE AFTER 2018-01-01)
105
127
  else
106
- model.run(default_config, all_pages, site_title, all_posts, page_create_lambda, logging_lambda, page_remove_lambda)
128
+ model.run(default_config, all_pages, site_title, page_create_lambda, logging_lambda, page_remove_lambda, collection_by_name_lambda)
107
129
  end
108
130
 
109
131
  end
@@ -3,7 +3,7 @@ module Jekyll
3
3
 
4
4
  class PaginationModel
5
5
 
6
- def run(default_config, site_pages, site_title, all_posts, page_create_lambda, logging_lambda, page_remove_lambda)
6
+ def run(default_config, site_pages, site_title, page_create_lambda, logging_lambda, page_remove_lambda, collection_by_name_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 )
@@ -12,13 +12,6 @@ module Jekyll
12
12
  return
13
13
  end
14
14
 
15
- # Create the necessary indexes for the posts
16
- all_categories = self.index_posts_by(all_posts, 'categories')
17
- all_categories['posts'] = all_posts; # Populate a category for all posts
18
- # (this is a default and must not be used in the category system)
19
- all_tags = self.index_posts_by(all_posts, 'tags')
20
- all_locales = self.index_posts_by(all_posts, 'locale')
21
-
22
15
  # Now for each template page generate the paginator for it
23
16
  for template in templates
24
17
  # All pages that should be paginated need to include the pagination config element
@@ -30,6 +23,19 @@ module Jekyll
30
23
  # were generated automatically and which weren't
31
24
  if( template_config['enabled'] )
32
25
  logging_lambda.call "found page: "+template.path
26
+
27
+ # Request all documents in all collections that the user has requested
28
+ all_posts = self.get_docs_in_collections(template_config['collection'], collection_by_name_lambda)
29
+
30
+ # Create the necessary indexes for the posts
31
+ all_categories = self.index_posts_by(all_posts, 'categories')
32
+ all_categories['posts'] = all_posts; # Populate a category for all posts (this is here for backward compatibility, do not use this as it will be decommissioned 2018-01-01)
33
+ # (this is a default and must not be used in the category system)
34
+ all_tags = self.index_posts_by(all_posts, 'tags')
35
+ all_locales = self.index_posts_by(all_posts, 'locale')
36
+
37
+ # TODO: NOTE!!! This whole request for posts and indexing results could be cached to improve performance, leaving like this for now during testing
38
+
33
39
  # Now construct the pagination data for this template page
34
40
  #self.paginate(site, template, template_config, all_posts, all_tags, all_categories, all_locales)
35
41
  self.paginate(template, template_config, site_title, all_posts, all_tags, all_categories, all_locales, page_create_lambda, logging_lambda, page_remove_lambda)
@@ -66,6 +72,25 @@ module Jekyll
66
72
  "an index.html page to use as the pagination page. Skipping pagination.", "warn"
67
73
  end
68
74
  end # function run_compatability (REMOVE AFTER 2018-01-01)
75
+
76
+ # Returns the combination of all documents in the collections that are specified
77
+ # raw_collection_names can either be a list of collections separated by a ',' or ' ' or a single string
78
+ def get_docs_in_collections(raw_collection_names, collection_by_name_lambda)
79
+ if raw_collection_names.is_a?(String)
80
+ collection_names = raw_collection_names.split(/;|,|\s/)
81
+ else
82
+ collection_names = raw_collection_names
83
+ end
84
+
85
+ docs = []
86
+ # Now for each of the collections get the docs
87
+ for coll_name in collection_names
88
+ # Request all the documents for the collection in question, and join it with the total collection
89
+ docs += collection_by_name_lambda.call(coll_name.downcase.strip)
90
+ end
91
+
92
+ return docs
93
+ end
69
94
 
70
95
  #
71
96
  # Rolls through all the pages passed in and finds all pages that have pagination enabled on them.
@@ -1,8 +1,8 @@
1
1
  module Jekyll
2
2
  module PaginateV2
3
- VERSION = "1.4.0"
3
+ VERSION = "1.5.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 v1.4.0 -m "Gem v1.4.0"
5
+ # git tag -a v1.5.0 -m "Gem v1.5.0"
6
6
  # git push origin --tags
7
7
  end
8
8
  end
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.4.0
4
+ version: 1.5.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: 2016-11-30 00:00:00.000000000 Z
11
+ date: 2016-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -63,6 +63,7 @@ extensions: []
63
63
  extra_rdoc_files: []
64
64
  files:
65
65
  - ".gitignore"
66
+ - CODE_OF_CONDUCT.md
66
67
  - Gemfile
67
68
  - LICENSE
68
69
  - README.md
@@ -103,34 +104,34 @@ files:
103
104
  - examples/02-category/toyota/index.md
104
105
  - examples/03-tags/Gemfile
105
106
  - examples/03-tags/README.md
107
+ - examples/03-tags/_biography/all/born-to-run.md
108
+ - examples/03-tags/_biography/all/forty-autumns.md
109
+ - examples/03-tags/_biography/all/life-in-questions-a.md
110
+ - examples/03-tags/_biography/all/not-dead-yet.md
111
+ - examples/03-tags/_biography/all/princess-diarist-the.md
112
+ - examples/03-tags/_biography/all/when-breath-becomes-air.md
113
+ - examples/03-tags/_biography/biography-musicians.md
114
+ - examples/03-tags/_biography/index.md
106
115
  - examples/03-tags/_config.yml
116
+ - examples/03-tags/_fantasy/all/harry-potter-deathly-hallows.md
117
+ - examples/03-tags/_fantasy/all/harry-potter-philosophers-stone.md
118
+ - examples/03-tags/_fantasy/all/mistborn-trilogy.md
119
+ - examples/03-tags/_fantasy/all/ready-player-one.md
120
+ - examples/03-tags/_fantasy/all/sword-of-destiny.md
121
+ - examples/03-tags/_fantasy/all/terry-pratchet-diary-2017.md
107
122
  - examples/03-tags/_includes/header.html
108
123
  - examples/03-tags/_layouts/home.html
109
124
  - examples/03-tags/_layouts/post.html
110
- - examples/03-tags/biography/_posts/2016-10-27-born-to-run.md
111
- - examples/03-tags/biography/_posts/2016-10-27-forty-autumns.md
112
- - examples/03-tags/biography/_posts/2016-10-27-life-in-questions-a.md
113
- - examples/03-tags/biography/_posts/2016-10-27-not-dead-yet.md
114
- - examples/03-tags/biography/_posts/2016-10-27-princess-diarist-the.md
115
- - examples/03-tags/biography/_posts/2016-10-27-when-breath-becomes-air.md
116
- - examples/03-tags/biography/biography-musicians.md
117
- - examples/03-tags/biography/biography.md
125
+ - examples/03-tags/_romance/all/breath-of-snow-and-ashes-a.md
126
+ - examples/03-tags/_romance/all/dressmaker-the.md
127
+ - examples/03-tags/_romance/all/fiery-cross-the.md
128
+ - examples/03-tags/_romance/all/it-ends-with-us.md
129
+ - examples/03-tags/_romance/all/outlander-novel.md
130
+ - examples/03-tags/_romance/all/virgins-outlander-short-story.md
131
+ - examples/03-tags/_romance/romance-historical.md
118
132
  - examples/03-tags/blog/_posts/2016-09-30-welcome-to-jekyll-paginate-v2.md
119
133
  - examples/03-tags/byisbn.md
120
- - examples/03-tags/fantasy/_posts/2016-10-27-harry-potter-deathly-hallows.md
121
- - examples/03-tags/fantasy/_posts/2016-10-27-harry-potter-philosophers-stone.md
122
- - examples/03-tags/fantasy/_posts/2016-10-27-mistborn-trilogy.md
123
- - examples/03-tags/fantasy/_posts/2016-10-27-ready-player-one.md
124
- - examples/03-tags/fantasy/_posts/2016-10-27-sword-of-destiny.md
125
- - examples/03-tags/fantasy/_posts/2016-10-27-terry-pratchet-diary-2017.md
126
134
  - examples/03-tags/index.md
127
- - examples/03-tags/romance/_posts/2016-10-27-breath-of-snow-and-ashes-a.md
128
- - examples/03-tags/romance/_posts/2016-10-27-dressmaker-the.md
129
- - examples/03-tags/romance/_posts/2016-10-27-fiery-cross-the.md
130
- - examples/03-tags/romance/_posts/2016-10-27-it-ends-with-us.md
131
- - examples/03-tags/romance/_posts/2016-10-27-outlander-novel.md
132
- - examples/03-tags/romance/_posts/2016-10-27-virgins-outlander-short-story.md
133
- - examples/03-tags/romance/romance-historical.md
134
135
  - examples/03-tags/tags/contemporary.md
135
136
  - examples/03-tags/tags/fantasy.md
136
137
  - examples/03-tags/tags/sci-fi.md