jekyll_plugin_support 1.1.0 → 3.1.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 +4 -4
- data/.rubocop.yml +38 -3
- data/CHANGELOG.md +30 -6
- data/README.md +474 -4
- data/jekyll_plugin_support.gemspec +3 -1
- data/lib/block/jekyll_plugin_support_block.rb +5 -6
- data/lib/block/jekyll_plugin_support_block_noarg.rb +1 -3
- data/lib/error/jekyll_custom_error.rb +6 -5
- data/lib/generator/jekyll_plugin_support_generator.rb +1 -7
- data/lib/helper/jekyll_plugin_helper.rb +5 -5
- data/lib/helper/jekyll_plugin_helper_class.rb +2 -2
- data/lib/hooks/a_page.rb +203 -0
- data/lib/hooks/all_collections_hooks.rb +61 -0
- data/lib/hooks/all_files.rb +48 -0
- data/lib/hooks/class_methods.rb +38 -0
- data/lib/jekyll_all_collections/all_collections_tag.rb +174 -0
- data/lib/jekyll_plugin_support/jekyll_plugin_support_class.rb +6 -7
- data/lib/jekyll_plugin_support/jekyll_plugin_support_spec_support.rb +1 -3
- data/lib/jekyll_plugin_support/version.rb +1 -1
- data/lib/jekyll_plugin_support.rb +27 -12
- data/lib/tag/jekyll_plugin_support_tag.rb +1 -4
- data/lib/tag/jekyll_plugin_support_tag_noarg.rb +0 -2
- data/lib/util/mslinn_binary_search.rb +152 -0
- data/lib/util/send_chain.rb +56 -0
- data/spec/all_collections_tag/all_collections_tag_sort_spec.rb +184 -0
- data/spec/bsearch_spec.rb +50 -0
- data/spec/custom_error_spec.rb +12 -10
- data/spec/date_sort_spec.rb +84 -0
- data/spec/jekyll_plugin_helper_options_spec.rb +9 -3
- data/spec/liquid_variable_parsing_spec.rb +7 -6
- data/spec/mslinn_binary_search_spec.rb +47 -0
- data/spec/send_chain_spec.rb +72 -0
- data/spec/send_spec.rb +28 -0
- data/spec/sorted_lru_files_spec.rb +82 -0
- data/spec/spec_helper.rb +15 -3
- data/spec/status_persistence.txt +4 -7
- data/spec/testable_spec.rb +38 -0
- metadata +56 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c20bec384d298ac931d132f59dbcaf621e9f55440954dc8c6579b1c9131df62e
|
4
|
+
data.tar.gz: 4cfd22137529da35c52f788ab70ec81fe9457d6b533ec5bc70f653b22791db0e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eafd8b44d05e23011bd30a2bb3bab69befb3cd90b520585d4cf05d164b1b2c76a5218cdd0bdbf3bc7ba6f9a25e789f171403f3553d2cb68d13e0c54346d69b5e
|
7
|
+
data.tar.gz: 1beb29113474e1d501d5394b90288f7e46047e846b868df80f1a5afe9287ae7eece17e7d00e95e9443b7d3b2a69d6d93d9c27d0f6d81d1f4d2f0afba8ae152fe
|
data/.rubocop.yml
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
plugins:
|
2
2
|
# - rubocop-jekyll
|
3
3
|
- rubocop-md
|
4
4
|
- rubocop-performance
|
@@ -26,6 +26,14 @@ Layout/HashAlignment:
|
|
26
26
|
EnforcedColonStyle: table
|
27
27
|
EnforcedHashRocketStyle: table
|
28
28
|
|
29
|
+
Layout/IndentationConsistency:
|
30
|
+
Exclude:
|
31
|
+
- "*.md"
|
32
|
+
|
33
|
+
Layout/InitialIndentation:
|
34
|
+
Exclude:
|
35
|
+
- "*.md"
|
36
|
+
|
29
37
|
Layout/LineLength:
|
30
38
|
Max: 150
|
31
39
|
|
@@ -37,14 +45,23 @@ Metrics/BlockLength:
|
|
37
45
|
- jekyll_plugin_support.gemspec
|
38
46
|
Max: 30
|
39
47
|
|
48
|
+
Metrics/ClassLength:
|
49
|
+
Exclude:
|
50
|
+
- "**/all_collections_tag.rb"
|
51
|
+
Max: 150
|
52
|
+
|
40
53
|
Metrics/CyclomaticComplexity:
|
41
|
-
Max:
|
54
|
+
Max: 35
|
42
55
|
|
43
56
|
Metrics/MethodLength:
|
44
57
|
Max: 50
|
45
58
|
|
59
|
+
Metrics/ModuleLength:
|
60
|
+
Exclude:
|
61
|
+
- "**/jekyll_plugin_support_class.rb"
|
62
|
+
|
46
63
|
Metrics/PerceivedComplexity:
|
47
|
-
Max:
|
64
|
+
Max: 35
|
48
65
|
|
49
66
|
Naming/FileName:
|
50
67
|
Exclude:
|
@@ -54,6 +71,9 @@ Naming/FileName:
|
|
54
71
|
RSpec/ExampleLength:
|
55
72
|
Max: 30
|
56
73
|
|
74
|
+
RSpec/MultipleMemoizedHelpers:
|
75
|
+
Enabled: false
|
76
|
+
|
57
77
|
RSpec/SpecFilePathFormat:
|
58
78
|
Enabled: false
|
59
79
|
IgnoreMethods: true
|
@@ -67,6 +87,13 @@ RSpec/IndexedLet:
|
|
67
87
|
RSpec/MultipleExpectations:
|
68
88
|
Max: 15
|
69
89
|
|
90
|
+
RSpec/MultipleDescribes:
|
91
|
+
Enabled: false
|
92
|
+
|
93
|
+
Security/Eval:
|
94
|
+
Exclude:
|
95
|
+
- spec/all_collections_tag/all_collections_tag_sort_spec.rb
|
96
|
+
|
70
97
|
Style/ClassVars:
|
71
98
|
Enabled: false
|
72
99
|
|
@@ -76,8 +103,16 @@ Style/Documentation:
|
|
76
103
|
Style/FrozenStringLiteralComment:
|
77
104
|
Enabled: false
|
78
105
|
|
106
|
+
Style/GlobalVars:
|
107
|
+
Exclude:
|
108
|
+
- spec/mslinn_binary_search_spec.rb
|
109
|
+
|
79
110
|
Style/StringConcatenation:
|
80
111
|
Enabled: false
|
81
112
|
|
113
|
+
Style/StringLiterals:
|
114
|
+
Exclude:
|
115
|
+
- spec/all_collections_tag/all_collections_tag_sort_spec.rb
|
116
|
+
|
82
117
|
Style/TrailingCommaInHashLiteral:
|
83
118
|
EnforcedStyleForMultiline: comma
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,26 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 3.1.0 / 2025-06-10
|
4
|
+
|
5
|
+
* Added attribute `order` and method `field` to support `jekyll_outline`.
|
6
|
+
* Added another constructor for `AllCollectionsHooks::APage`, called `apage_from`.
|
7
|
+
* Added new method `new_attribute` to module `JekyllSupport`.
|
8
|
+
* The displayed date field (`:date` or `:last_modified`) now defaults to the primary sort field.
|
9
|
+
* Modified specs tests.
|
10
|
+
* Jekyll tag `AllCollectionsTag` now accepts an optional parameter called
|
11
|
+
`collection_name`, which filters the selected data source. A warning is logged
|
12
|
+
if the data source is anything but `all_collections`.
|
13
|
+
* Moved `APage` and its constructors to the `JekyllCollections` module.
|
14
|
+
|
15
|
+
|
16
|
+
## 3.0.0 / 2025-02-09
|
17
|
+
|
18
|
+
* Numbered as v3.0.0 because `jekyll_draft` was at v2.1.0 and the two projects should have similar version numbers.
|
19
|
+
* `Jekyll_all_collections` was folded into this project.
|
20
|
+
* Now requires [Jekyll 4.4.1](https://jekyllrb.com/news/2025/01/29/jekyll-4-4-1-released/) or later,
|
21
|
+
and Ruby 3.2.0 or later
|
22
|
+
|
23
|
+
|
3
24
|
## 1.1.0 / 2025-02-07
|
4
25
|
|
5
26
|
* Now replaces include and layout variables with their values
|
@@ -30,12 +51,15 @@
|
|
30
51
|
The following seems to be optimal for custom plugins; it suppresses the ridiculously long stack trace that used to be generated:
|
31
52
|
|
32
53
|
```ruby
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
54
|
+
begin
|
55
|
+
# ...
|
56
|
+
rescue DemoInlineTagError => e # jekyll_plugin_support handles StandardError
|
57
|
+
@logger.error { e.logger_message }
|
58
|
+
exit! 1 if @die_on_demo_tag_error
|
59
|
+
|
60
|
+
e.html_message
|
61
|
+
end
|
62
|
+
```
|
39
63
|
|
40
64
|
|
41
65
|
## 1.0.1 / 2024-07-27
|
data/README.md
CHANGED
@@ -14,13 +14,13 @@ At present, only Jekyll tags and blocks are supported.
|
|
14
14
|
Public plugins that use `jekyll_plugin_support` include:
|
15
15
|
|
16
16
|
<ul style="columns: 2">
|
17
|
-
<li><a href='https://www.mslinn.com/jekyll_plugins/jekyll_all_collections'><code>jekyll_all_collections</code></a></li>
|
18
17
|
<li><a href='https://www.mslinn.com/jekyll_plugins/jekyll_badge'><code>jekyll_badge</code></a></li>
|
18
|
+
<li><a href='https://www.mslinn.com/jekyll_plugins/jekyll_draft'><code>jekyll_draft</code></a></li>
|
19
19
|
<li><a href='https://www.mslinn.com/jekyll_plugins/jekyll_emoji'><code>jekyll_emoji</code></a></li>
|
20
20
|
<li><a href='https://www.mslinn.com/jekyll_plugins/jekyll_flexible_include.html'><code>jekyll_flexible_include</code></a></li>
|
21
|
+
<li><a href='https://www.mslinn.com/jekyll_plugins/jekyll_google_translate'><code>jekyll_google_translate</code></a></li>
|
21
22
|
<li><a href='https://www.mslinn.com/jekyll_plugins/jekyll_href.html'><code>jekyll_href</code></a></li>
|
22
23
|
<li><a href='https://www.mslinn.com/jekyll_plugins/jekyll_img.html'><code>jekyll_img</code></a></li>
|
23
|
-
<li><a href='https://www.mslinn.com/jekyll_plugins/jekyll_plugin_template.html'><code>jekyll_plugin_template</code></a></li>
|
24
24
|
<li><a href='https://www.mslinn.com/jekyll_plugins/jekyll_outline.html'><code>jekyll_outline</code></a></li>
|
25
25
|
<li><a href='https://www.mslinn.com/jekyll_plugins/jekyll_pre.html'><code>jekyll_pre</code></a></li>
|
26
26
|
<li><a href='https://www.mslinn.com/jekyll_plugins/jekyll_quote.html'><code>jekyll_quote</code></a></li>
|
@@ -53,7 +53,21 @@ Jekyll plugin tags created from `jekyll_plugin_support` framework automatically
|
|
53
53
|
14. Plugins can be subclassed.
|
54
54
|
15. [`Nugem`](https://mslinn.com/ruby/6800-nugem.html) can create working scaffolding for new plugins built
|
55
55
|
using `jekyll_plugin_support`.
|
56
|
+
16. Four new attributes are added to
|
57
|
+
[`site`](https://jekyllrb.com/docs/variables/#site-variables):
|
56
58
|
|
59
|
+
a. `all_collections` includes all documents in all collections.
|
60
|
+
|
61
|
+
b. `all_documents` includes `all_collections` plus all standalone pages.
|
62
|
+
|
63
|
+
c. `everything` includes `all_documents` plus all static files.
|
64
|
+
|
65
|
+
d. `sorted_lru_files` is used by a new binary search lookup for matching page suffixes.
|
66
|
+
The `jekyll_href` and `jekyll_draft` plugins use this feature.
|
67
|
+
17. A new Ruby class, `APage`, which abstracts all URL-addressable entities in a Jekyll website.
|
68
|
+
An `APage` can be constructed from a Jekyll `Document` or `Page`, a static file, and a Ruby hash.
|
69
|
+
|
70
|
+
`APage` instances can help immensely when automating content generation and reporting tasks.
|
57
71
|
|
58
72
|
## Installation
|
59
73
|
|
@@ -66,7 +80,7 @@ add the following line to your Jekyll plugin’s `Gemfile`.
|
|
66
80
|
```ruby
|
67
81
|
group :jekyll_plugins do
|
68
82
|
# ...
|
69
|
-
gem 'jekyll_plugin_support', '>=
|
83
|
+
gem 'jekyll_plugin_support', '>= 3.1.0'
|
70
84
|
# ...
|
71
85
|
end
|
72
86
|
```
|
@@ -85,7 +99,7 @@ If your custom plugin will be packaged into a gem, add the following to your plu
|
|
85
99
|
```ruby
|
86
100
|
Gem::Specification.new do |spec|
|
87
101
|
# ...
|
88
|
-
spec.add_dependency 'jekyll_plugin_support', '>=
|
102
|
+
spec.add_dependency 'jekyll_plugin_support', '>= 3.1.0'
|
89
103
|
# ...
|
90
104
|
end
|
91
105
|
```
|
@@ -105,6 +119,9 @@ to your Jekyll project’s CSS file.
|
|
105
119
|
|
106
120
|
## About `jekyll_plugin_support`
|
107
121
|
|
122
|
+
This Jekyll plugin includes a generator,
|
123
|
+
triggered by a high-priority hook, and a block tag called `all_collections`.
|
124
|
+
|
108
125
|
`JekyllSupport::JekyllBlock` and `JekyllSupport::JekyllTag`
|
109
126
|
provide support for [Jekyll tag block plugins](https://jekyllrb.com/docs/plugins/tags/#tag-blocks)
|
110
127
|
and [Jekyll inline tag plugins](https://jekyllrb.com/docs/plugins/tags/), respectively.
|
@@ -175,6 +192,210 @@ For inline tags, `render_impl` does not accept any parameters.
|
|
175
192
|
For block tags, a single parameter is required, which receives any text enclosed within your block by the website author.
|
176
193
|
|
177
194
|
|
195
|
+
### New `Site` Attributes
|
196
|
+
|
197
|
+
No explicit initialization or setup is required.
|
198
|
+
Jekyll plugins can access the value of
|
199
|
+
`site.all_collections`, `site.all_documents` and `site.everything`;
|
200
|
+
however, Liquid code in Jekyll pages and documents cannot.
|
201
|
+
|
202
|
+
|
203
|
+
### Excluding Files
|
204
|
+
|
205
|
+
There are two ways to exclude files from the new `site` attributes.
|
206
|
+
|
207
|
+
1) The [`exclude` entry in `_config.yml`](https://jekyllrb.com/docs/configuration/options#global-configuration)
|
208
|
+
can be used as it normally would.
|
209
|
+
|
210
|
+
2) Adding the following entry to a page’s front matter causes that page to be excluded
|
211
|
+
from the collection created by this plugin:
|
212
|
+
|
213
|
+
```html
|
214
|
+
---
|
215
|
+
exclude_from_all: true
|
216
|
+
---
|
217
|
+
```
|
218
|
+
|
219
|
+
### `all_collections` Plugin Usage
|
220
|
+
|
221
|
+
Jekyll generators and tags receive an enhanced version of the `site` Jekyll variable.
|
222
|
+
|
223
|
+
|
224
|
+
#### From a Custom Plugin
|
225
|
+
|
226
|
+
In the following example of how to use the `all_collections` plugin in a custom plugin,
|
227
|
+
the `do_something_with` function processes all `Jekyll::Page`s, `Jekyll:Document`s, and static files.
|
228
|
+
|
229
|
+
```ruby
|
230
|
+
@site.everything.each do |apage|
|
231
|
+
do_something_with apage
|
232
|
+
end
|
233
|
+
```
|
234
|
+
|
235
|
+
|
236
|
+
#### Using the Block Tag
|
237
|
+
|
238
|
+
The general form of the Jekyll tag, including all options, is:
|
239
|
+
|
240
|
+
```html
|
241
|
+
{% all_collections
|
242
|
+
collection_name='posts'
|
243
|
+
data_selector='all_collections'
|
244
|
+
date_column='date|last_modified'
|
245
|
+
heading='All Posts'
|
246
|
+
id='post_outline'
|
247
|
+
sort_by='SORT_KEYS'
|
248
|
+
%}
|
249
|
+
```
|
250
|
+
|
251
|
+
Each of these attributes are explained below.
|
252
|
+
|
253
|
+
|
254
|
+
#### `collection_name` Attribute
|
255
|
+
|
256
|
+
Name of the collection that this `APage` belongs to, or `nil`.
|
257
|
+
|
258
|
+
|
259
|
+
##### `data_selector` Attribute
|
260
|
+
|
261
|
+
Name of the data collection to work from, defaults to `all_collections`.
|
262
|
+
Other allowable values are `all_documents` and `everything`.
|
263
|
+
|
264
|
+
|
265
|
+
##### `date_column` Attribute
|
266
|
+
|
267
|
+
One of two date columns can be displayed in the generated HTML:
|
268
|
+
either `date` (when the article was originally written),
|
269
|
+
or `last_modified`.
|
270
|
+
The default value for the `date_column` attribute is `date`.
|
271
|
+
|
272
|
+
|
273
|
+
##### `heading` Attribute
|
274
|
+
|
275
|
+
If no `heading` attribute is specified, a heading will automatically be generated, which contains the `sort_by` values,
|
276
|
+
for example:
|
277
|
+
|
278
|
+
```html
|
279
|
+
{% all_collections id='abcdef' sort_by="last_modified" %}
|
280
|
+
```
|
281
|
+
|
282
|
+
The above generates a heading like:
|
283
|
+
|
284
|
+
```html
|
285
|
+
<h2 id="abcdef">All Posts Sorted By last_modified</h2>
|
286
|
+
```
|
287
|
+
|
288
|
+
To suppress both a `h2` heading (and the enclosed `id`) from being generated,
|
289
|
+
specify an empty string for the value of `heading`:
|
290
|
+
|
291
|
+
```html
|
292
|
+
{% all_collections heading='' %}
|
293
|
+
```
|
294
|
+
|
295
|
+
|
296
|
+
##### `id` Attribute
|
297
|
+
|
298
|
+
If your Jekyll layout employs [`jekyll-toc`](https://github.com/allejo/jekyll-toc), then `id` attributes are important.
|
299
|
+
The `jekyll-toc` include checks for `id` attributes in `h2` ... `h6` tags, and if found,
|
300
|
+
and if the attribute value is enclosed in double quotes
|
301
|
+
(`id="my_id"`, not single quotes like `id='my_id'`),
|
302
|
+
then the heading is included in the table of contents.
|
303
|
+
|
304
|
+
To suppress an `id` from being generated,
|
305
|
+
and thereby preventing the heading from appearing in the automatically generated table of contents from `jekyll-toc`,
|
306
|
+
specify an empty string for the value of `id`, like this:
|
307
|
+
|
308
|
+
```html
|
309
|
+
{% all_collections id='' %}
|
310
|
+
```
|
311
|
+
|
312
|
+
|
313
|
+
##### `SORT_KEYS` Values
|
314
|
+
|
315
|
+
`SORT_KEYS` specifies how to sort the collection.
|
316
|
+
Values can include one or more of the following attributes:
|
317
|
+
`date`, `destination`, `draft`, `label`, `last_modified`, `last_modified_at`, `path`, `relative_path`,
|
318
|
+
`title`, `type`, and `url`.
|
319
|
+
Ascending sorts are the default; however, a descending sort can be achieved by prepending `-` before an attribute.
|
320
|
+
|
321
|
+
To specify more than one sort key, provide a comma-delimited string of values.
|
322
|
+
Included spaces are ignored.
|
323
|
+
For example, specify the primary sort key as `draft`,
|
324
|
+
the secondary sort key as `last_modified`,
|
325
|
+
and the tertiary key as `label`:
|
326
|
+
|
327
|
+
```html
|
328
|
+
{% all_collections
|
329
|
+
date_column='last_modified'
|
330
|
+
heading='All Posts'
|
331
|
+
id='asdf'
|
332
|
+
sort_by='draft, last_modified, label'
|
333
|
+
%}
|
334
|
+
```
|
335
|
+
|
336
|
+
|
337
|
+
#### Liquid Usage Examples
|
338
|
+
|
339
|
+
Here is a short Jekyll page, including front matter,
|
340
|
+
demonstrating this plugin being invoked with all default attribute values:
|
341
|
+
|
342
|
+
```html
|
343
|
+
---
|
344
|
+
description: "
|
345
|
+
Dump of all collections, sorted by date originally written, newest to oldest.
|
346
|
+
The heading text will be <code>All Posts Sorted By -date</code>
|
347
|
+
"
|
348
|
+
layout: default
|
349
|
+
title: Testing, 1, 2, 3
|
350
|
+
---
|
351
|
+
{% all_collections %}
|
352
|
+
```
|
353
|
+
|
354
|
+
Following are examples of how to specify the sort parameters.
|
355
|
+
|
356
|
+
**Explicitly express the default sort**<br>
|
357
|
+
(sort by the date originally written, newest to oldest):
|
358
|
+
|
359
|
+
```html
|
360
|
+
{% all_collections sort_by="-date" %}
|
361
|
+
```
|
362
|
+
|
363
|
+
Sort by date, from oldest to newest:
|
364
|
+
|
365
|
+
```html
|
366
|
+
{% all_collections sort_by="date" %}
|
367
|
+
```
|
368
|
+
|
369
|
+
**Sort by the date last modified, oldest to newest:**
|
370
|
+
|
371
|
+
```html
|
372
|
+
{% all_collections sort_by="last_modified" %}
|
373
|
+
```
|
374
|
+
|
375
|
+
**Sort by the date last modified, newest to oldest:**
|
376
|
+
|
377
|
+
```html
|
378
|
+
{% all_collections sort_by="-last_modified" %}
|
379
|
+
```
|
380
|
+
|
381
|
+
**Several attributes can be specified as sort criteria**<br>
|
382
|
+
by passing them as a comma-delimited string.
|
383
|
+
Included spaces are ignored:
|
384
|
+
|
385
|
+
```html
|
386
|
+
{% all_collections sort_by="-last_modified, -date" %}
|
387
|
+
{% all_collections sort_by="-last_modified, title" %}
|
388
|
+
{% all_collections sort_by="-last_modified, -date, title" %}
|
389
|
+
```
|
390
|
+
|
391
|
+
**The following two examples produce the same output:**
|
392
|
+
|
393
|
+
```html
|
394
|
+
{% all_collections sort_by="-last_modified,-date" %}
|
395
|
+
{% all_collections sort_by="-last_modified, -date" %}
|
396
|
+
```
|
397
|
+
|
398
|
+
|
178
399
|
## Predefined Plugin Variables
|
179
400
|
|
180
401
|
`Jekyll_plugin_support` defines the following Ruby variables that you can use in your plugin’s `render_impl` method:
|
@@ -730,6 +951,156 @@ redef_without_warning :VERSION, '0.1.0'.freeze
|
|
730
951
|
```
|
731
952
|
|
732
953
|
|
954
|
+
## Generator
|
955
|
+
|
956
|
+
This plugin incorporates a generator, which adds four new attributes to
|
957
|
+
[`site`](https://jekyllrb.com/docs/variables/#site-variables):
|
958
|
+
`all_collections`, `all_documents`, `everything`, and `sorted_lru_files`.
|
959
|
+
|
960
|
+
These three attributes can be referenced as `site.everything`, `site.all_collections`
|
961
|
+
and `site.all_documents`.
|
962
|
+
|
963
|
+
* `all_collections` includes all documents in all collections.
|
964
|
+
|
965
|
+
* `all_documents` includes `all_collections` plus all standalone pages.
|
966
|
+
|
967
|
+
* `everything` includes `all_documents` plus all static files.
|
968
|
+
|
969
|
+
* `sorted_lru_files` is used by a new binary search lookup for matching page suffixes.
|
970
|
+
Currently only `jekyll_href` and `jekyll_draft` use this feature.
|
971
|
+
|
972
|
+
|
973
|
+
### Collection Management
|
974
|
+
|
975
|
+
Jekyll provides inconsistent attributes for
|
976
|
+
[`site.pages`](https://jekyllrb.com/docs/pages/),
|
977
|
+
[`site.posts`](https://jekyllrb.com/docs/posts/) and
|
978
|
+
[`site.static_files`](https://jekyllrb.com/docs/static-files/).
|
979
|
+
|
980
|
+
|
981
|
+
* While the `url` attributes of items in `site.posts` and `site.pages` start with a slash (/),
|
982
|
+
`site.static_files` items do not have a `url` attribute.
|
983
|
+
* Static files have a `relative_path` attribute, which starts with a slash (/),
|
984
|
+
but although that attribute is also provided in `site.posts` and `site.pages`,
|
985
|
+
those values do not start with a slash.
|
986
|
+
* Paths ending with a slash (`/`) imply that a file called `index.html` should be fetched.
|
987
|
+
* HTML redirect files created by the
|
988
|
+
[`jekyll-redirect-from`](https://github.com/jekyll/jekyll-redirect-from) Jekyll plugin,
|
989
|
+
which are included in `site.static_files`, should be ignored.
|
990
|
+
|
991
|
+
These inconsistencies mean that combining the standard three collections of files
|
992
|
+
provided as `site` attributes will create a new collection that is difficult
|
993
|
+
to process consistently:
|
994
|
+
|
995
|
+
```ruby
|
996
|
+
# This pseudocode creates `oops`, which is problematic to process consistently
|
997
|
+
oops = site.all_collections + site.pages + site.static_files
|
998
|
+
```
|
999
|
+
|
1000
|
+
`oops`, above, is difficult to process because of inconsistencies in the provided attributes
|
1001
|
+
and how the attributes are constructed.
|
1002
|
+
|
1003
|
+
|
1004
|
+
### Solving The Problem
|
1005
|
+
|
1006
|
+
The generator normalizes these inconsistencies by utilizing the `APage` class
|
1007
|
+
and filtering out HTML redirect files.
|
1008
|
+
|
1009
|
+
The `all_collections` collection contains `APage` representations of `site.collections`.
|
1010
|
+
|
1011
|
+
The `all_documents` collection contains `APage` representations of `site.pages`.
|
1012
|
+
|
1013
|
+
The `everything` collection contains `APage` representations of:
|
1014
|
+
|
1015
|
+
```text
|
1016
|
+
# Pseudocode
|
1017
|
+
site.collections + site.pages + site.static_files - HTML_redirect_files
|
1018
|
+
```
|
1019
|
+
|
1020
|
+
|
1021
|
+
## The `APage` Class
|
1022
|
+
|
1023
|
+
The `site.all_collections`, `site.all_documents` and `site.everything` attributes
|
1024
|
+
consist of arrays of [`APage`](lib/hooks/a_page.rb) instances.
|
1025
|
+
|
1026
|
+
The `APage` class has the following attributes:
|
1027
|
+
|
1028
|
+
* `content` (HTML or Markdown)
|
1029
|
+
* `collection_name`
|
1030
|
+
* `content` (HTML or Markdown)
|
1031
|
+
* `data` (array)
|
1032
|
+
* `date` (Ruby Date)
|
1033
|
+
* `description`
|
1034
|
+
* `destination`,
|
1035
|
+
* `draft` (Boolean)
|
1036
|
+
* `ext` / `extname`
|
1037
|
+
* `href` always starts with a slash.
|
1038
|
+
This value is consistent with a `href` values in website HTML.
|
1039
|
+
Paths ending with a slash (`/`) have `index.html` appended so the path specifies an actual file.
|
1040
|
+
* `label`
|
1041
|
+
* `last_modified` (Ruby Date)
|
1042
|
+
* `last_modified_field` indicates the name of the field that originally contained the value for
|
1043
|
+
`last_modified` (`last_modified` or `last_modified_at`)
|
1044
|
+
* `layout`
|
1045
|
+
* `logger` helpful for error handling
|
1046
|
+
* `name`
|
1047
|
+
* `origin` indicates the original source of the item.
|
1048
|
+
Possible values are `collection`, `individual_page` and `static_file`.
|
1049
|
+
Knowing the origin of each item allows code to process each type of item appropriately.
|
1050
|
+
* `path`
|
1051
|
+
* `relative_path`
|
1052
|
+
* `tags`
|
1053
|
+
* `title`
|
1054
|
+
* `type`
|
1055
|
+
* `url`
|
1056
|
+
|
1057
|
+
|
1058
|
+
## `all_collections` Block Tag
|
1059
|
+
|
1060
|
+
The `all_collections` block tag creates a formatted listing of Jekyll files.
|
1061
|
+
The ordering is configurable; by default, the listing is sorted by `date`, newest to oldest.
|
1062
|
+
The `all_collections` tag has a `data_source` parameter that specifies which new property to report on
|
1063
|
+
(`all_collections`, `all_documents`, or `everything`).
|
1064
|
+
|
1065
|
+
For an example of how to use this Jekyll tag in conjunction with the
|
1066
|
+
[jekyll_outline](http://localhost:4001/jekyll_plugins/jekyll_outline.html) tag,
|
1067
|
+
see the [outline_tabs](http://localhost:4001/jekyll_plugins/jekyll_outline.html#outline_tabs)
|
1068
|
+
section of the jekyll_outline documentation.
|
1069
|
+
|
1070
|
+
|
1071
|
+
## Requirements
|
1072
|
+
|
1073
|
+
All the pages in the Jekyll website must have an implicit date
|
1074
|
+
(for example, all posts are assigned this property by Jekyll),
|
1075
|
+
or an explicit `date` set in front matter, like this:
|
1076
|
+
|
1077
|
+
```html
|
1078
|
+
---
|
1079
|
+
date: 2022-01-01
|
1080
|
+
---
|
1081
|
+
```
|
1082
|
+
|
1083
|
+
If a front matter variable called `last_modified` or `last_modified_at` exists,
|
1084
|
+
its value will be converted to a Ruby `Date`:
|
1085
|
+
|
1086
|
+
```html
|
1087
|
+
---
|
1088
|
+
last_modified: 2023-01-01
|
1089
|
+
---
|
1090
|
+
```
|
1091
|
+
|
1092
|
+
Or:
|
1093
|
+
|
1094
|
+
```html
|
1095
|
+
---
|
1096
|
+
last_modified_at: 2023-01-01
|
1097
|
+
---
|
1098
|
+
```
|
1099
|
+
|
1100
|
+
Otherwise, if `last_modified` or `last_modified_at` is not present in the front matter for a page,
|
1101
|
+
the `date` value will be used last modified date value.
|
1102
|
+
|
1103
|
+
|
733
1104
|
## Development
|
734
1105
|
|
735
1106
|
After checking out the `jekyll_plugin_suppprt` repository, run `bin/setup` to install dependencies.
|
@@ -763,6 +1134,51 @@ jekyll_plugin_support (0.1.0)
|
|
763
1134
|
```
|
764
1135
|
|
765
1136
|
|
1137
|
+
### Build and Install Locally
|
1138
|
+
|
1139
|
+
To build and install this gem onto your local machine, run:
|
1140
|
+
|
1141
|
+
```shell
|
1142
|
+
$ bundle exec rake install
|
1143
|
+
jekyll_all_collections 0.3.8 built to pkg/jekyll_all_collections-0.3.8.gem.
|
1144
|
+
jekyll_all_collections (0.3.8) installed.
|
1145
|
+
```
|
1146
|
+
|
1147
|
+
Examine the newly built gem:
|
1148
|
+
|
1149
|
+
```shell
|
1150
|
+
$ gem info jekyll_all_collections
|
1151
|
+
|
1152
|
+
*** LOCAL GEMS ***
|
1153
|
+
|
1154
|
+
jekyll_all_collections (0.3.8)
|
1155
|
+
Author: Mike Slinn
|
1156
|
+
Homepage:
|
1157
|
+
https://www.mslinn.com/jekyll_plugins/jekyll_all_collections.html
|
1158
|
+
License: MIT
|
1159
|
+
Installed at (0.3.8): /home/mslinn/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0
|
1160
|
+
|
1161
|
+
Provides normalized collections and extra functionality for Jekyll websites.
|
1162
|
+
```
|
1163
|
+
|
1164
|
+
|
1165
|
+
### Build and Push to RubyGems
|
1166
|
+
|
1167
|
+
To release a new version:
|
1168
|
+
|
1169
|
+
1. Update the version number in `version.rb`.
|
1170
|
+
2. Add an entry in `CHANGELOG.md` describing the changes since the last release.
|
1171
|
+
3. Commit all changes to git; if you don't the next step might fail with a confusing error message.
|
1172
|
+
4. Run the following:
|
1173
|
+
|
1174
|
+
```shell
|
1175
|
+
$ bundle exec rake release
|
1176
|
+
```
|
1177
|
+
|
1178
|
+
The above creates a git tag for the version, commits the created tag,
|
1179
|
+
and pushes the new `.gem` file to [RubyGems.org](https://rubygems.org).
|
1180
|
+
|
1181
|
+
|
766
1182
|
### Pry Breakpoint On StandardError
|
767
1183
|
|
768
1184
|
A `pry` breakpoint will be set in the `StandardError` handler if `pry_on_standard_error: true`
|
@@ -776,6 +1192,60 @@ blah:
|
|
776
1192
|
```
|
777
1193
|
|
778
1194
|
|
1195
|
+
## Debugging
|
1196
|
+
|
1197
|
+
You can control the verbosity of log output by adding the following to `_config.yml` in your Jekyll project:
|
1198
|
+
|
1199
|
+
```yaml
|
1200
|
+
plugin_loggers:
|
1201
|
+
AllCollectionsTag::AllCollectionsTag: warn
|
1202
|
+
```
|
1203
|
+
|
1204
|
+
1. First set breakpoints in the Ruby code that interests you.
|
1205
|
+
|
1206
|
+
2. You have several options for initiating a debug session:
|
1207
|
+
|
1208
|
+
1. Use the **Debug Demo** Visual Studio Code launch configuration.
|
1209
|
+
|
1210
|
+
2. Type the `demo/_bin/debug` command, without the `-r` options shown above.
|
1211
|
+
|
1212
|
+
```console
|
1213
|
+
... lots of output as bundle update runs...
|
1214
|
+
Bundle updated!
|
1215
|
+
|
1216
|
+
INFO PluginMetaLogger: Loaded AllCollectionsHooks v0.2.0 :site, :pre_render, :normal hook plugin.
|
1217
|
+
INFO PluginMetaLogger: Loaded DraftFilter plugin.
|
1218
|
+
INFO PluginMetaLogger: Loaded all_collections v0.2.0 tag plugin.
|
1219
|
+
Configuration file: /mnt/_/work/jekyll/my_plugins/jekyll_all_collections/demo/_config.yml
|
1220
|
+
Cleaner: Removing /mnt/_/work/jekyll/my_plugins/jekyll_all_collections/demo/_site...
|
1221
|
+
Cleaner: Removing /mnt/_/work/jekyll/my_plugins/jekyll_all_collections/demo/.jekyll-metadata...
|
1222
|
+
Cleaner: Removing /mnt/_/work/jekyll/my_plugins/jekyll_all_collections/demo/.jekyll-cache...
|
1223
|
+
Cleaner: Nothing to do for .sass-cache.
|
1224
|
+
Fast Debugger (ruby-debug-ide 0.7.3, debase 0.2.5.beta2, file filtering is supported) listens on 0.0.0.0:1234
|
1225
|
+
```
|
1226
|
+
|
1227
|
+
3. Run `bin/attach` and pass the directory name of a Jekyll website that has a suitable script called `_bin/debug`.
|
1228
|
+
The `demo` subdirectory fits this description.
|
1229
|
+
|
1230
|
+
```console
|
1231
|
+
$ bin/attach demo
|
1232
|
+
Successfully uninstalled jekyll_all_collections-0.1.2
|
1233
|
+
jekyll_all_collections 0.1.2 built to pkg/jekyll_all_collections-0.1.2.gem.
|
1234
|
+
jekyll_all_collections (0.1.2) installed.
|
1235
|
+
Fast Debugger (ruby-debug-ide 0.7.3, debase 0.2.4.1, file filtering is supported) listens on 0.0.0.0:1234
|
1236
|
+
```
|
1237
|
+
|
1238
|
+
|
1239
|
+
3. Attach to the debugger process if required.
|
1240
|
+
This git repo includes two [Visual Studio Code launch configurations](./.vscode/launch.json) for this purpose labeled
|
1241
|
+
**Attach rdbg** and **Attach with ruby_lsp**.
|
1242
|
+
|
1243
|
+
4. Point your web browser to http://localhost:4444
|
1244
|
+
|
1245
|
+
If a debugging session terminates abruptly and leaves ports tied up,
|
1246
|
+
run the `demo/_bin/release_port` script.
|
1247
|
+
|
1248
|
+
|
779
1249
|
## Demonstration Plugins and Website
|
780
1250
|
|
781
1251
|
A demo / test website is provided in the [`demo`](demo) directory.
|
@@ -29,9 +29,11 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.test_files = spec.files.grep %r{^(test|spec|features)/}
|
30
30
|
spec.version = JekyllPluginSupportVersion::VERSION
|
31
31
|
|
32
|
+
spec.add_dependency 'bigdecimal'
|
32
33
|
spec.add_dependency 'facets'
|
33
|
-
spec.add_dependency 'jekyll', '>=
|
34
|
+
spec.add_dependency 'jekyll', '>= 4.4.1'
|
34
35
|
spec.add_dependency 'jekyll_plugin_logger'
|
35
36
|
spec.add_dependency 'key-value-parser'
|
36
37
|
spec.add_dependency 'pry'
|
38
|
+
spec.add_dependency 'sorted_set'
|
37
39
|
end
|