jekyll-embed-urls 0.5.6 → 0.5.8
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/lib/jekyll/embed/cache.rb +1 -1
- data/lib/jekyll/embed/content.rb +2 -2
- data/lib/jekyll/embed/oembed.rb +2 -1
- data/lib/jekyll/embed.rb +27 -20
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 28bf483423f9197271caae346deae52aa1d4b34c229dc723f58624c52f63e4d3
|
4
|
+
data.tar.gz: bffb7fa7898714d8eee3284f35ead0819cecca5359fa0557ef1353c1fb322fe2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 143344abdd6ef63b5b8133a85697bf3aae0a64679773786a0e9fb96a26f77846abd202234169bed24f810eaf7018d96a6003897fc485d7a15f0af2ace773b589
|
7
|
+
data.tar.gz: fd6f00caec463617d2ce6dc0298db823f324708a5c4770725cc6391e9879fefa65bfc6c585d400652ada0feea838038ffefe73982da7795f3218ed920a2a61bf
|
data/lib/jekyll/embed/cache.rb
CHANGED
data/lib/jekyll/embed/content.rb
CHANGED
@@ -5,7 +5,7 @@ require 'cgi'
|
|
5
5
|
module Jekyll
|
6
6
|
class Embed
|
7
7
|
class Content
|
8
|
-
URL_RE =
|
8
|
+
URL_RE = %r{(<p[^>]*>[\s\n]*(<a[^>]*>)?[\s\n]*(https?://[^<\s\n]+)[\s\n]*(</a>)?[\s\n]*</p>)}m.freeze
|
9
9
|
|
10
10
|
class << self
|
11
11
|
# Find URLs on paragraphs. We do it after rendering because
|
@@ -13,7 +13,7 @@ module Jekyll
|
|
13
13
|
# catch both.
|
14
14
|
def embed!(content)
|
15
15
|
content.gsub!(URL_RE) do |match|
|
16
|
-
url = CGI.unescapeHTML(
|
16
|
+
url = CGI.unescapeHTML(Regexp.last_match(3))
|
17
17
|
embed = Jekyll::Embed.embed url
|
18
18
|
|
19
19
|
if embed == url
|
data/lib/jekyll/embed/oembed.rb
CHANGED
@@ -6,7 +6,7 @@ module OEmbed
|
|
6
6
|
module ProviderDecorator
|
7
7
|
def self.included(base)
|
8
8
|
base.class_eval do
|
9
|
-
def http_get(url, _)
|
9
|
+
private def http_get(url, _)
|
10
10
|
Jekyll::Embed.get(url.to_s).body
|
11
11
|
rescue Faraday::Error
|
12
12
|
raise OEmbed::UnknownResponse
|
@@ -17,3 +17,4 @@ module OEmbed
|
|
17
17
|
end
|
18
18
|
|
19
19
|
OEmbed::Provider.include OEmbed::ProviderDecorator
|
20
|
+
OEmbed::ProviderDiscovery.singleton_class.include OEmbed::ProviderDecorator
|
data/lib/jekyll/embed.rb
CHANGED
@@ -13,7 +13,7 @@ require_relative 'embed/cache'
|
|
13
13
|
if Gem::Version.new(Jekyll::VERSION) >= Gem::Version.new('4.2.0')
|
14
14
|
require_relative 'embed/content'
|
15
15
|
else
|
16
|
-
Jekyll.logger.warn
|
16
|
+
Jekyll.logger.warn 'Upgrade to Jekyll >= 4.2.0 to embed URLs in content'
|
17
17
|
end
|
18
18
|
|
19
19
|
OEmbed::Providers.register_all
|
@@ -57,7 +57,8 @@ module Jekyll
|
|
57
57
|
|
58
58
|
# Directive from Feature Policy
|
59
59
|
# @see {https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Feature-Policy#directives}
|
60
|
-
DIRECTIVES = %w[accelerometer ambient-light-sensor autoplay battery camera display-capture document-domain
|
60
|
+
DIRECTIVES = %w[accelerometer ambient-light-sensor autoplay battery camera display-capture document-domain
|
61
|
+
encrypted-media execution-while-not-rendered execution-while-out-of-viewport fullscreen gamepad geolocation gyroscope layout-animations legacy-image-formats magnetometer microphone midi navigation-override oversized-images payment picture-in-picture publickey-credentials-get speaker-selection sync-xhr usb screen-wake-lock web-share xr-spatial-tracking].freeze
|
61
62
|
|
62
63
|
# Templates
|
63
64
|
INCLUDE_OGP = '{% include ogp.html site=site page=page %}'
|
@@ -84,13 +85,13 @@ module Jekyll
|
|
84
85
|
'rel' => %w[noopener noreferrer],
|
85
86
|
'target' => '_blank'
|
86
87
|
}
|
87
|
-
}
|
88
|
+
}.freeze
|
88
89
|
|
89
90
|
class << self
|
90
91
|
def site
|
91
92
|
unless @site
|
92
93
|
raise Jekyll::Errors::InvalidConfigurationError,
|
93
|
-
|
94
|
+
'Site is missing, configure with `Jekyll::Embed.site = site`'
|
94
95
|
end
|
95
96
|
|
96
97
|
@site
|
@@ -101,7 +102,7 @@ module Jekyll
|
|
101
102
|
# @param [Jekyll::Site]
|
102
103
|
# @return [Jekyll::Site]
|
103
104
|
def site=(site)
|
104
|
-
raise ArgumentError,
|
105
|
+
raise ArgumentError, 'Site must be a Jekyll::Site' unless site.is_a? Jekyll::Site
|
105
106
|
|
106
107
|
@site = site
|
107
108
|
|
@@ -130,15 +131,15 @@ module Jekyll
|
|
130
131
|
def reset
|
131
132
|
@allow_same_origin =
|
132
133
|
@cache =
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
134
|
+
@config =
|
135
|
+
@fallback_template =
|
136
|
+
@get_cache =
|
137
|
+
@http_client =
|
138
|
+
@info =
|
139
|
+
@ogp_template =
|
140
|
+
@payload =
|
141
|
+
@value_for_attr =
|
142
|
+
nil
|
142
143
|
end
|
143
144
|
|
144
145
|
# Render the URL as HTML
|
@@ -170,7 +171,9 @@ module Jekyll
|
|
170
171
|
# @return [Hash]
|
171
172
|
def config
|
172
173
|
@config ||= Jekyll::Utils.deep_merge_hashes(DEFAULT_CONFIG, (site.config['embed'] || {})).tap do |c|
|
173
|
-
c['attributes']['allow'].concat (DIRECTIVES - c.dig('attributes', 'allow').join.split(';').map
|
174
|
+
c['attributes']['allow'].concat (DIRECTIVES - c.dig('attributes', 'allow').join.split(';').map do |s|
|
175
|
+
s.split(' ').first
|
176
|
+
end).join(" 'none';|").split('|')
|
174
177
|
end
|
175
178
|
end
|
176
179
|
|
@@ -208,8 +211,8 @@ module Jekyll
|
|
208
211
|
|
209
212
|
%w[image video audio].each do |attr|
|
210
213
|
page[attr] = ogp.public_send(:"#{attr}s").find do |a|
|
211
|
-
http?
|
212
|
-
end
|
214
|
+
http? a.url
|
215
|
+
end&.url
|
213
216
|
end
|
214
217
|
|
215
218
|
context = info.dup
|
@@ -262,6 +265,10 @@ module Jekyll
|
|
262
265
|
# @return [Faraday::Connection]
|
263
266
|
def http_client
|
264
267
|
@http_client ||= Faraday.new do |builder|
|
268
|
+
builder.options.timeout = 4
|
269
|
+
builder.options.open_timeout = 1
|
270
|
+
builder.options.read_timeout = 1
|
271
|
+
builder.options.write_timeout = 1
|
265
272
|
builder.use FaradayMiddleware::FollowRedirects
|
266
273
|
builder.use :http_cache, shared_cache: false, store: cache, serializer: Marshal
|
267
274
|
end
|
@@ -343,8 +350,8 @@ module Jekyll
|
|
343
350
|
@value_for_attr ||= {}
|
344
351
|
@value_for_attr[attr] ||=
|
345
352
|
case (value = config.dig('attributes', attr))
|
346
|
-
|
347
|
-
|
353
|
+
when String then value
|
354
|
+
when Array then value.join(' ')
|
348
355
|
end
|
349
356
|
end
|
350
357
|
|
@@ -355,7 +362,7 @@ module Jekyll
|
|
355
362
|
# @return [String]
|
356
363
|
def allow_same_origin(url)
|
357
364
|
unless site.config['url']
|
358
|
-
Jekyll.logger.warn
|
365
|
+
Jekyll.logger.warn 'Add url to _config.yml to determine if the site can embed itself'
|
359
366
|
return ' allow-same-origin'
|
360
367
|
end
|
361
368
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-embed-urls
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- f
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -128,6 +128,20 @@ dependencies:
|
|
128
128
|
- - "~>"
|
129
129
|
- !ruby/object:Gem::Version
|
130
130
|
version: '0'
|
131
|
+
- !ruby/object:Gem::Dependency
|
132
|
+
name: rubocop
|
133
|
+
requirement: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0'
|
138
|
+
type: :development
|
139
|
+
prerelease: false
|
140
|
+
version_requirements: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
131
145
|
description: Replaces URLs for their previsualization in Jekyll posts
|
132
146
|
email:
|
133
147
|
- f@sutty.nl
|
@@ -180,7 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
180
194
|
- !ruby/object:Gem::Version
|
181
195
|
version: '0'
|
182
196
|
requirements: []
|
183
|
-
rubygems_version: 3.
|
197
|
+
rubygems_version: 3.3.26
|
184
198
|
signing_key:
|
185
199
|
specification_version: 4
|
186
200
|
summary: Embed URL previsualization in Jekyll posts
|