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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d98dd353e927f8df1cf3832b2afefebb7be6dda942346cfaefb4899ec4de2606
4
- data.tar.gz: 3bae16798938728a608f21161324d5843da1e0df1e210ac0e34cf894d5d29ed4
3
+ metadata.gz: 33ad179cd8d6770d3828246bdc51cdbe398f7fd3f50b0101481e2dacd597191e
4
+ data.tar.gz: 543a944799bdb811fd84f3afb4ce0b8239e2008208feb0612360307bd1843c69
5
5
  SHA512:
6
- metadata.gz: 27cc832e73c2eaf4db34dcb6cb67c026702ed9e106aa965d61a572cb44c0c4edcc0ca08ad0039c24e074734ecbce6f71643f6e049e76d6830ba64a548a35ed04
7
- data.tar.gz: 819b74d3d7c6e1a6a6bc7d01797cccaa0c888dfcc7d3e8464b65c1d150bf5fa4dca349275e487163cf24ec38e7acaceae9d525a73f8eb5bf2676383cb85aa1a3
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JekyllHrefVersion
4
- VERSION = "1.0.9"
4
+ VERSION = "1.0.12"
5
5
  end
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(context)
81
- match(context) if @match
82
- link = replace_vars(context, @link)
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(context) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
115
- site = context.registers[:site]
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
- urls = site.collections
129
- .values
130
- .map { |x| x.class.method_defined?(:docs) ? x.docs : x }
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(context, link)
148
- variables = context.registers[:site].config['plugin-vars']
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.9
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-04-25 00:00:00.000000000 Z
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: jekyll_plugin_logger
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: debase
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: :development
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.1.4
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
+ ...