jekyll_href 1.2.3 → 1.2.5

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: f273b4ad20431d42f67bd6a8bba43823e158b4239d385951371e5511f31483f6
4
- data.tar.gz: 13ce74af244bd5d9d26c44a7ebeb340126f729f084cddf04c75d0b79e83e973e
3
+ metadata.gz: 071f512c7ac10e09846593c0ba16664176d94f4b231e2fb8c20d447671ebdafd
4
+ data.tar.gz: 8b2bc1abb6ef1ce60a45e47623cf258215c0e17d74aac15ab13eaa5a003aff1d
5
5
  SHA512:
6
- metadata.gz: 69169786943109c5f2fb288a430d247f8fa3a46b4d94c78607c012f3a9abd4116f38e66a4071e11c8bb53e8d21e7b3efe716aaf32d7a93c73d670026a24038bc
7
- data.tar.gz: b37d5401822827f70f9b1e00f5eef1e93f8cab00c97a808409d71e6f173d99c0dc7bab5e33c07c2e41b98d47a2749a2e9e771588f167c8b269fa50b07c47cc96
6
+ metadata.gz: 8f5ec5bdbaec6ea11245945dfa442725b99788e1229b2f2f38a2e6ed5881f8c67270b78d391fde9ec5a6df801ef2fdbbbf8cfba89bcab215eac7317ac9d5bef1
7
+ data.tar.gz: d0c075ec73231d74439cc4a804bd5fea1bb129ab4c018acb291c6aea531c633dd7f0c084c2ac361ba21b5fadbcaf7100a543fb019977f5d87927b36739c7bf95
data/.rubocop.yml CHANGED
@@ -64,7 +64,7 @@ Metrics/MethodLength:
64
64
  Max: 40
65
65
 
66
66
  Metrics/PerceivedComplexity:
67
- Max: 15
67
+ Max: 20
68
68
 
69
69
  Naming/FileName:
70
70
  Exclude:
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## 1.2.5 / 2023-05-26
2
+ * Added `style` and `class` options.
3
+
4
+ ## 1.2.4 / 2023-05-18
5
+ * When only a URI is provided, the plugin now generates the `http` scheme for IP4 & IP6 loopback addresses like
6
+ `localhost`, and `127.0.0.0`, as well as private IP4 addresses like 192.168.0.0 and 172.16.0.0;
7
+ otherwise it generates the `https` scheme.
8
+
1
9
  ## 1.2.3 / 2023-05-16
2
10
  * Added `label` option.
3
11
 
data/README.md CHANGED
@@ -82,6 +82,20 @@ To enforce the generation of this attribute, preface the link with the word `bla
82
82
  The `blank` and `notarget` parameters are mutually exclusive.
83
83
  If both are specified, `blank` prevails.
84
84
 
85
+ ### `class`
86
+ This option allows CSS classes to be added to the HTML generated by the `href` tag.
87
+ It has no effect on the `href_summary` tag output.
88
+
89
+ For example:
90
+
91
+ ```
92
+ {% href class='bg_yellow' https://mslinn.com click here %}
93
+ ```
94
+ Expands to:
95
+ ```
96
+ <a href="https://mslinn.com" class="bg_yellow" rel="nofollow" target="_blank">click here</a>
97
+ ```
98
+
85
99
  ### `follow`
86
100
  To suppress the `nofollow` attribute, preface the link with the word `follow`.
87
101
 
@@ -109,8 +123,8 @@ The `match` option looks through the pages collection for a URL with containing
109
123
 
110
124
 
111
125
  ### `shy`
112
- `shy` is only applicable for syntax 3 (implicit URL).
113
- This option causes displayed urls to have an &amp;shy; inserted after each slash (/).
126
+ The `shy` keyword option is only applicable for syntax 3 (implicit URL).
127
+ This option causes displayed urls to have an [`&amp;shy;`](https://developer.mozilla.org/en-US/docs/Web/CSS/hyphens) inserted after each slash (/).
114
128
  If both `shy` and `wbr` are specified, `wbr` prevails.
115
129
 
116
130
  For example:
@@ -119,21 +133,21 @@ For example:
119
133
  ```
120
134
  Expands to:
121
135
  ```
122
- <a href="https://mslinn.com/path/to/page.html">mslinn.com/&shy;path/&shy;to/&shy;page.html</a>
136
+ <a href="https://mslinn.com/path/to/page.html" rel="nofollow" target="_blank">mslinn.com/&shy;path/&shy;to/&shy;page.html</a>
123
137
  ```
124
138
 
125
- ### `shy`
126
- The `shy` keyword option is only applicable for syntax 3 (implicit URL).
127
- This option causes displayed urls to have an [`&amp;shy;`](https://developer.mozilla.org/en-US/docs/Web/CSS/hyphens) inserted after each slash (/).
128
- If both `shy` and `wbr` are specified, `wbr` prevails.
139
+ ### `style`
140
+ This option allows CSS styling to be added to the HTML generated by the `href` tag.
141
+ It has no effect on the `href_summary` tag output.
129
142
 
130
143
  For example:
144
+
131
145
  ```
132
- {% href shy mslinn.com/path/to/page.html %}
146
+ {% href style='color: red; font-weight: bold;' https://mslinn.com click here %}
133
147
  ```
134
148
  Expands to:
135
149
  ```
136
- <a href="https://mslinn.com/path/to/page.html" rel="nofollow" target="_blank">mslinn.com/&shy;path/&shy;to/&shy;page.html</a>
150
+ <a href="https://mslinn.com" rel="nofollow" style="color: ref; font-weight: bold" target="_blank">click here</a>
137
151
  ```
138
152
 
139
153
  ### `summary`
data/jekyll_href.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  END_OF_DESC
11
11
  spec.email = ['mslinn@mslinn.com']
12
12
  spec.files = Dir['.rubocop.yml', 'LICENSE.*', 'Rakefile', '{lib,spec}/**/*', '*.gemspec', '*.md']
13
- spec.homepage = 'https://www.mslinn.com/jekyll/3000-jekyll-plugins.html#href'
13
+ spec.homepage = 'https://www.mslinn.com/jekyll_plugins/jekyll_href.html'
14
14
  spec.license = 'MIT'
15
15
  spec.metadata = {
16
16
  'allowed_push_host' => 'https://rubygems.org',
@@ -28,9 +28,9 @@ Gem::Specification.new do |spec|
28
28
  spec.require_paths = ['lib']
29
29
  spec.required_ruby_version = '>= 2.6.0'
30
30
  spec.summary = "Generates an 'a href' tag, possibly with target='_blank' and rel='nofollow'."
31
- spec.test_files = spec.files.grep(%r!^(test|spec|features)/!)
32
31
  spec.version = JekyllHrefVersion::VERSION
33
32
 
33
+ spec.add_dependency 'ipaddress'
34
34
  spec.add_dependency 'jekyll', '>= 3.5.0'
35
35
  spec.add_dependency 'jekyll_all_collections', '~> 0.3.0', '>= 0.3.1'
36
36
  spec.add_dependency 'jekyll_plugin_support', '~> 0.6.0', '>= 0.6.1'
data/lib/href_tag.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'ipaddress'
1
2
  require 'jekyll_all_collections'
2
3
  require 'jekyll_plugin_logger'
3
4
  require 'jekyll_plugin_support'
@@ -46,7 +47,9 @@ module HrefTag
46
47
  globals_update(@helper.argv, linkk) # Sets @link and @text, might clear @follow and @target
47
48
  handle_match if @match
48
49
  save_summary
49
- "<a href='#{@link}'#{@target}#{@follow}>#{@text}</a>"
50
+ klass = " class='#{@klass}'" if @klass
51
+ style = " style='#{@style}'" if @style
52
+ "<a href='#{@link}'#{klass}#{style}#{@target}#{@follow}>#{@text}</a>"
50
53
  end
51
54
 
52
55
  private
@@ -121,11 +124,13 @@ module HrefTag
121
124
  AllCollectionsHooks.compute(@site)
122
125
 
123
126
  @blank = @helper.parameter_specified? 'blank'
127
+ @klass = @helper.parameter_specified? 'class'
124
128
  @follow = @helper.parameter_specified?('follow') ? '' : " rel='nofollow'"
125
129
  @match = @helper.parameter_specified? 'match'
126
130
  @label = @helper.parameter_specified? 'label'
127
131
  @summary_exclude = @helper.parameter_specified? 'summary_exclude'
128
132
  @shy = @helper.parameter_specified? 'shy'
133
+ @style = @helper.parameter_specified? 'style'
129
134
  @summary = @helper.parameter_specified? 'summary'
130
135
  @target = @blank ? " target='_blank'" : nil
131
136
  @target ||= @helper.parameter_specified?('notarget') ? '' : " target='_blank'"
@@ -151,7 +156,13 @@ module HrefTag
151
156
  text = linkk.gsub('/', '/&shy;') if @shy
152
157
  text = linkk.gsub('/', '/<wbr>') if @wbr
153
158
  @text = "<code>#{text}</code>"
154
- @link = linkk.start_with?('http') ? linkk : "https://#{linkk}"
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
155
166
  else
156
167
  @link = if @shy
157
168
  linkk.gsub('/', '/&shy;')
@@ -210,6 +221,19 @@ module HrefTag
210
221
  end
211
222
  end
212
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
+
213
237
  # Replace names in plugin-vars with values
214
238
  def replace_vars(text)
215
239
  variables = @site.config['plugin-vars']
@@ -1,3 +1,3 @@
1
1
  module JekyllHrefVersion
2
- VERSION = '1.2.3'.freeze
2
+ VERSION = '1.2.5'.freeze
3
3
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll_href
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.3
4
+ version: 1.2.5
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-05-17 00:00:00.000000000 Z
11
+ date: 2023-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ipaddress
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: jekyll
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -88,14 +102,14 @@ files:
88
102
  - spec/href_spec.rb
89
103
  - spec/spec_helper.rb
90
104
  - spec/status_persistence.txt
91
- homepage: https://www.mslinn.com/jekyll/3000-jekyll-plugins.html#href
105
+ homepage: https://www.mslinn.com/jekyll_plugins/jekyll_href.html
92
106
  licenses:
93
107
  - MIT
94
108
  metadata:
95
109
  allowed_push_host: https://rubygems.org
96
110
  bug_tracker_uri: https://github.com/mslinn/jekyll_href/issues
97
111
  changelog_uri: https://github.com/mslinn/jekyll_href/CHANGELOG.md
98
- homepage_uri: https://www.mslinn.com/jekyll/3000-jekyll-plugins.html#href
112
+ homepage_uri: https://www.mslinn.com/jekyll_plugins/jekyll_href.html
99
113
  source_code_uri: https://github.com/mslinn/jekyll_href
100
114
  post_install_message: |2+
101
115
 
@@ -119,9 +133,5 @@ rubygems_version: 3.3.3
119
133
  signing_key:
120
134
  specification_version: 4
121
135
  summary: Generates an 'a href' tag, possibly with target='_blank' and rel='nofollow'.
122
- test_files:
123
- - spec/hash_array_spec.rb
124
- - spec/href_spec.rb
125
- - spec/spec_helper.rb
126
- - spec/status_persistence.txt
136
+ test_files: []
127
137
  ...