onebox 1.5.7 → 1.5.8

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: 7f68792a4551ae1d514bc6bdbd07607ead5ebb5a
4
- data.tar.gz: e464aae6ea273ce32edcc3321c5b589e61162468
3
+ metadata.gz: 0ee3ee949d6acccb2fde3909408b020bbc1795ea
4
+ data.tar.gz: d34818d55947c38f9b2d89ba23f27b382e3f77de
5
5
  SHA512:
6
- metadata.gz: 81677af638f4db63c2fac2b5489fee88f3fd50924908b2294a3eca02e1013d85281a22712e84d16588a8ef41f45328f19fa5425b7f55c4ec9f4f4cd22bf3677a
7
- data.tar.gz: 514e05a5956aa021d98cc713c2f84df2a3bc6c916c82d93f167194c9c7f8d933d0d5e3bbd336a6baef1c0d5e8653a899b0107d8af5086adc607f8df98ea91040
6
+ metadata.gz: 2908ef091a88899845f40c9e89457017303c065c02ad116a5f48f4989450876fd46fb8efb9f49b492133e5d7b0ba8cd781e99176a1ca116dc9cb9a54a6bd5f17
7
+ data.tar.gz: c02f95a6d4cf36f5692a81353c398ddf984b6cf9b5b2cdb9f3de2a18696752d1c7ffd28c0c0558e2652c2271833183e656ddd48d851924ccd145375f32133f12
@@ -124,6 +124,21 @@ module Onebox
124
124
  zillow.com)
125
125
  end
126
126
 
127
+ # Often using the `html` attribute is not what we want, like for some blogs that
128
+ # include the entire page HTML. However for some providers like Imgur it allows us
129
+ # to return gifv and galleries.
130
+ def self.default_html_providers
131
+ ['Imgur']
132
+ end
133
+
134
+ def self.html_providers
135
+ @html_providers ||= default_html_providers.dup
136
+ end
137
+
138
+ def self.html_providers=(new_provs)
139
+ @html_providers = new_provs
140
+ end
141
+
127
142
  # A re-written URL coverts https:// -> // - it is useful on HTTPS sites that embed
128
143
  # youtube for example
129
144
  def self.rewrites
@@ -178,11 +193,22 @@ module Onebox
178
193
  html
179
194
  end
180
195
 
196
+ def html_type?
197
+ return data &&
198
+ data[:html] &&
199
+ (
200
+ (data[:html] =~ /iframe/) ||
201
+ WhitelistedGenericOnebox.html_providers.include?(data[:provider_name])
202
+ )
203
+ end
204
+
181
205
  def generic_html
182
- return data[:html] if data[:html] && data[:html] =~ /iframe/
206
+ return data[:html] if html_type?
183
207
  return layout.to_html if article_type?
184
208
  return html_for_video(data[:video]) if data[:video]
209
+
185
210
  return image_html if photo_type?
211
+
186
212
  return nil unless data[:title]
187
213
  layout.to_html
188
214
  end
@@ -1,3 +1,3 @@
1
1
  module Onebox
2
- VERSION = "1.5.7"
2
+ VERSION = "1.5.8"
3
3
  end
@@ -28,6 +28,24 @@ describe Onebox::Engine::WhitelistedGenericOnebox do
28
28
  end
29
29
  end
30
30
 
31
+ describe 'html_providers' do
32
+ class HTMLOnebox < Onebox::Engine::WhitelistedGenericOnebox
33
+ def data
34
+ {html: 'cool html',
35
+ provider_name: 'CoolSite'}
36
+ end
37
+ end
38
+
39
+ it "doesn't return the HTML when not in the `html_providers`" do
40
+ Onebox::Engine::WhitelistedGenericOnebox.html_providers = []
41
+ HTMLOnebox.new("http://coolsite.com").to_html.should be_nil
42
+ end
43
+
44
+ it "returns the HMTL when in the `html_providers`" do
45
+ Onebox::Engine::WhitelistedGenericOnebox.html_providers = ['CoolSite']
46
+ HTMLOnebox.new("http://coolsite.com").to_html.should == "cool html"
47
+ end
48
+ end
31
49
 
32
50
  describe 'rewrites' do
33
51
  class DummyOnebox < Onebox::Engine::WhitelistedGenericOnebox
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.7
4
+ version: 1.5.8
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: 2015-01-21 00:00:00.000000000 Z
13
+ date: 2015-01-22 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: multi_json