onebox 1.8.23 → 1.8.24
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/onebox/engine/whitelisted_generic_onebox.rb +19 -13
- data/lib/onebox/helpers.rb +1 -1
- data/lib/onebox/version.rb +1 -1
- data/onebox.gemspec +1 -1
- data/spec/lib/onebox/engine/whitelisted_generic_onebox_spec.rb +8 -0
- data/templates/whitelistedgeneric.mustache +4 -0
- metadata +5 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 46083e1a21f3b8566a13d1f23db6d2b63d0dab0f4e81a4f124b131cbf1f417df
|
4
|
+
data.tar.gz: dce9be021faa467dcb5e5675cc21529535f83c920614752232c5c5e9df21dea7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5bd9ed7b95189ebdd9dad2b29ba634684b12a65ceee1131f168423af934919251f4d6a16ddcbedbd27c77d4ee03b28d8701f44c61bb3868bffbf77dc385b6cb
|
7
|
+
data.tar.gz: 857d41458895aa81cc799edbae5b25cb67420afa5e7df0af31dfc22330a5849b206830de40d3df23a9931679a2d856471e6441bb5521a4fbb2f6e1dc7a97235a
|
@@ -211,7 +211,9 @@ module Onebox
|
|
211
211
|
d[:description] = html_entities.decode(Sanitize.fragment(Onebox::Helpers.truncate(d[:description].strip, 250)))
|
212
212
|
end
|
213
213
|
|
214
|
-
if !Onebox::Helpers.blank?(d[:
|
214
|
+
if !Onebox::Helpers.blank?(d[:site_name])
|
215
|
+
d[:domain] = html_entities.decode(Onebox::Helpers.truncate(d[:site_name].strip, 80))
|
216
|
+
elsif !Onebox::Helpers.blank?(d[:domain])
|
215
217
|
d[:domain] = "http://#{d[:domain]}" unless d[:domain] =~ /^https?:\/\//
|
216
218
|
d[:domain] = URI(d[:domain]).host.to_s.sub(/^www\./, '') rescue nil
|
217
219
|
end
|
@@ -220,18 +222,22 @@ module Onebox
|
|
220
222
|
d[:image] = d[:image_secure_url] || d[:image_url] || d[:thumbnail_url] || d[:image]
|
221
223
|
d[:video] = d[:video_secure_url] || d[:video_url] || d[:video]
|
222
224
|
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
225
|
+
if !Onebox::Helpers.blank?(d[:published_time])
|
226
|
+
d[:article_published_time] = Time.parse(d[:published_time]).strftime("%I:%M%p - %d %b %y")
|
227
|
+
else
|
228
|
+
# Twitter labels
|
229
|
+
if !Onebox::Helpers.blank?(d[:label1]) && !Onebox::Helpers.blank?(d[:data1]) && !!WhitelistedGenericOnebox.twitter_label_whitelist.find { |l| d[:label1] =~ /#{l}/i }
|
230
|
+
d[:label_1] = Sanitize.fragment(Onebox::Helpers.truncate(d[:label1].strip))
|
231
|
+
d[:data_1] = Sanitize.fragment(Onebox::Helpers.truncate(d[:data1].strip))
|
232
|
+
end
|
233
|
+
if !Onebox::Helpers.blank?(d[:label2]) && !Onebox::Helpers.blank?(d[:data2]) && !!WhitelistedGenericOnebox.twitter_label_whitelist.find { |l| d[:label2] =~ /#{l}/i }
|
234
|
+
unless Onebox::Helpers.blank?(d[:label_1])
|
235
|
+
d[:label_2] = Sanitize.fragment(Onebox::Helpers.truncate(d[:label2].strip))
|
236
|
+
d[:data_2] = Sanitize.fragment(Onebox::Helpers.truncate(d[:data2].strip))
|
237
|
+
else
|
238
|
+
d[:label_1] = Sanitize.fragment(Onebox::Helpers.truncate(d[:label2].strip))
|
239
|
+
d[:data_1] = Sanitize.fragment(Onebox::Helpers.truncate(d[:data2].strip))
|
240
|
+
end
|
235
241
|
end
|
236
242
|
end
|
237
243
|
|
data/lib/onebox/helpers.rb
CHANGED
@@ -24,7 +24,7 @@ module Onebox
|
|
24
24
|
og = {}
|
25
25
|
|
26
26
|
doc.css('meta').each do |m|
|
27
|
-
if (m["property"] && m["property"][/^og:(.+)$/i]) || (m["name"] && m["name"][/^og:(.+)$/i])
|
27
|
+
if (m["property"] && m["property"][/^(?:og|article):(.+)$/i]) || (m["name"] && m["name"][/^(?:og|article):(.+)$/i])
|
28
28
|
value = (m["content"] || m["value"]).to_s
|
29
29
|
og[$1.tr('-:', '_').to_sym] ||= value unless Onebox::Helpers::blank?(value)
|
30
30
|
end
|
data/lib/onebox/version.rb
CHANGED
data/onebox.gemspec
CHANGED
@@ -35,7 +35,7 @@ Gem::Specification.new do |spec|
|
|
35
35
|
spec.add_development_dependency 'fakeweb', '~> 1.3'
|
36
36
|
spec.add_development_dependency 'pry', '~> 0.10'
|
37
37
|
spec.add_development_dependency 'mocha', '~> 1.1'
|
38
|
-
spec.add_development_dependency 'rubocop', '~> 0.
|
38
|
+
spec.add_development_dependency 'rubocop', '~> 0.50'
|
39
39
|
spec.add_development_dependency 'twitter', '~> 4.8'
|
40
40
|
spec.add_development_dependency 'guard-rspec', '~> 4.2.8'
|
41
41
|
spec.add_development_dependency 'sinatra', '~> 1.4'
|
@@ -95,6 +95,14 @@ describe Onebox::Engine::WhitelistedGenericOnebox do
|
|
95
95
|
expect(onebox.to_html).not_to be_empty
|
96
96
|
expect(FakeWeb.last_request['Cookie']).to eq('evil=trout')
|
97
97
|
end
|
98
|
+
|
99
|
+
it "fetches site_name and article_published_time tags" do
|
100
|
+
onebox = described_class.new(url)
|
101
|
+
expect(onebox.to_html).not_to be_empty
|
102
|
+
|
103
|
+
expect(onebox.to_html).to include("Mail Online")
|
104
|
+
expect(onebox.to_html).to include("08:03PM - 08 Aug 14")
|
105
|
+
end
|
98
106
|
end
|
99
107
|
|
100
108
|
describe 'canonical link' do
|
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.8.
|
4
|
+
version: 1.8.24
|
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: 2017-11-
|
13
|
+
date: 2017-11-21 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: multi_json
|
@@ -214,14 +214,14 @@ dependencies:
|
|
214
214
|
requirements:
|
215
215
|
- - "~>"
|
216
216
|
- !ruby/object:Gem::Version
|
217
|
-
version: '0.
|
217
|
+
version: '0.50'
|
218
218
|
type: :development
|
219
219
|
prerelease: false
|
220
220
|
version_requirements: !ruby/object:Gem::Requirement
|
221
221
|
requirements:
|
222
222
|
- - "~>"
|
223
223
|
- !ruby/object:Gem::Version
|
224
|
-
version: '0.
|
224
|
+
version: '0.50'
|
225
225
|
- !ruby/object:Gem::Dependency
|
226
226
|
name: twitter
|
227
227
|
requirement: !ruby/object:Gem::Requirement
|
@@ -524,7 +524,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
524
524
|
version: '0'
|
525
525
|
requirements: []
|
526
526
|
rubyforge_project:
|
527
|
-
rubygems_version: 2.
|
527
|
+
rubygems_version: 2.7.2
|
528
528
|
signing_key:
|
529
529
|
specification_version: 4
|
530
530
|
summary: A gem for turning URLs into previews.
|
@@ -611,4 +611,3 @@ test_files:
|
|
611
611
|
- spec/lib/onebox_spec.rb
|
612
612
|
- spec/spec_helper.rb
|
613
613
|
- spec/support/html_spec_helper.rb
|
614
|
-
has_rdoc:
|