jekyll-embed-urls 0.6.5 → 0.7.0
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 +0 -0
- data/_includes/audio.html +3 -0
- data/_includes/image.html +3 -0
- data/_includes/video.html +3 -0
- data/lib/jekyll/embed.rb +62 -18
- data.tar.gz.sig +0 -0
- metadata +26 -24
- metadata.gz.sig +0 -0
- data/lib/jekyll/embed/cache.rb +0 -18
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f0bd4036faf5edc50c02614e2116962510612c676e0c3785239aaff456b9167d
|
|
4
|
+
data.tar.gz: ca0ca066de89cfa371d7e210bcbbe1a2e05a26ed2cb47be9d139314c0bdc708e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3d36b8d81a1e88af229d85e2d5e9283f6d7a0da009fae5a640abf1fee2f9a1c413983f4f4373645f5b2cdab5fbbf04b8a74112039efa0ca25ef4a307e28dd2cf
|
|
7
|
+
data.tar.gz: 3fd61a3bf39322d8e30376ffc3fe7c340390631ba2255e1c6bfc9d067b3784afaf6fb7f160ecceacf9671fe453052524594d404bd103adf8b21105de6961d28d
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/lib/jekyll/embed.rb
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'faraday'
|
|
4
|
-
require 'faraday-http-cache'
|
|
5
4
|
require 'faraday_middleware/response/follow_redirects'
|
|
6
5
|
require 'faraday_middleware/redirect_limit_reached'
|
|
7
6
|
require 'loofah'
|
|
@@ -9,7 +8,6 @@ require 'ogp'
|
|
|
9
8
|
require 'url_privacy'
|
|
10
9
|
|
|
11
10
|
require_relative 'embed/oembed'
|
|
12
|
-
require_relative 'embed/cache'
|
|
13
11
|
|
|
14
12
|
if Gem::Version.new(Jekyll::VERSION) >= Gem::Version.new('4.2.0')
|
|
15
13
|
require_relative 'embed/content'
|
|
@@ -65,6 +63,9 @@ module Jekyll
|
|
|
65
63
|
INCLUDE_OGP = '{% include ogp.html %}'
|
|
66
64
|
INCLUDE_FALLBACK = '{% include fallback.html %}'
|
|
67
65
|
INCLUDE_EMBED = '{% include embed.html %}'
|
|
66
|
+
INCLUDE_IMAGE = '{% include image.html %}'
|
|
67
|
+
INCLUDE_VIDEO = '{% include video.html %}'
|
|
68
|
+
INCLUDE_AUDIO = '{% include audio.html %}'
|
|
68
69
|
|
|
69
70
|
# The default referrer policy only sends the origin URL (not the
|
|
70
71
|
# full URL, only the protocol/scheme and domain part) if the remote
|
|
@@ -136,13 +137,14 @@ module Jekyll
|
|
|
136
137
|
@allow_same_origin =
|
|
137
138
|
@cache =
|
|
138
139
|
@config =
|
|
139
|
-
@
|
|
140
|
-
@
|
|
141
|
-
@
|
|
142
|
-
@
|
|
143
|
-
@
|
|
144
|
-
@
|
|
145
|
-
@
|
|
140
|
+
@embed_template =
|
|
141
|
+
@fallback_template =
|
|
142
|
+
@get_cache =
|
|
143
|
+
@http_client =
|
|
144
|
+
@info =
|
|
145
|
+
@ogp_template =
|
|
146
|
+
@payload =
|
|
147
|
+
@value_for_attr =
|
|
146
148
|
nil
|
|
147
149
|
end
|
|
148
150
|
|
|
@@ -156,20 +158,46 @@ module Jekyll
|
|
|
156
158
|
# @param [String] URL
|
|
157
159
|
# @return [String] HTML
|
|
158
160
|
def embed(url)
|
|
159
|
-
raise URI::Error unless url.is_a? String
|
|
161
|
+
raise URI::Error.new(url.class.name) unless url.is_a? String
|
|
160
162
|
|
|
161
163
|
url = url.strip
|
|
164
|
+
url = "https://#{url}" if url.start_with? '//'
|
|
162
165
|
|
|
163
166
|
# Quick check
|
|
164
|
-
raise URI::Error unless url.start_with? 'http'
|
|
167
|
+
raise URI::Error.new(url) unless url.start_with? 'http'
|
|
168
|
+
|
|
169
|
+
url = UrlPrivacy.clean(url)
|
|
165
170
|
|
|
166
171
|
# Just to verify the URL is valid
|
|
167
172
|
# TODO: Use Addressable
|
|
168
173
|
URI.parse url
|
|
169
174
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
175
|
+
# Check the content type, if it's not a webpage, we need to
|
|
176
|
+
# build something else
|
|
177
|
+
head = http_client.head url
|
|
178
|
+
|
|
179
|
+
raise URI::Error.new(head.status.to_s) unless head.success?
|
|
180
|
+
|
|
181
|
+
case head.headers['content-type']
|
|
182
|
+
when /\Atext\/html;? /
|
|
183
|
+
oembed(url) || ogp(url) || fallback(url) || url
|
|
184
|
+
when /\Aimage\//
|
|
185
|
+
context = info.dup
|
|
186
|
+
context[:url] = url
|
|
187
|
+
image_template.render!(payload, context)
|
|
188
|
+
when /\Avideo\//
|
|
189
|
+
context = info.dup
|
|
190
|
+
context[:url] = url
|
|
191
|
+
video_template.render!(payload, context)
|
|
192
|
+
when /\Aaudio\//
|
|
193
|
+
context = info.dup
|
|
194
|
+
context[:url] = url
|
|
195
|
+
audio_template.render!(payload, context)
|
|
196
|
+
else
|
|
197
|
+
raise URI::Error
|
|
198
|
+
end
|
|
199
|
+
rescue URI::Error, Faraday::Error => e
|
|
200
|
+
Jekyll.logger.warn "#{url.inspect} is not a valid URL: #{e.message}"
|
|
173
201
|
|
|
174
202
|
url
|
|
175
203
|
end
|
|
@@ -269,12 +297,17 @@ module Jekyll
|
|
|
269
297
|
# @return [Faraday::Response]
|
|
270
298
|
def get(url)
|
|
271
299
|
@get_cache ||= {}
|
|
272
|
-
@get_cache[url] ||= http_client.get url
|
|
300
|
+
@get_cache[url.to_s] ||= http_client.get url
|
|
273
301
|
end
|
|
274
302
|
|
|
275
|
-
|
|
303
|
+
def head(url)
|
|
304
|
+
@head_cache ||= {}
|
|
305
|
+
@head_cache[url.to_s] ||= http_client.head url
|
|
306
|
+
end
|
|
307
|
+
|
|
308
|
+
# @return [Jekyll::Cache]
|
|
276
309
|
def cache
|
|
277
|
-
@cache ||= Jekyll::
|
|
310
|
+
@cache ||= Jekyll::Cache.new('Jekyll::Embed')
|
|
278
311
|
end
|
|
279
312
|
|
|
280
313
|
# @return [Faraday::Connection]
|
|
@@ -285,7 +318,6 @@ module Jekyll
|
|
|
285
318
|
builder.options.read_timeout = 1
|
|
286
319
|
builder.options.write_timeout = 1
|
|
287
320
|
builder.use FaradayMiddleware::FollowRedirects
|
|
288
|
-
builder.use :http_cache, shared_cache: false, store: cache, serializer: Marshal
|
|
289
321
|
end
|
|
290
322
|
end
|
|
291
323
|
|
|
@@ -355,6 +387,18 @@ module Jekyll
|
|
|
355
387
|
@ogp_template ||= site.liquid_renderer.file('ogp.html').parse(INCLUDE_OGP)
|
|
356
388
|
end
|
|
357
389
|
|
|
390
|
+
def image_template
|
|
391
|
+
@image_template ||= site.liquid_renderer.file('image.html').parse(INCLUDE_IMAGE)
|
|
392
|
+
end
|
|
393
|
+
|
|
394
|
+
def video_template
|
|
395
|
+
@video_template ||= site.liquid_renderer.file('video.html').parse(INCLUDE_VIDEO)
|
|
396
|
+
end
|
|
397
|
+
|
|
398
|
+
def audio_template
|
|
399
|
+
@audio_template ||= site.liquid_renderer.file('audio.html').parse(INCLUDE_AUDIO)
|
|
400
|
+
end
|
|
401
|
+
|
|
358
402
|
def info
|
|
359
403
|
@info ||= {
|
|
360
404
|
registers: { site: site },
|
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: jekyll-embed-urls
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.7.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- f
|
|
@@ -12,7 +12,7 @@ cert_chain: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+wnlXGoB6DvjZ+48g
|
|
31
|
+
Vo94+QPTx5xCEUX50bkO2NZlQ4BE8IiHAaGR5c3tF5+pc+SnEFXFGJSYzXciyNgf
|
|
32
|
+
j2/Kvfs1W/X+W6mCoo6tTgHQM9vMk7bgREZkhQ33iNK6+7IsGCDlNuKcXjJykSqJ
|
|
33
|
+
zY6og/GTEVPpKbFvHcrebKT6HMOCIMD5Q/8whxTWH+GWMuoV9l7tikfX2uAKz/fS
|
|
34
|
+
Ci6FFLH2vK5bS5h0ZTCDaJwZ3ikKQl52F+IY3NxFmg3X38xlVrDqnIZWb06aAXjO
|
|
35
|
+
AloSNM24NWhA2fme6cgZOLKXvAKgf6pQsNtAnU1Pliou5GvJ62d8l+pdKGxJ4yTn
|
|
36
|
+
fVGcO+Lu49Bx33evJ2ixPmQ2OXc=
|
|
37
37
|
-----END CERTIFICATE-----
|
|
38
|
-
date:
|
|
38
|
+
date: 2026-11-05 00:00:00.000000000 Z
|
|
39
39
|
dependencies:
|
|
40
40
|
- !ruby/object:Gem::Dependency
|
|
41
41
|
name: jekyll
|
|
@@ -114,47 +114,47 @@ dependencies:
|
|
|
114
114
|
- !ruby/object:Gem::Version
|
|
115
115
|
version: '1.3'
|
|
116
116
|
- !ruby/object:Gem::Dependency
|
|
117
|
-
name:
|
|
117
|
+
name: faraday_middleware
|
|
118
118
|
requirement: !ruby/object:Gem::Requirement
|
|
119
119
|
requirements:
|
|
120
120
|
- - "~>"
|
|
121
121
|
- !ruby/object:Gem::Version
|
|
122
|
-
version: '
|
|
122
|
+
version: '1'
|
|
123
123
|
type: :runtime
|
|
124
124
|
prerelease: false
|
|
125
125
|
version_requirements: !ruby/object:Gem::Requirement
|
|
126
126
|
requirements:
|
|
127
127
|
- - "~>"
|
|
128
128
|
- !ruby/object:Gem::Version
|
|
129
|
-
version: '
|
|
129
|
+
version: '1'
|
|
130
130
|
- !ruby/object:Gem::Dependency
|
|
131
|
-
name:
|
|
131
|
+
name: url-privacy
|
|
132
132
|
requirement: !ruby/object:Gem::Requirement
|
|
133
133
|
requirements:
|
|
134
134
|
- - "~>"
|
|
135
135
|
- !ruby/object:Gem::Version
|
|
136
|
-
version:
|
|
136
|
+
version: 0.1.1
|
|
137
137
|
type: :runtime
|
|
138
138
|
prerelease: false
|
|
139
139
|
version_requirements: !ruby/object:Gem::Requirement
|
|
140
140
|
requirements:
|
|
141
141
|
- - "~>"
|
|
142
142
|
- !ruby/object:Gem::Version
|
|
143
|
-
version:
|
|
143
|
+
version: 0.1.1
|
|
144
144
|
- !ruby/object:Gem::Dependency
|
|
145
|
-
name:
|
|
145
|
+
name: sutty-liquid
|
|
146
146
|
requirement: !ruby/object:Gem::Requirement
|
|
147
147
|
requirements:
|
|
148
|
-
- - "
|
|
148
|
+
- - ">="
|
|
149
149
|
- !ruby/object:Gem::Version
|
|
150
|
-
version: 0
|
|
150
|
+
version: '0'
|
|
151
151
|
type: :runtime
|
|
152
152
|
prerelease: false
|
|
153
153
|
version_requirements: !ruby/object:Gem::Requirement
|
|
154
154
|
requirements:
|
|
155
|
-
- - "
|
|
155
|
+
- - ">="
|
|
156
156
|
- !ruby/object:Gem::Version
|
|
157
|
-
version: 0
|
|
157
|
+
version: '0'
|
|
158
158
|
- !ruby/object:Gem::Dependency
|
|
159
159
|
name: rubocop
|
|
160
160
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -182,12 +182,14 @@ files:
|
|
|
182
182
|
- CHANGELOG.md
|
|
183
183
|
- LICENSE.txt
|
|
184
184
|
- README.md
|
|
185
|
+
- _includes/audio.html
|
|
185
186
|
- _includes/embed.html
|
|
186
187
|
- _includes/fallback.html
|
|
188
|
+
- _includes/image.html
|
|
187
189
|
- _includes/ogp.html
|
|
190
|
+
- _includes/video.html
|
|
188
191
|
- lib/jekyll-embed-urls.rb
|
|
189
192
|
- lib/jekyll/embed.rb
|
|
190
|
-
- lib/jekyll/embed/cache.rb
|
|
191
193
|
- lib/jekyll/embed/content.rb
|
|
192
194
|
- lib/jekyll/embed/filter.rb
|
|
193
195
|
- lib/jekyll/embed/oembed.rb
|
metadata.gz.sig
CHANGED
|
Binary file
|
data/lib/jekyll/embed/cache.rb
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Jekyll
|
|
4
|
-
class Embed
|
|
5
|
-
# Jekyll cache that behaves like ActiveSupport::Cache
|
|
6
|
-
class Cache < Jekyll::Cache
|
|
7
|
-
def write(key, value)
|
|
8
|
-
self[key] = value
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def read(key)
|
|
12
|
-
self[key]
|
|
13
|
-
rescue StandardError
|
|
14
|
-
nil
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|