jekyll_plugin_support 1.1.0 → 3.0.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 +17 -1
- data/CHANGELOG.md +17 -6
- data/README.md +430 -2
- data/jekyll_plugin_support.gemspec +2 -1
- data/lib/block/jekyll_plugin_support_block.rb +2 -4
- data/lib/block/jekyll_plugin_support_block_noarg.rb +0 -2
- 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 +69 -0
- data/lib/hooks/all_collections_hooks.rb +61 -0
- data/lib/hooks/all_files.rb +48 -0
- data/lib/hooks/class_methods.rb +50 -0
- data/lib/jekyll_all_collections/all_collections_tag.rb +157 -0
- data/lib/jekyll_plugin_support/jekyll_plugin_support_class.rb +3 -5
- 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 +17 -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 +112 -0
- data/spec/bsearch_spec.rb +50 -0
- data/spec/custom_error_spec.rb +9 -9
- data/spec/date_sort_spec.rb +84 -0
- data/spec/jekyll_plugin_helper_options_spec.rb +7 -3
- data/spec/liquid_variable_parsing_spec.rb +6 -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 +2 -0
- data/spec/status_persistence.txt +3 -9
- data/spec/testable_spec.rb +38 -0
- metadata +45 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 74f595dc019d923dbbad9e84b1eacdaa15808b36d54fc692044e30f26e0767f1
|
4
|
+
data.tar.gz: 5632b03e8d9d29080ae0c43428d5c9a13243c4df529255013d63951d669a670d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5839393146e5d1ab2317f004a563bad4144467e506fd41516f489b065fa52d00bfcea4eedc7d8d06028afd35cba34b3360b19f4d968ec6a456e429f6a2af542
|
7
|
+
data.tar.gz: 203f6111c4127b4909534d4dcc6b7dcb7f3f5d7bbf9fa60016920558a6eb9faed7cd736212b8c3f25cb52514e21b75035dd00ea55928525127b9ca662ede224d
|
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,12 +45,20 @@ 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
|
+
|
40
52
|
Metrics/CyclomaticComplexity:
|
41
53
|
Max: 25
|
42
54
|
|
43
55
|
Metrics/MethodLength:
|
44
56
|
Max: 50
|
45
57
|
|
58
|
+
Metrics/ModuleLength:
|
59
|
+
Exclude:
|
60
|
+
- "**/jekyll_plugin_support_class.rb"
|
61
|
+
|
46
62
|
Metrics/PerceivedComplexity:
|
47
63
|
Max: 25
|
48
64
|
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 3.0.0 / 2025-02-09
|
4
|
+
|
5
|
+
* Numbered as v3.0.0 because `jekyll_draft` was at v2.1.0 and the two projects should have similar version numbers.
|
6
|
+
* `Jekyll_all_collections` was folded into this project.
|
7
|
+
* Now requires [Jekyll 4.4.1](https://jekyllrb.com/news/2025/01/29/jekyll-4-4-1-released/) or later,
|
8
|
+
and Ruby 3.2.0 or later
|
9
|
+
|
10
|
+
|
3
11
|
## 1.1.0 / 2025-02-07
|
4
12
|
|
5
13
|
* Now replaces include and layout variables with their values
|
@@ -30,12 +38,15 @@
|
|
30
38
|
The following seems to be optimal for custom plugins; it suppresses the ridiculously long stack trace that used to be generated:
|
31
39
|
|
32
40
|
```ruby
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
41
|
+
begin
|
42
|
+
# ...
|
43
|
+
rescue DemoInlineTagError => e # jekyll_plugin_support handles StandardError
|
44
|
+
@logger.error { e.logger_message }
|
45
|
+
exit! 1 if @die_on_demo_tag_error
|
46
|
+
|
47
|
+
e.html_message
|
48
|
+
end
|
49
|
+
```
|
39
50
|
|
40
51
|
|
41
52
|
## 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,17 @@ 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.
|
57
67
|
|
58
68
|
## Installation
|
59
69
|
|
@@ -105,6 +115,9 @@ to your Jekyll project’s CSS file.
|
|
105
115
|
|
106
116
|
## About `jekyll_plugin_support`
|
107
117
|
|
118
|
+
This Jekyll plugin includes a generator,
|
119
|
+
triggered by a high-priority hook, and a block tag called `all_collections`.
|
120
|
+
|
108
121
|
`JekyllSupport::JekyllBlock` and `JekyllSupport::JekyllTag`
|
109
122
|
provide support for [Jekyll tag block plugins](https://jekyllrb.com/docs/plugins/tags/#tag-blocks)
|
110
123
|
and [Jekyll inline tag plugins](https://jekyllrb.com/docs/plugins/tags/), respectively.
|
@@ -175,6 +188,195 @@ For inline tags, `render_impl` does not accept any parameters.
|
|
175
188
|
For block tags, a single parameter is required, which receives any text enclosed within your block by the website author.
|
176
189
|
|
177
190
|
|
191
|
+
### New `Site` Attributes
|
192
|
+
|
193
|
+
No explicit initialization or setup is required.
|
194
|
+
Jekyll plugins can access the value of
|
195
|
+
`site.all_collections`, `site.all_documents` and `site.everything`;
|
196
|
+
however, Liquid code in Jekyll pages and documents cannot.
|
197
|
+
|
198
|
+
|
199
|
+
### Excluding Files
|
200
|
+
|
201
|
+
There are two ways to exclude files from the new `site` attributes.
|
202
|
+
|
203
|
+
1) The [`exclude` entry in `_config.yml`](https://jekyllrb.com/docs/configuration/options#global-configuration)
|
204
|
+
can be used as it normally would.
|
205
|
+
|
206
|
+
2) Adding the following entry to a page’s front matter causes that page to be excluded
|
207
|
+
from the collection created by this plugin:
|
208
|
+
|
209
|
+
```html
|
210
|
+
---
|
211
|
+
exclude_from_all: true
|
212
|
+
---
|
213
|
+
```
|
214
|
+
|
215
|
+
### `all_collections` Plugin Usage
|
216
|
+
|
217
|
+
Jekyll generators and tags receive an enhanced version of the `site` Jekyll variable.
|
218
|
+
|
219
|
+
|
220
|
+
#### From a Custom Plugin
|
221
|
+
|
222
|
+
In the following example of how to use the `all_collections` plugin in a custom plugin,
|
223
|
+
the `do_something_with` function processes all `Jekyll::Page`s, `Jekyll:Document`s, and static files.
|
224
|
+
|
225
|
+
```ruby
|
226
|
+
@site.everything.each do |apage|
|
227
|
+
do_something_with apage
|
228
|
+
end
|
229
|
+
```
|
230
|
+
|
231
|
+
|
232
|
+
#### Using the Block Tag
|
233
|
+
|
234
|
+
The general form of the Jekyll tag, including all options, is:
|
235
|
+
|
236
|
+
```html
|
237
|
+
{% all_collections
|
238
|
+
date_column='date|last_modified'
|
239
|
+
heading='All Posts'
|
240
|
+
id='asdf'
|
241
|
+
sort_by='SORT_KEYS'
|
242
|
+
%}
|
243
|
+
```
|
244
|
+
|
245
|
+
|
246
|
+
##### `date_column` Attribute
|
247
|
+
|
248
|
+
One of two date columns can be displayed in the generated HTML:
|
249
|
+
either `date` (when the article was originally written),
|
250
|
+
or `last_modified`.
|
251
|
+
The default value for the `date_column` attribute is `date`.
|
252
|
+
|
253
|
+
|
254
|
+
##### `heading` Attribute
|
255
|
+
|
256
|
+
If no `heading` attribute is specified, a heading will automatically be generated, which contains the `sort_by` values,
|
257
|
+
for example:
|
258
|
+
|
259
|
+
```html
|
260
|
+
{% all_collections id='abcdef' sort_by="last_modified" %}
|
261
|
+
```
|
262
|
+
|
263
|
+
The above generates a heading like:
|
264
|
+
|
265
|
+
```html
|
266
|
+
<h2 id="abcdef">All Posts Sorted By last_modified</h2>
|
267
|
+
```
|
268
|
+
|
269
|
+
To suppress both a `h2` heading (and the enclosed `id`) from being generated,
|
270
|
+
specify an empty string for the value of `heading`:
|
271
|
+
|
272
|
+
```html
|
273
|
+
{% all_collections heading='' %}
|
274
|
+
```
|
275
|
+
|
276
|
+
|
277
|
+
##### `id` Attribute
|
278
|
+
|
279
|
+
If your Jekyll layout employs [`jekyll-toc`](https://github.com/allejo/jekyll-toc), then `id` attributes are important.
|
280
|
+
The `jekyll-toc` include checks for `id` attributes in `h2` ... `h6` tags, and if found,
|
281
|
+
and if the attribute value is enclosed in double quotes
|
282
|
+
(`id="my_id"`, not single quotes like `id='my_id'`),
|
283
|
+
then the heading is included in the table of contents.
|
284
|
+
|
285
|
+
To suppress an `id` from being generated,
|
286
|
+
and thereby preventing the heading from appearing in the automatically generated table of contents from `jekyll-toc`,
|
287
|
+
specify an empty string for the value of `id`, like this:
|
288
|
+
|
289
|
+
```html
|
290
|
+
{% all_collections id='' %}
|
291
|
+
```
|
292
|
+
|
293
|
+
|
294
|
+
##### `SORT_KEYS` Values
|
295
|
+
|
296
|
+
`SORT_KEYS` specifies how to sort the collection.
|
297
|
+
Values can include one or more of the following attributes:
|
298
|
+
`date`, `destination`, `draft`, `label`, `last_modified`, `last_modified_at`, `path`, `relative_path`,
|
299
|
+
`title`, `type`, and `url`.
|
300
|
+
Ascending sorts are the default; however, a descending sort can be achieved by prepending `-` before an attribute.
|
301
|
+
|
302
|
+
To specify more than one sort key, provide a comma-delimited string of values.
|
303
|
+
Included spaces are ignored.
|
304
|
+
For example, specify the primary sort key as `draft`,
|
305
|
+
the secondary sort key as `last_modified`,
|
306
|
+
and the tertiary key as `label`:
|
307
|
+
|
308
|
+
```html
|
309
|
+
{% all_collections
|
310
|
+
date_column='last_modified'
|
311
|
+
heading='All Posts'
|
312
|
+
id='asdf'
|
313
|
+
sort_by='draft, last_modified, label'
|
314
|
+
%}
|
315
|
+
```
|
316
|
+
|
317
|
+
|
318
|
+
#### Liquid Usage Examples
|
319
|
+
|
320
|
+
Here is a short Jekyll page, including front matter,
|
321
|
+
demonstrating this plugin being invoked with all default attribute values:
|
322
|
+
|
323
|
+
```html
|
324
|
+
---
|
325
|
+
description: "
|
326
|
+
Dump of all collections, sorted by date originally written, newest to oldest.
|
327
|
+
The heading text will be <code>All Posts Sorted By -date</code>
|
328
|
+
"
|
329
|
+
layout: default
|
330
|
+
title: Testing, 1, 2, 3
|
331
|
+
---
|
332
|
+
{% all_collections %}
|
333
|
+
```
|
334
|
+
|
335
|
+
Following are examples of how to specify the sort parameters.
|
336
|
+
|
337
|
+
**Explicitly express the default sort**<br>
|
338
|
+
(sort by the date originally written, newest to oldest):
|
339
|
+
|
340
|
+
```html
|
341
|
+
{% all_collections sort_by="-date" %}
|
342
|
+
```
|
343
|
+
|
344
|
+
Sort by date, from oldest to newest:
|
345
|
+
|
346
|
+
```html
|
347
|
+
{% all_collections sort_by="date" %}
|
348
|
+
```
|
349
|
+
|
350
|
+
**Sort by the date last modified, oldest to newest:**
|
351
|
+
|
352
|
+
```html
|
353
|
+
{% all_collections sort_by="last_modified" %}
|
354
|
+
```
|
355
|
+
|
356
|
+
**Sort by the date last modified, newest to oldest:**
|
357
|
+
|
358
|
+
```html
|
359
|
+
{% all_collections sort_by="-last_modified" %}
|
360
|
+
```
|
361
|
+
|
362
|
+
**Several attributes can be specified as sort criteria**<br>
|
363
|
+
by passing them as a comma-delimited string.
|
364
|
+
Included spaces are ignored:
|
365
|
+
|
366
|
+
```html
|
367
|
+
{% all_collections sort_by="-last_modified, -date" %}
|
368
|
+
{% all_collections sort_by="-last_modified, title" %}
|
369
|
+
{% all_collections sort_by="-last_modified, -date, title" %}
|
370
|
+
```
|
371
|
+
|
372
|
+
**The following two examples produce the same output:**
|
373
|
+
|
374
|
+
```html
|
375
|
+
{% all_collections sort_by="-last_modified,-date" %}
|
376
|
+
{% all_collections sort_by="-last_modified, -date" %}
|
377
|
+
```
|
378
|
+
|
379
|
+
|
178
380
|
## Predefined Plugin Variables
|
179
381
|
|
180
382
|
`Jekyll_plugin_support` defines the following Ruby variables that you can use in your plugin’s `render_impl` method:
|
@@ -730,6 +932,133 @@ redef_without_warning :VERSION, '0.1.0'.freeze
|
|
730
932
|
```
|
731
933
|
|
732
934
|
|
935
|
+
## Generator
|
936
|
+
|
937
|
+
This plugin incorporates a generator, which adds four new attributes to
|
938
|
+
[`site`](https://jekyllrb.com/docs/variables/#site-variables):
|
939
|
+
`all_collections`, `all_documents`, `everything`, and `sorted_lru_files`.
|
940
|
+
|
941
|
+
These three attributes can be referenced as `site.everything`, `site.all_collections`
|
942
|
+
and `site.all_documents`.
|
943
|
+
|
944
|
+
* `all_collections` includes all documents in all collections.
|
945
|
+
|
946
|
+
* `all_documents` includes `all_collections` plus all standalone pages.
|
947
|
+
|
948
|
+
* `everything` includes `all_documents` plus all static files.
|
949
|
+
|
950
|
+
* `sorted_lru_files` is used by a new binary search lookup for matching page suffixes.
|
951
|
+
Currently only `jekyll_href` and `jekyll_draft` use this feature.
|
952
|
+
|
953
|
+
|
954
|
+
### Collection Management
|
955
|
+
|
956
|
+
Jekyll provides inconsistent attributes for
|
957
|
+
[`site.pages`](https://jekyllrb.com/docs/pages/),
|
958
|
+
[`site.posts`](https://jekyllrb.com/docs/posts/) and
|
959
|
+
[`site.static_files`](https://jekyllrb.com/docs/static-files/).
|
960
|
+
|
961
|
+
|
962
|
+
* While the `url` attributes of items in `site.posts` and `site.pages` start with a slash (/),
|
963
|
+
`site.static_files` items do not have a `url` attribute.
|
964
|
+
* Static files have a `relative_path` attribute, which starts with a slash (/),
|
965
|
+
but although that attribute is also provided in `site.posts` and `site.pages`,
|
966
|
+
those values do not start with a slash.
|
967
|
+
* Paths ending with a slash (`/`) imply that a file called `index.html` should be fetched.
|
968
|
+
* HTML redirect files created by the
|
969
|
+
[`jekyll-redirect-from`](https://github.com/jekyll/jekyll-redirect-from) Jekyll plugin,
|
970
|
+
which are included in `site.static_files`, should be ignored.
|
971
|
+
|
972
|
+
These inconsistencies mean that combining the standard three collections of files
|
973
|
+
provided as `site` attributes will create a new collection that is difficult
|
974
|
+
to process consistently:
|
975
|
+
|
976
|
+
```ruby
|
977
|
+
# This pseudocode creates `oops`, which is problematic to process consistently
|
978
|
+
oops = site.all_collections + site.pages + site.static_files
|
979
|
+
```
|
980
|
+
|
981
|
+
`oops`, above, is difficult to process because of inconsistencies in the provided attributes
|
982
|
+
and how the attributes are constructed.
|
983
|
+
|
984
|
+
|
985
|
+
### Solving The Problem
|
986
|
+
|
987
|
+
The generator normalizes these inconsistencies by utilizing the `APage` class
|
988
|
+
and filtering out HTML redirect files.
|
989
|
+
|
990
|
+
The `all_collections` collection contains `APage` representations of `site.collections`.
|
991
|
+
|
992
|
+
The `all_documents` collection contains `APage` representations of `site.pages`.
|
993
|
+
|
994
|
+
The `everything` collection contains `APage` representations of:
|
995
|
+
|
996
|
+
```text
|
997
|
+
# Pseudocode
|
998
|
+
site.collections + site.pages + site.static_files - HTML_redirect_files
|
999
|
+
```
|
1000
|
+
|
1001
|
+
|
1002
|
+
## The `APage` Class
|
1003
|
+
|
1004
|
+
The `site.all_collections`, `site.all_documents` and `site.everything` attributes
|
1005
|
+
consist of arrays of [`APage`](lib/hooks/a_page.rb) instances.
|
1006
|
+
|
1007
|
+
The `APage` class has the following attributes:
|
1008
|
+
`content` (HTML or Markdown), `data` (array), `date` (Ruby Date), `description`, `destination`,
|
1009
|
+
`draft` (Boolean), `ext`, `href`, `label`, `last_modified` or `last_modified_at` (Ruby Date),
|
1010
|
+
`layout`, `origin`, `path`, `relative_path`, `tags`, `title`, `type`, and `url`.
|
1011
|
+
|
1012
|
+
* `href` always starts with a slash.
|
1013
|
+
This value is consistent with `a href` values in website HTML.
|
1014
|
+
Paths ending with a slash (`/`) have `index.html` appended so the path specifies an actual file.
|
1015
|
+
|
1016
|
+
* `origin` indicates the original source of the item.
|
1017
|
+
Possible values are `collection`, `individual_page` and `static_file`.
|
1018
|
+
Knowing the origin of each item allows code to process each type of item appropriately.
|
1019
|
+
|
1020
|
+
|
1021
|
+
## `all_collections` Block Tag
|
1022
|
+
|
1023
|
+
The `all_collections` block tag creates a formatted listing of Jekyll files.
|
1024
|
+
The ordering is configurable; by default, the listing is sorted by `date`, newest to oldest.
|
1025
|
+
The `all_collections` tag has a `data_source` parameter that specifies which new property to report on
|
1026
|
+
(`all_collections`, `all_documents`, or `everything`).
|
1027
|
+
|
1028
|
+
|
1029
|
+
## Requirements
|
1030
|
+
|
1031
|
+
All the pages in the Jekyll website must have an implicit date
|
1032
|
+
(for example, all posts are assigned this property by Jekyll),
|
1033
|
+
or an explicit `date` set in front matter, like this:
|
1034
|
+
|
1035
|
+
```html
|
1036
|
+
---
|
1037
|
+
date: 2022-01-01
|
1038
|
+
---
|
1039
|
+
```
|
1040
|
+
|
1041
|
+
If a front matter variable called `last_modified` or `last_modified_at` exists,
|
1042
|
+
its value will be converted to a Ruby `Date`:
|
1043
|
+
|
1044
|
+
```html
|
1045
|
+
---
|
1046
|
+
last_modified: 2023-01-01
|
1047
|
+
---
|
1048
|
+
```
|
1049
|
+
|
1050
|
+
Or:
|
1051
|
+
|
1052
|
+
```html
|
1053
|
+
---
|
1054
|
+
last_modified_at: 2023-01-01
|
1055
|
+
---
|
1056
|
+
```
|
1057
|
+
|
1058
|
+
Otherwise, if `last_modified` or `last_modified_at` is not present in the front matter for a page,
|
1059
|
+
the `date` value will be used last modified date value.
|
1060
|
+
|
1061
|
+
|
733
1062
|
## Development
|
734
1063
|
|
735
1064
|
After checking out the `jekyll_plugin_suppprt` repository, run `bin/setup` to install dependencies.
|
@@ -763,6 +1092,51 @@ jekyll_plugin_support (0.1.0)
|
|
763
1092
|
```
|
764
1093
|
|
765
1094
|
|
1095
|
+
### Build and Install Locally
|
1096
|
+
|
1097
|
+
To build and install this gem onto your local machine, run:
|
1098
|
+
|
1099
|
+
```shell
|
1100
|
+
$ bundle exec rake install
|
1101
|
+
jekyll_all_collections 0.3.8 built to pkg/jekyll_all_collections-0.3.8.gem.
|
1102
|
+
jekyll_all_collections (0.3.8) installed.
|
1103
|
+
```
|
1104
|
+
|
1105
|
+
Examine the newly built gem:
|
1106
|
+
|
1107
|
+
```shell
|
1108
|
+
$ gem info jekyll_all_collections
|
1109
|
+
|
1110
|
+
*** LOCAL GEMS ***
|
1111
|
+
|
1112
|
+
jekyll_all_collections (0.3.8)
|
1113
|
+
Author: Mike Slinn
|
1114
|
+
Homepage:
|
1115
|
+
https://www.mslinn.com/jekyll_plugins/jekyll_all_collections.html
|
1116
|
+
License: MIT
|
1117
|
+
Installed at (0.3.8): /home/mslinn/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0
|
1118
|
+
|
1119
|
+
Provides normalized collections and extra functionality for Jekyll websites.
|
1120
|
+
```
|
1121
|
+
|
1122
|
+
|
1123
|
+
### Build and Push to RubyGems
|
1124
|
+
|
1125
|
+
To release a new version:
|
1126
|
+
|
1127
|
+
1. Update the version number in `version.rb`.
|
1128
|
+
2. Add an entry in `CHANGELOG.md` describing the changes since the last release.
|
1129
|
+
3. Commit all changes to git; if you don't the next step might fail with a confusing error message.
|
1130
|
+
4. Run the following:
|
1131
|
+
|
1132
|
+
```shell
|
1133
|
+
$ bundle exec rake release
|
1134
|
+
```
|
1135
|
+
|
1136
|
+
The above creates a git tag for the version, commits the created tag,
|
1137
|
+
and pushes the new `.gem` file to [RubyGems.org](https://rubygems.org).
|
1138
|
+
|
1139
|
+
|
766
1140
|
### Pry Breakpoint On StandardError
|
767
1141
|
|
768
1142
|
A `pry` breakpoint will be set in the `StandardError` handler if `pry_on_standard_error: true`
|
@@ -776,6 +1150,60 @@ blah:
|
|
776
1150
|
```
|
777
1151
|
|
778
1152
|
|
1153
|
+
## Debugging
|
1154
|
+
|
1155
|
+
You can control the verbosity of log output by adding the following to `_config.yml` in your Jekyll project:
|
1156
|
+
|
1157
|
+
```yaml
|
1158
|
+
plugin_loggers:
|
1159
|
+
AllCollectionsTag::AllCollectionsTag: warn
|
1160
|
+
```
|
1161
|
+
|
1162
|
+
1. First set breakpoints in the Ruby code that interests you.
|
1163
|
+
|
1164
|
+
2. You have several options for initiating a debug session:
|
1165
|
+
|
1166
|
+
1. Use the **Debug Demo** Visual Studio Code launch configuration.
|
1167
|
+
|
1168
|
+
2. Type the `demo/_bin/debug` command, without the `-r` options shown above.
|
1169
|
+
|
1170
|
+
```console
|
1171
|
+
... lots of output as bundle update runs...
|
1172
|
+
Bundle updated!
|
1173
|
+
|
1174
|
+
INFO PluginMetaLogger: Loaded AllCollectionsHooks v0.2.0 :site, :pre_render, :normal hook plugin.
|
1175
|
+
INFO PluginMetaLogger: Loaded DraftFilter plugin.
|
1176
|
+
INFO PluginMetaLogger: Loaded all_collections v0.2.0 tag plugin.
|
1177
|
+
Configuration file: /mnt/_/work/jekyll/my_plugins/jekyll_all_collections/demo/_config.yml
|
1178
|
+
Cleaner: Removing /mnt/_/work/jekyll/my_plugins/jekyll_all_collections/demo/_site...
|
1179
|
+
Cleaner: Removing /mnt/_/work/jekyll/my_plugins/jekyll_all_collections/demo/.jekyll-metadata...
|
1180
|
+
Cleaner: Removing /mnt/_/work/jekyll/my_plugins/jekyll_all_collections/demo/.jekyll-cache...
|
1181
|
+
Cleaner: Nothing to do for .sass-cache.
|
1182
|
+
Fast Debugger (ruby-debug-ide 0.7.3, debase 0.2.5.beta2, file filtering is supported) listens on 0.0.0.0:1234
|
1183
|
+
```
|
1184
|
+
|
1185
|
+
3. Run `bin/attach` and pass the directory name of a Jekyll website that has a suitable script called `_bin/debug`.
|
1186
|
+
The `demo` subdirectory fits this description.
|
1187
|
+
|
1188
|
+
```console
|
1189
|
+
$ bin/attach demo
|
1190
|
+
Successfully uninstalled jekyll_all_collections-0.1.2
|
1191
|
+
jekyll_all_collections 0.1.2 built to pkg/jekyll_all_collections-0.1.2.gem.
|
1192
|
+
jekyll_all_collections (0.1.2) installed.
|
1193
|
+
Fast Debugger (ruby-debug-ide 0.7.3, debase 0.2.4.1, file filtering is supported) listens on 0.0.0.0:1234
|
1194
|
+
```
|
1195
|
+
|
1196
|
+
|
1197
|
+
3. Attach to the debugger process if required.
|
1198
|
+
This git repo includes two [Visual Studio Code launch configurations](./.vscode/launch.json) for this purpose labeled
|
1199
|
+
**Attach rdbg** and **Attach with ruby_lsp**.
|
1200
|
+
|
1201
|
+
4. Point your web browser to http://localhost:4444
|
1202
|
+
|
1203
|
+
If a debugging session terminates abruptly and leaves ports tied up,
|
1204
|
+
run the `demo/_bin/release_port` script.
|
1205
|
+
|
1206
|
+
|
779
1207
|
## Demonstration Plugins and Website
|
780
1208
|
|
781
1209
|
A demo / test website is provided in the [`demo`](demo) directory.
|
@@ -30,8 +30,9 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.version = JekyllPluginSupportVersion::VERSION
|
31
31
|
|
32
32
|
spec.add_dependency 'facets'
|
33
|
-
spec.add_dependency 'jekyll', '>=
|
33
|
+
spec.add_dependency 'jekyll', '>= 4.4.1'
|
34
34
|
spec.add_dependency 'jekyll_plugin_logger'
|
35
35
|
spec.add_dependency 'key-value-parser'
|
36
36
|
spec.add_dependency 'pry'
|
37
|
+
spec.add_dependency 'sorted_set'
|
37
38
|
end
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require_relative '../error/jekyll_plugin_error_handling'
|
2
|
-
|
3
1
|
module JekyllSupport
|
4
2
|
# Base class for Jekyll block tags
|
5
3
|
class JekyllBlock < Liquid::Block
|
@@ -35,7 +33,7 @@ module JekyllSupport
|
|
35
33
|
@helper = JekyllPluginHelper.new tag_name, markup, @logger, respond_to?(:no_arg_parsing)
|
36
34
|
|
37
35
|
@error_name = "#{tag_name.camelcase(:upper)}Error"
|
38
|
-
JekyllSupport::CustomError.factory @error_name
|
36
|
+
::JekyllSupport::CustomError.factory @error_name
|
39
37
|
end
|
40
38
|
|
41
39
|
# Liquid::Block subclasses do not render if there is no content within the tag
|
@@ -48,7 +46,7 @@ module JekyllSupport
|
|
48
46
|
# Defines @config, @envs, @mode, @page and @site
|
49
47
|
# @return [String]
|
50
48
|
def render(liquid_context)
|
51
|
-
@helper.liquid_context = JekyllSupport.inject_config_vars liquid_context # modifies liquid_context
|
49
|
+
@helper.liquid_context = ::JekyllSupport.inject_config_vars liquid_context # modifies liquid_context
|
52
50
|
text = super # Liquid variable values in content are looked up and substituted
|
53
51
|
|
54
52
|
@envs = liquid_context.environments.first
|
@@ -1,6 +1,3 @@
|
|
1
|
-
require 'jekyll'
|
2
|
-
require_relative '../error/jekyll_plugin_error_handling'
|
3
|
-
|
4
1
|
module JekyllSupport
|
5
2
|
# Base class for Jekyll generators.
|
6
3
|
# PluginMetaLogger.instance.config is populated with the contents of `_config.yml` before Jekyll::Generator instances run.
|
@@ -14,7 +11,6 @@ module JekyllSupport
|
|
14
11
|
@logger ||= PluginMetaLogger.instance.new_logger(self, PluginMetaLogger.instance.config)
|
15
12
|
|
16
13
|
@error_name = "#{self.class.name}Error"
|
17
|
-
# JekyllSupport::CustomError.factory @error_name
|
18
14
|
|
19
15
|
@site = site
|
20
16
|
@config = @site.config
|
@@ -23,8 +19,6 @@ module JekyllSupport
|
|
23
19
|
|
24
20
|
@mode = ENV['JEKYLL_ENV'] || 'development'
|
25
21
|
|
26
|
-
# set_error_context(self.class)
|
27
|
-
|
28
22
|
generate_impl
|
29
23
|
rescue StandardError => e
|
30
24
|
e.shorten_backtrace
|
@@ -62,7 +56,7 @@ module JekyllSupport
|
|
62
56
|
PluginMetaLogger.instance.info { msg }
|
63
57
|
end
|
64
58
|
|
65
|
-
def set_error_context(klass)
|
59
|
+
def set_error_context(klass) # rubocop:disable Naming/AccessorMethodName
|
66
60
|
return unless Object.const_defined? @error_name
|
67
61
|
|
68
62
|
error_class = Object.const_get @error_name
|
@@ -1,14 +1,13 @@
|
|
1
1
|
require 'facets/string/interpolate'
|
2
2
|
require 'key_value_parser'
|
3
3
|
require 'shellwords'
|
4
|
-
require_relative 'jekyll_plugin_helper_class'
|
5
|
-
require_relative 'jekyll_plugin_helper_attribution'
|
6
4
|
|
7
5
|
module JekyllSupport
|
8
6
|
class JekyllPluginHelper
|
9
7
|
attr_accessor :liquid_context
|
10
|
-
attr_reader :
|
11
|
-
:
|
8
|
+
attr_reader :argument_string, :argv, :argv_original, :attribution, :excerpt_caller, :keys_values_original,
|
9
|
+
:keys_values, :jpsh_subclass_caller, :logger, :markup, :no_arg_parsing, :params, :params_original,
|
10
|
+
:tag_name
|
12
11
|
|
13
12
|
# See https://github.com/Shopify/liquid/wiki/Liquid-for-Programmers#create-your-own-tags
|
14
13
|
# @param tag_name [String] the name of the tag, which we already know.
|
@@ -22,8 +21,9 @@ module JekyllSupport
|
|
22
21
|
def initialize(tag_name, markup, logger, no_arg_parsing)
|
23
22
|
@tag_name = tag_name
|
24
23
|
@logger = logger
|
25
|
-
@
|
24
|
+
@markup = markup
|
26
25
|
@argument_string = markup
|
26
|
+
@no_arg_parsing = no_arg_parsing
|
27
27
|
rescue StandardError => e
|
28
28
|
e.shorten_backtrace
|
29
29
|
@logger.error { e.message }
|
@@ -66,8 +66,8 @@ module JekyllSupport
|
|
66
66
|
|
67
67
|
abort("Error: The #{tag_name} plugin is not an instance of JekyllSupport::JekyllBlock or JekyllSupport::JekyllTag") \
|
68
68
|
unless klass.instance_of?(Class) &&
|
69
|
-
(klass.ancestors.include?(JekyllSupport::JekyllBlock) ||
|
70
|
-
klass.ancestors.include?(JekyllSupport::JekyllTag))
|
69
|
+
(klass.ancestors.include?(::JekyllSupport::JekyllBlock) ||
|
70
|
+
klass.ancestors.include?(::JekyllSupport::JekyllTag))
|
71
71
|
|
72
72
|
Liquid::Template.register_tag(tag_name, klass)
|
73
73
|
return if quiet
|