jekyll-embed-urls 0.6.6 → 0.7.1
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 +54 -11
- data.tar.gz.sig +0 -0
- metadata +21 -20
- 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: 612fbcd2557b3db7883b7bda7d1d874357cf4f652384f887685a6fb35d675ef4
|
|
4
|
+
data.tar.gz: 25166d8f4dc9d9b953583a2124cbdf35a22a3006afd63766389830de4360b2d1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 53301974408d6a8a99e33bdfea578d26c17de670e4b1d667aaff7a44ef40beac3be145d94a675c7d01fd8a7ef5bdbe34f0e8f5ca273e367832a14f32c7e7f02a
|
|
7
|
+
data.tar.gz: 488ebe6cb0a87f935bdcc01978c385a00adf8e7fc8d8fe889a95718845070f3b7042160789795a0244248ac7ac1cca188c7b6b7beefa73ef16bdb59b9cbe8ee7
|
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
|
|
@@ -157,20 +158,46 @@ module Jekyll
|
|
|
157
158
|
# @param [String] URL
|
|
158
159
|
# @return [String] HTML
|
|
159
160
|
def embed(url)
|
|
160
|
-
raise URI::Error unless url.is_a? String
|
|
161
|
+
raise URI::Error.new(url.class.name) unless url.is_a? String
|
|
161
162
|
|
|
162
163
|
url = url.strip
|
|
164
|
+
url = "https://#{url}" if url.start_with? '//'
|
|
163
165
|
|
|
164
166
|
# Quick check
|
|
165
|
-
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)
|
|
166
170
|
|
|
167
171
|
# Just to verify the URL is valid
|
|
168
172
|
# TODO: Use Addressable
|
|
169
173
|
URI.parse url
|
|
170
174
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
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}"
|
|
174
201
|
|
|
175
202
|
url
|
|
176
203
|
end
|
|
@@ -270,12 +297,17 @@ module Jekyll
|
|
|
270
297
|
# @return [Faraday::Response]
|
|
271
298
|
def get(url)
|
|
272
299
|
@get_cache ||= {}
|
|
273
|
-
@get_cache[url] ||= http_client.get url
|
|
300
|
+
@get_cache[url.to_s] ||= http_client.get url
|
|
274
301
|
end
|
|
275
302
|
|
|
276
|
-
|
|
303
|
+
def head(url)
|
|
304
|
+
@head_cache ||= {}
|
|
305
|
+
@head_cache[url.to_s] ||= http_client.head url
|
|
306
|
+
end
|
|
307
|
+
|
|
308
|
+
# @return [Jekyll::Cache]
|
|
277
309
|
def cache
|
|
278
|
-
@cache ||= Jekyll::
|
|
310
|
+
@cache ||= Jekyll::Cache.new('Jekyll::Embed')
|
|
279
311
|
end
|
|
280
312
|
|
|
281
313
|
# @return [Faraday::Connection]
|
|
@@ -286,7 +318,6 @@ module Jekyll
|
|
|
286
318
|
builder.options.read_timeout = 1
|
|
287
319
|
builder.options.write_timeout = 1
|
|
288
320
|
builder.use FaradayMiddleware::FollowRedirects
|
|
289
|
-
builder.use :http_cache, shared_cache: false, store: cache, serializer: Marshal
|
|
290
321
|
end
|
|
291
322
|
end
|
|
292
323
|
|
|
@@ -356,6 +387,18 @@ module Jekyll
|
|
|
356
387
|
@ogp_template ||= site.liquid_renderer.file('ogp.html').parse(INCLUDE_OGP)
|
|
357
388
|
end
|
|
358
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
|
+
|
|
359
402
|
def info
|
|
360
403
|
@info ||= {
|
|
361
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.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- f
|
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
|
35
35
|
AloSNM24NWhA2fme6cgZOLKXvAKgf6pQsNtAnU1Pliou5GvJ62d8l+pdKGxJ4yTn
|
|
36
36
|
fVGcO+Lu49Bx33evJ2ixPmQ2OXc=
|
|
37
37
|
-----END CERTIFICATE-----
|
|
38
|
-
date: 2026-
|
|
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,23 +182,24 @@ 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
|
|
194
|
-
homepage: https://
|
|
196
|
+
homepage: https://git.sutty.abyaya.la/jekyll/jekyll-embed-urls
|
|
195
197
|
licenses:
|
|
196
198
|
- GPL-3.0
|
|
197
199
|
metadata:
|
|
198
|
-
bug_tracker_uri: https://
|
|
199
|
-
homepage_uri: https://
|
|
200
|
-
source_code_uri: https://
|
|
201
|
-
changelog_uri: https://0xacab.org/sutty/jekyll/jekyll-embed-urls/-/blob/master/CHANGELOG.md
|
|
200
|
+
bug_tracker_uri: https://git.sutty.abyaya.la/jekyll/jekyll-embed-urls/issues
|
|
201
|
+
homepage_uri: https://git.sutty.abyaya.la/jekyll/jekyll-embed-urls
|
|
202
|
+
source_code_uri: https://git.sutty.abyaya.la/jekyll/jekyll-embed-urls
|
|
202
203
|
documentation_uri: https://rubydoc.info/gems/jekyll-embed-urls
|
|
203
204
|
post_install_message:
|
|
204
205
|
rdoc_options:
|
|
@@ -215,7 +216,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
215
216
|
requirements:
|
|
216
217
|
- - ">="
|
|
217
218
|
- !ruby/object:Gem::Version
|
|
218
|
-
version: '
|
|
219
|
+
version: '0'
|
|
219
220
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
220
221
|
requirements:
|
|
221
222
|
- - ">="
|
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
|