onebox 1.7.1 → 1.7.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0eb554e8d0c9c9bd449b812203d44e7b8ebaf586
4
- data.tar.gz: 93b23186d771f8f45c7934d3977613753ea8c6ef
3
+ metadata.gz: 2104fcbe20267fd2a272b43bccaf3ff7c0f4d0c3
4
+ data.tar.gz: 7292bbe6cf11d62f924272f26089c5e3071c9563
5
5
  SHA512:
6
- metadata.gz: 37463bc2dcd32dabba738c511cb1d4ee00a1f0a44e5dbf2aab04fe5c723cea3400d495d4c3fcc46d3a873c4100adddfb6be8e9a6e14bc1ed00812bfe3bd005ec
7
- data.tar.gz: 283d61dd73d49e7e714806700ebc6297dfe96b9282062b6dbc7365b7aac64375370c8d6232f0df9389caab0f9d7068e9ec1d88c26278a78eb75dd3a4965c9e3d
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 Onebox::Helpers.blank?(oembed_url)
65
- application_json = html_doc.at("//link[@type='application/json+oembed']/@href")
66
- oembed_url = application_json.value if application_json
67
- end
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
- if Onebox::Helpers.blank?(oembed_url)
70
- text_json = html_doc.at("//link[@type='text/json+oembed']/@href")
71
- oembed_url ||= text_json.value if text_json
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
@@ -1,3 +1,3 @@
1
1
  module Onebox
2
- VERSION = "1.7.1"
2
+ VERSION = "1.7.2"
3
3
  end
@@ -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
- {html: 'cool html',
35
- provider_name: 'CoolSite'}
34
+ {
35
+ html: 'cool html',
36
+ height: 123,
37
+ provider_name: 'CoolSite',
38
+ }
36
39
  end
37
40
  end
38
41
 
@@ -1,4 +1,4 @@
1
- {{#image}}<img src="{{image}}" class="thumbnail"/>{{/image}}
1
+ {{#image}}<img src="{{image}}" width="{{image_width}}" height="{{image_height}}" class="thumbnail"/>{{/image}}
2
2
 
3
3
  <h3><a href='{{{link}}}' target="_blank">{{title}}</a></h3>
4
4
 
data/web/views/index.haml CHANGED
@@ -22,8 +22,8 @@
22
22
  .message-group
23
23
  %label(for='placeholder-html')
24
24
  placeholder_html
25
- %span#placeholder-html
25
+ %pre#placeholder-html
26
26
  .message-group
27
27
  %label(for='preview-html')
28
28
  to_s
29
- %span#preview-html
29
+ %pre#preview-html
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.1
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.6.8
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.