onebox 1.5.31 → 1.5.32
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa9168446ef3d1d26838bbd529dedc3a15f583ea
|
4
|
+
data.tar.gz: d2e3b70b361f78002adef13326e492a73b60aeab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c047b42a97d0c327081370fcacbc5cf5164ba8af9d22538bcc2002ccdf410f8c967e60605053b995b5ca2d65d57b3042dc1d762a9da9c5d0ee1659a9278f8baf
|
7
|
+
data.tar.gz: fb64aeff91145d2d9f8ee23fc9f5d281fc40c7a8c1aea423fbdb114f9a4fa1be53bf13e327d641a06ae59fc8648dd7a34e65cfa9283eb4e863e9c8c51982e3c1
|
@@ -55,7 +55,8 @@ module Onebox
|
|
55
55
|
|
56
56
|
# Determine if we should use oEmbed or OpenGraph (prefers oEmbed)
|
57
57
|
oembed_alternate = html_doc.at("//link[@type='application/json+oembed']") || html_doc.at("//link[@type='text/json+oembed']")
|
58
|
-
|
58
|
+
# Do not use oEmbed for WordPress sites (https://meta.discourse.org/t/onebox-for-wordpress-4-4-sites/36765)
|
59
|
+
fetch_oembed_raw(oembed_alternate) unless oembed_alternate.nil? || oembed_alternate['href'] =~ /public-api.wordpress.com\/oembed/ || oembed_alternate['href'] =~ /wp-json\/oembed/
|
59
60
|
|
60
61
|
open_graph = parse_open_graph(html_doc, url)
|
61
62
|
if @raw
|
@@ -71,7 +72,14 @@ module Onebox
|
|
71
72
|
def fetch_oembed_raw(oembed_url)
|
72
73
|
return unless oembed_url
|
73
74
|
oembed_url = oembed_url['href'] unless oembed_url['href'].nil?
|
74
|
-
|
75
|
+
oembed_data = Onebox::Helpers.symbolize_keys(::MultiJson.load(Onebox::Helpers.fetch_response(oembed_url).body))
|
76
|
+
@raw =
|
77
|
+
if oembed_data[:html] && oembed_data[:html].bytesize > 4000
|
78
|
+
# fallback to OpenGraph if oEmbed data size is more than 4000 bytes
|
79
|
+
nil
|
80
|
+
else
|
81
|
+
oembed_data
|
82
|
+
end
|
75
83
|
rescue Errno::ECONNREFUSED, Net::HTTPError, MultiJson::LoadError
|
76
84
|
@raw = nil
|
77
85
|
end
|
@@ -19,6 +19,7 @@ module Onebox
|
|
19
19
|
%w(23hq.com
|
20
20
|
500px.com
|
21
21
|
8tracks.com
|
22
|
+
abc.net.au
|
22
23
|
about.com
|
23
24
|
answers.com
|
24
25
|
arstechnica.com
|
@@ -211,10 +212,9 @@ module Onebox
|
|
211
212
|
return data[:html] if html_type?
|
212
213
|
return layout.to_html if article_type?
|
213
214
|
return html_for_video(data[:video]) if data[:video]
|
214
|
-
|
215
215
|
return image_html if photo_type?
|
216
|
+
return nil if data[:title].nil? || data[:title].empty?
|
216
217
|
|
217
|
-
return nil unless data[:title]
|
218
218
|
layout.to_html
|
219
219
|
end
|
220
220
|
|
@@ -22,19 +22,7 @@ module Onebox
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def placeholder_html
|
25
|
-
|
26
|
-
meta_url = "http://v.youku.com/player/getPlayList/VideoIDS/#{video_id}"
|
27
|
-
response = Onebox::Helpers.fetch_response(meta_url)
|
28
|
-
meta = MultiJson::load(response.body) if response && response.body
|
29
|
-
image_src = if meta && meta['data'] && meta['data'][0] && meta['data'][0]['logo']
|
30
|
-
meta['data'][0]['logo']
|
31
|
-
else
|
32
|
-
nil
|
33
|
-
end
|
34
|
-
"<img src='#{image_src}' width='480' height='270'>"
|
35
|
-
else
|
36
|
-
to_html
|
37
|
-
end
|
25
|
+
to_html
|
38
26
|
end
|
39
27
|
|
40
28
|
private
|
data/lib/onebox/version.rb
CHANGED
@@ -6,8 +6,8 @@ describe Onebox::Engine::YoukuOnebox do
|
|
6
6
|
FakeWeb.register_uri(:get, 'http://v.youku.com/player/getPlayList/VideoIDS/XNjM3MzAxNzc2', body: response('youku-meta'), content_type: 'text/html')
|
7
7
|
end
|
8
8
|
|
9
|
-
it 'returns
|
9
|
+
it 'returns iframe as the placeholder' do
|
10
10
|
expect(Onebox.preview('http://v.youku.com/v_show/id_XNjM3MzAxNzc2.html')
|
11
|
-
.placeholder_html).to match(
|
11
|
+
.placeholder_html).to match(/iframe/)
|
12
12
|
end
|
13
13
|
end
|
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.5.
|
4
|
+
version: 1.5.32
|
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: 2016-01-
|
13
|
+
date: 2016-01-17 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: multi_json
|
@@ -431,7 +431,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
431
431
|
version: '0'
|
432
432
|
requirements: []
|
433
433
|
rubyforge_project:
|
434
|
-
rubygems_version: 2.
|
434
|
+
rubygems_version: 2.4.8
|
435
435
|
signing_key:
|
436
436
|
specification_version: 4
|
437
437
|
summary: A gem for turning URLs into previews.
|