jekyll-embed-urls 0.5.4 → 0.5.6
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/_includes/fallback.html +2 -2
- data/_includes/ogp.html +2 -2
- data/lib/jekyll/embed/content.rb +9 -2
- data/lib/jekyll/embed.rb +24 -8
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e6e72a30b43d661e9c852d548f48ba8f600cbbde41e6873489cf9ceb3d4435c
|
4
|
+
data.tar.gz: dd437ba4bbfa32d8e9c26792a3547672ae4197d8b23029b538d3a1ca814e64b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c6cb5356446f930287dd1feca9ac024db143a0f3bf531dc19f94e6e7b4a2602125a2b20bafb1029da46ad15c4cdfcbb4c2e783967f6bba16e1b21310c496557
|
7
|
+
data.tar.gz: b98314a98b042a9c7cf1f9cfbeacce6662d11b6c5ec8d6d85e0d96ea3f2bc32d0e0bcea8cf3fd387b7872fcbeb0555d2873ff242dc84f8e503e40a2374f23140
|
data/_includes/fallback.html
CHANGED
@@ -6,8 +6,8 @@
|
|
6
6
|
<img src="{{ page.image | uri_escape }}" class="img-fluid" />
|
7
7
|
{%- endif -%}
|
8
8
|
|
9
|
-
<h1>{{ page.title }}</h1>
|
10
|
-
<p class="lead">{{ page.description }}</p>
|
9
|
+
<h1>{{ page.title | escape_once }}</h1>
|
10
|
+
<p class="lead">{{ page.description | escape_once }}</p>
|
11
11
|
<p>
|
12
12
|
<small>
|
13
13
|
<a href="{{ page.url | uri_escape }}">{{ page.url }}</a>
|
data/_includes/ogp.html
CHANGED
@@ -9,8 +9,8 @@
|
|
9
9
|
<audio class="img-fluid" src="{{ page.audio | uri_escape }}"/>
|
10
10
|
{%- endif -%}
|
11
11
|
|
12
|
-
<h1>{{ page.title }}</h1>
|
13
|
-
<p class="lead">{{ page.description }}</p>
|
12
|
+
<h1>{{ page.title | escape_once }}</h1>
|
13
|
+
<p class="lead">{{ page.description | escape_once }}</p>
|
14
14
|
<p>
|
15
15
|
<small>
|
16
16
|
<a href="{{ page.url | uri_escape }}">{{ page.url }}</a>
|
data/lib/jekyll/embed/content.rb
CHANGED
@@ -12,8 +12,15 @@ module Jekyll
|
|
12
12
|
# sometimes we use HTML instead of pure Markdown and this way we
|
13
13
|
# catch both.
|
14
14
|
def embed!(content)
|
15
|
-
content.gsub!(URL_RE) do |
|
16
|
-
|
15
|
+
content.gsub!(URL_RE) do |match|
|
16
|
+
url = CGI.unescapeHTML($3)
|
17
|
+
embed = Jekyll::Embed.embed url
|
18
|
+
|
19
|
+
if embed == url
|
20
|
+
match
|
21
|
+
else
|
22
|
+
embed
|
23
|
+
end
|
17
24
|
end
|
18
25
|
end
|
19
26
|
end
|
data/lib/jekyll/embed.rb
CHANGED
@@ -160,7 +160,7 @@ module Jekyll
|
|
160
160
|
# TODO: Use Addressable
|
161
161
|
URI.parse url
|
162
162
|
|
163
|
-
oembed(url) || ogp(url) || fallback(url)
|
163
|
+
oembed(url) || ogp(url) || fallback(url) || url
|
164
164
|
rescue URI::Error
|
165
165
|
Jekyll.logger.warn "#{url.inspect} is not a valid URL"
|
166
166
|
|
@@ -197,17 +197,23 @@ module Jekyll
|
|
197
197
|
def ogp(url)
|
198
198
|
cache.getset("ogp+#{url}") do
|
199
199
|
ogp = OGP::OpenGraph.new get(url).body
|
200
|
-
|
201
|
-
context[:registers][:page] = payload['page'] = {
|
200
|
+
page = {
|
202
201
|
locale: ogp.locales.first,
|
203
|
-
image: ogp.images.first&.url,
|
204
202
|
title: ogp.title,
|
205
203
|
url: ogp.url,
|
206
|
-
audio: ogp.audios.first&.url,
|
207
|
-
video: ogp.videos.first&.url,
|
208
204
|
description: ogp.description,
|
209
|
-
type: ogp.type
|
210
|
-
|
205
|
+
type: ogp.type,
|
206
|
+
data: ogp.data
|
207
|
+
}.transform_keys(&:to_s)
|
208
|
+
|
209
|
+
%w[image video audio].each do |attr|
|
210
|
+
page[attr] = ogp.public_send(:"#{attr}s").find do |a|
|
211
|
+
http? i.url
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
context = info.dup
|
216
|
+
context[:registers][:page] = payload['page'] = page
|
211
217
|
|
212
218
|
cleanup ogp_template.render!(payload, context), url
|
213
219
|
end
|
@@ -364,6 +370,16 @@ module Jekyll
|
|
364
370
|
def payload
|
365
371
|
@payload ||= site.site_payload
|
366
372
|
end
|
373
|
+
|
374
|
+
# Discover if a string is a valid HTTP URL
|
375
|
+
#
|
376
|
+
# @param :url [String]
|
377
|
+
# @return [Boolean]
|
378
|
+
def http?(url)
|
379
|
+
url.start_with?('http') && URI.parse(url).is_a?(URI::HTTP)
|
380
|
+
rescue URI::Error
|
381
|
+
false
|
382
|
+
end
|
367
383
|
end
|
368
384
|
end
|
369
385
|
end
|