jekyll-paginate-content 1.0.1 → 1.0.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: 8193492da30cca6ed01817af4d699e23342122de
4
- data.tar.gz: 86ac1f58a1bd28b6602753133ad762a7d496ad86
3
+ metadata.gz: 92687574f2e5d7f3666bf6c8076c14833b1505dd
4
+ data.tar.gz: af26416882ede550faefdb9d64ddef9e42578807
5
5
  SHA512:
6
- metadata.gz: f9fae88e8fe6aa414ad57157203ff47e69c257c176c1ea8f960874f9bc4bc8b25579405384e1cd7134d41537d49e4047a0285c21feb253afa1864c2b95478cf2
7
- data.tar.gz: 1e7f5892aae3a0e3d3d821639d7cd7597e0a22b75fc45d9535847b650bef2f5239ce64af18c913db3e335cb6d7be538e26f1460de3668498acdfba146b38c539
6
+ metadata.gz: 93bd2542e563e1495f3cc245452aedeb833994895a7d5415209c816d58e6eedade502f8552d95466bcdba9c00a271739bb861b2c8c96b6b855ed311c325dbdf1
7
+ data.tar.gz: e6886038d592797351b241e22e54dbd555a6c6f4da0b23e7cef3db7e29d8642d55278df6c3b51f6810b8d0a727d3d7e0f09d26505424fd3f038e384e97d1b56b
data/README.md CHANGED
@@ -127,10 +127,14 @@ See other [demos](#demos).
127
127
 
128
128
  1. You want to split long posts and pages/articles/reviews, etc. into multiple pages, e.g. chapters;
129
129
  1. You want to offer faster loading times to your readers;
130
- 1. You wamt to make slide/presentation-type content;
130
+ 1. You want to make slide/presentation-type content;
131
131
  1. You want more ad revenue from your Jekyll site;
132
132
  1. You wanna be the cool kid. :stuck_out_tongue:
133
133
 
134
+ ## What's new?
135
+
136
+ v1.0.2 Don't regenerate unnecessarily
137
+
134
138
  ## Installation
135
139
 
136
140
  Add the gem to your application's Gemfile:
@@ -302,7 +306,7 @@ paginate_content:
302
306
  ```
303
307
  ## Splitting content
304
308
 
305
- How your files are split depends on your `separator`:
309
+ How your content is split depends on your `separator`:
306
310
 
307
311
  ### Manual mode
308
312
 
@@ -396,6 +400,7 @@ These properties/fields are available to your layouts and content via the `pagin
396
400
  | | | |
397
401
  | `single_page` | `view_all` | Path to the original/full page |
398
402
  | `seo` | | HTML header tags for SEO, see [below](#search-engine-optimization-seo)
403
+ | `toc` | | Table Of Contents generator, see [below](#table-of-contents-toc)
399
404
  | | | |
400
405
  | `section` | | Text of the first header (<h1> etc.) on this page
401
406
  | `previous_section` | `prev_section` | Ditto for the previous page |
@@ -431,7 +436,7 @@ The tags, categories, and `hidden` are set up this way to avoid duplicate counts
431
436
 
432
437
  ### Setting custom properties
433
438
 
434
- `paginate_content` in `_config.yml` has a `properties` option:
439
+ `paginate_content` has a `properties` option:
435
440
 
436
441
  ```yaml
437
442
  paginate_content:
@@ -745,7 +750,7 @@ The difference between this and the one built into [kramdown](https://kramdown.g
745
750
 
746
751
  ### Excluding sections
747
752
 
748
- Should you want some fields excluded from the Table Of Contents, add them to the `toc_exclude` option in your site configuration or content front-matter:
753
+ Should you want some sections excluded from the Table Of Contents, add them to the `toc_exclude` option in your site configuration or content front-matter:
749
754
 
750
755
  ```yaml
751
756
  paginate_content:
@@ -70,6 +70,8 @@ module Jekyll
70
70
 
71
71
  # Run through each specified collection
72
72
 
73
+ total_skipped = 0
74
+
73
75
  collections.each do |collection|
74
76
  if collection == "pages"
75
77
  items = site.pages
@@ -95,13 +97,18 @@ module Jekyll
95
97
  end
96
98
 
97
99
  process.each do |item|
98
- pager = Paginator.new(site, collection, item, @config)
99
- next if pager.items.empty?
100
+ paginator = Paginator.new(site, collection, item, @config)
101
+ if paginator.skipped
102
+ debug "[#{collection}] \"#{item.data['title']}\" skipped"
103
+ total_skipped += 1
104
+ end
100
105
 
101
- debug "[#{collection}] \"#{item.data['title']}\", #{pager.items.length-1}+1 pages"
102
- total_parts += pager.items.length-1;
106
+ next if paginator.items.empty?
107
+
108
+ debug "[#{collection}] \"#{item.data['title']}\", #{paginator.items.length-1}+1 pages"
109
+ total_parts += paginator.items.length-1;
103
110
  total_copies += 1
104
- new_items << pager.items
111
+ new_items << paginator.items
105
112
  old_items << item
106
113
  end
107
114
 
@@ -119,6 +126,12 @@ module Jekyll
119
126
  info "[#{collection}] Generated #{total_parts}+#{total_copies} pages"
120
127
  end
121
128
  end
129
+
130
+ if total_skipped > 0
131
+ s = (total_skipped == 1 ? '' : 's')
132
+ info "Skipped #{total_skipped} unchanged item#{s}"
133
+ end
134
+
122
135
  runtime = "%.6f" % (Time.now - start_time).to_f
123
136
  debug "Runtime: #{runtime}s"
124
137
  end
@@ -232,22 +245,32 @@ module Jekyll
232
245
  end
233
246
 
234
247
  class Paginator
248
+ attr_accessor :skipped
249
+
235
250
  def initialize(site, collection, item, config)
236
251
  @site = site
237
252
  @collection = collection
253
+ @items = []
254
+ @skipped = false
255
+
256
+ source = item.path
257
+ html = item.destination('')
238
258
 
239
- final_config = {}.merge(config)
240
- if item.data.has_key?('paginate_content')
241
- item.data['paginate_content'].each do |k,v|
242
- s = k.downcase.strip.to_sym
243
- final_config[s] = v
259
+ if !File.exist?(html) || (File.mtime(html) < File.mtime(source))
260
+ final_config = {}.merge(config)
261
+ if item.data.has_key?('paginate_content')
262
+ item.data['paginate_content'].each do |k,v|
263
+ s = k.downcase.strip.to_sym
264
+ final_config[s] = v
265
+ end
244
266
  end
245
- end
246
267
 
247
- @config = final_config
268
+ @config = final_config
248
269
 
249
- @items = []
250
- self.split(item)
270
+ self.split(item)
271
+ else
272
+ @skipped = true
273
+ end
251
274
  end
252
275
 
253
276
  def items
@@ -1,7 +1,7 @@
1
1
  module Jekyll
2
2
  module Paginate
3
3
  module Content
4
- VERSION = "1.0.1"
4
+ VERSION = "1.0.2"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-paginate-content
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Ibrado
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-12-26 00:00:00.000000000 Z
11
+ date: 2017-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll