jekyll_href 1.2.5 → 1.2.7
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 +5 -3
- data/CHANGELOG.md +105 -42
- data/README.md +197 -99
- data/jekyll_href.gemspec +2 -2
- data/lib/href_match.rb +43 -0
- data/lib/href_page_title.rb +49 -0
- data/lib/href_private.rb +143 -0
- data/lib/href_summary.rb +39 -0
- data/lib/href_summary_tag.rb +17 -6
- data/lib/href_tag.rb +24 -200
- data/lib/jekyll_href/version.rb +1 -1
- data/lib/jekyll_href.rb +1 -2
- 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 -27
- metadata +12 -20
data/lib/href_private.rb
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
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, @shy, @target, @url, @wbr
|
|
33
|
+
def globals_initial
|
|
34
|
+
@path = @page['path']
|
|
35
|
+
AllCollectionsHooks.compute(@site)
|
|
36
|
+
|
|
37
|
+
@blank = @helper.parameter_specified? 'blank'
|
|
38
|
+
@klass = @helper.parameter_specified? 'class'
|
|
39
|
+
@follow = @helper.parameter_specified?('follow') ? '' : " rel='nofollow'"
|
|
40
|
+
@label = @helper.parameter_specified? 'label'
|
|
41
|
+
@match = @helper.parameter_specified? 'match'
|
|
42
|
+
@shy = @helper.parameter_specified? 'shy'
|
|
43
|
+
@style = @helper.parameter_specified? 'style'
|
|
44
|
+
@summary = @helper.parameter_specified? 'summary'
|
|
45
|
+
@summary_exclude = @helper.parameter_specified? 'summary_exclude'
|
|
46
|
+
@target = @blank ? " target='_blank'" : nil
|
|
47
|
+
@target ||= @helper.parameter_specified?('notarget') ? '' : " target='_blank'"
|
|
48
|
+
@url = @helper.parameter_specified? 'url'
|
|
49
|
+
@wbr = @helper.parameter_specified? 'wbr'
|
|
50
|
+
|
|
51
|
+
@label_source = if @helper.parameter_specified? 'page_title'
|
|
52
|
+
:from_page_title
|
|
53
|
+
elsif @label
|
|
54
|
+
:from_explicit_label
|
|
55
|
+
else
|
|
56
|
+
:from_implicit_label
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
return unless @tag_config
|
|
60
|
+
|
|
61
|
+
@die_on_href_error = @tag_config['die_on_href_error'] == true
|
|
62
|
+
@die_on_nomatch = @tag_config['die_on_nomatch'] == true
|
|
63
|
+
@pry_on_href_error = @tag_config['pry_on_href_error'] == true
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# Might set @external_link, @follow, @local_link, @linkk, @target, and @text
|
|
67
|
+
def globals_update(tokens, linkk)
|
|
68
|
+
if linkk.start_with? 'mailto:'
|
|
69
|
+
handle_mailto linkk
|
|
70
|
+
return
|
|
71
|
+
else
|
|
72
|
+
if @label_source == :from_page_title
|
|
73
|
+
handle_page_title linkk
|
|
74
|
+
return
|
|
75
|
+
end
|
|
76
|
+
@text = @label || tokens.join(' ').strip
|
|
77
|
+
if @text.to_s.empty?
|
|
78
|
+
handle_empty_text linkk
|
|
79
|
+
else
|
|
80
|
+
handle_text linkk
|
|
81
|
+
end
|
|
82
|
+
@link_save = @link
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
if @external_link
|
|
86
|
+
@target = ''
|
|
87
|
+
return
|
|
88
|
+
end
|
|
89
|
+
@follow = ''
|
|
90
|
+
@target = '' unless @blank
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def handle_empty_text(linkk)
|
|
94
|
+
text = linkk
|
|
95
|
+
text = linkk&.gsub('/', '/­') if @shy
|
|
96
|
+
text = linkk&.gsub('/', '/<wbr>') if @wbr
|
|
97
|
+
@text = "<code>#{text}</code>"
|
|
98
|
+
@external_link = linkk.start_with? 'http'
|
|
99
|
+
@local_link = !@external_link
|
|
100
|
+
@mailto_link = false
|
|
101
|
+
@link = if @external_link
|
|
102
|
+
linkk
|
|
103
|
+
elsif insecure_ip_address linkk
|
|
104
|
+
"http://#{linkk}"
|
|
105
|
+
else
|
|
106
|
+
"https://#{linkk}"
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def handle_mailto(linkk)
|
|
111
|
+
@mailto_link = true
|
|
112
|
+
@local_link = @external_link = false
|
|
113
|
+
@link = linkk
|
|
114
|
+
@target = @follow = ''
|
|
115
|
+
@text = @helper.argv.join(' ')
|
|
116
|
+
return unless @text.empty?
|
|
117
|
+
|
|
118
|
+
text = linkk.delete_prefix('mailto:')
|
|
119
|
+
@text = "<code>#{text}</code>"
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
def handle_text(linkk)
|
|
123
|
+
@link = if @shy
|
|
124
|
+
linkk&.gsub('/', '/­')
|
|
125
|
+
elsif @wbr
|
|
126
|
+
linkk&.gsub('/', '/<wbr>')
|
|
127
|
+
else
|
|
128
|
+
linkk
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
def insecure_ip_address(string)
|
|
133
|
+
return true if string.start_with? 'localhost'
|
|
134
|
+
|
|
135
|
+
return false unless IPAddress.valid? string
|
|
136
|
+
|
|
137
|
+
ip_address = IPAddress string
|
|
138
|
+
true if ip_address.loopback? || ip_address.private?
|
|
139
|
+
ensure
|
|
140
|
+
false
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
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 == true
|
|
10
|
+
warning = <<~END_WARNING
|
|
11
|
+
Warning: a 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
|
@@ -10,11 +10,13 @@ require_relative 'hash_array'
|
|
|
10
10
|
# @license SPDX-License-Identifier: Apache-2.0
|
|
11
11
|
# Generates an href.
|
|
12
12
|
|
|
13
|
-
module
|
|
13
|
+
module MSlinn
|
|
14
14
|
MiniHref = Struct.new(:follow, :html, :link, :line_number, :link_save, :path, :summary_exclude, :summary_href, keyword_init: true)
|
|
15
15
|
|
|
16
|
+
HRefError = JekyllSupport.define_error
|
|
17
|
+
|
|
16
18
|
# Implements href Jekyll tag
|
|
17
|
-
class
|
|
19
|
+
class HRefTag < JekyllSupport::JekyllTag
|
|
18
20
|
attr_reader :follow, :helper, :line_number, :link_save, :match, :page, :path, :site,
|
|
19
21
|
:summary, :summary_exclude, :summary_href, :target, :text, :url
|
|
20
22
|
attr_accessor :link
|
|
@@ -29,20 +31,18 @@ module HrefTag
|
|
|
29
31
|
[follow, match, path, target, text] <=> [other.follow, other.match, other.path, other.target, other.text]
|
|
30
32
|
end
|
|
31
33
|
|
|
32
|
-
def to_s
|
|
33
|
-
"On line #{line_number} of #{path}: #{follow} #{match} #{target} #{link} => '#{text}'"
|
|
34
|
-
end
|
|
35
|
-
|
|
36
34
|
# Method prescribed by the Jekyll plugin lifecycle.
|
|
37
35
|
# @param liquid_context [Liquid::Context]
|
|
38
36
|
# @return [String]
|
|
39
37
|
def render_impl
|
|
40
38
|
globals_initial
|
|
41
|
-
linkk = compute_linkk
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
linkk, error_msg = compute_linkk
|
|
40
|
+
return error_msg unless linkk
|
|
41
|
+
|
|
42
|
+
linkk.delete_prefix './' # normalize relative links
|
|
44
43
|
@url = linkk if @url
|
|
45
44
|
@link_save = linkk
|
|
45
|
+
|
|
46
46
|
@helper_save = @helper.clone
|
|
47
47
|
globals_update(@helper.argv, linkk) # Sets @link and @text, might clear @follow and @target
|
|
48
48
|
handle_match if @match
|
|
@@ -50,201 +50,25 @@ module HrefTag
|
|
|
50
50
|
klass = " class='#{@klass}'" if @klass
|
|
51
51
|
style = " style='#{@style}'" if @style
|
|
52
52
|
"<a href='#{@link}'#{klass}#{style}#{@target}#{@follow}>#{@text}</a>"
|
|
53
|
+
rescue HRefError => e # jekyll_plugin_support handles StandardError
|
|
54
|
+
e.shorten_backtrace
|
|
55
|
+
msg = format_error_message e.message
|
|
56
|
+
@logger.error "#{e.class} raised #{msg}"
|
|
57
|
+
binding.pry if @pry_on_img_error # rubocop:disable Lint/Debugger
|
|
58
|
+
raise e if @die_on_href_error
|
|
59
|
+
|
|
60
|
+
"<div class='href_error'>#{e.class} raised in #{self.class};\n#{msg}</div>"
|
|
53
61
|
end
|
|
54
62
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
def save_summary
|
|
58
|
-
return if @summary_exclude || @link_save.start_with?('mailto:') || @link_save.start_with?('#')
|
|
59
|
-
|
|
60
|
-
@summary = @summary.to_s.empty? ? @text : @summary.to_s
|
|
61
|
-
if @summary == true
|
|
62
|
-
warning = <<~END_WARNING
|
|
63
|
-
Warning: a href plugin keyword option was detected in the link text for #{@path} on line #{line_number}.
|
|
64
|
-
The href tag will not be included in the summary, and the link text will not have the word summary included.
|
|
65
|
-
This is probably unintentional. Consider using the label option to correct this problem."
|
|
66
|
-
END_WARNING
|
|
67
|
-
puts warning.red
|
|
68
|
-
return
|
|
69
|
-
end
|
|
70
|
-
return if @summary.class != String || @summary.empty?
|
|
71
|
-
|
|
72
|
-
@summary = @summary[0].upcase + @summary[1..]
|
|
73
|
-
@summary_href = "<a href='#{@link_save}'#{@target}#{@follow}>#{@summary}</a>"
|
|
74
|
-
mini_href = MiniHref.new(
|
|
75
|
-
follow: @follow,
|
|
76
|
-
html: @summary_href,
|
|
77
|
-
line_number: @line_number,
|
|
78
|
-
link: @link_save,
|
|
79
|
-
link_save: @link_save,
|
|
80
|
-
path: @path,
|
|
81
|
-
summary_exclude: @summary_exclude,
|
|
82
|
-
summary_href: @summary_href
|
|
83
|
-
)
|
|
84
|
-
if @link_save.start_with? 'http'
|
|
85
|
-
add_global_link_for_page mini_href
|
|
86
|
-
else
|
|
87
|
-
add_local_link_for_page mini_href
|
|
88
|
-
end
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
# Does not look at or compute @link
|
|
92
|
-
def compute_linkk
|
|
93
|
-
return @link if @link
|
|
94
|
-
|
|
95
|
-
linkk = @url
|
|
96
|
-
if linkk.nil? || !linkk
|
|
97
|
-
linkk = @helper.argv&.shift
|
|
98
|
-
@helper.params&.shift
|
|
99
|
-
@helper.keys_values&.delete(linkk)
|
|
100
|
-
dump_linkk_relations(linkk) if linkk.nil?
|
|
101
|
-
elsif @url.to_s.empty?
|
|
102
|
-
dump_linkk_relations(linkk)
|
|
103
|
-
end
|
|
104
|
-
linkk
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
def dump_linkk_relations(linkk)
|
|
108
|
-
msg = <<~END_MESSAGE
|
|
109
|
-
jekyll_href error: no url was provided on #{@path}:#{@line_number}.
|
|
110
|
-
@helper.markup=#{@helper.markup}
|
|
111
|
-
@helper.argv='#{@helper.argv}'
|
|
112
|
-
linkk='#{linkk}'
|
|
113
|
-
@match='#{@match}'
|
|
114
|
-
@url='#{@url}'
|
|
115
|
-
@follow='#{@follow}
|
|
116
|
-
@target='#{@target}'
|
|
117
|
-
END_MESSAGE
|
|
118
|
-
abort msg.red
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
# Sets @follow, @helper, @match, @path, @shy, @target, @url, @wbr
|
|
122
|
-
def globals_initial
|
|
123
|
-
@path = @page['path']
|
|
124
|
-
AllCollectionsHooks.compute(@site)
|
|
125
|
-
|
|
126
|
-
@blank = @helper.parameter_specified? 'blank'
|
|
127
|
-
@klass = @helper.parameter_specified? 'class'
|
|
128
|
-
@follow = @helper.parameter_specified?('follow') ? '' : " rel='nofollow'"
|
|
129
|
-
@match = @helper.parameter_specified? 'match'
|
|
130
|
-
@label = @helper.parameter_specified? 'label'
|
|
131
|
-
@summary_exclude = @helper.parameter_specified? 'summary_exclude'
|
|
132
|
-
@shy = @helper.parameter_specified? 'shy'
|
|
133
|
-
@style = @helper.parameter_specified? 'style'
|
|
134
|
-
@summary = @helper.parameter_specified? 'summary'
|
|
135
|
-
@target = @blank ? " target='_blank'" : nil
|
|
136
|
-
@target ||= @helper.parameter_specified?('notarget') ? '' : " target='_blank'"
|
|
137
|
-
@url = @helper.parameter_specified? 'url'
|
|
138
|
-
@wbr = @helper.parameter_specified? 'wbr'
|
|
139
|
-
end
|
|
140
|
-
|
|
141
|
-
# Might set @follow, @linkk, @target, and @text
|
|
142
|
-
def globals_update(tokens, linkk)
|
|
143
|
-
if linkk.start_with? 'mailto:'
|
|
144
|
-
@link = linkk
|
|
145
|
-
@target = @follow = ''
|
|
146
|
-
@text = @helper.argv.join(' ')
|
|
147
|
-
if @text.empty?
|
|
148
|
-
text = linkk.delete_prefix('mailto:')
|
|
149
|
-
@text = "<code>#{text}</code>"
|
|
150
|
-
end
|
|
151
|
-
return
|
|
152
|
-
else
|
|
153
|
-
@text = @label || tokens.join(' ').strip
|
|
154
|
-
if @text.to_s.empty?
|
|
155
|
-
text = linkk
|
|
156
|
-
text = linkk.gsub('/', '/­') if @shy
|
|
157
|
-
text = linkk.gsub('/', '/<wbr>') if @wbr
|
|
158
|
-
@text = "<code>#{text}</code>"
|
|
159
|
-
@link = if linkk.start_with?('http')
|
|
160
|
-
linkk
|
|
161
|
-
elsif insecure_ip_address linkk
|
|
162
|
-
"http://#{linkk}"
|
|
163
|
-
else
|
|
164
|
-
"https://#{linkk}"
|
|
165
|
-
end
|
|
166
|
-
else
|
|
167
|
-
@link = if @shy
|
|
168
|
-
linkk.gsub('/', '/­')
|
|
169
|
-
elsif @wbr
|
|
170
|
-
linkk.gsub('/', '/<wbr>')
|
|
171
|
-
else
|
|
172
|
-
linkk
|
|
173
|
-
end
|
|
174
|
-
end
|
|
175
|
-
@link_save = @link
|
|
176
|
-
end
|
|
177
|
-
|
|
178
|
-
return if @link.start_with? 'http'
|
|
179
|
-
|
|
180
|
-
@follow = ''
|
|
181
|
-
@target = '' unless @blank
|
|
182
|
-
end
|
|
183
|
-
|
|
184
|
-
def handle_match
|
|
185
|
-
match_post
|
|
186
|
-
@follow = ''
|
|
187
|
-
@target = '' unless @blank
|
|
188
|
-
end
|
|
189
|
-
|
|
190
|
-
# Might set @link and @text
|
|
191
|
-
def match_post
|
|
192
|
-
config = @site.config['href']
|
|
193
|
-
@die_if_nomatch = !config.nil? && config['nomatch'] && config['nomatch'] == 'fatal'
|
|
194
|
-
@path, @fragment = @link.split('#')
|
|
195
|
-
|
|
196
|
-
@logger.debug do
|
|
197
|
-
<<~END_DEBUG
|
|
198
|
-
@link=#{@link}
|
|
199
|
-
@site.posts.docs[0].url = #{@site.posts.docs[0].url}
|
|
200
|
-
@site.posts.docs[0].path = #{@site.posts.docs[0].path}
|
|
201
|
-
END_DEBUG
|
|
202
|
-
end
|
|
203
|
-
|
|
204
|
-
all_urls = @site.all_collections.map(&:url)
|
|
205
|
-
compute_link_and_text(all_urls)
|
|
206
|
-
end
|
|
207
|
-
|
|
208
|
-
def compute_link_and_text(all_urls)
|
|
209
|
-
url_matches = all_urls.select { |url| url&.include? @path }
|
|
210
|
-
case url_matches.length
|
|
211
|
-
when 0
|
|
212
|
-
abort "href error: No url matches '#{@link}'" if @die_if_nomatch
|
|
213
|
-
@link_save = @link = '#'
|
|
214
|
-
@text = "<i>#{@link} is not available</i>"
|
|
215
|
-
when 1
|
|
216
|
-
@link = url_matches.first
|
|
217
|
-
@link = "#{@link}##{@fragment}" if @fragment
|
|
218
|
-
@link_save = @link
|
|
219
|
-
else
|
|
220
|
-
abort "Error: More than one url matched '#{@path}': #{url_matches.join(', ')}"
|
|
221
|
-
end
|
|
222
|
-
end
|
|
223
|
-
|
|
224
|
-
def insecure_ip_address(string)
|
|
225
|
-
return true if string.start_with? 'localhost'
|
|
226
|
-
|
|
227
|
-
return false unless IPAddress.valid? string
|
|
228
|
-
|
|
229
|
-
ip_address = IPAddress string
|
|
230
|
-
return true if ip_address.loopback? || ip_address.private?
|
|
231
|
-
rescue StandardError
|
|
232
|
-
false
|
|
233
|
-
ensure
|
|
234
|
-
false
|
|
235
|
-
end
|
|
236
|
-
|
|
237
|
-
# Replace names in plugin-vars with values
|
|
238
|
-
def replace_vars(text)
|
|
239
|
-
variables = @site.config['plugin-vars']
|
|
240
|
-
return text unless variables
|
|
241
|
-
|
|
242
|
-
variables.each do |name, value|
|
|
243
|
-
text = text.gsub "{{#{name}}}", value
|
|
244
|
-
end
|
|
245
|
-
text
|
|
63
|
+
def to_s
|
|
64
|
+
"On line #{line_number} of #{path}: #{follow} #{match} #{target} #{link} => '#{text}'"
|
|
246
65
|
end
|
|
247
66
|
|
|
248
67
|
JekyllPluginHelper.register(self, 'href')
|
|
249
68
|
end
|
|
250
69
|
end
|
|
70
|
+
|
|
71
|
+
require_relative 'href_match'
|
|
72
|
+
require_relative 'href_private'
|
|
73
|
+
require_relative 'href_page_title'
|
|
74
|
+
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,29 +1,15 @@
|
|
|
1
1
|
example_id | status | run_time |
|
|
2
2
|
----------------------------------------------------------------- | ------ | --------------- |
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
./spec/href_spec.rb[1:13] | passed | 0.02714 seconds |
|
|
17
|
-
/mnt/_/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:1] | passed | 0.02582 seconds |
|
|
18
|
-
/mnt/_/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:2] | passed | 0.01031 seconds |
|
|
19
|
-
/mnt/_/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:3] | passed | 0.01045 seconds |
|
|
20
|
-
/mnt/_/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:4] | passed | 0.01038 seconds |
|
|
21
|
-
/mnt/_/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:5] | passed | 0.01081 seconds |
|
|
22
|
-
/mnt/_/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:6] | passed | 0.01053 seconds |
|
|
23
|
-
/mnt/_/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:7] | passed | 0.01125 seconds |
|
|
24
|
-
/mnt/_/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:8] | passed | 0.01113 seconds |
|
|
25
|
-
/mnt/_/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:9] | passed | 0.01088 seconds |
|
|
26
|
-
/mnt/_/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:10] | passed | 0.01066 seconds |
|
|
27
|
-
/mnt/_/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:11] | failed | 0.06099 seconds |
|
|
28
|
-
/mnt/_/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:12] | passed | 0.01096 seconds |
|
|
29
|
-
/mnt/_/work/jekyll/my_plugins/jekyll_href/spec/href_spec.rb[1:13] | passed | 0.01028 seconds |
|
|
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.7
|
|
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-12-27 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: ipaddress
|
|
@@ -42,42 +42,30 @@ dependencies:
|
|
|
42
42
|
name: jekyll_all_collections
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
44
44
|
requirements:
|
|
45
|
-
- - "~>"
|
|
46
|
-
- !ruby/object:Gem::Version
|
|
47
|
-
version: 0.3.0
|
|
48
45
|
- - ">="
|
|
49
46
|
- !ruby/object:Gem::Version
|
|
50
|
-
version: 0.3.
|
|
47
|
+
version: 0.3.3
|
|
51
48
|
type: :runtime
|
|
52
49
|
prerelease: false
|
|
53
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
54
51
|
requirements:
|
|
55
|
-
- - "~>"
|
|
56
|
-
- !ruby/object:Gem::Version
|
|
57
|
-
version: 0.3.0
|
|
58
52
|
- - ">="
|
|
59
53
|
- !ruby/object:Gem::Version
|
|
60
|
-
version: 0.3.
|
|
54
|
+
version: 0.3.3
|
|
61
55
|
- !ruby/object:Gem::Dependency
|
|
62
56
|
name: jekyll_plugin_support
|
|
63
57
|
requirement: !ruby/object:Gem::Requirement
|
|
64
58
|
requirements:
|
|
65
|
-
- - "~>"
|
|
66
|
-
- !ruby/object:Gem::Version
|
|
67
|
-
version: 0.6.0
|
|
68
59
|
- - ">="
|
|
69
60
|
- !ruby/object:Gem::Version
|
|
70
|
-
version: 0.
|
|
61
|
+
version: 0.8.1
|
|
71
62
|
type: :runtime
|
|
72
63
|
prerelease: false
|
|
73
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
74
65
|
requirements:
|
|
75
|
-
- - "~>"
|
|
76
|
-
- !ruby/object:Gem::Version
|
|
77
|
-
version: 0.6.0
|
|
78
66
|
- - ">="
|
|
79
67
|
- !ruby/object:Gem::Version
|
|
80
|
-
version: 0.
|
|
68
|
+
version: 0.8.1
|
|
81
69
|
description: 'Generates an ''a href'' tag, possibly with target=''_blank'' and rel=''nofollow''.
|
|
82
70
|
|
|
83
71
|
'
|
|
@@ -94,11 +82,15 @@ files:
|
|
|
94
82
|
- Rakefile
|
|
95
83
|
- jekyll_href.gemspec
|
|
96
84
|
- lib/hash_array.rb
|
|
85
|
+
- lib/href_match.rb
|
|
86
|
+
- lib/href_page_title.rb
|
|
87
|
+
- lib/href_private.rb
|
|
88
|
+
- lib/href_summary.rb
|
|
97
89
|
- lib/href_summary_tag.rb
|
|
98
90
|
- lib/href_tag.rb
|
|
99
91
|
- lib/jekyll_href.rb
|
|
100
92
|
- lib/jekyll_href/version.rb
|
|
101
|
-
- spec/hash_array_spec.rb
|
|
93
|
+
- spec/hash_array_spec/hash_array_spec.rb
|
|
102
94
|
- spec/href_spec.rb
|
|
103
95
|
- spec/spec_helper.rb
|
|
104
96
|
- spec/status_persistence.txt
|
|
@@ -129,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
129
121
|
- !ruby/object:Gem::Version
|
|
130
122
|
version: '0'
|
|
131
123
|
requirements: []
|
|
132
|
-
rubygems_version: 3.3.
|
|
124
|
+
rubygems_version: 3.3.7
|
|
133
125
|
signing_key:
|
|
134
126
|
specification_version: 4
|
|
135
127
|
summary: Generates an 'a href' tag, possibly with target='_blank' and rel='nofollow'.
|