jekyll_href 1.2.6 → 1.2.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -3
- data/CHANGELOG.md +107 -43
- data/README.md +197 -99
- data/jekyll_href.gemspec +2 -2
- data/lib/enums.rb +21 -0
- data/lib/hash_array.rb +5 -1
- data/lib/href_match.rb +38 -0
- data/lib/href_page_title.rb +34 -0
- data/lib/href_private.rb +155 -0
- data/lib/href_summary.rb +39 -0
- data/lib/href_summary_tag.rb +17 -6
- data/lib/href_tag.rb +26 -196
- data/lib/jekyll_href/version.rb +1 -1
- data/lib/jekyll_href.rb +2 -3
- data/spec/{hash_array_spec.rb → hash_array_spec/hash_array_spec.rb} +1 -1
- data/spec/spec_helper.rb +0 -2
- data/spec/status_persistence.txt +13 -13
- metadata +12 -7
data/lib/href_private.rb
ADDED
@@ -0,0 +1,155 @@
|
|
1
|
+
module MSlinn
|
2
|
+
class HRefTag
|
3
|
+
private
|
4
|
+
|
5
|
+
# Does not look at or compute @link
|
6
|
+
def compute_linkk
|
7
|
+
return @link, nil if @link
|
8
|
+
|
9
|
+
linkk = @url
|
10
|
+
if linkk.nil? || !linkk
|
11
|
+
linkk = @helper.argv&.shift
|
12
|
+
@helper.params&.shift
|
13
|
+
@helper.keys_values&.delete linkk
|
14
|
+
return nil, error_no_uri if linkk.nil?
|
15
|
+
elsif @url.to_s.empty?
|
16
|
+
return nil, error_no_uri
|
17
|
+
end
|
18
|
+
[linkk, nil]
|
19
|
+
rescue HRefError => e
|
20
|
+
[nil, e]
|
21
|
+
end
|
22
|
+
|
23
|
+
def error_no_uri
|
24
|
+
msg = <<~END_MESSAGE
|
25
|
+
No URL was provided on #{@path}:#{@line_number} (after front matter).
|
26
|
+
<pre>{% href #{@argument_string.strip} %}</pre>
|
27
|
+
END_MESSAGE
|
28
|
+
@logger.error { JekyllPluginHelper.remove_html_tags msg.strip }
|
29
|
+
"<div class='href_error'>HRefError: #{msg}</div>"
|
30
|
+
end
|
31
|
+
|
32
|
+
# Sets @follow, @helper, @match, @path, @target, @url, @hyphenation
|
33
|
+
def globals_initial
|
34
|
+
@path = @page['path']
|
35
|
+
AllCollectionsHooks.compute @site
|
36
|
+
@hyphenation = Hyphenation::NONE
|
37
|
+
|
38
|
+
@blank = @helper.parameter_specified? 'blank'
|
39
|
+
@klass = @helper.parameter_specified? 'class'
|
40
|
+
@follow_specified = @helper.parameter_specified?('follow')
|
41
|
+
@follow = @follow_specified ? '' : ' rel="nofollow"'
|
42
|
+
@label = @helper.parameter_specified? 'label'
|
43
|
+
@match = @helper.parameter_specified? 'match'
|
44
|
+
@hyphenation = Hyphenation::SHY if @helper.parameter_specified? 'shy'
|
45
|
+
@style = @helper.parameter_specified? 'style'
|
46
|
+
@summary = @helper.parameter_specified? 'summary'
|
47
|
+
@summary_exclude = @helper.parameter_specified? 'summary_exclude'
|
48
|
+
@target = @blank ? " target='_blank'" : nil
|
49
|
+
@target ||= @helper.parameter_specified?('notarget') ? '' : " target='_blank'"
|
50
|
+
@url = @helper.parameter_specified? 'url'
|
51
|
+
|
52
|
+
if @helper.parameter_specified? 'wbr' # <wbr> has precedence over ­
|
53
|
+
if @hyphenation == Hyphenation::SHY
|
54
|
+
@logger.info do
|
55
|
+
"Warning: wbr and shy were both specified for the href tag on line #{@line_number} (after front matter) of #{@page['path']}"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
@hyphenation = Hyphenation::WBR
|
59
|
+
end
|
60
|
+
|
61
|
+
@label_source = if @helper.parameter_specified? 'page_title'
|
62
|
+
LabelSource::FROM_PAGE_TITLE
|
63
|
+
elsif @label
|
64
|
+
LabelSource::FROM_EXPLICIT_LABEL
|
65
|
+
else
|
66
|
+
LabelSource::FROM_IMPLICIT_LABEL
|
67
|
+
end
|
68
|
+
|
69
|
+
return unless @tag_config
|
70
|
+
|
71
|
+
@die_on_href_error = @tag_config['die_on_href_error'] == true
|
72
|
+
@die_on_nomatch = @tag_config['die_on_nomatch'] == true
|
73
|
+
@pry_on_href_error = @tag_config['pry_on_href_error'] == true
|
74
|
+
end
|
75
|
+
|
76
|
+
# Sets @link_type
|
77
|
+
# Might set @follow, @link, @link_save and @text
|
78
|
+
def globals_update(tokens, linkk)
|
79
|
+
@link_type = LinkType::UNKNOWN
|
80
|
+
|
81
|
+
if linkk.start_with? 'mailto:'
|
82
|
+
handle_mailto linkk
|
83
|
+
return
|
84
|
+
end
|
85
|
+
|
86
|
+
@link_type = if linkk.start_with? 'http'
|
87
|
+
LinkType::EXTERNAL
|
88
|
+
elsif linkk.start_with? '#'
|
89
|
+
LinkType::FRAGMENT
|
90
|
+
else
|
91
|
+
LinkType::LOCAL
|
92
|
+
end
|
93
|
+
|
94
|
+
@follow = !@follow_specified && @link_type == LinkType::EXTERNAL ? ' rel="nofollow"' : ''
|
95
|
+
|
96
|
+
handle_page_title linkk if @label_source == LabelSource::FROM_PAGE_TITLE
|
97
|
+
@text = @label || tokens.join(' ').strip
|
98
|
+
@link = if @text.to_s.empty?
|
99
|
+
handle_empty_text linkk
|
100
|
+
else
|
101
|
+
linkk
|
102
|
+
end
|
103
|
+
@link_save = @link
|
104
|
+
return if @link_type == LinkType::EXTERNAL
|
105
|
+
|
106
|
+
@follow = @target = ''
|
107
|
+
nil
|
108
|
+
end
|
109
|
+
|
110
|
+
# Sets @text and @link
|
111
|
+
def handle_empty_text(linkk)
|
112
|
+
text = hyphenate linkk
|
113
|
+
@text = "<code>#{text}</code>"
|
114
|
+
@link = if linkk.start_with? '#'
|
115
|
+
linkk
|
116
|
+
elsif insecure_ip_address linkk
|
117
|
+
"http://#{linkk}"
|
118
|
+
else
|
119
|
+
"https://#{linkk}"
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
def handle_mailto(linkk)
|
124
|
+
@link_type = LinkType::MAILTO
|
125
|
+
@link = linkk
|
126
|
+
@target = @follow = ''
|
127
|
+
@text = @label || @helper.argv.join(' ')
|
128
|
+
return unless @text.empty?
|
129
|
+
|
130
|
+
text = hyphenate(linkk.delete_prefix('mailto:'))
|
131
|
+
@text = "<code>#{text}</code>"
|
132
|
+
end
|
133
|
+
|
134
|
+
def hyphenate(linkk)
|
135
|
+
if @hyphenation == Hyphenation::WBR
|
136
|
+
linkk&.gsub('/', '/<wbr>')
|
137
|
+
elsif @hyphenation == Hyphenation::SHY
|
138
|
+
linkk&.gsub('/', '/­')
|
139
|
+
else
|
140
|
+
linkk
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
def insecure_ip_address(string)
|
145
|
+
return true if string.start_with?('localhost', 'http://localhost')
|
146
|
+
|
147
|
+
return false unless IPAddress.valid? string
|
148
|
+
|
149
|
+
ip_address = IPAddress string
|
150
|
+
true if ip_address.loopback? || ip_address.private?
|
151
|
+
ensure
|
152
|
+
false
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
data/lib/href_summary.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
module MSlinn
|
2
|
+
class HRefTag
|
3
|
+
private
|
4
|
+
|
5
|
+
def save_summary
|
6
|
+
return if @summary_exclude || @link_save.start_with?('mailto:') || @link_save.start_with?('#')
|
7
|
+
|
8
|
+
@summary = @summary.to_s.empty? ? @text : @summary.to_s
|
9
|
+
if @summary.to_s == 'true'
|
10
|
+
warning = <<~END_WARNING
|
11
|
+
Warning: The 'summary' href plugin keyword option was detected in the link text for #{@path} on line #{line_number}.
|
12
|
+
The href tag will not be included in the summary, and the link text will not have the word summary included.
|
13
|
+
This is probably unintentional. Consider using the label option to correct this problem."
|
14
|
+
END_WARNING
|
15
|
+
puts warning.red
|
16
|
+
return
|
17
|
+
end
|
18
|
+
return if @summary.class != String || @summary.empty?
|
19
|
+
|
20
|
+
@summary = @summary[0].upcase + @summary[1..]
|
21
|
+
@summary_href = "<a href='#{@link_save}'#{@target}#{@follow}>#{@summary}</a>"
|
22
|
+
mini_href = MiniHref.new(
|
23
|
+
follow: @follow,
|
24
|
+
html: @summary_href,
|
25
|
+
line_number: @line_number,
|
26
|
+
link: @link_save,
|
27
|
+
link_save: @link_save,
|
28
|
+
path: @path,
|
29
|
+
summary_exclude: @summary_exclude,
|
30
|
+
summary_href: @summary_href
|
31
|
+
)
|
32
|
+
if @link_save.start_with? 'http'
|
33
|
+
add_global_link_for_page mini_href
|
34
|
+
else
|
35
|
+
add_local_link_for_page mini_href
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/href_summary_tag.rb
CHANGED
@@ -2,8 +2,8 @@ require 'jekyll_plugin_logger'
|
|
2
2
|
require 'jekyll_plugin_support'
|
3
3
|
require_relative 'jekyll_href/version'
|
4
4
|
|
5
|
-
module
|
6
|
-
class HrefSummary < JekyllSupport::JekyllTag
|
5
|
+
module MSlinn
|
6
|
+
class HrefSummary < JekyllSupport::JekyllTag
|
7
7
|
include JekyllHrefVersion
|
8
8
|
|
9
9
|
# Class instance variables accumulate hrefs across invocations.
|
@@ -28,6 +28,11 @@ module HrefSummaryTag
|
|
28
28
|
def render_impl
|
29
29
|
@helper.gem_file __FILE__ # Enables attribution
|
30
30
|
@include_local = @helper.parameter_specified? 'include_local'
|
31
|
+
|
32
|
+
@die_on_href_error = @tag_config['die_on_href_error'] == true if @tag_config
|
33
|
+
@pry_on_href_error = @tag_config['pry_on_href_error'] == true if @tag_config
|
34
|
+
|
35
|
+
@path = @page['path']
|
31
36
|
global_refs = render_global_refs
|
32
37
|
local_refs = render_local_refs
|
33
38
|
have_refs = !(global_refs + local_refs).empty?
|
@@ -36,12 +41,19 @@ module HrefSummaryTag
|
|
36
41
|
#{local_refs}
|
37
42
|
#{@helper.attribute if @helper.attribution && have_refs}
|
38
43
|
END_RENDER
|
44
|
+
rescue HRefError => e # jekyll_plugin_support handles StandardError
|
45
|
+
e.shorten_backtrace
|
46
|
+
msg = format_error_message e.message
|
47
|
+
@logger.error "#{e.class} raised #{msg}"
|
48
|
+
binding.pry if @pry_on_img_error # rubocop:disable Lint/Debugger
|
49
|
+
raise e if @die_on_href_error
|
50
|
+
|
51
|
+
"<div class='href_error'>#{e.class} raised in #{self.class};\n#{msg}</div>"
|
39
52
|
end
|
40
53
|
|
41
54
|
def render_global_refs
|
42
55
|
hrefs = HashArray.instance_variable_get(:@global_hrefs)
|
43
|
-
|
44
|
-
entries = hrefs[path]&.select { |h| h.path == path }
|
56
|
+
entries = hrefs[@path]&.select { |h| h.path == @path }
|
45
57
|
return '' if entries.nil? || entries.empty?
|
46
58
|
|
47
59
|
summaries = entries.map { |href| "<li>#{href.summary_href}</li>" }
|
@@ -61,8 +73,7 @@ module HrefSummaryTag
|
|
61
73
|
return '' unless @include_local
|
62
74
|
|
63
75
|
hrefs = HashArray.instance_variable_get(:@local_hrefs)
|
64
|
-
|
65
|
-
entries = hrefs[path]&.select { |h| h.path == path }
|
76
|
+
entries = hrefs[@path]&.select { |h| h.path == @path }
|
66
77
|
return '' if entries.nil? || entries.empty?
|
67
78
|
|
68
79
|
summary = entries.map { |href| "<li>#{href.summary_href}</li>" }
|
data/lib/href_tag.rb
CHANGED
@@ -3,7 +3,7 @@ require 'jekyll_all_collections'
|
|
3
3
|
require 'jekyll_plugin_logger'
|
4
4
|
require 'jekyll_plugin_support'
|
5
5
|
require 'liquid'
|
6
|
-
|
6
|
+
require_relative 'enums'
|
7
7
|
require_relative 'jekyll_href/version'
|
8
8
|
require_relative 'hash_array'
|
9
9
|
|
@@ -11,11 +11,13 @@ require_relative 'hash_array'
|
|
11
11
|
# @license SPDX-License-Identifier: Apache-2.0
|
12
12
|
# Generates an href.
|
13
13
|
|
14
|
-
module
|
14
|
+
module MSlinn
|
15
15
|
MiniHref = Struct.new(:follow, :html, :link, :line_number, :link_save, :path, :summary_exclude, :summary_href, keyword_init: true)
|
16
16
|
|
17
|
+
HRefError = JekyllSupport.define_error
|
18
|
+
|
17
19
|
# Implements href Jekyll tag
|
18
|
-
class
|
20
|
+
class HRefTag < JekyllSupport::JekyllTag
|
19
21
|
attr_reader :follow, :helper, :line_number, :link_save, :match, :page, :path, :site,
|
20
22
|
:summary, :summary_exclude, :summary_href, :target, :text, :url
|
21
23
|
attr_accessor :link
|
@@ -30,10 +32,6 @@ module HrefTag
|
|
30
32
|
[follow, match, path, target, text] <=> [other.follow, other.match, other.path, other.target, other.text]
|
31
33
|
end
|
32
34
|
|
33
|
-
def to_s
|
34
|
-
"On line #{line_number} of #{path}: #{follow} #{match} #{target} #{link} => '#{text}'"
|
35
|
-
end
|
36
|
-
|
37
35
|
# Method prescribed by the Jekyll plugin lifecycle.
|
38
36
|
# @param liquid_context [Liquid::Context]
|
39
37
|
# @return [String]
|
@@ -42,207 +40,39 @@ module HrefTag
|
|
42
40
|
linkk, error_msg = compute_linkk
|
43
41
|
return error_msg unless linkk
|
44
42
|
|
45
|
-
linkk
|
46
|
-
linkk.delete_prefix('./') # normalize relative links
|
43
|
+
linkk.delete_prefix './' # normalize relative links
|
47
44
|
@url = linkk if @url
|
48
45
|
@link_save = linkk
|
46
|
+
|
49
47
|
@helper_save = @helper.clone
|
50
48
|
globals_update(@helper.argv, linkk) # Sets @link and @text, might clear @follow and @target
|
51
|
-
handle_match if @match
|
49
|
+
handle_match(@link) if @match
|
50
|
+
raise HrefError, "@link_type was not set" if @link_type == LinkType::UNKNOWN
|
51
|
+
|
52
52
|
save_summary
|
53
53
|
klass = " class='#{@klass}'" if @klass
|
54
54
|
style = " style='#{@style}'" if @style
|
55
55
|
"<a href='#{@link}'#{klass}#{style}#{@target}#{@follow}>#{@text}</a>"
|
56
|
+
rescue HRefError => e # jekyll_plugin_support handles StandardError
|
57
|
+
msg = format_error_message "#{e.message}\n<pre> {% href #{@argument_string.strip} %}</pre>"
|
58
|
+
@text = "<div class='href_error'>#{msg}</div>"
|
59
|
+
e.shorten_backtrace
|
60
|
+
@logger.error "#{e.class} raised #{msg}"
|
61
|
+
binding.pry if @pry_on_img_error # rubocop:disable Lint/Debugger
|
62
|
+
raise e if @die_on_href_error
|
63
|
+
|
64
|
+
"<div class='href_error'>#{e.class} raised in #{self.class};\n#{msg}</div>"
|
56
65
|
end
|
57
66
|
|
58
|
-
|
59
|
-
|
60
|
-
def save_summary
|
61
|
-
return if @summary_exclude || @link_save.start_with?('mailto:') || @link_save.start_with?('#')
|
62
|
-
|
63
|
-
@summary = @summary.to_s.empty? ? @text : @summary.to_s
|
64
|
-
if @summary == true
|
65
|
-
warning = <<~END_WARNING
|
66
|
-
Warning: a href plugin keyword option was detected in the link text for #{@path} on line #{line_number}.
|
67
|
-
The href tag will not be included in the summary, and the link text will not have the word summary included.
|
68
|
-
This is probably unintentional. Consider using the label option to correct this problem."
|
69
|
-
END_WARNING
|
70
|
-
puts warning.red
|
71
|
-
return
|
72
|
-
end
|
73
|
-
return if @summary.class != String || @summary.empty?
|
74
|
-
|
75
|
-
@summary = @summary[0].upcase + @summary[1..]
|
76
|
-
@summary_href = "<a href='#{@link_save}'#{@target}#{@follow}>#{@summary}</a>"
|
77
|
-
mini_href = MiniHref.new(
|
78
|
-
follow: @follow,
|
79
|
-
html: @summary_href,
|
80
|
-
line_number: @line_number,
|
81
|
-
link: @link_save,
|
82
|
-
link_save: @link_save,
|
83
|
-
path: @path,
|
84
|
-
summary_exclude: @summary_exclude,
|
85
|
-
summary_href: @summary_href
|
86
|
-
)
|
87
|
-
if @link_save.start_with? 'http'
|
88
|
-
add_global_link_for_page mini_href
|
89
|
-
else
|
90
|
-
add_local_link_for_page mini_href
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
# Does not look at or compute @link
|
95
|
-
def compute_linkk
|
96
|
-
return @link, nil if @link
|
97
|
-
|
98
|
-
linkk = @url
|
99
|
-
if linkk.nil? || !linkk
|
100
|
-
linkk = @helper.argv&.shift
|
101
|
-
@helper.params&.shift
|
102
|
-
@helper.keys_values&.delete(linkk)
|
103
|
-
return nil, error_no_uri if linkk.nil?
|
104
|
-
elsif @url.to_s.empty?
|
105
|
-
return nil, error_no_uri
|
106
|
-
end
|
107
|
-
[linkk, nil]
|
108
|
-
end
|
109
|
-
|
110
|
-
def error_no_uri
|
111
|
-
msg = <<~END_MESSAGE
|
112
|
-
Error: no url was provided on #{@path}:#{@line_number} (after front matter).
|
113
|
-
<pre>{% href #{@argument_string}%}</pre>
|
114
|
-
END_MESSAGE
|
115
|
-
@logger.error { Sanitize.fragment msg }
|
116
|
-
"<span class='error'>Error: #{msg}</span>"
|
117
|
-
end
|
118
|
-
|
119
|
-
# Sets @follow, @helper, @match, @path, @shy, @target, @url, @wbr
|
120
|
-
def globals_initial
|
121
|
-
@path = @page['path']
|
122
|
-
AllCollectionsHooks.compute(@site)
|
123
|
-
|
124
|
-
@blank = @helper.parameter_specified? 'blank'
|
125
|
-
@klass = @helper.parameter_specified? 'class'
|
126
|
-
@follow = @helper.parameter_specified?('follow') ? '' : " rel='nofollow'"
|
127
|
-
@match = @helper.parameter_specified? 'match'
|
128
|
-
@label = @helper.parameter_specified? 'label'
|
129
|
-
@summary_exclude = @helper.parameter_specified? 'summary_exclude'
|
130
|
-
@shy = @helper.parameter_specified? 'shy'
|
131
|
-
@style = @helper.parameter_specified? 'style'
|
132
|
-
@summary = @helper.parameter_specified? 'summary'
|
133
|
-
@target = @blank ? " target='_blank'" : nil
|
134
|
-
@target ||= @helper.parameter_specified?('notarget') ? '' : " target='_blank'"
|
135
|
-
@url = @helper.parameter_specified? 'url'
|
136
|
-
@wbr = @helper.parameter_specified? 'wbr'
|
137
|
-
end
|
138
|
-
|
139
|
-
# Might set @follow, @linkk, @target, and @text
|
140
|
-
def globals_update(tokens, linkk)
|
141
|
-
if linkk.start_with? 'mailto:'
|
142
|
-
@link = linkk
|
143
|
-
@target = @follow = ''
|
144
|
-
@text = @helper.argv.join(' ')
|
145
|
-
if @text.empty?
|
146
|
-
text = linkk.delete_prefix('mailto:')
|
147
|
-
@text = "<code>#{text}</code>"
|
148
|
-
end
|
149
|
-
return
|
150
|
-
else
|
151
|
-
@text = @label || tokens.join(' ').strip
|
152
|
-
if @text.to_s.empty?
|
153
|
-
text = linkk
|
154
|
-
text = linkk.gsub('/', '/­') if @shy
|
155
|
-
text = linkk.gsub('/', '/<wbr>') if @wbr
|
156
|
-
@text = "<code>#{text}</code>"
|
157
|
-
@link = if linkk.start_with?('http')
|
158
|
-
linkk
|
159
|
-
elsif insecure_ip_address linkk
|
160
|
-
"http://#{linkk}"
|
161
|
-
else
|
162
|
-
"https://#{linkk}"
|
163
|
-
end
|
164
|
-
else
|
165
|
-
@link = if @shy
|
166
|
-
linkk.gsub('/', '/­')
|
167
|
-
elsif @wbr
|
168
|
-
linkk.gsub('/', '/<wbr>')
|
169
|
-
else
|
170
|
-
linkk
|
171
|
-
end
|
172
|
-
end
|
173
|
-
@link_save = @link
|
174
|
-
end
|
175
|
-
|
176
|
-
return if @link.start_with? 'http'
|
177
|
-
|
178
|
-
@follow = ''
|
179
|
-
@target = '' unless @blank
|
180
|
-
end
|
181
|
-
|
182
|
-
def handle_match
|
183
|
-
match_post
|
184
|
-
@follow = ''
|
185
|
-
@target = '' unless @blank
|
186
|
-
end
|
187
|
-
|
188
|
-
# Might set @link and @text
|
189
|
-
def match_post
|
190
|
-
config = @site.config['href']
|
191
|
-
@die_if_nomatch = !config.nil? && config['nomatch'] && config['nomatch'] == 'fatal'
|
192
|
-
@path, @fragment = @link.split('#')
|
193
|
-
|
194
|
-
@logger.debug do
|
195
|
-
<<~END_DEBUG
|
196
|
-
@link=#{@link}
|
197
|
-
@site.posts.docs[0].url = #{@site.posts.docs[0].url}
|
198
|
-
@site.posts.docs[0].path = #{@site.posts.docs[0].path}
|
199
|
-
END_DEBUG
|
200
|
-
end
|
201
|
-
|
202
|
-
all_urls = @site.all_collections.map(&:url)
|
203
|
-
compute_link_and_text(all_urls)
|
204
|
-
end
|
205
|
-
|
206
|
-
def compute_link_and_text(all_urls)
|
207
|
-
url_matches = all_urls.select { |url| url&.include? @path }
|
208
|
-
case url_matches.length
|
209
|
-
when 0
|
210
|
-
abort "href error: No url matches '#{@link}'" if @die_if_nomatch
|
211
|
-
@link_save = @link = '#'
|
212
|
-
@text = "<i>#{@link} is not available</i>"
|
213
|
-
when 1
|
214
|
-
@link = url_matches.first
|
215
|
-
@link = "#{@link}##{@fragment}" if @fragment
|
216
|
-
@link_save = @link
|
217
|
-
else
|
218
|
-
abort "Error: More than one url matched '#{@path}': #{url_matches.join(', ')}"
|
219
|
-
end
|
220
|
-
end
|
221
|
-
|
222
|
-
def insecure_ip_address(string)
|
223
|
-
return true if string.start_with? 'localhost'
|
224
|
-
|
225
|
-
return false unless IPAddress.valid? string
|
226
|
-
|
227
|
-
ip_address = IPAddress string
|
228
|
-
return true if ip_address.loopback? || ip_address.private?
|
229
|
-
rescue StandardError
|
230
|
-
false
|
231
|
-
ensure
|
232
|
-
false
|
233
|
-
end
|
234
|
-
|
235
|
-
# Replace names in plugin-vars with values
|
236
|
-
def replace_vars(text)
|
237
|
-
variables = @site.config['plugin-vars']
|
238
|
-
return text unless variables
|
239
|
-
|
240
|
-
variables.each do |name, value|
|
241
|
-
text = text.gsub "{{#{name}}}", value
|
242
|
-
end
|
243
|
-
text
|
67
|
+
def to_s
|
68
|
+
"On line #{line_number} of #{path}: #{follow} #{match} #{target} #{link} => '#{text}'"
|
244
69
|
end
|
245
70
|
|
246
71
|
JekyllPluginHelper.register(self, 'href')
|
247
72
|
end
|
248
73
|
end
|
74
|
+
|
75
|
+
require_relative 'href_match'
|
76
|
+
require_relative 'href_private'
|
77
|
+
require_relative 'href_page_title'
|
78
|
+
require_relative 'href_summary'
|
data/lib/jekyll_href/version.rb
CHANGED
data/lib/jekyll_href.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -6,9 +6,7 @@ require 'yaml'
|
|
6
6
|
require_relative "../lib/jekyll_href"
|
7
7
|
|
8
8
|
RSpec.configure do |config|
|
9
|
-
config.filter_run :focus
|
10
9
|
# config.order = "random"
|
11
|
-
config.run_all_when_everything_filtered = true
|
12
10
|
|
13
11
|
# See https://relishapp.com/rspec/rspec-core/docs/command-line/only-failures
|
14
12
|
config.example_status_persistence_file_path = "../spec/status_persistence.txt"
|
data/spec/status_persistence.txt
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
example_id | status | run_time |
|
2
2
|
----------------------------------------------------------------- | ------ | --------------- |
|
3
|
-
/mnt/f/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:1] | passed | 0.
|
4
|
-
/mnt/f/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:2] |
|
5
|
-
/mnt/f/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:3] |
|
6
|
-
/mnt/f/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:4] |
|
7
|
-
/mnt/f/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:5] |
|
8
|
-
/mnt/f/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:6] |
|
9
|
-
/mnt/f/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:7] | passed | 0.
|
10
|
-
/mnt/f/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:8] |
|
11
|
-
/mnt/f/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:9] |
|
12
|
-
/mnt/f/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:10] | passed | 0.
|
13
|
-
/mnt/f/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:11] | passed | 0.
|
14
|
-
/mnt/f/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:12] | passed | 0.
|
15
|
-
/mnt/f/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:13] | passed | 0.
|
3
|
+
/mnt/f/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:1] | passed | 0.00938 seconds |
|
4
|
+
/mnt/f/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:2] | failed | 0.01389 seconds |
|
5
|
+
/mnt/f/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:3] | failed | 0.00319 seconds |
|
6
|
+
/mnt/f/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:4] | failed | 0.00211 seconds |
|
7
|
+
/mnt/f/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:5] | failed | 0.00196 seconds |
|
8
|
+
/mnt/f/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:6] | failed | 0.00205 seconds |
|
9
|
+
/mnt/f/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:7] | passed | 0.00212 seconds |
|
10
|
+
/mnt/f/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:8] | failed | 0.00209 seconds |
|
11
|
+
/mnt/f/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:9] | failed | 0.0021 seconds |
|
12
|
+
/mnt/f/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:10] | passed | 0.00278 seconds |
|
13
|
+
/mnt/f/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:11] | passed | 0.00237 seconds |
|
14
|
+
/mnt/f/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:12] | passed | 0.00218 seconds |
|
15
|
+
/mnt/f/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:13] | passed | 0.00211 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.2.
|
4
|
+
version: 1.2.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Slinn
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ipaddress
|
@@ -58,16 +58,16 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.
|
61
|
+
version: 0.8.1
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.
|
68
|
+
version: 0.8.1
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: typesafe_enum
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
@@ -95,12 +95,17 @@ files:
|
|
95
95
|
- README.md
|
96
96
|
- Rakefile
|
97
97
|
- jekyll_href.gemspec
|
98
|
+
- lib/enums.rb
|
98
99
|
- lib/hash_array.rb
|
100
|
+
- lib/href_match.rb
|
101
|
+
- lib/href_page_title.rb
|
102
|
+
- lib/href_private.rb
|
103
|
+
- lib/href_summary.rb
|
99
104
|
- lib/href_summary_tag.rb
|
100
105
|
- lib/href_tag.rb
|
101
106
|
- lib/jekyll_href.rb
|
102
107
|
- lib/jekyll_href/version.rb
|
103
|
-
- spec/hash_array_spec.rb
|
108
|
+
- spec/hash_array_spec/hash_array_spec.rb
|
104
109
|
- spec/href_spec.rb
|
105
110
|
- spec/spec_helper.rb
|
106
111
|
- spec/status_persistence.txt
|
@@ -131,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
131
136
|
- !ruby/object:Gem::Version
|
132
137
|
version: '0'
|
133
138
|
requirements: []
|
134
|
-
rubygems_version: 3.3.
|
139
|
+
rubygems_version: 3.3.7
|
135
140
|
signing_key:
|
136
141
|
specification_version: 4
|
137
142
|
summary: Generates an 'a href' tag, possibly with target='_blank' and rel='nofollow'.
|