jekyll_outline 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +14 -2
- data/CHANGELOG.md +6 -0
- data/README.md +82 -27
- data/jekyll_outline.gemspec +2 -2
- data/lib/jekyll_outline/version.rb +1 -1
- data/lib/outline_tag.rb +64 -25
- data/spec/status_persistence.txt +3 -0
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f19cd3e8a114d272e1a25858375c4f9cae27be24c8c7df0794340efc43311cf4
|
4
|
+
data.tar.gz: 2c9502f7e10ed8bcdf992b4f7761a597c16d154c4f7889b130ee72d4197ee9ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd40905342095e621420f8255ab6b59e935559d2b7c744ac6c474dd47c993eaf3a4cd79ac3c0a2983977690485b5feb108aff6b2f222ac6a9ad26523cde88790
|
7
|
+
data.tar.gz: 4dde939dffacc17793cb972adec4bf4efaf17fff24251592e517efcb6f8f68823322ade76df90dd55aa29e50d15fa673afc9e13e623a2adf088181d6d263c32b
|
data/.rubocop.yml
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
require:
|
2
|
-
- rubocop-
|
2
|
+
- rubocop-md
|
3
|
+
- rubocop-performance
|
3
4
|
- rubocop-rake
|
5
|
+
- rubocop-rspec
|
4
6
|
|
5
7
|
AllCops:
|
6
8
|
Exclude:
|
@@ -17,19 +19,29 @@ Gemspec/RequireMFA:
|
|
17
19
|
Enabled: false
|
18
20
|
|
19
21
|
Layout/HashAlignment:
|
20
|
-
|
22
|
+
EnforcedColonStyle: table
|
23
|
+
EnforcedHashRocketStyle: table
|
21
24
|
|
22
25
|
Layout/LineLength:
|
23
26
|
Max: 150
|
24
27
|
|
28
|
+
Metrics/AbcSize:
|
29
|
+
Max: 30
|
30
|
+
|
25
31
|
Metrics/BlockLength:
|
26
32
|
Exclude:
|
27
33
|
- jekyll_outline.gemspec
|
28
34
|
Max: 40
|
29
35
|
|
36
|
+
Metrics/CyclomaticComplexity:
|
37
|
+
Max: 20
|
38
|
+
|
30
39
|
Metrics/MethodLength:
|
31
40
|
Max: 30
|
32
41
|
|
42
|
+
Metrics/PerceivedComplexity:
|
43
|
+
Max: 20
|
44
|
+
|
33
45
|
Naming/FileName:
|
34
46
|
Exclude:
|
35
47
|
- Rakefile
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## 1.2.0 / 2023-04-23
|
2
|
+
- Added optional `field` parameter.
|
3
|
+
|
4
|
+
## 1.1.1 / 2023-04-02
|
5
|
+
* Added [`attribution` support](https://github.com/mslinn/jekyll_plugin_support#subclass-attribution).
|
6
|
+
|
1
7
|
## 1.1.0 / 2023-03-14
|
2
8
|
* `outline_js` tag added, for including Javascript necessary to position images relating to the outline.
|
3
9
|
* Now generates a series of divs, instead of one big div.
|
data/README.md
CHANGED
@@ -6,30 +6,62 @@
|
|
6
6
|
|
7
7
|
|
8
8
|
## Installation
|
9
|
-
|
10
|
-
Add this line to your application's Gemfile:
|
9
|
+
Add the following line to your Jekyll project's Gemfile, within the `jekyll_plugins` group:
|
11
10
|
|
12
11
|
```ruby
|
13
|
-
|
12
|
+
group :jekyll_plugins do
|
13
|
+
gem 'jekyll_outline'
|
14
|
+
end
|
14
15
|
```
|
15
16
|
|
16
17
|
And then execute:
|
17
18
|
|
18
|
-
$ bundle
|
19
|
+
$ bundle
|
20
|
+
|
21
|
+
|
22
|
+
## Fields
|
23
|
+
By default, each displayed entry consists of a document title,
|
24
|
+
wrapped within an <a href> HTML tag that links to the page for that entry,
|
25
|
+
followed by an indication of whether the document is visible (a draft) or not.
|
26
|
+
|
27
|
+
Entry can also include following fields:
|
28
|
+
`draft`, `categories`, `description`, `date`, `last_modified` or `last_modified_at`, `layout`, `order`, `title`, `slug`, `ext`, `tags`, and `excerpt`.
|
29
|
+
|
30
|
+
Specify the fields like this:
|
31
|
+
|
32
|
+
```
|
33
|
+
{% outline fields="title – <i> description </i>" %}
|
34
|
+
000: Topic 0..19
|
35
|
+
020: Topic 20..39
|
36
|
+
040: Topic 40..
|
37
|
+
{% endoutline %}
|
38
|
+
```
|
39
|
+
|
40
|
+
Words that are not a known field are transcribed into the output.
|
41
|
+
|
42
|
+
In the above example, notice that the HTML is space delimited from the field names.
|
43
|
+
The parser is simple and stupid: each token is matched against the known keywords.
|
44
|
+
Tokens are separated by white space.
|
19
45
|
|
20
46
|
|
21
47
|
### CSS
|
22
48
|
The CSS used for the demo website should be copied to your project.
|
23
|
-
See the
|
49
|
+
See the sections of [`demo/assets/css/styles.css`](/mslinn/jekyll_outline/blob/master/demo/assets/css/style.css#L252-L315) as shown:
|
24
50
|
|
25
51
|
```css
|
52
|
+
/* Start of jekyll_plugin_support css */
|
53
|
+
... copy this portion ...
|
54
|
+
/* End of jekyll_plugin_support css */
|
55
|
+
|
26
56
|
/* Start of jekyll_outline css */
|
27
57
|
... copy this portion ...
|
28
58
|
/* End of jekyll_outline css */
|
29
59
|
```
|
30
60
|
|
31
61
|
### JavaScript
|
32
|
-
This project's `outline_js` tag returns the Javascript necessary to position images relating to the outline.
|
62
|
+
This project's `outline_js` tag returns the Javascript necessary to position images relating to the outline.
|
63
|
+
If used without parameters it just returns the JavaScript.
|
64
|
+
Use the tag this way:
|
33
65
|
|
34
66
|
```html
|
35
67
|
<script>
|
@@ -37,7 +69,8 @@ This project's `outline_js` tag returns the Javascript necessary to position ima
|
|
37
69
|
</script>
|
38
70
|
```
|
39
71
|
|
40
|
-
If passed the `wrap_in_script_tag` parameter, it wraps the JavaScript in `<script></script
|
72
|
+
If passed the `wrap_in_script_tag` parameter, it wraps the JavaScript in `<script></script>`.
|
73
|
+
Use the tag this way:
|
41
74
|
|
42
75
|
```html
|
43
76
|
{% outline_js wrap_in_script_tag %}
|
@@ -45,7 +78,6 @@ If passed the `wrap_in_script_tag` parameter, it wraps the JavaScript in `<scrip
|
|
45
78
|
|
46
79
|
|
47
80
|
## Explanation
|
48
|
-
|
49
81
|
Given an outline that looks like this:
|
50
82
|
```html
|
51
83
|
{% outline stuff %}
|
@@ -57,9 +89,9 @@ Given an outline that looks like this:
|
|
57
89
|
|
58
90
|
...and given pages in the `stuff` collection with the following names:
|
59
91
|
|
60
|
-
- 010-published.html has title **Published Stuff Post 010**
|
61
|
-
- 020-unpublished.html has title **Unpublished Post 020**
|
62
|
-
- 030-unpublished.html has title **Unpublished Post 030**
|
92
|
+
- `010-published.html` has title **Published Stuff Post 010**
|
93
|
+
- `020-unpublished.html` has title **Unpublished Post 020**
|
94
|
+
- `030-unpublished.html` has title **Unpublished Post 030**
|
63
95
|
|
64
96
|
Then links to the pages in the `stuff` collection's pages are interleaved into the generated outline like this:
|
65
97
|
```html
|
@@ -80,12 +112,17 @@ Then links to the pages in the `stuff` collection's pages are interleaved into t
|
|
80
112
|
</div>
|
81
113
|
```
|
82
114
|
|
83
|
-
The JavaScript searches for images in the current page that were created by the
|
115
|
+
The JavaScript searches for images in the current page that were created by the
|
116
|
+
[`img`](https://github.com/mslinn/jekyll_img) tag plugin,
|
84
117
|
and have `id`s that correspond to outline sections.
|
85
118
|
|
86
|
-
Each of following image's `id`s have
|
119
|
+
Each of following image's `id`s have an `outline_` prefix, followed by a number, which corresponds to one of the sections.
|
87
120
|
Note that leading zeros in the first column above are not present in the `id`s below.
|
121
|
+
|
122
|
+
If you want to provide images to embed at appropriate locations within the outline,
|
123
|
+
wrap them within an invisible `div` so the web page does not jump around as the images are loaded.
|
88
124
|
```html
|
125
|
+
<div style="display: none;">
|
89
126
|
{% img align="right"
|
90
127
|
id="outline_0"
|
91
128
|
size="quartersize"
|
@@ -107,6 +144,7 @@ Note that leading zeros in the first column above are not present in the `id`s b
|
|
107
144
|
style="margin-top: 0"
|
108
145
|
wrapper_class="clear"
|
109
146
|
%}
|
147
|
+
</div>
|
110
148
|
```
|
111
149
|
The JavaScript identifies the images and repositions them in the DOM such that they follow the appropriate heading.
|
112
150
|
If no image corresponds to a heading, no error or warning is generated.
|
@@ -114,21 +152,23 @@ The images can be located anywhere on the page; they will be relocated appropria
|
|
114
152
|
If an image does not correspond to a heading, it is deleted.
|
115
153
|
|
116
154
|
|
155
|
+
|
156
|
+
|
157
|
+
## Attribution
|
158
|
+
See [`jekyll_plugin_support` for `attribution`](https://github.com/mslinn/jekyll_plugin_support#subclass-attribution)
|
159
|
+
|
160
|
+
|
117
161
|
## Additional Information
|
118
162
|
More information is available on
|
119
163
|
[Mike Slinn’s website](https://www.mslinn.com/jekyll/3000-jekyll-plugins.html#outline).
|
120
164
|
|
121
165
|
|
122
166
|
## Development
|
167
|
+
After checking out the repo, run `bin/setup` to install development dependencies.
|
123
168
|
|
124
|
-
|
125
|
-
You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
126
|
-
|
127
|
-
Install development dependencies like this:
|
128
|
-
```
|
129
|
-
$ BUNDLE_WITH="development" bundle install
|
130
|
-
```
|
169
|
+
Then you can run `bin/console` for an interactive prompt that will allow you to experiment using `irb`.
|
131
170
|
|
171
|
+
### Build and Install Locally
|
132
172
|
To build and install this gem onto your local machine, run:
|
133
173
|
```shell
|
134
174
|
$ bundle exec rake install
|
@@ -150,16 +190,28 @@ jekyll_outline (0.1.0)
|
|
150
190
|
```
|
151
191
|
|
152
192
|
|
153
|
-
##
|
154
|
-
A test website is provided in the `demo` directory.
|
155
|
-
|
193
|
+
## Demo
|
194
|
+
A demo / test website is provided in the `demo` directory.
|
195
|
+
It can be used to debug the plugin or to run freely.
|
196
|
+
|
197
|
+
### Run Freely
|
198
|
+
1. Run from the command line:
|
199
|
+
```shell
|
200
|
+
$ demo/_bin/debug -r
|
201
|
+
```
|
202
|
+
|
203
|
+
2. View the generated website at [`http://localhost:4444`](http://localhost:4444)
|
204
|
+
|
205
|
+
### Plugin Debugging
|
206
|
+
1. Set breakpoints in Visual Studio Code.
|
156
207
|
|
157
208
|
2. Initiate a debug session from the command line:
|
158
209
|
```shell
|
159
|
-
$
|
210
|
+
$ demo/_bin/debug
|
160
211
|
```
|
161
212
|
|
162
|
-
3. Once the `Fast Debugger` signon appears, launch the Visual Studio Code launch
|
213
|
+
3. Once the `Fast Debugger` signon appears, launch the Visual Studio Code launch
|
214
|
+
configuration called `Attach rdebug-ide`.
|
163
215
|
|
164
216
|
4. View the generated website at [`http://localhost:4444`](http://localhost:4444)
|
165
217
|
|
@@ -178,10 +230,13 @@ To release a new version,
|
|
178
230
|
|
179
231
|
|
180
232
|
## Contributing
|
181
|
-
|
182
233
|
Bug reports and pull requests are welcome on GitHub at https://github.com/mslinn/jekyll_outline.
|
183
234
|
|
235
|
+
1. Fork the project
|
236
|
+
2. Create a descriptively named feature branch
|
237
|
+
3. Add your feature
|
238
|
+
4. Submit a pull request
|
184
239
|
|
185
|
-
## License
|
186
240
|
|
241
|
+
## License
|
187
242
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/jekyll_outline.gemspec
CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |spec|
|
|
13
13
|
'.rubocop.yml', 'LICENSE.*', 'Rakefile', '{lib,spec}/**/*', '*.gemspec', '*.md',
|
14
14
|
'demo/assets/js/jekyll_outline.js'
|
15
15
|
]
|
16
|
-
spec.homepage = 'https://www.mslinn.com/
|
16
|
+
spec.homepage = 'https://www.mslinn.com/jekyll_plugins/jekyll_outline.html'
|
17
17
|
spec.license = 'MIT'
|
18
18
|
spec.metadata = {
|
19
19
|
'allowed_push_host' => 'https://rubygems.org',
|
@@ -36,5 +36,5 @@ Gem::Specification.new do |spec|
|
|
36
36
|
|
37
37
|
spec.add_dependency 'jekyll', '>= 3.5.0'
|
38
38
|
spec.add_dependency 'jekyll_draft', '~> 1.1.0'
|
39
|
-
spec.add_dependency 'jekyll_plugin_support', '~> 0.
|
39
|
+
spec.add_dependency 'jekyll_plugin_support', '~> 0.6.0'
|
40
40
|
end
|
data/lib/outline_tag.rb
CHANGED
@@ -20,25 +20,32 @@ module OutlineTag
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def to_s
|
23
|
-
" <h3 class='post_title clear' id=\"title_#{order}\">#{title}</h3>"
|
23
|
+
" <h3 class='post_title clear' id=\"title_#{@order}\">#{@title}</h3>"
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
class OutlineTag < JekyllSupport::JekyllBlock
|
27
|
+
class OutlineTag < JekyllSupport::JekyllBlock # rubocop:disable Metrics/ClassLength
|
28
28
|
include JekyllOutlineVersion
|
29
29
|
|
30
30
|
FIXNUM_MAX = (2**((0.size * 8) - 2)) - 1
|
31
31
|
|
32
32
|
def render_impl(text)
|
33
|
-
|
33
|
+
headers = make_headers(super) # Process the block content.
|
34
|
+
|
35
|
+
@helper.gem_file __FILE__
|
36
|
+
@fields = @helper.parameter_specified?('fields')&.split(' ') || ['title']
|
37
|
+
@logger.info { "@fields are: #{@fields}" }
|
38
|
+
@collection_name = @helper.remaining_markup
|
34
39
|
abort 'OutlineTag: collection_name was not specified' unless @collection_name
|
35
40
|
|
36
|
-
|
37
|
-
collection = headers +
|
41
|
+
@docs = obtain_docs(@collection_name)
|
42
|
+
collection = headers + @docs
|
43
|
+
|
38
44
|
<<~HEREDOC
|
39
45
|
<div class="outer_posts">
|
40
|
-
#{make_entries
|
46
|
+
#{make_entries collection}
|
41
47
|
</div>
|
48
|
+
#{@helper.attribute if @helper.attribution}
|
42
49
|
HEREDOC
|
43
50
|
end
|
44
51
|
|
@@ -56,35 +63,67 @@ module OutlineTag
|
|
56
63
|
# @section_state can have values: :head, :in_body
|
57
64
|
# @param collection Array of Jekyll::Document and Outline::Header
|
58
65
|
# @return Array of String
|
59
|
-
def make_entries(collection)
|
66
|
+
def make_entries(collection)
|
60
67
|
sorted = collection.sort_by(&obtain_order)
|
61
|
-
pruned = remove_empty_headers
|
68
|
+
pruned = remove_empty_headers sorted
|
62
69
|
@section_state = :head
|
63
70
|
@section_id = 0
|
64
71
|
result = pruned.map do |entry|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
72
|
+
handle entry
|
73
|
+
end
|
74
|
+
result << " </div>\n </div>" if @section_state == :in_body
|
75
|
+
result&.join("\n")
|
76
|
+
end
|
77
|
+
|
78
|
+
KNOWN_FIELDS = %w[draft categories description date last_modified_at layout order title slug ext tags excerpt].freeze
|
79
|
+
|
80
|
+
def handle(entry)
|
81
|
+
if entry.instance_of? Header
|
82
|
+
@header_order = entry.order
|
83
|
+
section_end = " </div>\n" if @section_state == :in_body
|
84
|
+
@section_state = :head
|
85
|
+
entry = section_end + entry.to_s if section_end
|
86
|
+
entry
|
87
|
+
else
|
88
|
+
if @section_state == :head
|
89
|
+
section_start = "<div id='posts_wrapper_#{@header_order}' class='clearfix'>\n " \
|
90
|
+
"<div id='posts_#{@header_order}' class='posts'>\n"
|
91
|
+
end
|
92
|
+
@section_state = :in_body
|
93
|
+
date = entry.data['last_modified_at'] # "%Y-%m-%d"
|
94
|
+
draft = Jekyll::Draft.draft_html(entry)
|
95
|
+
visible_line = handle_entry entry
|
96
|
+
result = " <span>#{date}</span> <span><a href='#{entry.url}'>#{visible_line.strip}</a>#{draft}</span>"
|
97
|
+
result = section_start + result if section_start
|
98
|
+
result
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def handle_entry(entry)
|
103
|
+
result = ''
|
104
|
+
@fields.each do |field|
|
105
|
+
if KNOWN_FIELDS.include? field
|
106
|
+
if entry.data.key? field
|
107
|
+
result += "#{entry.data[field]} "
|
108
|
+
else
|
109
|
+
@logger.warn { "#{field} is a known field, but it was not present in entry #{entry}" }
|
75
110
|
end
|
76
|
-
|
77
|
-
|
78
|
-
draft = Jekyll::Draft.draft_html(entry)
|
79
|
-
result = " <span>#{date}</span> <span><a href='#{entry.url}'>#{entry.data['title']}</a>#{draft}</span>"
|
80
|
-
result = section_start + result if section_start
|
81
|
-
result
|
111
|
+
else
|
112
|
+
result += "#{field} "
|
82
113
|
end
|
83
114
|
end
|
84
|
-
result << " </div>\n </div>" if @section_state == :in_body
|
85
115
|
result
|
86
116
|
end
|
87
117
|
|
118
|
+
# Find the given document
|
119
|
+
def obtain_doc(doc_name)
|
120
|
+
abort "#{@collection_name} is not a valid collection." unless @site.collections.key? @collection_name
|
121
|
+
@site
|
122
|
+
.collections[@collection_name]
|
123
|
+
.docs
|
124
|
+
.find { |doc| doc.path.end_with? "#{doc_name}.html" }
|
125
|
+
end
|
126
|
+
|
88
127
|
# Ignores files called index.html
|
89
128
|
def obtain_docs(collection_name)
|
90
129
|
abort "#{@collection_name} is not a valid collection." unless @site.collections.key? @collection_name
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll_outline
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Slinn
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-05-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.
|
47
|
+
version: 0.6.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.
|
54
|
+
version: 0.6.0
|
55
55
|
description: 'Jekyll tag plugin that creates a clickable table of contents.
|
56
56
|
|
57
57
|
'
|
@@ -74,14 +74,15 @@ files:
|
|
74
74
|
- lib/outline_tag.rb
|
75
75
|
- spec/outline_spec.rb
|
76
76
|
- spec/spec_helper.rb
|
77
|
-
|
77
|
+
- spec/status_persistence.txt
|
78
|
+
homepage: https://www.mslinn.com/jekyll_plugins/jekyll_outline.html
|
78
79
|
licenses:
|
79
80
|
- MIT
|
80
81
|
metadata:
|
81
82
|
allowed_push_host: https://rubygems.org
|
82
83
|
bug_tracker_uri: https://github.com/mslinn/jekyll_outline/issues
|
83
84
|
changelog_uri: https://github.com/mslinn/jekyll_outline/CHANGELOG.md
|
84
|
-
homepage_uri: https://www.mslinn.com/
|
85
|
+
homepage_uri: https://www.mslinn.com/jekyll_plugins/jekyll_outline.html
|
85
86
|
source_code_uri: https://github.com/mslinn/jekyll_outline
|
86
87
|
post_install_message: |2+
|
87
88
|
|
@@ -108,4 +109,5 @@ summary: Jekyll tag plugin that creates a clickable table of contents.
|
|
108
109
|
test_files:
|
109
110
|
- spec/outline_spec.rb
|
110
111
|
- spec/spec_helper.rb
|
112
|
+
- spec/status_persistence.txt
|
111
113
|
...
|