jekyll_href 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -3
- data/.ruby-version +1 -0
- data/.vscode/launch.json +75 -0
- data/.vscode/settings.json +4 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +133 -0
- data/README.md +5 -42
- data/Rakefile +2 -1
- data/jekyll_href.gemspec +29 -29
- data/lib/jekyll_href/version.rb +1 -1
- data/lib/jekyll_href.rb +107 -73
- data/sig/jekyll_href.rbs +4 -0
- metadata +105 -21
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d29ce08e7cf07fc3acbe97e979f72e74d5110a32e3005d56b3910519f8edee6b
|
|
4
|
+
data.tar.gz: 798085924055ba3509413dccef85dcd584c2d781c3d32403d03ce9125b163349
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 13184917dbf55acf5e84fa64b01bc3c8c7446a75c5db61eadeca5087ee8c701d031687ca1c7c9412c00472635691369d4cd44f70bb8ae56e4789aeba1afdc956
|
|
7
|
+
data.tar.gz: b83722150b30f7845e26e7c065f982230581813aaefd5fac19ec33fecc19ef759f089d23b18b52892e932e8cca228880d4c849168101441ff6e676e9f6c4145a
|
data/.rubocop.yml
CHANGED
|
@@ -9,12 +9,12 @@ AllCops:
|
|
|
9
9
|
NewCops: enable
|
|
10
10
|
TargetRubyVersion: 2.6
|
|
11
11
|
|
|
12
|
-
Gemspec/RequireMFA:
|
|
13
|
-
Enabled: false
|
|
14
|
-
|
|
15
12
|
Layout/LineLength:
|
|
16
13
|
Max: 150
|
|
17
14
|
|
|
15
|
+
Layout/MultilineOperationIndentation:
|
|
16
|
+
Enabled: false
|
|
17
|
+
|
|
18
18
|
Layout/MultilineMethodCallIndentation:
|
|
19
19
|
Enabled: false
|
|
20
20
|
|
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.0.0
|
data/.vscode/launch.json
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
{
|
|
2
|
+
// Use IntelliSense to learn about possible attributes.
|
|
3
|
+
// Hover to view descriptions of existing attributes.
|
|
4
|
+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
|
5
|
+
"version": "0.2.0",
|
|
6
|
+
"configurations": [
|
|
7
|
+
{
|
|
8
|
+
"cwd": "${workspaceRoot}",
|
|
9
|
+
"name": "Attach rdebug-ide",
|
|
10
|
+
"request": "attach",
|
|
11
|
+
"remoteHost": "localhost",
|
|
12
|
+
"remotePort": "1234",
|
|
13
|
+
"remoteWorkspaceRoot": "/",
|
|
14
|
+
"restart": true,
|
|
15
|
+
"showDebuggerOutput": true,
|
|
16
|
+
"type": "Ruby",
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"cwd": "${workspaceRoot}",
|
|
20
|
+
"debuggerPort": "1234",
|
|
21
|
+
"name": "Debug Jekyll",
|
|
22
|
+
"program": "/usr/local/bin/jekyll",
|
|
23
|
+
"args": [
|
|
24
|
+
"serve",
|
|
25
|
+
"--livereload_port", "35721",
|
|
26
|
+
"--force_polling",
|
|
27
|
+
"--host", "0.0.0.0",
|
|
28
|
+
"--port", "4001",
|
|
29
|
+
"--future",
|
|
30
|
+
"--incremental",
|
|
31
|
+
"--livereload",
|
|
32
|
+
"--drafts",
|
|
33
|
+
"--unpublished"
|
|
34
|
+
],
|
|
35
|
+
"request": "launch",
|
|
36
|
+
"restart": true,
|
|
37
|
+
"showDebuggerOutput": true,
|
|
38
|
+
"stopOnEntry": true,
|
|
39
|
+
"type": "Ruby",
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"name": "Debug Local Ruby",
|
|
43
|
+
"type": "Ruby",
|
|
44
|
+
"request": "launch",
|
|
45
|
+
"program": "${workspaceRoot}/main.rb"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"args": [
|
|
49
|
+
"-I",
|
|
50
|
+
"${workspaceRoot}",
|
|
51
|
+
"${file}"
|
|
52
|
+
],
|
|
53
|
+
"cwd": "${workspaceRoot}",
|
|
54
|
+
"name": "RSpec - active spec file only",
|
|
55
|
+
"program": "/home/mslinn/.gems/bin/rspec",
|
|
56
|
+
"showDebuggerOutput": false,
|
|
57
|
+
"request": "launch",
|
|
58
|
+
"type": "Ruby",
|
|
59
|
+
"useBundler": true,
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"args": [
|
|
63
|
+
"-I",
|
|
64
|
+
"${workspaceRoot}"
|
|
65
|
+
],
|
|
66
|
+
"cwd": "${workspaceRoot}",
|
|
67
|
+
"name": "RSpec - all",
|
|
68
|
+
"program": "/home/mslinn/.gems/bin/rspec",
|
|
69
|
+
"request": "launch",
|
|
70
|
+
"showDebuggerOutput": false,
|
|
71
|
+
"type": "Ruby",
|
|
72
|
+
"useBundler": true,
|
|
73
|
+
}
|
|
74
|
+
]
|
|
75
|
+
}
|
data/CHANGELOG.md
CHANGED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
jekyll_href (1.0.2)
|
|
5
|
+
|
|
6
|
+
GEM
|
|
7
|
+
remote: https://rubygems.org/
|
|
8
|
+
specs:
|
|
9
|
+
addressable (2.8.0)
|
|
10
|
+
public_suffix (>= 2.0.2, < 5.0)
|
|
11
|
+
ast (2.4.2)
|
|
12
|
+
coderay (1.1.3)
|
|
13
|
+
colorator (1.1.0)
|
|
14
|
+
concurrent-ruby (1.1.9)
|
|
15
|
+
debase (0.2.4.1)
|
|
16
|
+
debase-ruby_core_source (>= 0.10.2)
|
|
17
|
+
debase-ruby_core_source (0.10.14)
|
|
18
|
+
diff-lcs (1.5.0)
|
|
19
|
+
em-websocket (0.5.3)
|
|
20
|
+
eventmachine (>= 0.12.9)
|
|
21
|
+
http_parser.rb (~> 0)
|
|
22
|
+
eventmachine (1.2.7)
|
|
23
|
+
ffi (1.15.5)
|
|
24
|
+
forwardable-extended (2.6.0)
|
|
25
|
+
http_parser.rb (0.8.0)
|
|
26
|
+
i18n (1.10.0)
|
|
27
|
+
concurrent-ruby (~> 1.0)
|
|
28
|
+
jekyll (4.2.2)
|
|
29
|
+
addressable (~> 2.4)
|
|
30
|
+
colorator (~> 1.0)
|
|
31
|
+
em-websocket (~> 0.5)
|
|
32
|
+
i18n (~> 1.0)
|
|
33
|
+
jekyll-sass-converter (~> 2.0)
|
|
34
|
+
jekyll-watch (~> 2.0)
|
|
35
|
+
kramdown (~> 2.3)
|
|
36
|
+
kramdown-parser-gfm (~> 1.0)
|
|
37
|
+
liquid (~> 4.0)
|
|
38
|
+
mercenary (~> 0.4.0)
|
|
39
|
+
pathutil (~> 0.9)
|
|
40
|
+
rouge (~> 3.0)
|
|
41
|
+
safe_yaml (~> 1.0)
|
|
42
|
+
terminal-table (~> 2.0)
|
|
43
|
+
jekyll-sass-converter (2.2.0)
|
|
44
|
+
sassc (> 2.0.1, < 3.0)
|
|
45
|
+
jekyll-watch (2.2.1)
|
|
46
|
+
listen (~> 3.0)
|
|
47
|
+
kramdown (2.3.1)
|
|
48
|
+
rexml
|
|
49
|
+
kramdown-parser-gfm (1.1.0)
|
|
50
|
+
kramdown (~> 2.0)
|
|
51
|
+
liquid (4.0.3)
|
|
52
|
+
listen (3.7.1)
|
|
53
|
+
rb-fsevent (~> 0.10, >= 0.10.3)
|
|
54
|
+
rb-inotify (~> 0.9, >= 0.9.10)
|
|
55
|
+
mercenary (0.4.0)
|
|
56
|
+
method_source (1.0.0)
|
|
57
|
+
parallel (1.21.0)
|
|
58
|
+
parser (3.1.1.0)
|
|
59
|
+
ast (~> 2.4.1)
|
|
60
|
+
pathutil (0.16.2)
|
|
61
|
+
forwardable-extended (~> 2.6)
|
|
62
|
+
pry (0.14.1)
|
|
63
|
+
coderay (~> 1.1)
|
|
64
|
+
method_source (~> 1.0)
|
|
65
|
+
public_suffix (4.0.6)
|
|
66
|
+
rainbow (3.1.1)
|
|
67
|
+
rake (13.0.6)
|
|
68
|
+
rb-fsevent (0.11.1)
|
|
69
|
+
rb-inotify (0.10.1)
|
|
70
|
+
ffi (~> 1.0)
|
|
71
|
+
regexp_parser (2.2.1)
|
|
72
|
+
rexml (3.2.5)
|
|
73
|
+
rouge (3.28.0)
|
|
74
|
+
rspec (3.11.0)
|
|
75
|
+
rspec-core (~> 3.11.0)
|
|
76
|
+
rspec-expectations (~> 3.11.0)
|
|
77
|
+
rspec-mocks (~> 3.11.0)
|
|
78
|
+
rspec-core (3.11.0)
|
|
79
|
+
rspec-support (~> 3.11.0)
|
|
80
|
+
rspec-expectations (3.11.0)
|
|
81
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
82
|
+
rspec-support (~> 3.11.0)
|
|
83
|
+
rspec-mocks (3.11.0)
|
|
84
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
85
|
+
rspec-support (~> 3.11.0)
|
|
86
|
+
rspec-support (3.11.0)
|
|
87
|
+
rubocop (1.18.4)
|
|
88
|
+
parallel (~> 1.10)
|
|
89
|
+
parser (>= 3.0.0.0)
|
|
90
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
91
|
+
regexp_parser (>= 1.8, < 3.0)
|
|
92
|
+
rexml
|
|
93
|
+
rubocop-ast (>= 1.8.0, < 2.0)
|
|
94
|
+
ruby-progressbar (~> 1.7)
|
|
95
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
|
96
|
+
rubocop-ast (1.16.0)
|
|
97
|
+
parser (>= 3.1.1.0)
|
|
98
|
+
rubocop-jekyll (0.12.0)
|
|
99
|
+
rubocop (~> 1.18.0)
|
|
100
|
+
rubocop-performance (~> 1.2)
|
|
101
|
+
rubocop-performance (1.13.3)
|
|
102
|
+
rubocop (>= 1.7.0, < 2.0)
|
|
103
|
+
rubocop-ast (>= 0.4.0)
|
|
104
|
+
rubocop-rake (0.6.0)
|
|
105
|
+
rubocop (~> 1.0)
|
|
106
|
+
ruby-debug-ide (0.7.3)
|
|
107
|
+
rake (>= 0.8.1)
|
|
108
|
+
ruby-progressbar (1.11.0)
|
|
109
|
+
safe_yaml (1.0.5)
|
|
110
|
+
sassc (2.4.0)
|
|
111
|
+
ffi (~> 1.9)
|
|
112
|
+
terminal-table (2.0.0)
|
|
113
|
+
unicode-display_width (~> 1.1, >= 1.1.1)
|
|
114
|
+
unicode-display_width (1.8.0)
|
|
115
|
+
|
|
116
|
+
PLATFORMS
|
|
117
|
+
x86_64-linux
|
|
118
|
+
|
|
119
|
+
DEPENDENCIES
|
|
120
|
+
bundler
|
|
121
|
+
debase
|
|
122
|
+
jekyll
|
|
123
|
+
jekyll_href!
|
|
124
|
+
pry
|
|
125
|
+
rake
|
|
126
|
+
rspec
|
|
127
|
+
rubocop
|
|
128
|
+
rubocop-jekyll
|
|
129
|
+
rubocop-rake
|
|
130
|
+
ruby-debug-ide
|
|
131
|
+
|
|
132
|
+
BUNDLED WITH
|
|
133
|
+
2.3.7
|
data/README.md
CHANGED
|
@@ -6,21 +6,16 @@
|
|
|
6
6
|
The Liquid tag generates and `<a href>` HTML tag, by default containing `target="_blank"` and `rel=nofollow`.
|
|
7
7
|
To suppress the `nofollow` attribute, preface the link with the word `follow`.
|
|
8
8
|
To suppress the `target` attribute, preface the link with the word `notarget`.
|
|
9
|
-
Also provides a convenient way to generate formatted and clickable URIs.
|
|
10
9
|
|
|
11
10
|
|
|
12
11
|
### Syntax:
|
|
13
12
|
```
|
|
14
|
-
{% href [match | [follow] [notarget]]
|
|
13
|
+
{% href [match | [follow] [notarget]] url text to display %}
|
|
15
14
|
```
|
|
16
15
|
Note that the url should not be enclosed in quotes.
|
|
17
16
|
Also please note that the square brackets denote optional parameters, and should not be typed.
|
|
18
17
|
|
|
19
18
|
|
|
20
|
-
### Additional Information
|
|
21
|
-
More information is available on my web site about [my Jekyll plugins](https://www.mslinn.com/blog/2020/10/03/jekyll-plugins.html).
|
|
22
|
-
|
|
23
|
-
|
|
24
19
|
## Installation
|
|
25
20
|
|
|
26
21
|
Add this line to your Jekyll website's `Gemfile`, within the `jekyll_plugins` group:
|
|
@@ -41,7 +36,6 @@ Or install it yourself as:
|
|
|
41
36
|
|
|
42
37
|
## Usage
|
|
43
38
|
|
|
44
|
-
### Defaults
|
|
45
39
|
```
|
|
46
40
|
{% href https://mslinn.com The Awesome %}
|
|
47
41
|
```
|
|
@@ -53,7 +47,7 @@ Expands to this:
|
|
|
53
47
|
|
|
54
48
|
Which renders as this: <a href='https://mslinn.com' target='_blank' rel='nofollow'>The Awesome</a>
|
|
55
49
|
|
|
56
|
-
|
|
50
|
+
|
|
57
51
|
```
|
|
58
52
|
{% href follow https://mslinn.com The Awesome %}
|
|
59
53
|
```
|
|
@@ -64,7 +58,6 @@ Expands to this:
|
|
|
64
58
|
```
|
|
65
59
|
|
|
66
60
|
|
|
67
|
-
### `notarget`
|
|
68
61
|
```
|
|
69
62
|
{% href notarget https://mslinn.com The Awesome %}
|
|
70
63
|
```
|
|
@@ -75,7 +68,6 @@ Expands to this:
|
|
|
75
68
|
```
|
|
76
69
|
|
|
77
70
|
|
|
78
|
-
### `follow notarget`
|
|
79
71
|
```
|
|
80
72
|
{% href follow notarget https://mslinn.com The Awesome %}
|
|
81
73
|
```
|
|
@@ -85,55 +77,26 @@ Expands to this:
|
|
|
85
77
|
<a href='https://mslinn.com'>The Awesome</a>
|
|
86
78
|
```
|
|
87
79
|
|
|
88
|
-
### `match`
|
|
89
|
-
Looks for a post with a matching URL.
|
|
90
80
|
```
|
|
91
81
|
{% href match setting-up-django-oscar.html tutorial site %}
|
|
92
82
|
```
|
|
93
83
|
|
|
94
|
-
|
|
84
|
+
Expands to this:
|
|
95
85
|
```html
|
|
96
86
|
<a href='/blog/2021/02/11/setting-up-django-oscar.html'>tutorial site</a>
|
|
97
87
|
```
|
|
98
88
|
|
|
99
|
-
### URI
|
|
100
|
-
```html
|
|
101
|
-
{% href mslinn.com %}
|
|
102
|
-
```
|
|
103
|
-
Expands to this:
|
|
104
|
-
```html
|
|
105
|
-
<a href='https://mslinn.com' target='_blank' rel='nofollow'><code>mslinn.com</code></a>
|
|
106
|
-
```
|
|
107
|
-
Which renders as: [`mslinn.com`](https://mslinn.com)
|
|
108
89
|
|
|
109
90
|
## Development
|
|
110
91
|
|
|
111
92
|
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
112
93
|
|
|
113
|
-
|
|
114
|
-
```
|
|
115
|
-
$ BUNDLE_WITH="development" bundle install
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
To install this gem onto your local machine, run:
|
|
119
|
-
```shell
|
|
120
|
-
$ bundle exec rake install
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
To release a new version,
|
|
124
|
-
1. Update the version number in `version.rb`.
|
|
125
|
-
2. Commit all changes to git; if you don't the next step might fail with an unexplainable error message.
|
|
126
|
-
3. Run the following:
|
|
127
|
-
```shell
|
|
128
|
-
$ bundle exec rake release
|
|
129
|
-
```
|
|
130
|
-
The above creates a git tag for the version, commits the created tag,
|
|
131
|
-
and pushes the new `.gem` file to [RubyGems.org](https://rubygems.org).
|
|
94
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
132
95
|
|
|
133
96
|
|
|
134
97
|
## Contributing
|
|
135
98
|
|
|
136
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
|
99
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/jekyll_href.
|
|
137
100
|
|
|
138
101
|
|
|
139
102
|
## License
|
data/Rakefile
CHANGED
data/jekyll_href.gemspec
CHANGED
|
@@ -3,42 +3,42 @@
|
|
|
3
3
|
require_relative "lib/jekyll_href/version"
|
|
4
4
|
|
|
5
5
|
Gem::Specification.new do |spec|
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
spec.name = "jekyll_href"
|
|
7
|
+
spec.version = JekyllHref::VERSION
|
|
8
8
|
spec.authors = ["Mike Slinn"]
|
|
9
|
-
spec.bindir = "exe"
|
|
10
|
-
spec.description = <<~END_OF_DESC
|
|
11
|
-
Generates an 'a href' tag, possibly with target='_blank' and rel='nofollow'.
|
|
12
|
-
END_OF_DESC
|
|
13
9
|
spec.email = ["mslinn@mslinn.com"]
|
|
14
|
-
|
|
15
|
-
spec.
|
|
10
|
+
|
|
11
|
+
spec.summary = "Generates an 'a href' tag, possibly with target='_blank' and rel='nofollow'."
|
|
12
|
+
spec.description = "Generates an 'a href' tag, possibly with target='_blank' and rel='nofollow'."
|
|
13
|
+
spec.homepage = "https://github.com/mslinn/jekyll_href"
|
|
16
14
|
spec.license = "MIT"
|
|
17
|
-
spec.
|
|
18
|
-
"allowed_push_host" => "https://rubygems.org",
|
|
19
|
-
"bug_tracker_uri" => "#{github}/issues",
|
|
20
|
-
"changelog_uri" => "#{github}/CHANGELOG.md",
|
|
21
|
-
"homepage_uri" => spec.homepage,
|
|
22
|
-
"source_code_uri" => github,
|
|
23
|
-
}
|
|
24
|
-
spec.name = "jekyll_href"
|
|
25
|
-
spec.post_install_message = <<~END_MESSAGE
|
|
15
|
+
spec.required_ruby_version = ">= 2.6.0"
|
|
26
16
|
|
|
27
|
-
|
|
17
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org/"
|
|
28
18
|
|
|
29
|
-
|
|
30
|
-
spec.
|
|
31
|
-
spec.
|
|
32
|
-
spec.summary = "Generates an 'a href' tag, possibly with target='_blank' and rel='nofollow'."
|
|
33
|
-
spec.test_files = spec.files.grep(%r!^(test|spec|features)/!)
|
|
34
|
-
spec.version = JekyllHref::VERSION
|
|
19
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
|
20
|
+
spec.metadata["source_code_uri"] = "https://github.com/mslinn/jekyll_href"
|
|
21
|
+
spec.metadata["changelog_uri"] = "https://github.com/mslinn/jekyll_href/CHANGELOG.md"
|
|
35
22
|
|
|
36
|
-
|
|
37
|
-
|
|
23
|
+
# Specify which files should be added to the gem when it is released.
|
|
24
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
25
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
26
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
|
27
|
+
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
spec.bindir = "exe"
|
|
31
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
|
32
|
+
spec.require_paths = ["lib"]
|
|
38
33
|
|
|
34
|
+
spec.add_development_dependency 'bundler'
|
|
39
35
|
spec.add_development_dependency 'debase'
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
36
|
+
spec.add_development_dependency 'jekyll'
|
|
37
|
+
spec.add_development_dependency 'pry'
|
|
38
|
+
spec.add_development_dependency 'rake'
|
|
39
|
+
spec.add_development_dependency 'rspec'
|
|
40
|
+
spec.add_development_dependency 'rubocop'
|
|
41
|
+
spec.add_development_dependency 'rubocop-jekyll'
|
|
42
|
+
spec.add_development_dependency 'rubocop-rake'
|
|
43
43
|
spec.add_development_dependency 'ruby-debug-ide'
|
|
44
44
|
end
|
data/lib/jekyll_href/version.rb
CHANGED
data/lib/jekyll_href.rb
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "jekyll_plugin_logger"
|
|
4
|
-
require "liquid"
|
|
5
3
|
require_relative "jekyll_href/version"
|
|
6
4
|
|
|
7
5
|
# @author Copyright 2020 Michael Slinn
|
|
@@ -49,103 +47,139 @@ require_relative "jekyll_href/version"
|
|
|
49
47
|
# @example Substitute name/value pair for the django-github variable:
|
|
50
48
|
# {% href {{django-github}}/django/core/management/__init__.py#L398-L401
|
|
51
49
|
# <code>django.core.management.execute_from_command_line</code> %}
|
|
50
|
+
module JekyllHref
|
|
51
|
+
class Error < StandardError; end
|
|
52
|
+
|
|
53
|
+
class HrefSetup
|
|
54
|
+
attr_reader :follow, :match_keyword, :tokens, :target, :text
|
|
55
|
+
|
|
56
|
+
def initialize(tag_line, parse_context)
|
|
57
|
+
@tokens = tag_line.strip.split
|
|
58
|
+
@parse_context = parse_context
|
|
59
|
+
@follow = get_value('follow', " rel='nofollow'")
|
|
60
|
+
@target = get_value('notarget', " target='_blank'")
|
|
61
|
+
|
|
62
|
+
@match_keyword = false
|
|
63
|
+
match_index = @tokens.index('match')
|
|
64
|
+
if match_index
|
|
65
|
+
context.delete_at(match_index)
|
|
66
|
+
@follow = ''
|
|
67
|
+
@match_keyword = true
|
|
68
|
+
@target = ''
|
|
69
|
+
end
|
|
52
70
|
|
|
53
|
-
|
|
54
|
-
# @param tag_name [String] is the name of the tag, which we already know.
|
|
55
|
-
# @param command_line [Hash, String, Liquid::Tag::Parser] the arguments from the web page.
|
|
56
|
-
# @param tokens [Liquid::ParseContext] tokenized command line
|
|
57
|
-
# @return [void]
|
|
58
|
-
def initialize(tag_name, command_line, tokens)
|
|
59
|
-
super
|
|
60
|
-
|
|
61
|
-
@match = false
|
|
62
|
-
@tokens = command_line.strip.split
|
|
63
|
-
@follow = get_value("follow", " rel='nofollow'")
|
|
64
|
-
@target = get_value("notarget", " target='_blank'")
|
|
65
|
-
@logger = PluginMetaLogger.instance.new_logger(self)
|
|
66
|
-
|
|
67
|
-
match_index = tokens.index("match")
|
|
68
|
-
if match_index
|
|
69
|
-
tokens.delete_at(match_index)
|
|
70
|
-
@follow = ""
|
|
71
|
-
@match = true
|
|
72
|
-
@target = ""
|
|
71
|
+
finalize
|
|
73
72
|
end
|
|
74
73
|
|
|
75
|
-
|
|
76
|
-
|
|
74
|
+
def replace_vars(variables)
|
|
75
|
+
variables.each do |name, value|
|
|
76
|
+
@link = @link.gsub("{{#{name}}}", value)
|
|
77
|
+
end
|
|
78
|
+
@link
|
|
79
|
+
end
|
|
77
80
|
|
|
78
|
-
|
|
79
|
-
# @return [String]
|
|
80
|
-
def render(context)
|
|
81
|
-
match(context) if @match
|
|
82
|
-
link = replace_vars(context, @link)
|
|
83
|
-
@logger.debug { "@link=#{@link}; link=#{link}" }
|
|
84
|
-
"<a href='#{link}'#{@target}#{@follow}>#{@text}</a>"
|
|
85
|
-
end
|
|
81
|
+
private
|
|
86
82
|
|
|
87
|
-
|
|
83
|
+
def finalize
|
|
84
|
+
@link = @tokens.shift
|
|
88
85
|
|
|
89
|
-
|
|
90
|
-
|
|
86
|
+
@text = @tokens.join(' ').strip
|
|
87
|
+
if @text.empty?
|
|
88
|
+
@text = "<code>${@link}</code>"
|
|
89
|
+
@link = "https://#{@link}"
|
|
90
|
+
end
|
|
91
91
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
92
|
+
unless @link.start_with? 'http'
|
|
93
|
+
@follow = ''
|
|
94
|
+
@target = ''
|
|
95
|
+
end
|
|
96
96
|
end
|
|
97
97
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
98
|
+
def get_value(token, default_value)
|
|
99
|
+
value = default_value
|
|
100
|
+
target_index = @tokens.index(token)
|
|
101
|
+
if target_index
|
|
102
|
+
@tokens.delete_at(target_index)
|
|
103
|
+
value = ""
|
|
104
|
+
end
|
|
105
|
+
value
|
|
101
106
|
end
|
|
102
107
|
end
|
|
103
108
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
@
|
|
109
|
-
|
|
109
|
+
class HrefRender
|
|
110
|
+
def initialize(context, href_setup)
|
|
111
|
+
@context = context
|
|
112
|
+
@site = @context.registers[:site]
|
|
113
|
+
@config = @site.config
|
|
114
|
+
@href_setup = href_setup
|
|
115
|
+
match(context) if @href_setup.match_keyword
|
|
110
116
|
end
|
|
111
|
-
value
|
|
112
|
-
end
|
|
113
117
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
die_if_nomatch = !config.nil? && config['nomatch'] && config['nomatch']=='fatal'
|
|
118
|
+
def link
|
|
119
|
+
@href_setup.replace_vars @config['plugin-vars']
|
|
120
|
+
end
|
|
118
121
|
|
|
119
|
-
|
|
122
|
+
private
|
|
120
123
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
when 0
|
|
124
|
+
def handle_no_args
|
|
125
|
+
href_config = @config['href']
|
|
126
|
+
die_if_nomatch = !href_config.nil? &&
|
|
127
|
+
href_config['nomatch'] &&
|
|
128
|
+
href_config['nomatch'] == 'fatal'
|
|
127
129
|
if die_if_nomatch
|
|
128
130
|
abort "href error: No url matches '#{@link}'"
|
|
129
131
|
else
|
|
130
132
|
@link = "#"
|
|
131
133
|
@text = "<i>#{@link} is not available</i>"
|
|
132
134
|
end
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
def match
|
|
138
|
+
path, fragment = @link.split('#')
|
|
139
|
+
posts = @site.posts.docs.select { |x| x.url.include?(path) }
|
|
140
|
+
case posts.length
|
|
141
|
+
when 0
|
|
142
|
+
handle_no_args
|
|
143
|
+
when 1
|
|
144
|
+
@link = "#{@link}\##{fragment}" if fragment
|
|
145
|
+
else
|
|
146
|
+
abort "Error: More than one url matched: #{matches.join(", ")}"
|
|
147
|
+
end
|
|
137
148
|
end
|
|
138
149
|
end
|
|
139
150
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
151
|
+
class HrefTag < Liquid::Tag
|
|
152
|
+
# @param tag_name [String] is the name of the tag, which we already know.
|
|
153
|
+
# @param tag_line [Hash, String, Liquid::Tag::Parser] the contents between {% and %} in the web page (should be a string).
|
|
154
|
+
# @param parse_context [Liquid::ParseContext] looks like:
|
|
155
|
+
# <Liquid::ParseContext:0x00005595446e5800
|
|
156
|
+
# @template_options={
|
|
157
|
+
# :line_numbers=>true,
|
|
158
|
+
# :locale=>#<Liquid::I18n:0x00005595446e5760 @path="/home/mslinn/.gems/gems/liquid-4.0.3/lib/liquid/locales/en.yml">},
|
|
159
|
+
# @locale=#<Liquid::I18n:0x00005595446e5760
|
|
160
|
+
# @path="/home/mslinn/.gems/gems/liquid-4.0.3/lib/liquid/locales/en.yml">,
|
|
161
|
+
# @warnings=[],
|
|
162
|
+
# @depth=0,
|
|
163
|
+
# @partial=false,
|
|
164
|
+
# @options={:line_numbers=>true, :locale=>#<Liquid::I18n:0x00005595446e5760
|
|
165
|
+
# @path="/home/mslinn/.gems/gems/liquid-4.0.3/lib/liquid/locales/en.yml">},
|
|
166
|
+
# @error_mode=:strict,
|
|
167
|
+
# @line_number=9,
|
|
168
|
+
# @trim_whitespace=false>
|
|
169
|
+
# @return [void]
|
|
170
|
+
def initialize(tag_name, tag_line, parse_context)
|
|
171
|
+
super
|
|
172
|
+
@href_setup = HrefSetup.new(tag_line, parse_context)
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
# Method prescribed by the Jekyll plugin lifecycle.
|
|
176
|
+
# @param context [Liquid::Context] Context keeps the variable stack and resolves variables, as well as keywords
|
|
177
|
+
# @return [String]
|
|
178
|
+
def render(context)
|
|
179
|
+
href_render = HrefRender.new(context, @href_setup)
|
|
180
|
+
"<a href='#{href_render.link}'#{@href_setup.target}#{@href_setup.follow}>#{@href_setup.text}</a>"
|
|
145
181
|
end
|
|
146
|
-
link
|
|
147
182
|
end
|
|
148
183
|
end
|
|
149
184
|
|
|
150
|
-
|
|
151
|
-
Liquid::Template.register_tag('href', ExternalHref)
|
|
185
|
+
Liquid::Template.register_tag('href', JekyllHref::HrefTag)
|
data/sig/jekyll_href.rbs
ADDED
metadata
CHANGED
|
@@ -1,37 +1,65 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: jekyll_href
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Mike Slinn
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2022-03-
|
|
11
|
+
date: 2022-03-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: debase
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
13
41
|
- !ruby/object:Gem::Dependency
|
|
14
42
|
name: jekyll
|
|
15
43
|
requirement: !ruby/object:Gem::Requirement
|
|
16
44
|
requirements:
|
|
17
45
|
- - ">="
|
|
18
46
|
- !ruby/object:Gem::Version
|
|
19
|
-
version:
|
|
20
|
-
type: :
|
|
47
|
+
version: '0'
|
|
48
|
+
type: :development
|
|
21
49
|
prerelease: false
|
|
22
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
51
|
requirements:
|
|
24
52
|
- - ">="
|
|
25
53
|
- !ruby/object:Gem::Version
|
|
26
|
-
version:
|
|
54
|
+
version: '0'
|
|
27
55
|
- !ruby/object:Gem::Dependency
|
|
28
|
-
name:
|
|
56
|
+
name: pry
|
|
29
57
|
requirement: !ruby/object:Gem::Requirement
|
|
30
58
|
requirements:
|
|
31
59
|
- - ">="
|
|
32
60
|
- !ruby/object:Gem::Version
|
|
33
61
|
version: '0'
|
|
34
|
-
type: :
|
|
62
|
+
type: :development
|
|
35
63
|
prerelease: false
|
|
36
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
65
|
requirements:
|
|
@@ -39,7 +67,63 @@ dependencies:
|
|
|
39
67
|
- !ruby/object:Gem::Version
|
|
40
68
|
version: '0'
|
|
41
69
|
- !ruby/object:Gem::Dependency
|
|
42
|
-
name:
|
|
70
|
+
name: rake
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: rspec
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - ">="
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '0'
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - ">="
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '0'
|
|
97
|
+
- !ruby/object:Gem::Dependency
|
|
98
|
+
name: rubocop
|
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
|
100
|
+
requirements:
|
|
101
|
+
- - ">="
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: '0'
|
|
104
|
+
type: :development
|
|
105
|
+
prerelease: false
|
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - ">="
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: '0'
|
|
111
|
+
- !ruby/object:Gem::Dependency
|
|
112
|
+
name: rubocop-jekyll
|
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
115
|
+
- - ">="
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: '0'
|
|
118
|
+
type: :development
|
|
119
|
+
prerelease: false
|
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
+
requirements:
|
|
122
|
+
- - ">="
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: '0'
|
|
125
|
+
- !ruby/object:Gem::Dependency
|
|
126
|
+
name: rubocop-rake
|
|
43
127
|
requirement: !ruby/object:Gem::Requirement
|
|
44
128
|
requirements:
|
|
45
129
|
- - ">="
|
|
@@ -66,9 +150,7 @@ dependencies:
|
|
|
66
150
|
- - ">="
|
|
67
151
|
- !ruby/object:Gem::Version
|
|
68
152
|
version: '0'
|
|
69
|
-
description:
|
|
70
|
-
|
|
71
|
-
'
|
|
153
|
+
description: Generates an 'a href' tag, possibly with target='_blank' and rel='nofollow'.
|
|
72
154
|
email:
|
|
73
155
|
- mslinn@mslinn.com
|
|
74
156
|
executables: []
|
|
@@ -76,26 +158,28 @@ extensions: []
|
|
|
76
158
|
extra_rdoc_files: []
|
|
77
159
|
files:
|
|
78
160
|
- ".rubocop.yml"
|
|
161
|
+
- ".ruby-version"
|
|
162
|
+
- ".vscode/launch.json"
|
|
163
|
+
- ".vscode/settings.json"
|
|
79
164
|
- CHANGELOG.md
|
|
165
|
+
- Gemfile
|
|
166
|
+
- Gemfile.lock
|
|
80
167
|
- LICENSE.txt
|
|
81
168
|
- README.md
|
|
82
169
|
- Rakefile
|
|
83
170
|
- jekyll_href.gemspec
|
|
84
171
|
- lib/jekyll_href.rb
|
|
85
172
|
- lib/jekyll_href/version.rb
|
|
86
|
-
|
|
173
|
+
- sig/jekyll_href.rbs
|
|
174
|
+
homepage: https://github.com/mslinn/jekyll_href
|
|
87
175
|
licenses:
|
|
88
176
|
- MIT
|
|
89
177
|
metadata:
|
|
90
|
-
allowed_push_host: https://rubygems.org
|
|
91
|
-
|
|
92
|
-
changelog_uri: https://github.com/mslinn/jekyll_href/CHANGELOG.md
|
|
93
|
-
homepage_uri: https://www.mslinn.com/blog/2020/10/03/jekyll-plugins.html#href
|
|
178
|
+
allowed_push_host: https://rubygems.org/
|
|
179
|
+
homepage_uri: https://github.com/mslinn/jekyll_href
|
|
94
180
|
source_code_uri: https://github.com/mslinn/jekyll_href
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
Thanks for installing jekyll_href!
|
|
98
|
-
|
|
181
|
+
changelog_uri: https://github.com/mslinn/jekyll_href/CHANGELOG.md
|
|
182
|
+
post_install_message:
|
|
99
183
|
rdoc_options: []
|
|
100
184
|
require_paths:
|
|
101
185
|
- lib
|
|
@@ -110,7 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
110
194
|
- !ruby/object:Gem::Version
|
|
111
195
|
version: '0'
|
|
112
196
|
requirements: []
|
|
113
|
-
rubygems_version: 3.
|
|
197
|
+
rubygems_version: 3.2.5
|
|
114
198
|
signing_key:
|
|
115
199
|
specification_version: 4
|
|
116
200
|
summary: Generates an 'a href' tag, possibly with target='_blank' and rel='nofollow'.
|