jekyll_href 1.0.14 → 1.1.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 +13 -1
- data/CHANGELOG.md +4 -0
- data/README.md +11 -10
- data/Rakefile +0 -2
- data/jekyll_href.gemspec +18 -26
- data/lib/jekyll_href/version.rb +1 -3
- data/lib/jekyll_href.rb +29 -25
- data/lib/jekyll_tag_helper2.rb +0 -2
- data/spec/href_spec.rb +0 -2
- data/spec/spec_helper.rb +0 -2
- data/spec/status_persistence.txt +13 -13
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0656497a33e45341646549dc55a45747f8418acd5f84298e145134bf7c10eec5'
|
4
|
+
data.tar.gz: 2c938cbc5e5f09bc2b8ea42ea11dde9d28e44e74512d7ebc203bccc2d127a8f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cdbdfe53569e693e1a81cb3e30b773cc239f81ce05f46ad2f20fe638dfef0777ca4cbcafd79ba9faedc9af1bb416f2a9628abbf8d82f423dd66ef36233059402
|
7
|
+
data.tar.gz: 1a74a3ace7f95d965a4db351501b908345257ab6138ab9ad3f4647499230e2d2a24fcd02c17fd0577376c913dc60cb3689b526046097a33a107ccea3ea3ce484
|
data/.rubocop.yml
CHANGED
@@ -21,7 +21,19 @@ Layout/LineLength:
|
|
21
21
|
Layout/MultilineMethodCallIndentation:
|
22
22
|
Enabled: false
|
23
23
|
|
24
|
-
Metrics/
|
24
|
+
Metrics/AbcSize:
|
25
|
+
Max: 25
|
26
|
+
|
27
|
+
Metrics/CyclomaticComplexity:
|
28
|
+
Max: 10
|
29
|
+
|
30
|
+
Metrics/MethodLength:
|
31
|
+
Max: 30
|
32
|
+
|
33
|
+
Metrics/PerceivedComplexity:
|
34
|
+
Max: 10
|
35
|
+
|
36
|
+
Style/FrozenStringLiteralComment:
|
25
37
|
Enabled: false
|
26
38
|
|
27
39
|
Style/PercentLiteralDelimiters:
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -4,14 +4,17 @@
|
|
4
4
|
|
5
5
|
`Jekyll_href` is a Jekyll plugin that provides a new Liquid tag: `href`.
|
6
6
|
It provides a convenient way to generate formatted and clickable URIs.
|
7
|
-
The Liquid tag generates an `a href` HTML tag,
|
7
|
+
The Liquid tag generates an `a href` HTML tag,
|
8
|
+
which by default contains `target="_blank"` and `rel=nofollow`.
|
8
9
|
|
9
10
|
If the url starts with `http`, or the `match` keyword is specified:
|
10
11
|
- The url will open in a new tab or window.
|
11
12
|
- The url will include `rel=nofollow` for SEO purposes.
|
12
13
|
|
13
|
-
CAUTION: if linked text contains a single or double quote
|
14
|
-
|
14
|
+
CAUTION: if linked text contains a single or double quote,
|
15
|
+
you will see the error message: `Liquid Exception: Unmatched quote`.
|
16
|
+
Instead, use ' (`'`), " (`"`), ‘ (`‘`),
|
17
|
+
’ (`’`), “ (`“`), and ” (`”`)
|
15
18
|
|
16
19
|
In `_config.yml`, if a section called `plugin-vars` exists,
|
17
20
|
then its name/value pairs are available for substitution.
|
@@ -131,7 +134,8 @@ The `match` option looks through the pages collection for a URL with containing
|
|
131
134
|
|
132
135
|
|
133
136
|
## Additional Information
|
134
|
-
More information is available on my
|
137
|
+
More information is available on my website about
|
138
|
+
[my Jekyll plugins](https://www.mslinn.com/blog/2020/10/03/jekyll-plugins.html).
|
135
139
|
|
136
140
|
|
137
141
|
## Installation
|
@@ -148,10 +152,6 @@ And then execute:
|
|
148
152
|
|
149
153
|
$ bundle install
|
150
154
|
|
151
|
-
Or install it yourself as:
|
152
|
-
|
153
|
-
$ gem install jekyll_href
|
154
|
-
|
155
155
|
|
156
156
|
## Generated HTML
|
157
157
|
|
@@ -223,7 +223,8 @@ Which renders as: [`mslinn.com`](https://mslinn.com)
|
|
223
223
|
|
224
224
|
## Development
|
225
225
|
|
226
|
-
After checking out the repo, run `bin/setup` to install dependencies.
|
226
|
+
After checking out the repo, run `bin/setup` to install dependencies.
|
227
|
+
You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
227
228
|
|
228
229
|
Install development dependencies like this:
|
229
230
|
```
|
@@ -236,7 +237,7 @@ $ bundle exec rake install
|
|
236
237
|
```
|
237
238
|
|
238
239
|
## Test
|
239
|
-
A test
|
240
|
+
A test website is provided in the `demo` directory.
|
240
241
|
1. Set breakpoints.
|
241
242
|
|
242
243
|
2. Initiate a debug session from the command line:
|
data/Rakefile
CHANGED
data/jekyll_href.gemspec
CHANGED
@@ -1,47 +1,39 @@
|
|
1
|
-
|
1
|
+
require_relative 'lib/jekyll_href/version'
|
2
2
|
|
3
|
-
|
3
|
+
Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
|
4
|
+
github = 'https://github.com/mslinn/jekyll_href'
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
spec.authors = ["Mike Slinn"]
|
9
|
-
spec.bindir = "exe"
|
6
|
+
spec.authors = ['Mike Slinn']
|
7
|
+
spec.bindir = 'exe'
|
10
8
|
spec.description = <<~END_OF_DESC
|
11
9
|
Generates an 'a href' tag, possibly with target='_blank' and rel='nofollow'.
|
12
10
|
END_OF_DESC
|
13
|
-
spec.email = [
|
14
|
-
spec.files = Dir[
|
15
|
-
spec.homepage =
|
16
|
-
spec.license =
|
11
|
+
spec.email = ['mslinn@mslinn.com']
|
12
|
+
spec.files = Dir['.rubocop.yml', 'LICENSE.*', 'Rakefile', '{lib,spec}/**/*', '*.gemspec', '*.md']
|
13
|
+
spec.homepage = 'https://www.mslinn.com/blog/2020/10/03/jekyll-plugins.html#href'
|
14
|
+
spec.license = 'MIT'
|
17
15
|
spec.metadata = {
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
16
|
+
'allowed_push_host' => 'https://rubygems.org',
|
17
|
+
'bug_tracker_uri' => "#{github}/issues",
|
18
|
+
'changelog_uri' => "#{github}/CHANGELOG.md",
|
19
|
+
'homepage_uri' => spec.homepage,
|
20
|
+
'source_code_uri' => github,
|
23
21
|
}
|
24
|
-
spec.name =
|
22
|
+
spec.name = 'jekyll_href'
|
25
23
|
spec.post_install_message = <<~END_MESSAGE
|
26
24
|
|
27
25
|
Thanks for installing #{spec.name}!
|
28
26
|
|
29
27
|
END_MESSAGE
|
30
|
-
spec.require_paths = [
|
31
|
-
spec.required_ruby_version =
|
28
|
+
spec.require_paths = ['lib']
|
29
|
+
spec.required_ruby_version = '>= 2.6.0'
|
32
30
|
spec.summary = "Generates an 'a href' tag, possibly with target='_blank' and rel='nofollow'."
|
33
31
|
spec.test_files = spec.files.grep(%r!^(test|spec|features)/!)
|
34
32
|
spec.version = JekyllHrefVersion::VERSION
|
35
33
|
|
36
34
|
spec.add_dependency 'jekyll', '>= 3.5.0'
|
37
|
-
spec.add_dependency 'jekyll_all_collections'
|
35
|
+
spec.add_dependency 'jekyll_all_collections', '>= 0.2.0'
|
38
36
|
spec.add_dependency 'jekyll_plugin_logger'
|
39
37
|
spec.add_dependency 'key-value-parser'
|
40
38
|
spec.add_dependency 'shellwords'
|
41
|
-
|
42
|
-
# spec.add_development_dependency 'debase'
|
43
|
-
# spec.add_development_dependency 'rubocop-jekyll'
|
44
|
-
# spec.add_development_dependency 'rubocop-rake'
|
45
|
-
# spec.add_development_dependency 'rubocop-rspec'
|
46
|
-
# spec.add_development_dependency 'ruby-debug-ide'
|
47
39
|
end
|
data/lib/jekyll_href/version.rb
CHANGED
data/lib/jekyll_href.rb
CHANGED
@@ -1,9 +1,7 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require
|
4
|
-
|
5
|
-
require "liquid"
|
6
|
-
require_relative "jekyll_href/version"
|
1
|
+
require 'jekyll_all_collections'
|
2
|
+
require 'jekyll_plugin_logger'
|
3
|
+
require 'liquid'
|
4
|
+
require_relative 'jekyll_href/version'
|
7
5
|
require_relative './jekyll_tag_helper2'
|
8
6
|
|
9
7
|
# @author Copyright 2020 Michael Slinn
|
@@ -49,8 +47,10 @@ class ExternalHref < Liquid::Tag # rubocop:disable Metrics/ClassLength
|
|
49
47
|
|
50
48
|
private
|
51
49
|
|
52
|
-
|
53
|
-
|
50
|
+
# Does not look at or compute @link
|
51
|
+
def compute_linkk
|
52
|
+
return @link if @link
|
53
|
+
|
54
54
|
linkk = @url
|
55
55
|
if linkk.nil? || !linkk
|
56
56
|
linkk = @helper.argv&.shift
|
@@ -63,7 +63,7 @@ class ExternalHref < Liquid::Tag # rubocop:disable Metrics/ClassLength
|
|
63
63
|
linkk
|
64
64
|
end
|
65
65
|
|
66
|
-
def dump_linkk_relations(linkk)
|
66
|
+
def dump_linkk_relations(linkk)
|
67
67
|
msg = <<~END_MESSAGE
|
68
68
|
jekyll_href error: no url was provided on #{@path}:#{@line_number}.
|
69
69
|
@helper.markup=#{@helper.markup}
|
@@ -77,14 +77,14 @@ class ExternalHref < Liquid::Tag # rubocop:disable Metrics/ClassLength
|
|
77
77
|
abort msg.red
|
78
78
|
end
|
79
79
|
|
80
|
-
def globals_initial(liquid_context)
|
80
|
+
def globals_initial(liquid_context)
|
81
81
|
# Sets @follow, @helper, @match, @page, @path, @site, @target, @url
|
82
82
|
@helper.liquid_context = liquid_context
|
83
83
|
|
84
84
|
@page = liquid_context.registers[:page]
|
85
85
|
@path = @page['path']
|
86
86
|
@site = liquid_context.registers[:site]
|
87
|
-
|
87
|
+
AllCollectionsHooks.compute(@site)
|
88
88
|
|
89
89
|
@follow = @helper.parameter_specified?('follow') ? '' : " rel='nofollow'"
|
90
90
|
@match = @helper.parameter_specified?('match')
|
@@ -94,8 +94,8 @@ class ExternalHref < Liquid::Tag # rubocop:disable Metrics/ClassLength
|
|
94
94
|
@url = @helper.parameter_specified?('url')
|
95
95
|
end
|
96
96
|
|
97
|
-
|
98
|
-
|
97
|
+
# Might set @follow, @linkk, @target, and @text
|
98
|
+
def globals_update(tokens, linkk)
|
99
99
|
if linkk.start_with? 'mailto:'
|
100
100
|
@link = linkk
|
101
101
|
@target = @follow = ''
|
@@ -106,7 +106,7 @@ class ExternalHref < Liquid::Tag # rubocop:disable Metrics/ClassLength
|
|
106
106
|
end
|
107
107
|
return
|
108
108
|
else
|
109
|
-
@text = tokens.join(
|
109
|
+
@text = tokens.join(' ').strip
|
110
110
|
if @text.to_s.empty?
|
111
111
|
@text = "<code>#{linkk}</code>"
|
112
112
|
@link = "https://#{linkk}"
|
@@ -115,7 +115,7 @@ class ExternalHref < Liquid::Tag # rubocop:disable Metrics/ClassLength
|
|
115
115
|
end
|
116
116
|
end
|
117
117
|
|
118
|
-
return if @link.start_with?
|
118
|
+
return if @link.start_with? 'http'
|
119
119
|
|
120
120
|
@follow = ''
|
121
121
|
@target = '' unless @blank
|
@@ -127,11 +127,11 @@ class ExternalHref < Liquid::Tag # rubocop:disable Metrics/ClassLength
|
|
127
127
|
@target = '' unless @blank
|
128
128
|
end
|
129
129
|
|
130
|
-
|
131
|
-
|
130
|
+
# Might set @link and @text
|
131
|
+
def match_post
|
132
132
|
config = @site.config['href']
|
133
|
-
die_if_nomatch = !config.nil? && config['nomatch'] && config['nomatch'] == 'fatal'
|
134
|
-
path, fragment = @link.split('#')
|
133
|
+
@die_if_nomatch = !config.nil? && config['nomatch'] && config['nomatch'] == 'fatal'
|
134
|
+
@path, @fragment = @link.split('#')
|
135
135
|
|
136
136
|
@logger.debug do
|
137
137
|
<<~END_DEBUG
|
@@ -142,22 +142,26 @@ class ExternalHref < Liquid::Tag # rubocop:disable Metrics/ClassLength
|
|
142
142
|
end
|
143
143
|
|
144
144
|
all_urls = @site.all_collections.map(&:url)
|
145
|
-
|
145
|
+
compute_link_and_text(all_urls)
|
146
|
+
end
|
147
|
+
|
148
|
+
def compute_link_and_text(all_urls)
|
149
|
+
url_matches = all_urls.select { |url| url&.include? @path }
|
146
150
|
case url_matches.length
|
147
151
|
when 0
|
148
|
-
abort "href error: No url matches '#{@link}'" if die_if_nomatch
|
149
|
-
@link =
|
152
|
+
abort "href error: No url matches '#{@link}'" if @die_if_nomatch
|
153
|
+
@link = '#'
|
150
154
|
@text = "<i>#{@link} is not available</i>"
|
151
155
|
when 1
|
152
156
|
@link = url_matches.first
|
153
|
-
@link = "#{@link}\##{fragment}" if fragment
|
157
|
+
@link = "#{@link}\##{@fragment}" if @fragment
|
154
158
|
else
|
155
|
-
abort "Error: More than one url matched '#{path}': #{url_matches.join(
|
159
|
+
abort "Error: More than one url matched '#{@path}': #{url_matches.join(', ')}"
|
156
160
|
end
|
157
161
|
end
|
158
162
|
|
163
|
+
# Replace names in plugin-vars with values
|
159
164
|
def replace_vars(text)
|
160
|
-
# Replace names in plugin-vars with values
|
161
165
|
variables = @site.config['plugin-vars']
|
162
166
|
return text unless variables
|
163
167
|
|
data/lib/jekyll_tag_helper2.rb
CHANGED
data/spec/href_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
data/spec/status_persistence.txt
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
example_id | status | run_time |
|
2
2
|
----------------------------------------------------------------- | ------ | --------------- |
|
3
|
-
/mnt/
|
4
|
-
/mnt/
|
5
|
-
/mnt/
|
6
|
-
/mnt/
|
7
|
-
/mnt/
|
8
|
-
/mnt/
|
9
|
-
/mnt/
|
10
|
-
/mnt/
|
11
|
-
/mnt/
|
12
|
-
/mnt/
|
13
|
-
/mnt/
|
14
|
-
/mnt/
|
15
|
-
/mnt/
|
3
|
+
/mnt/_/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:1] | passed | 0.00581 seconds |
|
4
|
+
/mnt/_/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:2] | passed | 0.00416 seconds |
|
5
|
+
/mnt/_/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:3] | passed | 0.00401 seconds |
|
6
|
+
/mnt/_/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:4] | passed | 0.00384 seconds |
|
7
|
+
/mnt/_/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:5] | passed | 0.00401 seconds |
|
8
|
+
/mnt/_/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:6] | passed | 0.00405 seconds |
|
9
|
+
/mnt/_/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:7] | passed | 0.00501 seconds |
|
10
|
+
/mnt/_/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:8] | passed | 0.00461 seconds |
|
11
|
+
/mnt/_/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:9] | passed | 0.00397 seconds |
|
12
|
+
/mnt/_/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:10] | passed | 0.0039 seconds |
|
13
|
+
/mnt/_/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:11] | passed | 0.00404 seconds |
|
14
|
+
/mnt/_/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:12] | passed | 0.00427 seconds |
|
15
|
+
/mnt/_/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:13] | passed | 0.0041 seconds |
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.1.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-02-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 0.2.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 0.2.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: jekyll_plugin_logger
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|