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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 584d1054d0ca1dd735a214cebe2b08427bdf3d1a
4
- data.tar.gz: 5b070e05e93e822320f5450a70cc993d8f7bc9e3
2
+ SHA256:
3
+ metadata.gz: 46083e1a21f3b8566a13d1f23db6d2b63d0dab0f4e81a4f124b131cbf1f417df
4
+ data.tar.gz: dce9be021faa467dcb5e5675cc21529535f83c920614752232c5c5e9df21dea7
5
5
  SHA512:
6
- metadata.gz: 9b7537379a2d5119196364a192d211dc308f7656f4e782bce43f39a73af582a57d96a368bd3056dc6d5ab56d4960d107c9073bfe0a35dc0125801a8a00769a97
7
- data.tar.gz: af5cc488f634add8fa6af284068035f30f14c7d85f0983744cc6617e6b238f2ce9b4c8c91d424da73e6aa33cd8dcd30191857eaef9e260b1b9ab8b6a1ec1e10b
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[:domain])
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
- # Twitter labels
224
- if !Onebox::Helpers.blank?(d[:label1]) && !Onebox::Helpers.blank?(d[:data1]) && !!WhitelistedGenericOnebox.twitter_label_whitelist.find { |l| d[:label1] =~ /#{l}/i }
225
- d[:label_1] = Sanitize.fragment(Onebox::Helpers.truncate(d[:label1].strip))
226
- d[:data_1] = Sanitize.fragment(Onebox::Helpers.truncate(d[:data1].strip))
227
- end
228
- if !Onebox::Helpers.blank?(d[:label2]) && !Onebox::Helpers.blank?(d[:data2]) && !!WhitelistedGenericOnebox.twitter_label_whitelist.find { |l| d[:label2] =~ /#{l}/i }
229
- unless Onebox::Helpers.blank?(d[:label_1])
230
- d[:label_2] = Sanitize.fragment(Onebox::Helpers.truncate(d[:label2].strip))
231
- d[:data_2] = Sanitize.fragment(Onebox::Helpers.truncate(d[:data2].strip))
232
- else
233
- d[:label_1] = Sanitize.fragment(Onebox::Helpers.truncate(d[:label2].strip))
234
- d[:data_1] = Sanitize.fragment(Onebox::Helpers.truncate(d[:data2].strip))
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
 
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Onebox
2
- VERSION = "1.8.23"
2
+ VERSION = "1.8.24"
3
3
  end
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.30'
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
@@ -4,6 +4,10 @@
4
4
 
5
5
  <p>{{description}}</p>
6
6
 
7
+ {{#article_published_time}}
8
+ <p><span class="label1">{{article_published_time}}</span>
9
+ {{/article_published_time}}
10
+
7
11
  {{#data_1}}
8
12
  <p><span class="label1">{{label_1}}: {{data_1}}</span>
9
13
  {{#data_2}}
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.23
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-08 00:00:00.000000000 Z
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.30'
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.30'
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.6.13
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: