onebox 1.2.0 → 1.2.1

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: 888991c0d98fd255f0e123084956661cfe16550c
4
- data.tar.gz: 7de707a9ff4443abfceecf1b6046bcc34af675c1
3
+ metadata.gz: 0b209b40f4e38a3ee270316c83cc8801c706bd95
4
+ data.tar.gz: 4cf005fc5971da222e14a5b39140981d7fe8bb89
5
5
  SHA512:
6
- metadata.gz: 838ffafee83459b702e30a2f603b69a46b744ef462f4452fabaca1775fdd7cad437a437a70af44d83e4e5acfaedf82af724801ed1ad27679c6c86e2d77045dd1
7
- data.tar.gz: 3960704c47e5db13667aa35af74bba172f8e23d4a54b707d842eab7944c535cb146ec235a90c7bf7a4582cd7f4c7babd17a9fc9bf749d12c0f5db1a8866fa606
6
+ metadata.gz: 2c4bc3e5d97e9714541074d7e235555022216b21047d5c658a10c3b48ff8658dc96cb4483ab7a2eefd1fd3d3f524bed3c6cb96ca5b0520e1bb5553057421667c
7
+ data.tar.gz: 4c7cf8166a4a7da5fdad37a0c7b0d047ae53aec9defb2824c19c8030c62412a41ccd674b59a9825adb722cc8964699c7f2513e2749ea616a29ead8bd673ff741
data/README.md CHANGED
@@ -139,10 +139,10 @@ Adding Support for a new URL
139
139
  end
140
140
  ```
141
141
 
142
- 4. Create new handlebars template
142
+ 4. Create new mustache template
143
143
 
144
144
  ``` html
145
- # in templates/name.handlebars
145
+ # in templates/name.mustache
146
146
  <div class="onebox">
147
147
  <a href="{{url}}">
148
148
  <h1>{{name}}</h1>
@@ -162,7 +162,7 @@ Adding Support for a new URL
162
162
  6. Require in Engine module
163
163
 
164
164
  ``` ruby
165
- # in lib/onebox/engine/engine.rb
165
+ # in lib/onebox/engine.rb
166
166
  require_relative "engine/name_onebox"
167
167
  ```
168
168
 
data/lib/onebox/engine.rb CHANGED
@@ -41,7 +41,7 @@ module Onebox
41
41
  private
42
42
 
43
43
  def record
44
- result = cache.fetch(url) { data }
44
+ result = cache.fetch(url) { data }
45
45
  cache[url] = result if cache.respond_to?(:key?)
46
46
  result
47
47
  end
@@ -127,9 +127,14 @@ module Onebox
127
127
  !!list.find {|h| %r((^|\.)#{Regexp.escape(h)}$).match(uri.host) }
128
128
  end
129
129
 
130
+ def self.probable_wordpress(uri)
131
+ !!(uri.path =~ /\d{4}\/\d{2}\/\d{2}/)
132
+ end
133
+
130
134
  def self.===(other)
131
135
  if other.kind_of?(URI)
132
- return WhitelistedGenericOnebox.host_matches(other, WhitelistedGenericOnebox.whitelist)
136
+ return WhitelistedGenericOnebox.host_matches(other, WhitelistedGenericOnebox.whitelist) ||
137
+ WhitelistedGenericOnebox.probable_wordpress(other)
133
138
  else
134
139
  super
135
140
  end
@@ -150,7 +155,7 @@ module Onebox
150
155
  end
151
156
 
152
157
  def generic_html
153
- return data[:html] if data[:html]
158
+ return data[:html] if data[:html] && data[:html] =~ /iframe/
154
159
  return html_for_video(data[:video]) if data[:video]
155
160
  return image_html if photo_type?
156
161
  return nil unless data[:title]
@@ -168,7 +173,10 @@ module Onebox
168
173
  end
169
174
 
170
175
  def data
171
- return raw if raw.is_a?(Hash)
176
+ if raw.is_a?(Hash)
177
+ raw[:link] ||= link
178
+ return raw
179
+ end
172
180
 
173
181
  data_hash = { link: link, title: raw.title, description: raw.description }
174
182
  data_hash[:image] = raw.images.first if raw.images && raw.images.first
@@ -1,3 +1,3 @@
1
1
  module Onebox
2
- VERSION = "1.2.0"
2
+ VERSION = "1.2.1"
3
3
  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.2.0
4
+ version: 1.2.1
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: 2014-02-13 00:00:00.000000000 Z
13
+ date: 2014-02-18 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: multi_json