onebox 1.8.26 → 1.8.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 46a7ed36caa2a4739734bac88039bf5112e82237
4
- data.tar.gz: 5567b27220d7ab70aa94b72f4769f6803043b802
3
+ metadata.gz: '08ae08abe8fd51a365cbd459c4e4f278ea150263'
4
+ data.tar.gz: 9bf91c3aaf8a4752b834758df951fdb15803490e
5
5
  SHA512:
6
- metadata.gz: 18bab86adf0e4dde4e4db0990ce59898489afc3061d4b1b3b3040ae566b0a10d7d6de1651b8cf920ea408d2fdc59b0dbedc2209086a039ab33b2f67a3450b1cb
7
- data.tar.gz: 8453cb98229163cfa8cafb92a5d5d62b605cdf64db20fac6b80f2b06ee15fdf9d7d1432e90ad3733fda573b01037a1b79a6a4db63af74cb1d3f105e8d9f69e8b
6
+ metadata.gz: 28ef6d769b53b73850a805c714ac50d7da17c0057141a4b427700f8eec7e00de2c42eafc78259bdf20ab2168c6878cdf4d48ec82c82862aed911de5d52086d92
7
+ data.tar.gz: 9afca78a39e27f4cb0551c68dad859ac3063ee0ba7d7796798187fc9efd979b97dd7c0efb14f22001f475faf8efc11701f3137c279931139950b81bddb90c3f3
@@ -44,6 +44,9 @@ module Onebox
44
44
  twitter.each { |k, v| @raw[k] ||= v unless Onebox::Helpers::blank?(v) }
45
45
  oembed.each { |k, v| @raw[k] ||= v unless Onebox::Helpers::blank?(v) }
46
46
 
47
+ favicon = get_favicon
48
+ @raw["favicon".to_sym] = favicon unless Onebox::Helpers::blank?(favicon)
49
+
47
50
  @raw
48
51
  end
49
52
 
@@ -111,6 +114,20 @@ module Onebox
111
114
 
112
115
  twitter
113
116
  end
117
+
118
+ def get_favicon
119
+ return nil unless html_doc
120
+
121
+ favicon = html_doc.css('link[rel="shortcut icon"], link[rel="icon shortcut"], link[rel="shortcut"], link[rel="icon"]').first
122
+ favicon = favicon.nil? ? nil : favicon['href']&.strip
123
+
124
+ if favicon && favicon.match(/^https?:\/\//i).nil?
125
+ uri = URI(url)
126
+ favicon = uri.scheme + "://" + uri.host.sub(/\/$/,"") + "/" + favicon.sub(/^\//,"")
127
+ end
128
+
129
+ favicon
130
+ end
114
131
  end
115
132
  end
116
133
  end
data/lib/onebox/layout.rb CHANGED
@@ -53,6 +53,7 @@ module Onebox
53
53
  {
54
54
  link: record[:link],
55
55
  title: record[:title],
56
+ favicon: record[:favicon],
56
57
  domain: domain,
57
58
  article_published_time: record[:article_published_time],
58
59
  article_published_time_title: record[:article_published_time_title],
@@ -1,3 +1,3 @@
1
1
  module Onebox
2
- VERSION = "1.8.26"
2
+ VERSION = "1.8.27"
3
3
  end
@@ -100,7 +100,7 @@ describe Onebox::Engine::WhitelistedGenericOnebox do
100
100
  onebox = described_class.new(url)
101
101
  expect(onebox.to_html).not_to be_empty
102
102
 
103
- expect(onebox.to_html).to include("Mail Online - 8 Aug 14")
103
+ expect(onebox.to_html).to include("Mail Online – 8 Aug 14")
104
104
  end
105
105
  end
106
106
 
@@ -116,6 +116,8 @@ describe Onebox::Engine::WhitelistedGenericOnebox do
116
116
  it 'fetches opengraph data and twitter labels from canonical link' do
117
117
  onebox = described_class.new(mobile_url)
118
118
  expect(onebox.to_html).not_to be_nil
119
+ expect(onebox.to_html).to include("images/favicon.ico")
120
+ expect(onebox.to_html).to include("Etsy")
119
121
  expect(onebox.to_html).to include("Personalized Word Pillow Case")
120
122
  expect(onebox.to_html).to include("Allow your personality to shine through your decor; this contemporary and modern accent will help you do just that.")
121
123
  expect(onebox.to_html).to include("https://img1.etsystatic.com/028/1/6088772/il_570xN.613262127_e0zl.jpg")
@@ -1,7 +1,10 @@
1
1
  <aside class="onebox {{subname}}">
2
2
  <header class="source">
3
+ {{#favicon}}
4
+ <img src="{{favicon}}" class="site-icon"/>
5
+ {{/favicon}}
3
6
  {{#article_published_time}}
4
- <a href="{{link}}" target='_blank' title="{{article_published_time_title}}">{{domain}} - {{article_published_time}}</a>
7
+ <a href="{{link}}" target='_blank' title="{{article_published_time_title}}">{{domain}} &ndash; {{article_published_time}}</a>
5
8
  {{/article_published_time}}
6
9
  {{^article_published_time}}
7
10
  <a href="{{link}}" target='_blank'>{{domain}}</a>
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.26
4
+ version: 1.8.27
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-23 00:00:00.000000000 Z
13
+ date: 2017-11-25 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: multi_json