onebox 1.9.23 → 1.9.24
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/onebox/engine/pastebin_onebox.rb +1 -1
- data/lib/onebox/engine/pdf_onebox.rb +1 -1
- data/lib/onebox/engine/vimeo_onebox.rb +14 -8
- data/lib/onebox/engine/wechat_mp_onebox.rb +1 -1
- data/lib/onebox/helpers.rb +1 -1
- data/lib/onebox/version.rb +1 -1
- data/onebox.gemspec +2 -1
- metadata +19 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf558389e0bd7431942769ee39ee40f770245463e97e25400accfe3a130af77f
|
4
|
+
data.tar.gz: 23d64fbf25b722401c33aac9f0230a1d9d904d9db13794041b744c7d43165bec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06dfe747b8a6408ef1a34c07410f32baf4d94d1cf986edee4e5267daa2eb81278569e1263bc2c9565f20ac123f93c5ca35d324f3eba6140044cfb6169b499652
|
7
|
+
data.tar.gz: 1e6c04cea5599d7d1121c7e6ff502ca0d723fd3037e1955289ff26dce5eb74350db399ffa9293d7f9286971ef9b3cf5e88409ef30eeb454675b738c8924e1c64
|
@@ -6,24 +6,23 @@ module Onebox
|
|
6
6
|
include Engine
|
7
7
|
include StandardEmbed
|
8
8
|
|
9
|
-
|
10
|
-
matches_regexp(/^https?:\/\/(www\.)?vimeo\.com\/\d+\/[^\/]+?$/)
|
9
|
+
matches_regexp(/^https?:\/\/(www\.)?vimeo\.com\/\d+/)
|
11
10
|
always_https
|
12
11
|
|
13
12
|
WIDTH ||= 640
|
14
13
|
HEIGHT ||= 360
|
15
14
|
|
16
15
|
def placeholder_html
|
17
|
-
|
18
|
-
"<img src='#{image_src}' width='#{WIDTH}' height='#{HEIGHT}' #{og_data.title_attr}>"
|
16
|
+
::Onebox::Helpers.video_placeholder_html
|
19
17
|
end
|
20
18
|
|
21
19
|
def to_html
|
22
|
-
|
23
|
-
if
|
24
|
-
|
25
|
-
|
20
|
+
video_id = oembed_data[:video_id]
|
21
|
+
if video_id.nil?
|
22
|
+
# for private videos
|
23
|
+
video_id = uri.path[/\/(\d+)/, 1]
|
26
24
|
end
|
25
|
+
video_src = "https://player.vimeo.com/video/#{video_id}"
|
27
26
|
video_src = video_src.gsub('autoplay=1', '').chomp("?")
|
28
27
|
<<-HTML
|
29
28
|
<iframe width="#{WIDTH}"
|
@@ -38,6 +37,13 @@ module Onebox
|
|
38
37
|
|
39
38
|
private
|
40
39
|
|
40
|
+
def oembed_data
|
41
|
+
response = Onebox::Helpers.fetch_response("https://vimeo.com/api/oembed.json?url=#{url}")
|
42
|
+
@oembed_data = Onebox::Helpers.symbolize_keys(::MultiJson.load(response))
|
43
|
+
rescue
|
44
|
+
"{}"
|
45
|
+
end
|
46
|
+
|
41
47
|
def og_data
|
42
48
|
@og_data = get_opengraph
|
43
49
|
end
|
@@ -26,7 +26,7 @@ module Onebox
|
|
26
26
|
def extract_script_value(var_name)
|
27
27
|
if (script_elem = raw.css("script").select { |script| script.inner_text.include? "var #{var_name} = " }) && script_elem.any?
|
28
28
|
e = Nokogiri::HTML(script_elem[0].inner_text.match(/var\s+#{Regexp.quote(var_name)}\s+=\s+"(.*?)";/)[1])
|
29
|
-
|
29
|
+
CGI::unescapeHTML(e.text.scan(/(?:\\x([a-f0-9]{2}))|(.)/i).map { |x| x[0] ? [x[0].to_i(16)].pack('U') : x[1] }.join)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
data/lib/onebox/helpers.rb
CHANGED
data/lib/onebox/version.rb
CHANGED
data/onebox.gemspec
CHANGED
@@ -32,7 +32,8 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.add_development_dependency 'fakeweb', '~> 1.3'
|
33
33
|
spec.add_development_dependency 'pry', '~> 0.10'
|
34
34
|
spec.add_development_dependency 'mocha', '~> 1.1'
|
35
|
-
spec.add_development_dependency 'rubocop', '~> 0.
|
35
|
+
spec.add_development_dependency 'rubocop', '~> 0.69.0'
|
36
|
+
spec.add_development_dependency 'rubocop-discourse', '~> 1.0.1'
|
36
37
|
spec.add_development_dependency 'twitter', '~> 4.8'
|
37
38
|
spec.add_development_dependency 'guard-rspec', '~> 4.2.8'
|
38
39
|
spec.add_development_dependency 'sinatra', '~> 1.4'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: onebox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.9.
|
4
|
+
version: 1.9.24
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joanna Zeta
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2019-11-
|
13
|
+
date: 2019-11-27 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: multi_json
|
@@ -172,14 +172,28 @@ dependencies:
|
|
172
172
|
requirements:
|
173
173
|
- - "~>"
|
174
174
|
- !ruby/object:Gem::Version
|
175
|
-
version:
|
175
|
+
version: 0.69.0
|
176
176
|
type: :development
|
177
177
|
prerelease: false
|
178
178
|
version_requirements: !ruby/object:Gem::Requirement
|
179
179
|
requirements:
|
180
180
|
- - "~>"
|
181
181
|
- !ruby/object:Gem::Version
|
182
|
-
version:
|
182
|
+
version: 0.69.0
|
183
|
+
- !ruby/object:Gem::Dependency
|
184
|
+
name: rubocop-discourse
|
185
|
+
requirement: !ruby/object:Gem::Requirement
|
186
|
+
requirements:
|
187
|
+
- - "~>"
|
188
|
+
- !ruby/object:Gem::Version
|
189
|
+
version: 1.0.1
|
190
|
+
type: :development
|
191
|
+
prerelease: false
|
192
|
+
version_requirements: !ruby/object:Gem::Requirement
|
193
|
+
requirements:
|
194
|
+
- - "~>"
|
195
|
+
- !ruby/object:Gem::Version
|
196
|
+
version: 1.0.1
|
183
197
|
- !ruby/object:Gem::Dependency
|
184
198
|
name: twitter
|
185
199
|
requirement: !ruby/object:Gem::Requirement
|
@@ -407,7 +421,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
407
421
|
- !ruby/object:Gem::Version
|
408
422
|
version: '0'
|
409
423
|
requirements: []
|
410
|
-
rubygems_version: 3.0.
|
424
|
+
rubygems_version: 3.0.4
|
411
425
|
signing_key:
|
412
426
|
specification_version: 4
|
413
427
|
summary: A gem for generating embeddable HTML previews from URLs.
|