onebox 1.7.1 → 1.7.2
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/standard_embed.rb +9 -7
- data/lib/onebox/engine/whitelisted_generic_onebox.rb +10 -2
- data/lib/onebox/version.rb +1 -1
- data/spec/lib/onebox/engine/whitelisted_generic_onebox_spec.rb +5 -2
- data/templates/whitelistedgeneric.mustache +1 -1
- data/web/views/index.haml +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2104fcbe20267fd2a272b43bccaf3ff7c0f4d0c3
|
4
|
+
data.tar.gz: 7292bbe6cf11d62f924272f26089c5e3071c9563
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5050d6a43ddb0a98daa8623c5f7d636a63a4642a0a69184c85908f778a89efd49c0655890d1c67f1342b604fd9c7249e774022a896481e9dc2761de012d9c06c
|
7
|
+
data.tar.gz: 09f0001109957fb97fe5a9d69e1ed768c919c6b05bbb0e7e7b7c16a31878463bd20b9b5470f6d68d8ad0ecc6dbe93ef42f2e59aff8b9fa66c5336a88ace99eeb
|
@@ -61,14 +61,16 @@ module Onebox
|
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
|
-
if
|
65
|
-
|
66
|
-
|
67
|
-
|
64
|
+
if html_doc
|
65
|
+
if Onebox::Helpers.blank?(oembed_url)
|
66
|
+
application_json = html_doc.at("//link[@type='application/json+oembed']/@href")
|
67
|
+
oembed_url = application_json.value if application_json
|
68
|
+
end
|
68
69
|
|
69
|
-
|
70
|
-
|
71
|
-
|
70
|
+
if Onebox::Helpers.blank?(oembed_url)
|
71
|
+
text_json = html_doc.at("//link[@type='text/json+oembed']/@href")
|
72
|
+
oembed_url ||= text_json.value if text_json
|
73
|
+
end
|
72
74
|
end
|
73
75
|
|
74
76
|
return {} if Onebox::Helpers.blank?(oembed_url)
|
@@ -264,6 +264,7 @@ module Onebox
|
|
264
264
|
|
265
265
|
def is_embedded?
|
266
266
|
data[:html] &&
|
267
|
+
data[:height] &&
|
267
268
|
(
|
268
269
|
data[:html]["iframe"] ||
|
269
270
|
WhitelistedGenericOnebox.html_providers.include?(data[:provider_name])
|
@@ -278,8 +279,8 @@ module Onebox
|
|
278
279
|
return if Onebox::Helpers.blank?(data[:image])
|
279
280
|
|
280
281
|
alt = data[:description] || data[:title]
|
281
|
-
width = data[:image_width] || data[:thumbnail_width]
|
282
|
-
height = data[:image_height] || data[:thumbnail_height]
|
282
|
+
width = data[:image_width] || data[:thumbnail_width] || data[:width]
|
283
|
+
height = data[:image_height] || data[:thumbnail_height] || data[:height]
|
283
284
|
"<img src='#{data[:image]}' alt='#{alt}' width='#{width}' height='#{height}'>"
|
284
285
|
end
|
285
286
|
|
@@ -309,6 +310,13 @@ module Onebox
|
|
309
310
|
def embedded_html
|
310
311
|
fragment = Nokogiri::HTML::fragment(data[:html])
|
311
312
|
fragment.css("img").each { |img| img["class"] = "thumbnail" }
|
313
|
+
if iframe = fragment.at_css("iframe")
|
314
|
+
iframe.remove_attribute("style")
|
315
|
+
iframe["width"] = data[:width] || "100%"
|
316
|
+
iframe["height"] = data[:height]
|
317
|
+
iframe["scrolling"] = "no"
|
318
|
+
iframe["frameborder"] = "0"
|
319
|
+
end
|
312
320
|
fragment.to_html
|
313
321
|
end
|
314
322
|
end
|
data/lib/onebox/version.rb
CHANGED
@@ -31,8 +31,11 @@ describe Onebox::Engine::WhitelistedGenericOnebox do
|
|
31
31
|
describe 'html_providers' do
|
32
32
|
class HTMLOnebox < Onebox::Engine::WhitelistedGenericOnebox
|
33
33
|
def data
|
34
|
-
{
|
35
|
-
|
34
|
+
{
|
35
|
+
html: 'cool html',
|
36
|
+
height: 123,
|
37
|
+
provider_name: 'CoolSite',
|
38
|
+
}
|
36
39
|
end
|
37
40
|
end
|
38
41
|
|
data/web/views/index.haml
CHANGED
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.7.
|
4
|
+
version: 1.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joanna Zeta
|
@@ -469,7 +469,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
469
469
|
version: '0'
|
470
470
|
requirements: []
|
471
471
|
rubyforge_project:
|
472
|
-
rubygems_version: 2.
|
472
|
+
rubygems_version: 2.5.1
|
473
473
|
signing_key:
|
474
474
|
specification_version: 4
|
475
475
|
summary: A gem for turning URLs into previews.
|