jekyll_href 1.0.9 → 1.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/jekyll_href.gemspec +3 -2
- data/lib/jekyll_href/version.rb +1 -1
- data/lib/jekyll_href.rb +21 -16
- metadata +10 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33ad179cd8d6770d3828246bdc51cdbe398f7fd3f50b0101481e2dacd597191e
|
4
|
+
data.tar.gz: 543a944799bdb811fd84f3afb4ce0b8239e2008208feb0612360307bd1843c69
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be0fd539b076cedb893cee10a528f4a3c71d2ec01e84c16a26455ec4c4aacded321bc11f96ac8ff5d6647b2cdf3692aba9bb843e419d67c54aab9a47edb63ff9
|
7
|
+
data.tar.gz: f2d3abce3b08922eefa404905d1f61f319150662f891dd03171e716479d16e068e4e2a02b9975b5f609716f942876ee9b7d542d14236dba141fb4fcaa6e3ce66
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
## 1.0.12 / 2022-08-09
|
2
|
+
* No longer abends if `plugin-vars` is not present in `_config.yml`
|
3
|
+
|
4
|
+
## 1.0.11 / 2022-04-27
|
5
|
+
* Suppresses target and rel=nofollow attributes for mailto: links.
|
6
|
+
|
7
|
+
## 1.0.10 / 2022-04-27
|
8
|
+
* Works from pre-computed `site['all_collections']` provided by a new dependency called `jekyll_all_collections`.
|
9
|
+
|
1
10
|
## 1.0.9 / 2022-04-25
|
2
11
|
* Match now looks at all collections, not just posts
|
3
12
|
|
data/jekyll_href.gemspec
CHANGED
@@ -34,11 +34,12 @@ Gem::Specification.new do |spec|
|
|
34
34
|
spec.version = JekyllHrefVersion::VERSION
|
35
35
|
|
36
36
|
spec.add_dependency 'jekyll', '>= 3.5.0'
|
37
|
+
spec.add_dependency 'jekyll_all_collections'
|
37
38
|
spec.add_dependency 'jekyll_plugin_logger'
|
38
39
|
|
39
|
-
spec.add_development_dependency 'debase'
|
40
|
+
# spec.add_development_dependency 'debase'
|
40
41
|
# spec.add_development_dependency 'rubocop-jekyll'
|
41
42
|
# spec.add_development_dependency 'rubocop-rake'
|
42
43
|
# spec.add_development_dependency 'rubocop-rspec'
|
43
|
-
spec.add_development_dependency 'ruby-debug-ide'
|
44
|
+
# spec.add_development_dependency 'ruby-debug-ide'
|
44
45
|
end
|
data/lib/jekyll_href/version.rb
CHANGED
data/lib/jekyll_href.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "jekyll_plugin_logger"
|
4
|
+
require "jekyll_all_collections"
|
4
5
|
require "liquid"
|
5
6
|
require_relative "jekyll_href/version"
|
6
7
|
|
@@ -51,6 +52,7 @@ require_relative "jekyll_href/version"
|
|
51
52
|
# <code>django.core.management.execute_from_command_line</code> %}
|
52
53
|
|
53
54
|
class ExternalHref < Liquid::Tag
|
55
|
+
|
54
56
|
# @param tag_name [String] is the name of the tag, which we already know.
|
55
57
|
# @param command_line [Hash, String, Liquid::Tag::Parser] the arguments from the web page.
|
56
58
|
# @param _parse_context [Liquid::ParseContext] tokenized command line
|
@@ -76,10 +78,15 @@ class ExternalHref < Liquid::Tag
|
|
76
78
|
end
|
77
79
|
|
78
80
|
# Method prescribed by the Jekyll plugin lifecycle.
|
81
|
+
# @param liquid_context [Liquid::Context]
|
79
82
|
# @return [String]
|
80
|
-
def render(
|
81
|
-
|
82
|
-
|
83
|
+
def render(liquid_context)
|
84
|
+
@site = liquid_context.registers[:site]
|
85
|
+
JekyllAllCollections::maybe_compute_all_collections(@site)
|
86
|
+
|
87
|
+
match(liquid_context) if @match
|
88
|
+
link = replace_vars(liquid_context, @link)
|
89
|
+
@target = @follow = "" if link.start_with? "mailto:"
|
83
90
|
@logger.debug { "@link=#{@link}; link=#{link}" }
|
84
91
|
"<a href='#{link}'#{@target}#{@follow}>#{@text}</a>"
|
85
92
|
end
|
@@ -111,9 +118,8 @@ class ExternalHref < Liquid::Tag
|
|
111
118
|
value
|
112
119
|
end
|
113
120
|
|
114
|
-
def match(
|
115
|
-
|
116
|
-
config = site.config['href']
|
121
|
+
def match(liquid_context) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
|
122
|
+
config = @site.config['href']
|
117
123
|
die_if_nomatch = !config.nil? && config['nomatch'] && config['nomatch']=='fatal'
|
118
124
|
|
119
125
|
path, fragment = @link.split('#')
|
@@ -121,16 +127,13 @@ class ExternalHref < Liquid::Tag
|
|
121
127
|
@logger.debug {
|
122
128
|
<<~END_DEBUG
|
123
129
|
@link=#{@link}
|
124
|
-
site.posts[0].url = #{site.posts.docs[0].url}
|
125
|
-
site.posts[0].path = #{site.posts.docs[0].path}
|
130
|
+
@site.posts.docs[0].url = #{@site.posts.docs[0].url}
|
131
|
+
@site.posts.docs[0].path = #{@site.posts.docs[0].path}
|
126
132
|
END_DEBUG
|
127
133
|
}
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
.flatten
|
132
|
-
.map(&:url) # TODO Optimize this by caching the result
|
133
|
-
url_matches = urls.select { |url| url.include? path }
|
134
|
+
|
135
|
+
all_urls = @site.all_collections.map(&:url)
|
136
|
+
url_matches = all_urls.select { |url| url.include? path }
|
134
137
|
case url_matches.length
|
135
138
|
when 0
|
136
139
|
abort "href error: No url matches '#{@link}'" if die_if_nomatch
|
@@ -144,8 +147,10 @@ class ExternalHref < Liquid::Tag
|
|
144
147
|
end
|
145
148
|
end
|
146
149
|
|
147
|
-
def replace_vars(
|
148
|
-
variables =
|
150
|
+
def replace_vars(liquid_context, link)
|
151
|
+
variables = @site.config['plugin-vars']
|
152
|
+
return link unless variables
|
153
|
+
|
149
154
|
variables.each do |name, value|
|
150
155
|
link = link.gsub "{{#{name}}}", value
|
151
156
|
end
|
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.0.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Slinn
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-08-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -25,7 +25,7 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 3.5.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: jekyll_all_collections
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
@@ -39,27 +39,13 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: ruby-debug-ide
|
42
|
+
name: jekyll_plugin_logger
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
58
44
|
requirements:
|
59
45
|
- - ">="
|
60
46
|
- !ruby/object:Gem::Version
|
61
47
|
version: '0'
|
62
|
-
type: :
|
48
|
+
type: :runtime
|
63
49
|
prerelease: false
|
64
50
|
version_requirements: !ruby/object:Gem::Requirement
|
65
51
|
requirements:
|
@@ -68,7 +54,7 @@ dependencies:
|
|
68
54
|
version: '0'
|
69
55
|
description: 'Generates an ''a href'' tag, possibly with target=''_blank'' and rel=''nofollow''.
|
70
56
|
|
71
|
-
'
|
57
|
+
'
|
72
58
|
email:
|
73
59
|
- mslinn@mslinn.com
|
74
60
|
executables: []
|
@@ -110,8 +96,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
96
|
- !ruby/object:Gem::Version
|
111
97
|
version: '0'
|
112
98
|
requirements: []
|
113
|
-
rubygems_version: 3.
|
114
|
-
signing_key:
|
99
|
+
rubygems_version: 3.3.3
|
100
|
+
signing_key:
|
115
101
|
specification_version: 4
|
116
102
|
summary: Generates an 'a href' tag, possibly with target='_blank' and rel='nofollow'.
|
117
103
|
test_files: []
|
104
|
+
...
|