onebox 1.2.3 → 1.2.4

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: d9dbbcef9ad30d0ab30cf3b5392f01b781dca291
4
- data.tar.gz: 7cd665b5a0d344b702fe7df32b6c691010539028
3
+ metadata.gz: 4a1c79c861fa854b2cb6f8e846858c6d3960a7d7
4
+ data.tar.gz: 711cefc867ea1db4cc654f345914e859a1534a1e
5
5
  SHA512:
6
- metadata.gz: 8bd2e6ed6565c4df9114a62e4628affb6b6227a40bfbd5e483f9ef0d73f8fb196d5dca3034ba46bd30173099d9a5647522dd9e307cf0918057fd1a137da7b892
7
- data.tar.gz: a80fa2616b82977524212e8d084849910558e9910f385d8b943c5805f4791e06056bc21974bb9de40660a84fecc4c43703ddc1bc16f69c3ffa9255a58ec20ce2
6
+ metadata.gz: 63ca35b58d58aacef5d7074ae4a205aedcdee285038d93072d92fda68caea97030de36810fb366929373a6afaefe1ee0337c7b0ac4a50325effd99fa7cef57cd
7
+ data.tar.gz: 0e2e452056785863e67cff50581d544914022b450a63f675e141fafb3eb1e0b435fabe2ac09b78807f3729829fc3d58d6ed8979b298db0c01f87ca560eb5cc82
@@ -120,13 +120,17 @@ module Onebox
120
120
  end
121
121
 
122
122
  def self.default_rewrites
123
- %w()
123
+ %w(slideshare.net)
124
124
  end
125
125
 
126
126
  def self.host_matches(uri, list)
127
127
  !!list.find {|h| %r((^|\.)#{Regexp.escape(h)}$).match(uri.host) }
128
128
  end
129
129
 
130
+ def self.probable_discourse(uri)
131
+ !!(uri.path =~ /\/t\/[^\/]+\/\d+(\/\d+)?(\?.*)?$/)
132
+ end
133
+
130
134
  def self.probable_wordpress(uri)
131
135
  !!(uri.path =~ /\d{4}\/\d{2}\/\d{2}/)
132
136
  end
@@ -134,7 +138,8 @@ module Onebox
134
138
  def self.===(other)
135
139
  if other.kind_of?(URI)
136
140
  return WhitelistedGenericOnebox.host_matches(other, WhitelistedGenericOnebox.whitelist) ||
137
- WhitelistedGenericOnebox.probable_wordpress(other)
141
+ WhitelistedGenericOnebox.probable_wordpress(other) ||
142
+ WhitelistedGenericOnebox.probable_discourse(other)
138
143
  else
139
144
  super
140
145
  end
@@ -145,6 +150,10 @@ module Onebox
145
150
  data[:type] =~ /photo/ || data[:type] =~ /image/
146
151
  end
147
152
 
153
+ def article_type?
154
+ data[:type] == "article"
155
+ end
156
+
148
157
  def rewrite_agnostic(html)
149
158
  return html unless html
150
159
  uri = URI(@url)
@@ -156,6 +165,7 @@ module Onebox
156
165
 
157
166
  def generic_html
158
167
  return data[:html] if data[:html] && data[:html] =~ /iframe/
168
+ return layout.to_html if article_type?
159
169
  return html_for_video(data[:video]) if data[:video]
160
170
  return image_html if photo_type?
161
171
  return nil unless data[:title]
@@ -168,6 +178,7 @@ module Onebox
168
178
 
169
179
  def placeholder_html
170
180
  result = nil
181
+ return to_html if article_type?
171
182
  result = image_html if (data[:html] && data[:html] =~ /iframe/) || data[:video] || photo_type?
172
183
  result || to_html
173
184
  end
@@ -22,6 +22,7 @@ module Onebox
22
22
  unless paras.empty?
23
23
  cnt = 0
24
24
  while text.length < Onebox::LayoutSupport.max_text && cnt <= 3
25
+ break if cnt >= paras.size
25
26
  text << " " unless cnt == 0
26
27
  paragraph = paras[cnt].inner_text[0..Onebox::LayoutSupport.max_text]
27
28
  paragraph.gsub!(/\[\d+\]/mi, "")
@@ -36,7 +37,7 @@ module Onebox
36
37
  title: raw.css("html body h1").inner_text,
37
38
  description: text
38
39
  }
39
- img = raw.css(".infobox .image img")
40
+ img = raw.css(".image img")
40
41
  if img && img.first
41
42
  result[:image] = img.first["src"]
42
43
  end
@@ -1,3 +1,3 @@
1
1
  module Onebox
2
- VERSION = "1.2.3"
2
+ VERSION = "1.2.4"
3
3
  end
@@ -1,4 +1,4 @@
1
- <img src="{{image}}" class="thumbnail"/>
1
+ {{#image}}<img src="{{image}}" class="thumbnail"/>{{/image}}
2
2
 
3
3
  <h3><a href='{{{link}}}'>{{title}}</a></h3>
4
4
 
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.3
4
+ version: 1.2.4
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-24 00:00:00.000000000 Z
13
+ date: 2014-02-25 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: multi_json