jekyll_href 1.2.11 → 1.2.13
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/CHANGELOG.md +12 -0
- data/README.md +33 -5
- data/jekyll_href.gemspec +11 -10
- data/lib/href_match.rb +13 -9
- data/lib/href_private.rb +1 -1
- data/lib/href_summary.rb +1 -1
- data/lib/href_summary_tag.rb +3 -6
- data/lib/href_tag.rb +37 -10
- data/lib/jekyll_href/version.rb +1 -1
- metadata +5 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15395e432574a69be4a28def40f3c20bf199fa762f8ca94155408e864921c406
|
4
|
+
data.tar.gz: 4d7385465ad6ddd8b9f52c6efbb62f7fd757015d10f23017e63639ddfc8e6670
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 595817a332ef1fe8044249f075efc94a8fc6ba4f284ba2d97ef504d72cabf63799831c808e8450fe6c935d859c5296dda3805e42fd3ada764be2fe2c9985b616
|
7
|
+
data.tar.gz: 07b1e783d4b0015097229fda3a2257fdfc8b7b523673f212bdde3c7423eb889badd30a6f36b57c3dcd95eaea321f1f48cdd9db90f96cee167852b6f9b8aa4341
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 1.2.13 / 2024-12-23
|
4
|
+
|
5
|
+
* Fixed reference to undefined `url_matches`.
|
6
|
+
* References that point to draft pages are rendered differently in production mode,
|
7
|
+
and an info-level log message is generated.
|
8
|
+
|
9
|
+
|
10
|
+
## 1.2.12 / 2024-08-17
|
11
|
+
|
12
|
+
* Enhanced `match` so that if no label parameter is provided, the title of the matched web page is used.
|
13
|
+
* Now dependent on jekyll_plugin_support v1.0.2+ for better error handling.
|
14
|
+
|
3
15
|
|
4
16
|
## 1.2.11 / 2024-07-27
|
5
17
|
|
data/README.md
CHANGED
@@ -46,7 +46,22 @@ href_summary:
|
|
46
46
|
pry_on_href_error: true # Default value is false
|
47
47
|
```
|
48
48
|
|
49
|
-
##
|
49
|
+
## Suppprted Syntaxes
|
50
|
+
|
51
|
+
Square brackets in the [BNF notation](https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_form)
|
52
|
+
below denote optional keyword parameters, and are not meant to be typed.
|
53
|
+
|
54
|
+
## Syntax 1 (most verbose, but provides best results and enables implicit matching title)
|
55
|
+
|
56
|
+
```html
|
57
|
+
{% href [match | [follow] [blank|notarget] [summary_exclude]] url="local_page.html" label="text to display" %}
|
58
|
+
```
|
59
|
+
|
60
|
+
1. The url can be #relative, a page in the Jekyll website, or prefaced with a protocol, such as `https:`
|
61
|
+
2. If `match` is provided, and `label` is not provided, then the title of the matched page is used as the label.
|
62
|
+
|
63
|
+
|
64
|
+
## Syntax 2 (requires `url` without embedded spaces)
|
50
65
|
|
51
66
|
```html
|
52
67
|
{% href [match | [follow] [blank|notarget] [page_title] [summary_exclude]] url text to display %}
|
@@ -54,10 +69,9 @@ href_summary:
|
|
54
69
|
|
55
70
|
1. The url must be a single token, without embedded spaces.
|
56
71
|
2. The url need not be enclosed in quotes.
|
57
|
-
3. The square brackets denote optional keyword parameters, and should not be typed.
|
58
72
|
|
59
73
|
|
60
|
-
## Syntax
|
74
|
+
## Syntax 3 (always works)
|
61
75
|
|
62
76
|
This syntax is recommended when the URL contains a colon (:).
|
63
77
|
|
@@ -68,10 +82,9 @@ This syntax is recommended when the URL contains a colon (:).
|
|
68
82
|
|
69
83
|
1. Each of the above examples contain an embedded newline, which is legal.
|
70
84
|
2. The url must be enclosed by either single or double quotes.
|
71
|
-
3. The square brackets denote optional keyword parameters, and should not be typed.
|
72
85
|
|
73
86
|
|
74
|
-
## Syntax
|
87
|
+
## Syntax 4 (implicit URL)
|
75
88
|
|
76
89
|
```html
|
77
90
|
{% href [match | [follow] [blank|notarget] [page_title] [summary_exclude]] [shy|wbr] www.domain.com %}
|
@@ -287,6 +300,21 @@ Expands to:
|
|
287
300
|
|
288
301
|
Substitutions are only made to the URL, not to the linked text.
|
289
302
|
|
303
|
+
8. Dollar signs
|
304
|
+
|
305
|
+
If the URL has a dollar sign in it, jekyll_href will attempt to replace an environment variable with its value.
|
306
|
+
That will likely fail silently. To work around the problem, replace dollar signs in URLs with $.
|
307
|
+
|
308
|
+
For example, given this URL:
|
309
|
+
https://ammonite.io/#import$ivy
|
310
|
+
rewrite as:
|
311
|
+
https://ammonite.io/#import$ivy.
|
312
|
+
|
313
|
+
Here is a complete invocation:
|
314
|
+
|
315
|
+
{% href url="https://ammonite.io/#import$ivy"
|
316
|
+
label="<code>import $ivy</code>" %}
|
317
|
+
|
290
318
|
|
291
319
|
## References Generation
|
292
320
|
|
data/jekyll_href.gemspec
CHANGED
@@ -3,15 +3,15 @@ require_relative 'lib/jekyll_href/version'
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
github = 'https://github.com/mslinn/jekyll_href'
|
5
5
|
|
6
|
-
spec.authors
|
7
|
-
spec.bindir
|
6
|
+
spec.authors = ['Mike Slinn']
|
7
|
+
spec.bindir = 'exe'
|
8
8
|
spec.description = <<~END_OF_DESC
|
9
9
|
Generates an 'a href' tag, possibly with target='_blank' and rel='nofollow'.
|
10
10
|
END_OF_DESC
|
11
|
-
spec.email
|
12
|
-
spec.files
|
11
|
+
spec.email = ['mslinn@mslinn.com']
|
12
|
+
spec.files = Dir['.rubocop.yml', 'LICENSE.*', 'Rakefile', '{lib,spec}/**/*', '*.gemspec', '*.md']
|
13
13
|
spec.homepage = 'https://www.mslinn.com/jekyll_plugins/jekyll_href.html'
|
14
|
-
spec.license
|
14
|
+
spec.license = 'MIT'
|
15
15
|
spec.metadata = {
|
16
16
|
'allowed_push_host' => 'https://rubygems.org',
|
17
17
|
'bug_tracker_uri' => "#{github}/issues",
|
@@ -19,20 +19,21 @@ Gem::Specification.new do |spec|
|
|
19
19
|
'homepage_uri' => spec.homepage,
|
20
20
|
'source_code_uri' => github,
|
21
21
|
}
|
22
|
-
spec.name
|
22
|
+
spec.name = 'jekyll_href'
|
23
|
+
spec.platform = Gem::Platform::RUBY
|
23
24
|
spec.post_install_message = <<~END_MESSAGE
|
24
25
|
|
25
26
|
Thanks for installing #{spec.name}!
|
26
27
|
|
27
28
|
END_MESSAGE
|
28
|
-
spec.require_paths
|
29
|
+
spec.require_paths = ['lib']
|
29
30
|
spec.required_ruby_version = '>= 2.6.0'
|
30
|
-
spec.summary
|
31
|
-
spec.version
|
31
|
+
spec.summary = "Generates an 'a href' tag, possibly with target='_blank' and rel='nofollow'."
|
32
|
+
spec.version = JekyllHrefVersion::VERSION
|
32
33
|
|
33
34
|
spec.add_dependency 'ipaddress'
|
34
35
|
spec.add_dependency 'jekyll', '>= 3.5.0'
|
35
36
|
spec.add_dependency 'jekyll_all_collections'
|
36
|
-
spec.add_dependency 'jekyll_plugin_support', '>= 1.0.
|
37
|
+
spec.add_dependency 'jekyll_plugin_support', '>= 1.0.3'
|
37
38
|
spec.add_dependency 'typesafe_enum'
|
38
39
|
end
|
data/lib/href_match.rb
CHANGED
@@ -2,19 +2,24 @@ module JekyllSupport
|
|
2
2
|
class HRefTag
|
3
3
|
private
|
4
4
|
|
5
|
-
def compute_link_and_text
|
6
|
-
|
7
|
-
case
|
5
|
+
def compute_link_and_text
|
6
|
+
page_matches = @site.all_collections.map.select { |page| page.url&.include? @path }
|
7
|
+
case page_matches.length
|
8
8
|
when 0
|
9
|
-
|
9
|
+
msg = "HRef error: No url matches '#{@link}', found on line #{@line_number} (after front matter) of #{@path}"
|
10
|
+
@logger.error { msg }
|
11
|
+
abort msg if @die_if_nomatch
|
12
|
+
|
13
|
+
@text = "<i class='h_ref_error'>#{@link} is not a valid local page</i>"
|
10
14
|
@link_save = @link = '#'
|
11
|
-
@text = "<i>#{@link} is not available</i>"
|
12
15
|
when 1
|
13
|
-
@link =
|
16
|
+
@link = page_matches.first.url
|
14
17
|
@link = "#{@link}##{@fragment}" if @fragment
|
15
18
|
@link_save = @link
|
19
|
+
@text = page_matches.first.title unless @label
|
16
20
|
else
|
17
|
-
|
21
|
+
logger.error { "Error: More than one url matched '#{@path}':\n #{page_matches.map(&:url).join("\n ")}" }
|
22
|
+
exit! 2
|
18
23
|
end
|
19
24
|
end
|
20
25
|
|
@@ -31,8 +36,7 @@ module JekyllSupport
|
|
31
36
|
END_DEBUG
|
32
37
|
end
|
33
38
|
|
34
|
-
|
35
|
-
compute_link_and_text(all_urls)
|
39
|
+
compute_link_and_text
|
36
40
|
end
|
37
41
|
end
|
38
42
|
end
|
data/lib/href_private.rb
CHANGED
@@ -26,7 +26,7 @@ module JekyllSupport
|
|
26
26
|
<pre>{% href #{@argument_string.strip} %}</pre>
|
27
27
|
END_MESSAGE
|
28
28
|
@logger.error { JekyllSupport::JekyllPluginHelper.remove_html_tags msg.strip }
|
29
|
-
"<div class='
|
29
|
+
"<div class='h_ref_error'>HRefError: #{msg}</div>"
|
30
30
|
end
|
31
31
|
|
32
32
|
# Sets @follow, @helper, @match, @path, @target, @url, @hyphenation
|
data/lib/href_summary.rb
CHANGED
data/lib/href_summary_tag.rb
CHANGED
@@ -40,13 +40,10 @@ module JekyllSupport
|
|
40
40
|
#{@helper.attribute if @helper.attribution && have_refs}
|
41
41
|
END_RENDER
|
42
42
|
rescue HRefError => e # jekyll_plugin_support handles StandardError
|
43
|
-
e.
|
44
|
-
|
45
|
-
@logger.error "#{e.class} raised #{msg}"
|
46
|
-
binding.pry if @pry_on_img_error # rubocop:disable Lint/Debugger
|
47
|
-
raise e if @die_on_href_error
|
43
|
+
@logger.error { e.logger_message }
|
44
|
+
exit! 1 if @die_on_demo_block_error
|
48
45
|
|
49
|
-
|
46
|
+
e.html_message
|
50
47
|
end
|
51
48
|
|
52
49
|
def render_global_refs
|
data/lib/href_tag.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'ipaddress'
|
2
|
+
require 'jekyll_draft'
|
2
3
|
require 'jekyll_all_collections'
|
3
4
|
require 'jekyll_plugin_logger'
|
4
5
|
require 'jekyll_plugin_support'
|
@@ -46,29 +47,55 @@ module JekyllSupport
|
|
46
47
|
|
47
48
|
@helper_save = @helper.clone
|
48
49
|
globals_update(@helper.argv, linkk) # Sets @link and @text, might clear @follow and @target
|
49
|
-
handle_match(
|
50
|
+
handle_match(linkk) if @match # Sets @text if not set by now, also @link_type, etc.
|
50
51
|
raise HrefError, '@link_type was not set' if @link_type == LinkType::UNKNOWN
|
51
52
|
|
52
53
|
save_summary
|
53
54
|
klass = " class='#{@klass}'" if @klass
|
54
55
|
style = " style='#{@style}'" if @style
|
56
|
+
if @link_type == LinkType::LOCAL && local_page_draft?(@link)
|
57
|
+
klass = "draft_link #{klass}".strip
|
58
|
+
return "<span #{klass}#{style} title='This page is not available yet.'>#{@text}</span>" if @mode == 'production'
|
59
|
+
end
|
60
|
+
|
55
61
|
"<a href='#{@link}'#{klass}#{style}#{@target}#{@follow}>#{@text}</a>"
|
56
62
|
rescue HRefError => e # jekyll_plugin_support handles StandardError
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
e.
|
61
|
-
@logger.error "#{e.class} raised #{msg}"
|
62
|
-
binding.pry if @pry_on_img_error # rubocop:disable Lint/Debugger
|
63
|
-
raise e if @die_on_href_error
|
64
|
-
|
65
|
-
"<div class='href_error'>#{e.class} raised in #{self.class};\n#{msg}</div>"
|
63
|
+
@logger.error { e.logger_message }
|
64
|
+
exit 1 if @die_on_demo_tag_error
|
65
|
+
|
66
|
+
e.html_message
|
66
67
|
end
|
67
68
|
|
68
69
|
def to_s
|
69
70
|
"On line #{line_number} of #{path}: #{follow} #{match} #{target} #{link} => '#{text}'"
|
70
71
|
end
|
71
72
|
|
73
|
+
def local_page_draft?(url)
|
74
|
+
filetype = File.extname url
|
75
|
+
page_matches = @site.all_collections.map.select { |page| page.url == url }
|
76
|
+
case page_matches.length
|
77
|
+
when 0
|
78
|
+
return false unless %w[htm html md].include? filetype
|
79
|
+
|
80
|
+
msg = "HRef error: No url matches '#{url}', found on line #{@line_number} (after front matter)"
|
81
|
+
@logger.error { msg }
|
82
|
+
abort msg if @die_if_nomatch
|
83
|
+
|
84
|
+
@text = "<i class='h_ref_error'>#{url} is not a valid local page</i>"
|
85
|
+
@link_save = @link = '#'
|
86
|
+
true
|
87
|
+
when 1
|
88
|
+
@link = page_matches.first.url
|
89
|
+
@link = "#{@link}##{@fragment}" if @fragment
|
90
|
+
@link_save = @link
|
91
|
+
@text = page_matches.first.title unless @label
|
92
|
+
Jekyll::Draft.draft? page_matches.first
|
93
|
+
else
|
94
|
+
logger.error { "Error: More than one url matched '#{url}'. Collections are: #{page_matches.join(', ')}" }
|
95
|
+
exit! 2
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
72
99
|
JekyllSupport::JekyllPluginHelper.register(self, 'href')
|
73
100
|
end
|
74
101
|
end
|
data/lib/jekyll_href/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
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.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Slinn
|
8
|
-
autorequire:
|
9
8
|
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date: 2024-
|
10
|
+
date: 2024-12-23 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: ipaddress
|
@@ -58,14 +57,14 @@ dependencies:
|
|
58
57
|
requirements:
|
59
58
|
- - ">="
|
60
59
|
- !ruby/object:Gem::Version
|
61
|
-
version: 1.0.
|
60
|
+
version: 1.0.3
|
62
61
|
type: :runtime
|
63
62
|
prerelease: false
|
64
63
|
version_requirements: !ruby/object:Gem::Requirement
|
65
64
|
requirements:
|
66
65
|
- - ">="
|
67
66
|
- !ruby/object:Gem::Version
|
68
|
-
version: 1.0.
|
67
|
+
version: 1.0.3
|
69
68
|
- !ruby/object:Gem::Dependency
|
70
69
|
name: typesafe_enum
|
71
70
|
requirement: !ruby/object:Gem::Requirement
|
@@ -136,8 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
135
|
- !ruby/object:Gem::Version
|
137
136
|
version: '0'
|
138
137
|
requirements: []
|
139
|
-
rubygems_version: 3.
|
140
|
-
signing_key:
|
138
|
+
rubygems_version: 3.6.0
|
141
139
|
specification_version: 4
|
142
140
|
summary: Generates an 'a href' tag, possibly with target='_blank' and rel='nofollow'.
|
143
141
|
test_files: []
|