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 +4 -4
- data/README.md +3 -3
- data/lib/onebox/engine.rb +1 -1
- data/lib/onebox/engine/whitelisted_generic_onebox.rb +11 -3
- data/lib/onebox/version.rb +1 -1
- 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: 0b209b40f4e38a3ee270316c83cc8801c706bd95
|
4
|
+
data.tar.gz: 4cf005fc5971da222e14a5b39140981d7fe8bb89
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
142
|
+
4. Create new mustache template
|
143
143
|
|
144
144
|
``` html
|
145
|
-
# in templates/name.
|
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
|
165
|
+
# in lib/onebox/engine.rb
|
166
166
|
require_relative "engine/name_onebox"
|
167
167
|
```
|
168
168
|
|
data/lib/onebox/engine.rb
CHANGED
@@ -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
|
-
|
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
|
data/lib/onebox/version.rb
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.2.
|
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
|
+
date: 2014-02-18 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: multi_json
|