jekyll-embed-urls 0.6.0 → 0.6.2
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
- checksums.yaml.gz.sig +2 -0
- data/README.md +4 -1
- data/_includes/embed.html +11 -0
- data/_includes/fallback.html +9 -7
- data/_includes/ogp.html +3 -3
- data/lib/jekyll/embed/content.rb +1 -1
- data/lib/jekyll/embed.rb +35 -14
- data.tar.gz.sig +0 -0
- metadata +32 -4
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2671ab5689686d0a583e1136fe0b99d7614e9d23b75fae9865c000b7def5fe7c
|
4
|
+
data.tar.gz: 3ebcd68f3c94590cf0d57933810a56d017f1e01e21ca519c2792824178b9997c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c7229cb23e7b63afaa78fa703bb08e8f1c6a77f4079a067b03fcd95b8ee5e0aded41711a96036c0e251154e8a76a022c24f5d5b88652eac3ff18c77d8ed5f58
|
7
|
+
data.tar.gz: de5eff0325072f11055dd61aad1748587ffce39e84dcb3e85aac4903d90872a1ea400e7e876ddd2c59a6bb641b6822b3dc04b9f5afab9dea50bbfa36a8bd1169
|
checksums.yaml.gz.sig
ADDED
data/README.md
CHANGED
@@ -47,7 +47,8 @@ embed:
|
|
47
47
|
- canvas
|
48
48
|
- area
|
49
49
|
- map
|
50
|
-
# Attribute values can be strings or array of strings
|
50
|
+
# Attribute values can be strings or array of strings, or nil/false for
|
51
|
+
# removing them, or true to add them without value
|
51
52
|
attributes:
|
52
53
|
referrerpolicy: strict-origin-when-cross-origin
|
53
54
|
sandbox:
|
@@ -60,6 +61,8 @@ embed:
|
|
60
61
|
- clipboard-write;
|
61
62
|
loading: 'lazy'
|
62
63
|
controls: true
|
64
|
+
width: nil
|
65
|
+
height: nil
|
63
66
|
rel:
|
64
67
|
- noopener
|
65
68
|
- noreferrer
|
data/_includes/fallback.html
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
{% if page.url contains "//archive.org/" or page.url contains "//www.archive.org/" %}
|
2
|
-
<
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
2
|
+
<div class="embed-responsive embed-responsive-16by9">
|
3
|
+
<iframe
|
4
|
+
class="embed-responsive-item"
|
5
|
+
allow="{{ embed.allow | join: " " }}"
|
6
|
+
sandbox="{{ embed.sandbox | join: " " }}"
|
7
|
+
loading="{{ embed.loading }}"
|
8
|
+
referrerpolicy="{{ embed.referrerpolicy }}"
|
9
|
+
src="{{ page.url | replace: "/details/", "/embed/" | uri_escape }}"></iframe>
|
10
|
+
</div>
|
9
11
|
{% else %}
|
10
12
|
{% include ogp.html type="fallback" %}
|
11
13
|
{% endif %}
|
data/_includes/ogp.html
CHANGED
@@ -22,10 +22,10 @@
|
|
22
22
|
{%- endif -%}
|
23
23
|
|
24
24
|
<header class="card-body">
|
25
|
-
<h1>{{ page.title | escape_once }}</h1>
|
25
|
+
<h1 class="lead">{{ page.title | escape_once | newline_to_br }}</h1>
|
26
26
|
{% if page.description %}
|
27
|
-
<p
|
28
|
-
{{- page.description | escape_once -}}
|
27
|
+
<p>
|
28
|
+
{{- page.description | escape_once | newline_to_br -}}
|
29
29
|
</p>
|
30
30
|
{% endif %}
|
31
31
|
|
data/lib/jekyll/embed/content.rb
CHANGED
@@ -13,7 +13,7 @@ module Jekyll
|
|
13
13
|
# @param :content [String]
|
14
14
|
# @return [String]
|
15
15
|
def embed(content)
|
16
|
-
Nokogiri::HTML5.fragment(content).tap do |html|
|
16
|
+
::Nokogiri::HTML5.fragment(content).tap do |html|
|
17
17
|
html.css('p > a').each do |a|
|
18
18
|
next unless a.parent.children.size == 1
|
19
19
|
next unless a['href'] == a.text.strip
|
data/lib/jekyll/embed.rb
CHANGED
@@ -51,9 +51,9 @@ module Jekyll
|
|
51
51
|
# legitimate reasons to remove media from the Internet.
|
52
52
|
class Embed
|
53
53
|
# Attributes to apply by HTMLElement
|
54
|
-
IFRAME_ATTRIBUTES = %w[allow sandbox referrerpolicy loading].freeze
|
55
|
-
IMAGE_ATTRIBUTES = %w[referrerpolicy loading].freeze
|
56
|
-
MEDIA_ATTRIBUTES = %w[controls].freeze
|
54
|
+
IFRAME_ATTRIBUTES = %w[allow sandbox referrerpolicy loading height width].freeze
|
55
|
+
IMAGE_ATTRIBUTES = %w[referrerpolicy loading height width].freeze
|
56
|
+
MEDIA_ATTRIBUTES = %w[controls height width].freeze
|
57
57
|
A_ATTRIBUTES = %w[referrerpolicy rel target].freeze
|
58
58
|
|
59
59
|
# Directive from Feature Policy
|
@@ -64,6 +64,7 @@ module Jekyll
|
|
64
64
|
# Templates
|
65
65
|
INCLUDE_OGP = '{% include ogp.html %}'
|
66
66
|
INCLUDE_FALLBACK = '{% include fallback.html %}'
|
67
|
+
INCLUDE_EMBED = '{% include embed.html %}'
|
67
68
|
|
68
69
|
# The default referrer policy only sends the origin URL (not the
|
69
70
|
# full URL, only the protocol/scheme and domain part) if the remote
|
@@ -84,7 +85,9 @@ module Jekyll
|
|
84
85
|
'loading' => 'lazy',
|
85
86
|
'controls' => true,
|
86
87
|
'rel' => %w[noopener noreferrer],
|
87
|
-
'target' => '_blank'
|
88
|
+
'target' => '_blank',
|
89
|
+
'height' => nil,
|
90
|
+
'width' => nil
|
88
91
|
}
|
89
92
|
}.freeze
|
90
93
|
|
@@ -191,7 +194,10 @@ module Jekyll
|
|
191
194
|
# Prevent caching of nil?
|
192
195
|
raise OEmbed::Error unless oembed.respond_to? :html
|
193
196
|
|
194
|
-
|
197
|
+
context = info.dup
|
198
|
+
context[:registers][:page] = payload['page'] = cleanup(oembed.html, url)
|
199
|
+
|
200
|
+
embed_template.render!(payload, context)
|
195
201
|
end
|
196
202
|
rescue OEmbed::Error
|
197
203
|
nil
|
@@ -233,7 +239,7 @@ module Jekyll
|
|
233
239
|
# Try something
|
234
240
|
def fallback(url)
|
235
241
|
cache.getset("fallback+#{url}") do
|
236
|
-
html = Nokogiri::HTML.fragment get(url).body
|
242
|
+
html = ::Nokogiri::HTML.fragment get(url).body
|
237
243
|
element = html.css('article').first
|
238
244
|
element ||= html.css('section').first
|
239
245
|
element ||= html.css('main').first
|
@@ -255,7 +261,7 @@ module Jekyll
|
|
255
261
|
rescue ArgumentError
|
256
262
|
Jekyll.logger.warn 'Invalid contents (fallback):', url
|
257
263
|
nil
|
258
|
-
rescue Faraday::Error, Nokogiri::SyntaxError
|
264
|
+
rescue Faraday::Error, ::Nokogiri::SyntaxError
|
259
265
|
nil
|
260
266
|
end
|
261
267
|
|
@@ -292,7 +298,7 @@ module Jekyll
|
|
292
298
|
# Add our own attributes
|
293
299
|
html.css('iframe').each do |iframe|
|
294
300
|
IFRAME_ATTRIBUTES.each do |attr|
|
295
|
-
iframe
|
301
|
+
set_value_for_attr(iframe, attr)
|
296
302
|
end
|
297
303
|
|
298
304
|
# Embedding itself require allow-same-origin
|
@@ -301,7 +307,7 @@ module Jekyll
|
|
301
307
|
|
302
308
|
html.css('audio, video').each do |media|
|
303
309
|
MEDIA_ATTRIBUTES.each do |attr|
|
304
|
-
media
|
310
|
+
set_value_for_attr(media, attr)
|
305
311
|
end
|
306
312
|
|
307
313
|
media['src'] = UrlPrivacy.clean media['src']
|
@@ -309,22 +315,22 @@ module Jekyll
|
|
309
315
|
|
310
316
|
html.css('img').each do |img|
|
311
317
|
IMAGE_ATTRIBUTES.each do |attr|
|
312
|
-
img
|
318
|
+
set_value_for_attr(img, attr)
|
313
319
|
end
|
314
320
|
end
|
315
321
|
|
316
322
|
html.css('a').each do |a|
|
317
323
|
A_ATTRIBUTES.each do |attr|
|
318
|
-
a
|
324
|
+
set_value_for_attr(a, attr)
|
319
325
|
end
|
320
326
|
end
|
321
327
|
|
322
328
|
html.css('[src]').each do |element|
|
323
|
-
element['src'] =
|
329
|
+
element['src'] = UrlPrivacy.clean(element['src'])
|
324
330
|
end
|
325
331
|
|
326
332
|
html.css('[href]').each do |element|
|
327
|
-
element['href'] =
|
333
|
+
element['href'] = UrlPrivacy.clean(element['href'])
|
328
334
|
end
|
329
335
|
|
330
336
|
# Return the cleaned up HTML as a String
|
@@ -337,6 +343,10 @@ module Jekyll
|
|
337
343
|
|
338
344
|
private
|
339
345
|
|
346
|
+
def embed_template
|
347
|
+
@embed_template ||= site.liquid_renderer.file('embed.html').parse(INCLUDE_EMBED)
|
348
|
+
end
|
349
|
+
|
340
350
|
def fallback_template
|
341
351
|
@fallback_template ||= site.liquid_renderer.file('fallback.html').parse(INCLUDE_FALLBACK)
|
342
352
|
end
|
@@ -359,11 +369,22 @@ module Jekyll
|
|
359
369
|
@value_for_attr ||= {}
|
360
370
|
@value_for_attr[attr] ||=
|
361
371
|
case (value = config.dig('attributes', attr))
|
362
|
-
when String then value
|
363
372
|
when Array then value.join(' ')
|
373
|
+
else value
|
364
374
|
end
|
365
375
|
end
|
366
376
|
|
377
|
+
# @param element [Nokogiri::XML::Element]
|
378
|
+
# @param attr [String]
|
379
|
+
# @return [nil]
|
380
|
+
def set_value_for_attr(element, attr)
|
381
|
+
case (value = value_for_attr(attr))
|
382
|
+
when NilClass, FalseClass then element.delete(attr)
|
383
|
+
when TrueClass then element[attr] = nil
|
384
|
+
else element[attr] = value
|
385
|
+
end
|
386
|
+
end
|
387
|
+
|
367
388
|
# If the iframe comes from the same site, we can allow the same
|
368
389
|
# origin policy on the sandbox.
|
369
390
|
#
|
data.tar.gz.sig
ADDED
Binary file
|
metadata
CHANGED
@@ -1,14 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-embed-urls
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- f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+
BgNVHQ8EBAMCBLAwHQYDVR0OBBYEFIH0kjcsF7inzAwy488EEY5thfpiMBkGA1Ud
|
27
|
+
EQQSMBCBDmZhdW5vQHN1dHR5Lm5sMBkGA1UdEgQSMBCBDmZhdW5vQHN1dHR5Lm5s
|
28
|
+
MA0GCSqGSIb3DQEBCwUAA4IBgQCEo4E1ZAjlzw7LeJlju4BWUvKLjrbGiDNBYQir
|
29
|
+
lmyHhYXWV3gnozs08sM3BNzwsPwDwIhYOu3Kc+36DtEpKToUxqEGbsxX8uGzyp88
|
30
|
+
HTlaNsaHCZBeB2wgUYcIeO2lKdNu+V9WxfTRhYu+02OfLRv65qSfm6uck1Ml1Cg/
|
31
|
+
tn1Y7mLHSdnWPZCQhQZA0wX/SFL64DeozAwJLhYtKneU/m5PEqv9nNnJVCLlbODB
|
32
|
+
zFTjbsKtpWxNN+xWsJbjukggS8uX1400WqyjUCitDxDJknP+xeAg8wt2wT+IC1X1
|
33
|
+
zMY8gjxoBfwPum74cBTaZzYMpeGaS1fJ3N4NBU+SHLRDiKaVZzEnoNyJDHnsXXrX
|
34
|
+
MvF98+bTUHC9xcklH7RCO5uqUOq7cxIcMjzx3cpR6+AW6zXYQBjWfNB9KfaAstZy
|
35
|
+
cpurTQHNJfL/ah+9dYbgDXdG5HAAjRMAsWSvERw95YdN9XzQZCdUk5wUs+A6cNtO
|
36
|
+
AZZUMTVYNx8JqUeemxlXBRjsD/s=
|
37
|
+
-----END CERTIFICATE-----
|
38
|
+
date: 2025-05-07 00:00:00.000000000 Z
|
12
39
|
dependencies:
|
13
40
|
- !ruby/object:Gem::Dependency
|
14
41
|
name: jekyll
|
@@ -155,6 +182,7 @@ files:
|
|
155
182
|
- CHANGELOG.md
|
156
183
|
- LICENSE.txt
|
157
184
|
- README.md
|
185
|
+
- _includes/embed.html
|
158
186
|
- _includes/fallback.html
|
159
187
|
- _includes/ogp.html
|
160
188
|
- lib/jekyll-embed-urls.rb
|
@@ -194,7 +222,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
194
222
|
- !ruby/object:Gem::Version
|
195
223
|
version: '0'
|
196
224
|
requirements: []
|
197
|
-
rubygems_version: 3.3.
|
225
|
+
rubygems_version: 3.3.27
|
198
226
|
signing_key:
|
199
227
|
specification_version: 4
|
200
228
|
summary: Embed URL previsualization in Jekyll posts
|
metadata.gz.sig
ADDED
Binary file
|