jekyll_miscellaneous 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +7 -0
- data/.rubocop.yml +27 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +137 -0
- data/LICENSE +21 -0
- data/README.md +210 -0
- data/jekyll_miscellaneous.gemspec +29 -0
- data/lib/jekyll_miscellaneous/filters/base64.rb +42 -0
- data/lib/jekyll_miscellaneous/filters/hash_color.rb +27 -0
- data/lib/jekyll_miscellaneous/filters/regex_replace.rb +50 -0
- data/lib/jekyll_miscellaneous/filters/truncate.rb +49 -0
- data/lib/jekyll_miscellaneous/filters/uri_encode.rb +25 -0
- data/lib/jekyll_miscellaneous/hooks/external_links.rb +88 -0
- data/lib/jekyll_miscellaneous/hooks/mark.rb +30 -0
- data/lib/jekyll_miscellaneous/tags/you_tube.rb +35 -0
- data/lib/jekyll_miscellaneous/version.rb +5 -0
- data/lib/jekyll_miscellaneous.rb +15 -0
- metadata +201 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5688b271a9bba25143a4455d9f457f7198237dbe1b526246d28461636abd4261
|
4
|
+
data.tar.gz: 1c0a091453c3b6f70622a234a71d51c387d511becd8beb7375fc73011ccc3a2a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 34b832409df0b5a69f6d4fdeeac67aee8d4aa5ed0926a9eb27309353c8ddfabfa12c4d68a3485a24ed5fec26647ac895a651a81e0d34e54a83aebc74a48c02e4
|
7
|
+
data.tar.gz: 65fca93361783315bf144dd42fe531ce90178709ac10dee2036960c68e2022922df42746d82e9b995a2270e23a0df610d7d8765e47b542bf00aed3e378b21a56
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require:
|
2
|
+
- rubocop-performance
|
3
|
+
- rubocop-rspec
|
4
|
+
|
5
|
+
AllCops:
|
6
|
+
NewCops: enable
|
7
|
+
Exclude:
|
8
|
+
- '.git/**/*'
|
9
|
+
- 'bin/*'
|
10
|
+
SuggestExtensions: false
|
11
|
+
|
12
|
+
Metrics/BlockLength:
|
13
|
+
IgnoredMethods: ['describe', 'context']
|
14
|
+
|
15
|
+
RSpec/MultipleMemoizedHelpers:
|
16
|
+
Enabled: false
|
17
|
+
RSpec/MultipleExpectations:
|
18
|
+
Enabled: false
|
19
|
+
RSpec/MessageSpies:
|
20
|
+
Enabled: false
|
21
|
+
RSpec/NestedGroups:
|
22
|
+
Enabled: false
|
23
|
+
RSpec/ContextWording:
|
24
|
+
Enabled: false
|
25
|
+
|
26
|
+
Style/Documentation:
|
27
|
+
Enabled: false
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,137 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
jekyll_miscellaneous (1.0.1)
|
5
|
+
jekyll (~> 4.0)
|
6
|
+
nokogiri (~> 1.13)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
addressable (2.8.0)
|
12
|
+
public_suffix (>= 2.0.2, < 5.0)
|
13
|
+
ansi (1.5.0)
|
14
|
+
ast (2.4.2)
|
15
|
+
codecov (0.6.0)
|
16
|
+
simplecov (>= 0.15, < 0.22)
|
17
|
+
colorator (1.1.0)
|
18
|
+
concurrent-ruby (1.1.9)
|
19
|
+
diff-lcs (1.5.0)
|
20
|
+
docile (1.4.0)
|
21
|
+
em-websocket (0.5.3)
|
22
|
+
eventmachine (>= 0.12.9)
|
23
|
+
http_parser.rb (~> 0)
|
24
|
+
eventmachine (1.2.7)
|
25
|
+
ffi (1.15.5)
|
26
|
+
forwardable-extended (2.6.0)
|
27
|
+
http_parser.rb (0.8.0)
|
28
|
+
i18n (1.9.1)
|
29
|
+
concurrent-ruby (~> 1.0)
|
30
|
+
jekyll (4.2.1)
|
31
|
+
addressable (~> 2.4)
|
32
|
+
colorator (~> 1.0)
|
33
|
+
em-websocket (~> 0.5)
|
34
|
+
i18n (~> 1.0)
|
35
|
+
jekyll-sass-converter (~> 2.0)
|
36
|
+
jekyll-watch (~> 2.0)
|
37
|
+
kramdown (~> 2.3)
|
38
|
+
kramdown-parser-gfm (~> 1.0)
|
39
|
+
liquid (~> 4.0)
|
40
|
+
mercenary (~> 0.4.0)
|
41
|
+
pathutil (~> 0.9)
|
42
|
+
rouge (~> 3.0)
|
43
|
+
safe_yaml (~> 1.0)
|
44
|
+
terminal-table (~> 2.0)
|
45
|
+
jekyll-sass-converter (2.1.0)
|
46
|
+
sassc (> 2.0.1, < 3.0)
|
47
|
+
jekyll-watch (2.2.1)
|
48
|
+
listen (~> 3.0)
|
49
|
+
kramdown (2.3.1)
|
50
|
+
rexml
|
51
|
+
kramdown-parser-gfm (1.1.0)
|
52
|
+
kramdown (~> 2.0)
|
53
|
+
liquid (4.0.3)
|
54
|
+
listen (3.7.1)
|
55
|
+
rb-fsevent (~> 0.10, >= 0.10.3)
|
56
|
+
rb-inotify (~> 0.9, >= 0.9.10)
|
57
|
+
mercenary (0.4.0)
|
58
|
+
nokogiri (1.13.1-x86_64-linux)
|
59
|
+
racc (~> 1.4)
|
60
|
+
parallel (1.21.0)
|
61
|
+
parser (3.1.0.0)
|
62
|
+
ast (~> 2.4.1)
|
63
|
+
pathutil (0.16.2)
|
64
|
+
forwardable-extended (~> 2.6)
|
65
|
+
public_suffix (4.0.6)
|
66
|
+
racc (1.6.0)
|
67
|
+
rainbow (3.1.1)
|
68
|
+
rake (13.0.6)
|
69
|
+
rb-fsevent (0.11.1)
|
70
|
+
rb-inotify (0.10.1)
|
71
|
+
ffi (~> 1.0)
|
72
|
+
regexp_parser (2.2.1)
|
73
|
+
rexml (3.2.5)
|
74
|
+
rouge (3.28.0)
|
75
|
+
rspec (3.11.0)
|
76
|
+
rspec-core (~> 3.11.0)
|
77
|
+
rspec-expectations (~> 3.11.0)
|
78
|
+
rspec-mocks (~> 3.11.0)
|
79
|
+
rspec-core (3.11.0)
|
80
|
+
rspec-support (~> 3.11.0)
|
81
|
+
rspec-expectations (3.11.0)
|
82
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
83
|
+
rspec-support (~> 3.11.0)
|
84
|
+
rspec-mocks (3.11.0)
|
85
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
86
|
+
rspec-support (~> 3.11.0)
|
87
|
+
rspec-support (3.11.0)
|
88
|
+
rubocop (1.25.1)
|
89
|
+
parallel (~> 1.10)
|
90
|
+
parser (>= 3.1.0.0)
|
91
|
+
rainbow (>= 2.2.2, < 4.0)
|
92
|
+
regexp_parser (>= 1.8, < 3.0)
|
93
|
+
rexml
|
94
|
+
rubocop-ast (>= 1.15.1, < 2.0)
|
95
|
+
ruby-progressbar (~> 1.7)
|
96
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
97
|
+
rubocop-ast (1.15.2)
|
98
|
+
parser (>= 3.0.1.1)
|
99
|
+
rubocop-performance (1.13.2)
|
100
|
+
rubocop (>= 1.7.0, < 2.0)
|
101
|
+
rubocop-ast (>= 0.4.0)
|
102
|
+
rubocop-rspec (2.8.0)
|
103
|
+
rubocop (~> 1.19)
|
104
|
+
ruby-progressbar (1.11.0)
|
105
|
+
safe_yaml (1.0.5)
|
106
|
+
sassc (2.4.0)
|
107
|
+
ffi (~> 1.9)
|
108
|
+
simplecov (0.21.2)
|
109
|
+
docile (~> 1.1)
|
110
|
+
simplecov-html (~> 0.11)
|
111
|
+
simplecov_json_formatter (~> 0.1)
|
112
|
+
simplecov-console (0.9.1)
|
113
|
+
ansi
|
114
|
+
simplecov
|
115
|
+
terminal-table
|
116
|
+
simplecov-html (0.12.3)
|
117
|
+
simplecov_json_formatter (0.1.3)
|
118
|
+
terminal-table (2.0.0)
|
119
|
+
unicode-display_width (~> 1.1, >= 1.1.1)
|
120
|
+
unicode-display_width (1.8.0)
|
121
|
+
|
122
|
+
PLATFORMS
|
123
|
+
x86_64-linux
|
124
|
+
|
125
|
+
DEPENDENCIES
|
126
|
+
codecov (~> 0.6.0)
|
127
|
+
jekyll_miscellaneous!
|
128
|
+
rake (>= 12.3.3)
|
129
|
+
rspec (~> 3.11)
|
130
|
+
rubocop (~> 1.25)
|
131
|
+
rubocop-performance (~> 1.13)
|
132
|
+
rubocop-rspec (~> 2.8)
|
133
|
+
simplecov (~> 0.21)
|
134
|
+
simplecov-console (~> 0.9.1)
|
135
|
+
|
136
|
+
BUNDLED WITH
|
137
|
+
2.2.26
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2022 Alejandro AR <kinduff@protonmail.com> (https://kinduff.com)
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,210 @@
|
|
1
|
+
# Jekyll Miscellaneous
|
2
|
+
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/jekyll_miscellaneous.svg)](https://badge.fury.io/rb/jekyll_miscellaneous) [![codecov](https://codecov.io/gh/kinduff/jekyll_miscellaneous/branch/main/graph/badge.svg?token=VWB60QW0UV)](https://codecov.io/gh/kinduff/jekyll_miscellaneous)
|
4
|
+
|
5
|
+
A collection of opinionated plugins for Jekyll.
|
6
|
+
|
7
|
+
## How to install
|
8
|
+
|
9
|
+
Install the gem:
|
10
|
+
|
11
|
+
```
|
12
|
+
gem install jekyll_miscellaneous
|
13
|
+
```
|
14
|
+
|
15
|
+
Or add it to your Gemfile. You can use `bundle add jekyll_miscellaneous`.
|
16
|
+
|
17
|
+
Then use the plugin in your Jekyll's `_config.yml` file.
|
18
|
+
|
19
|
+
```
|
20
|
+
plugins:
|
21
|
+
- jekyll_miscellaneous
|
22
|
+
```
|
23
|
+
|
24
|
+
## How to use
|
25
|
+
|
26
|
+
This gem includes multiple Jekyll or Liquid plugins that you can use immediately without further configuration.
|
27
|
+
|
28
|
+
- Tags
|
29
|
+
- [YouTube](#youtube)
|
30
|
+
- Filters
|
31
|
+
- [Base64 Encode](#base64-encode)
|
32
|
+
- [Base64 Decode](#base64-decode)
|
33
|
+
- [Hash Color](#hash-color)
|
34
|
+
- [Regex Replace](#regex-replace)
|
35
|
+
- [Clean URLs](#clean-urls)
|
36
|
+
- [Truncate](#truncate)
|
37
|
+
- [URI Encode](#uri-encode)
|
38
|
+
- Hooks
|
39
|
+
- [External Links](#external-links)
|
40
|
+
- [Mark](#mark)
|
41
|
+
|
42
|
+
More to come.
|
43
|
+
|
44
|
+
### YouTube
|
45
|
+
|
46
|
+
Given:
|
47
|
+
|
48
|
+
```liquid
|
49
|
+
{% youtube "dQw4w9WgXcQ" %}
|
50
|
+
```
|
51
|
+
|
52
|
+
Will output:
|
53
|
+
|
54
|
+
```html
|
55
|
+
<div class="youtube-container">
|
56
|
+
<iframe src="https://www.youtube-nocookie.com/embed/dQw4w9WgXcQ"></iframe>
|
57
|
+
</div>
|
58
|
+
```
|
59
|
+
|
60
|
+
### Base64 Encode
|
61
|
+
|
62
|
+
Given:
|
63
|
+
|
64
|
+
```liquid
|
65
|
+
{% 'Hello, World!' | base64_encode %}
|
66
|
+
```
|
67
|
+
|
68
|
+
Will output:
|
69
|
+
|
70
|
+
```
|
71
|
+
SGVsbG8sIFdvcmxkIQ==
|
72
|
+
```
|
73
|
+
|
74
|
+
### Base64 Decode
|
75
|
+
|
76
|
+
Given:
|
77
|
+
|
78
|
+
```liquid
|
79
|
+
{% 'SGVsbG8sIFdvcmxkIQ==' | base64_decode %}
|
80
|
+
```
|
81
|
+
|
82
|
+
Will output:
|
83
|
+
|
84
|
+
```
|
85
|
+
Hello, World!
|
86
|
+
```
|
87
|
+
|
88
|
+
### Hash Color
|
89
|
+
|
90
|
+
Given:
|
91
|
+
|
92
|
+
```liquid
|
93
|
+
{% 'Hello, World!' | hash_color %}
|
94
|
+
```
|
95
|
+
|
96
|
+
Will output:
|
97
|
+
|
98
|
+
```
|
99
|
+
hsl(349, 100%, 90%)
|
100
|
+
```
|
101
|
+
|
102
|
+
### Regex Replace
|
103
|
+
|
104
|
+
Given:
|
105
|
+
|
106
|
+
```liquid
|
107
|
+
{% 'Hello, World!' | regex_replace '$Hello', 'Goodbye' %}
|
108
|
+
```
|
109
|
+
|
110
|
+
Will output:
|
111
|
+
|
112
|
+
```
|
113
|
+
Goodbye, World!
|
114
|
+
```
|
115
|
+
|
116
|
+
### Clean URLs
|
117
|
+
|
118
|
+
Given:
|
119
|
+
|
120
|
+
```liquid
|
121
|
+
{% 'Hello, http://example.com World!' | clean_urls %}
|
122
|
+
```
|
123
|
+
|
124
|
+
Will output:
|
125
|
+
|
126
|
+
```
|
127
|
+
Hello, World!
|
128
|
+
```
|
129
|
+
|
130
|
+
### Truncate
|
131
|
+
|
132
|
+
Given:
|
133
|
+
|
134
|
+
```liquid
|
135
|
+
{% 'Hello, World!' | truncate 10 %}
|
136
|
+
{% 'Hello, World!' | truncate 10 ',' %}
|
137
|
+
{% 'Hello, World!' | truncate 10 ',' '!' %}
|
138
|
+
```
|
139
|
+
|
140
|
+
Will output:
|
141
|
+
|
142
|
+
```
|
143
|
+
Hello, ...
|
144
|
+
Hello...
|
145
|
+
Hello!
|
146
|
+
```
|
147
|
+
|
148
|
+
### URI encode
|
149
|
+
|
150
|
+
Given:
|
151
|
+
|
152
|
+
```liquid
|
153
|
+
{% 'Hello, World!' | uri_encode %}
|
154
|
+
```
|
155
|
+
|
156
|
+
Will output:
|
157
|
+
|
158
|
+
```
|
159
|
+
Hello%2C%20World%21
|
160
|
+
```
|
161
|
+
|
162
|
+
### External links
|
163
|
+
|
164
|
+
With the configuration:
|
165
|
+
|
166
|
+
```yaml
|
167
|
+
base_url: https://kinduff.com
|
168
|
+
```
|
169
|
+
|
170
|
+
Given:
|
171
|
+
|
172
|
+
```html
|
173
|
+
<p>
|
174
|
+
Link to the
|
175
|
+
<a href="https://example.com">example</a>.
|
176
|
+
</p>
|
177
|
+
```
|
178
|
+
|
179
|
+
Will output:
|
180
|
+
|
181
|
+
```html
|
182
|
+
<p>
|
183
|
+
Link to the
|
184
|
+
<a href="https://example.com" rel="external" target="_blank">example ⧉</a>.
|
185
|
+
</p>
|
186
|
+
```
|
187
|
+
|
188
|
+
More in the documentation.
|
189
|
+
|
190
|
+
### Mark
|
191
|
+
|
192
|
+
Given:
|
193
|
+
|
194
|
+
```markdown
|
195
|
+
Hello, ==World==!
|
196
|
+
```
|
197
|
+
|
198
|
+
Will output:
|
199
|
+
|
200
|
+
```html
|
201
|
+
<p>Hello, <mark>World</mark>!</p>
|
202
|
+
```
|
203
|
+
|
204
|
+
## Contributing
|
205
|
+
|
206
|
+
1. Fork it (`https://github.com/kinduff/jekyll_miscellaneous/fork`).
|
207
|
+
2. Create your feature branch (`git checkout -b my-new-feature`).
|
208
|
+
3. Commit your changes (`git commit -am "Add some feature"`).
|
209
|
+
4. Push to the branch (`git push origin my-new-feature`).
|
210
|
+
5. Create new Pull Request.
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'jekyll_miscellaneous/version'
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'jekyll_miscellaneous'
|
8
|
+
spec.summary = 'A collection of opinionated plugins for Jekyll.'
|
9
|
+
spec.description = 'A collection of opinionated plugins for Jekyll.'
|
10
|
+
spec.version = JekyllMiscellaneous::VERSION
|
11
|
+
spec.authors = ['Alejandro AR']
|
12
|
+
spec.email = ['kinduff@protonmail.com']
|
13
|
+
spec.homepage = 'https://github.com/kinduff/jekyll_miscellaneous'
|
14
|
+
spec.licenses = ['MIT']
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
16
|
+
spec.require_paths = ['lib']
|
17
|
+
spec.required_ruby_version = '>= 2.5'
|
18
|
+
spec.add_dependency 'jekyll', '~> 4.0'
|
19
|
+
spec.add_dependency 'nokogiri', '~> 1.13'
|
20
|
+
spec.add_development_dependency 'rake', '>= 12.3.3'
|
21
|
+
spec.add_development_dependency 'rspec', '~> 3.11'
|
22
|
+
spec.add_development_dependency 'rubocop', '~> 1.25'
|
23
|
+
spec.add_development_dependency 'rubocop-performance', '~> 1.13'
|
24
|
+
spec.add_development_dependency 'rubocop-rspec', '~> 2.8'
|
25
|
+
spec.add_development_dependency 'simplecov', '~> 0.21'
|
26
|
+
spec.add_development_dependency 'simplecov-console', '~> 0.9.1'
|
27
|
+
spec.add_development_dependency 'codecov', '~> 0.6.0'
|
28
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
29
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'base64'
|
4
|
+
module JekyllMiscellaneous
|
5
|
+
module Filters
|
6
|
+
module Base64
|
7
|
+
# Encodes a string to Base64, and returns the result.
|
8
|
+
#
|
9
|
+
# == Parameters:
|
10
|
+
# input::
|
11
|
+
# The string to encode.
|
12
|
+
#
|
13
|
+
# == Returns:
|
14
|
+
# The Base64 encoded string.
|
15
|
+
#
|
16
|
+
# == Example:
|
17
|
+
# base64_encode('Hello, World!')
|
18
|
+
# # => "SGVsbG8sIFdvcmxkIQ=="
|
19
|
+
def base64_encode(input)
|
20
|
+
::Base64.encode64(input)
|
21
|
+
end
|
22
|
+
|
23
|
+
# Decodes a Base64 string, and returns the result.
|
24
|
+
#
|
25
|
+
# == Parameters:
|
26
|
+
# input::
|
27
|
+
# The Base64 string to decode.
|
28
|
+
#
|
29
|
+
# == Returns:
|
30
|
+
# The decoded string.
|
31
|
+
#
|
32
|
+
# == Example:
|
33
|
+
# base64_decode('SGVsbG8sIFdvcmxkIQ==')
|
34
|
+
# # => "Hello, World!"
|
35
|
+
def base64_decode(input)
|
36
|
+
::Base64.decode64(input)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
Liquid::Template.register_filter(JekyllMiscellaneous::Filters::Base64)
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module JekyllMiscellaneous
|
4
|
+
module Filters
|
5
|
+
module HashColor
|
6
|
+
# Returns a string with the hexadecimal color code of the hash.
|
7
|
+
#
|
8
|
+
# == Parameters:
|
9
|
+
# input::
|
10
|
+
# The hash to get the hexadecimal color code from.
|
11
|
+
#
|
12
|
+
# == Returns:
|
13
|
+
# The hexadecimal color code of the hash.
|
14
|
+
#
|
15
|
+
# == Example:
|
16
|
+
# hash_color('Hello, World!')
|
17
|
+
# # => "hsl(349, 100%, 90%)"
|
18
|
+
def hash_color(input)
|
19
|
+
hash = 0
|
20
|
+
input.each_byte { |c| hash = c + ((hash << 5) - hash) }
|
21
|
+
"hsl(#{hash % 360}, 100%, 90%)"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
Liquid::Template.register_filter(JekyllMiscellaneous::Filters::HashColor)
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module JekyllMiscellaneous
|
4
|
+
module Filters
|
5
|
+
module RegexReplace
|
6
|
+
# Replaces all occurrences of a regular expression in a string with a
|
7
|
+
# replacement.
|
8
|
+
#
|
9
|
+
# == Parameters:
|
10
|
+
# input::
|
11
|
+
# The string to replace the regular expression in.
|
12
|
+
# regex::
|
13
|
+
# The regular expression to replace, as a string.
|
14
|
+
# replacement::
|
15
|
+
# The string to replace the regular expression with.
|
16
|
+
#
|
17
|
+
# == Returns:
|
18
|
+
# The string with all occurrences of the regular expression replaced.
|
19
|
+
#
|
20
|
+
# == Example:
|
21
|
+
# regex_replace('Hello, World!', '$Hello', 'Goodbye')
|
22
|
+
# # => "Goodbye, World!"
|
23
|
+
def regex_replace(input, regex, replacement)
|
24
|
+
formatted_regex = /#{regex}/
|
25
|
+
input.gsub(formatted_regex, replacement)
|
26
|
+
end
|
27
|
+
|
28
|
+
# Replaces all occurrences of URLs in a string with a nothing.
|
29
|
+
#
|
30
|
+
# == Note:
|
31
|
+
# It will strip and squeeze the result string.
|
32
|
+
#
|
33
|
+
# == Parameters:
|
34
|
+
# input::
|
35
|
+
# The string to clean the urls from.
|
36
|
+
#
|
37
|
+
# == Returns:
|
38
|
+
# The string without URLs.
|
39
|
+
#
|
40
|
+
# == Example:
|
41
|
+
# regex_replace_urls('Hello, http://example.com World!')
|
42
|
+
# # => "Hello, World!"
|
43
|
+
def clean_urls(input)
|
44
|
+
regex_replace(input.delete('…'), '(?<=^|[\s,])([\w-]+\.[a-z]{2,}\S*)\b', '').strip.squeeze(' ')
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
Liquid::Template.register_filter(JekyllMiscellaneous::Filters::RegexReplace)
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module JekyllMiscellaneous
|
4
|
+
module Filters
|
5
|
+
module Truncate
|
6
|
+
# Truncates a string to a certain length, and adds an ellipsis if the
|
7
|
+
# string is truncated. If the string is already shorter than the
|
8
|
+
# specified length, it is returned unchanged. If the string is longer
|
9
|
+
# than the specified length, it is truncated to that length. The
|
10
|
+
# ellipsis is added to the end of the string. The separator is used to
|
11
|
+
# split the string into words.
|
12
|
+
#
|
13
|
+
# == Parameters:
|
14
|
+
# input::
|
15
|
+
# The string to truncate.
|
16
|
+
# length::
|
17
|
+
# The maximum length of the string.
|
18
|
+
# separator::
|
19
|
+
# The string to use as a separator.
|
20
|
+
# omission::
|
21
|
+
# The string to use as an omission.
|
22
|
+
#
|
23
|
+
# == Returns:
|
24
|
+
# The truncated string.
|
25
|
+
#
|
26
|
+
# == Example:
|
27
|
+
# truncate('Hello, World!', 10)
|
28
|
+
# # => "Hello, ..."
|
29
|
+
# truncate('Hello, World!', 10, ',')
|
30
|
+
# # => "Hello..."
|
31
|
+
# truncate('Hello, World!', 10, ',', '!')
|
32
|
+
# # => "Hello!"
|
33
|
+
def truncate(input, truncate_at = 140, separator = nil, omission = '...')
|
34
|
+
return input.dup unless input.length > truncate_at
|
35
|
+
|
36
|
+
length_with_room_for_omission = truncate_at - omission.length
|
37
|
+
stop = if separator
|
38
|
+
input.rindex(separator, length_with_room_for_omission) || length_with_room_for_omission
|
39
|
+
else
|
40
|
+
length_with_room_for_omission
|
41
|
+
end
|
42
|
+
|
43
|
+
"#{input[0...stop]}#{omission}"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
Liquid::Template.register_filter(JekyllMiscellaneous::Filters::Truncate)
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module JekyllMiscellaneous
|
4
|
+
module Filters
|
5
|
+
module URIEncode
|
6
|
+
# Encodes a string to URI, and returns the result.
|
7
|
+
#
|
8
|
+
# == Parameters:
|
9
|
+
# input::
|
10
|
+
# The string to encode.
|
11
|
+
#
|
12
|
+
# == Returns:
|
13
|
+
# The URI encoded string.
|
14
|
+
#
|
15
|
+
# == Example:
|
16
|
+
# uri_encode('Hello, World!')
|
17
|
+
# # => "Hello%2C%20World%21"
|
18
|
+
def uri_encode(input)
|
19
|
+
URI.encode_www_form_component(input)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
Liquid::Template.register_filter(JekyllMiscellaneous::Filters::URIEncode)
|
@@ -0,0 +1,88 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'nokogiri'
|
4
|
+
require 'uri'
|
5
|
+
|
6
|
+
module JekyllMiscellaneous
|
7
|
+
module Hooks
|
8
|
+
module ExternalLinks
|
9
|
+
# Calls {.process_content} on the resource's content. If the resource is
|
10
|
+
# an asset file, does nothing.
|
11
|
+
#
|
12
|
+
# == Parameters:
|
13
|
+
# resource::
|
14
|
+
# The resource to process.
|
15
|
+
#
|
16
|
+
# == Returns:
|
17
|
+
# The processed resource.
|
18
|
+
def self.process(resource)
|
19
|
+
return if resource.data['layout'].nil?
|
20
|
+
|
21
|
+
site_hostname = URI(resource.site.config['base_url']).host
|
22
|
+
link_selector = 'body a'
|
23
|
+
|
24
|
+
return if resource.respond_to?(:asset_file?) && resource.asset_file?
|
25
|
+
|
26
|
+
resource.output = process_content(
|
27
|
+
site_hostname,
|
28
|
+
resource.output,
|
29
|
+
link_selector
|
30
|
+
)
|
31
|
+
end
|
32
|
+
|
33
|
+
# Processes a string of content with Nokogiri. The content is processed
|
34
|
+
# with the given link selector. The links are checked to see if they
|
35
|
+
# match the site hostname. If they do not, the link is modified to
|
36
|
+
# include +rel="external"+ and +target="_blank"+.
|
37
|
+
#
|
38
|
+
# The links are modified to include +⧉+ (a unicode character) to indicate
|
39
|
+
# that they are external. Except:
|
40
|
+
#
|
41
|
+
# - When the link is a relative URL.
|
42
|
+
# - When the link contains an image.
|
43
|
+
# - When the link has a the class +skip-external+.
|
44
|
+
#
|
45
|
+
# == Parameters:
|
46
|
+
# site_hostname::
|
47
|
+
# The hostname of the site.
|
48
|
+
# content::
|
49
|
+
# The content to process.
|
50
|
+
# link_selector::
|
51
|
+
# The CSS selector used to find links.
|
52
|
+
#
|
53
|
+
# == Returns
|
54
|
+
#
|
55
|
+
# site_hostname::
|
56
|
+
# The hostname of the site.
|
57
|
+
# content::
|
58
|
+
# The content to process.
|
59
|
+
# link_selector::
|
60
|
+
# The CSS selector for the links.
|
61
|
+
#
|
62
|
+
# == Returns:
|
63
|
+
# The content with instances of +a+ HTML tags with new attributes.
|
64
|
+
def self.process_content(site_hostname, content, link_selector)
|
65
|
+
content = Nokogiri::HTML(content)
|
66
|
+
content.css(link_selector).each do |a|
|
67
|
+
next unless /\Ahttp/i.match?(a.get_attribute('href'))
|
68
|
+
next if %r{\Ahttp(s)?://#{site_hostname}}i.match?(a.get_attribute('href'))
|
69
|
+
|
70
|
+
a.set_attribute('rel', 'external')
|
71
|
+
a.set_attribute('target', '_blank')
|
72
|
+
|
73
|
+
next if a.children.size.positive? && a.children.map(&:name).include?('img')
|
74
|
+
next if a.get_attribute('class')&.include?('skip-external')
|
75
|
+
|
76
|
+
a.content = "#{a.content} ⧉"
|
77
|
+
end
|
78
|
+
content.to_s
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
# :nocov:
|
85
|
+
Jekyll::Hooks.register [:documents, :pages], :post_render do |doc|
|
86
|
+
JekyllMiscellaneous::Hooks::ExternalLinks.process(doc)
|
87
|
+
end
|
88
|
+
# :nocov:
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module JekyllMiscellaneous
|
4
|
+
module Hooks
|
5
|
+
module Mark
|
6
|
+
# Searches and replaces within a document's content for the expression
|
7
|
+
# +==input==+, and replaces it with the HTML tag +<mark>input</mark>+.
|
8
|
+
#
|
9
|
+
# == Parameters:
|
10
|
+
# doc::
|
11
|
+
# The document to search and replace within.
|
12
|
+
#
|
13
|
+
# == Returns:
|
14
|
+
# The document with the expression replaced.
|
15
|
+
#
|
16
|
+
# == Example:
|
17
|
+
# =='Hello, World!'==
|
18
|
+
# <mark>Hello, World!</mark>
|
19
|
+
def self.process(doc)
|
20
|
+
doc.content.gsub!(/==+(\w(.*?)?[^ .=]?)==+/, '<mark>\\1</mark>')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# :nocov:
|
27
|
+
Jekyll::Hooks.register [:documents], :pre_render do |doc|
|
28
|
+
JekyllMiscellaneous::Hooks::Mark.process(doc)
|
29
|
+
end
|
30
|
+
# :nocov:
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module JekyllMiscellaneous
|
4
|
+
module Tags
|
5
|
+
class YouTube < Liquid::Tag
|
6
|
+
# Initialize the YouTube tag.
|
7
|
+
#
|
8
|
+
# == Parameters:
|
9
|
+
# tag_name::
|
10
|
+
# The name of the tag.
|
11
|
+
# id::
|
12
|
+
# The ID of the YouTube video.
|
13
|
+
# tokens::
|
14
|
+
# The tokens to parse.
|
15
|
+
def initialize(tag_name, id, tokens)
|
16
|
+
super
|
17
|
+
@id = id.strip
|
18
|
+
end
|
19
|
+
|
20
|
+
# Render the YouTube tag.
|
21
|
+
#
|
22
|
+
# == Returns:
|
23
|
+
# Returns the HTML for the YouTube video.
|
24
|
+
#
|
25
|
+
# == Example:
|
26
|
+
# {% youtube "dQw4w9WgXcQ" %}
|
27
|
+
# <div class="youtube-container"><iframe src="https://www.youtube-nocookie.com/embed/dQw4w9WgXcQ"></iframe></div>
|
28
|
+
def render(_context)
|
29
|
+
"<div class='youtube-container'><iframe src=\"https://www.youtube-nocookie.com/embed/#{@id}\"></iframe></div>"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
Liquid::Template.register_tag('youtube', JekyllMiscellaneous::Tags::YouTube)
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'jekyll'
|
4
|
+
require_relative 'jekyll_miscellaneous/version'
|
5
|
+
|
6
|
+
require_relative 'jekyll_miscellaneous/filters/base64'
|
7
|
+
require_relative 'jekyll_miscellaneous/filters/hash_color'
|
8
|
+
require_relative 'jekyll_miscellaneous/filters/regex_replace'
|
9
|
+
require_relative 'jekyll_miscellaneous/filters/truncate'
|
10
|
+
require_relative 'jekyll_miscellaneous/filters/uri_encode'
|
11
|
+
|
12
|
+
require_relative 'jekyll_miscellaneous/hooks/external_links'
|
13
|
+
require_relative 'jekyll_miscellaneous/hooks/mark'
|
14
|
+
|
15
|
+
require_relative 'jekyll_miscellaneous/tags/you_tube'
|
metadata
ADDED
@@ -0,0 +1,201 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll_miscellaneous
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alejandro AR
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-02-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: jekyll
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '4.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: nokogiri
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.13'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.13'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 12.3.3
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 12.3.3
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.11'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.11'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubocop
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.25'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.25'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop-performance
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.13'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.13'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop-rspec
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '2.8'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '2.8'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: simplecov
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0.21'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0.21'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: simplecov-console
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 0.9.1
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 0.9.1
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: codecov
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: 0.6.0
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 0.6.0
|
153
|
+
description: A collection of opinionated plugins for Jekyll.
|
154
|
+
email:
|
155
|
+
- kinduff@protonmail.com
|
156
|
+
executables: []
|
157
|
+
extensions: []
|
158
|
+
extra_rdoc_files: []
|
159
|
+
files:
|
160
|
+
- ".gitignore"
|
161
|
+
- ".rubocop.yml"
|
162
|
+
- Gemfile
|
163
|
+
- Gemfile.lock
|
164
|
+
- LICENSE
|
165
|
+
- README.md
|
166
|
+
- jekyll_miscellaneous.gemspec
|
167
|
+
- lib/jekyll_miscellaneous.rb
|
168
|
+
- lib/jekyll_miscellaneous/filters/base64.rb
|
169
|
+
- lib/jekyll_miscellaneous/filters/hash_color.rb
|
170
|
+
- lib/jekyll_miscellaneous/filters/regex_replace.rb
|
171
|
+
- lib/jekyll_miscellaneous/filters/truncate.rb
|
172
|
+
- lib/jekyll_miscellaneous/filters/uri_encode.rb
|
173
|
+
- lib/jekyll_miscellaneous/hooks/external_links.rb
|
174
|
+
- lib/jekyll_miscellaneous/hooks/mark.rb
|
175
|
+
- lib/jekyll_miscellaneous/tags/you_tube.rb
|
176
|
+
- lib/jekyll_miscellaneous/version.rb
|
177
|
+
homepage: https://github.com/kinduff/jekyll_miscellaneous
|
178
|
+
licenses:
|
179
|
+
- MIT
|
180
|
+
metadata:
|
181
|
+
rubygems_mfa_required: 'true'
|
182
|
+
post_install_message:
|
183
|
+
rdoc_options: []
|
184
|
+
require_paths:
|
185
|
+
- lib
|
186
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
187
|
+
requirements:
|
188
|
+
- - ">="
|
189
|
+
- !ruby/object:Gem::Version
|
190
|
+
version: '2.5'
|
191
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
192
|
+
requirements:
|
193
|
+
- - ">="
|
194
|
+
- !ruby/object:Gem::Version
|
195
|
+
version: '0'
|
196
|
+
requirements: []
|
197
|
+
rubygems_version: 3.2.22
|
198
|
+
signing_key:
|
199
|
+
specification_version: 4
|
200
|
+
summary: A collection of opinionated plugins for Jekyll.
|
201
|
+
test_files: []
|