onebox 1.8.17 → 1.8.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/onebox/engine/pdf_onebox.rb +4 -1
- data/lib/onebox/engine/standard_embed.rb +2 -5
- data/lib/onebox/layout.rb +1 -1
- data/lib/onebox/version.rb +1 -1
- data/lib/onebox/web.rb +2 -0
- data/spec/fixtures/discourse_topic_reply.response +1 -0
- data/spec/lib/onebox/engine/pdf_onebox_spec.rb +8 -0
- data/spec/lib/onebox/layout_spec.rb +6 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e7e216d163d7adc99ee432d4bc16e639fa621f4
|
4
|
+
data.tar.gz: 9c9224c516ef324d858dfab29e37d68e80e0b23a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2501d3ae5025b97e8efb9133f6dedb91e21d7c0ee4d6775f8a0cc736798cc7109980f93b6dd70ebe6906713934674f071db7acf556e06054d9a0d9d5575fcd54
|
7
|
+
data.tar.gz: 07c2a809870856370d0062e34285ccfe14baa24e3c24eb83689b7884c9cd0accbf1239008930826ef077fbaeb769c8429f66cf17e060fccab4aabcd493ae7e21
|
@@ -24,7 +24,10 @@ module Onebox
|
|
24
24
|
def get_pdf_info
|
25
25
|
uri = URI.parse(@url)
|
26
26
|
size = Onebox::Helpers.fetch_content_length(@url)
|
27
|
-
return {
|
27
|
+
return {
|
28
|
+
filesize: size ? Onebox::Helpers.pretty_filesize(size.to_i) : nil,
|
29
|
+
name: File.basename(uri.path)
|
30
|
+
}
|
28
31
|
rescue
|
29
32
|
nil
|
30
33
|
end
|
@@ -58,7 +58,8 @@ module Onebox
|
|
58
58
|
response = (Onebox::Helpers.fetch_response(url, nil, nil, headers) rescue nil)
|
59
59
|
doc = Nokogiri::HTML(response)
|
60
60
|
|
61
|
-
|
61
|
+
ignore_canonical = doc.at('meta[property="og:ignore_canonical"]')
|
62
|
+
unless ignore_canonical && ignore_canonical['content'].to_s == 'true'
|
62
63
|
# prefer canonical link
|
63
64
|
canonical_link = doc.at('//link[@rel="canonical"]/@href')
|
64
65
|
if canonical_link && "#{URI(canonical_link).host}#{URI(canonical_link).path}" != "#{URI(url).host}#{URI(url).path}"
|
@@ -124,10 +125,6 @@ module Onebox
|
|
124
125
|
|
125
126
|
twitter
|
126
127
|
end
|
127
|
-
|
128
|
-
def skip_canonical_link
|
129
|
-
WhitelistedGenericOnebox.probable_discourse(URI(url))
|
130
|
-
end
|
131
128
|
end
|
132
129
|
end
|
133
130
|
end
|
data/lib/onebox/layout.rb
CHANGED
data/lib/onebox/version.rb
CHANGED
data/lib/onebox/web.rb
CHANGED
@@ -88,6 +88,7 @@ And that too in just over an year, way to go! [boom]">
|
|
88
88
|
<meta name="twitter:title" content="Congratulations, most stars in 2013 GitHub Octoverse!" />
|
89
89
|
<meta property="og:description" content="Ah, cool. I was not sure how to see that since GitHub changed around the way project top stats looked. Thanks for that link and thank you -- and everyone else who is contributing to the project!" />
|
90
90
|
<meta name="twitter:description" content="Ah, cool. I was not sure how to see that since GitHub changed around the way project top stats looked. Thanks for that link and thank you -- and everyone else who is contributing to the project!" />
|
91
|
+
<meta property="og:ignore_canonical" content="true" />
|
91
92
|
|
92
93
|
|
93
94
|
|
@@ -4,8 +4,12 @@ describe Onebox::Engine::PdfOnebox do
|
|
4
4
|
let(:link) { "https://acrobatusers.com/assets/uploads/public_downloads/2217/adobe-acrobat-xi-merge-pdf-files-tutorial-ue.pdf" }
|
5
5
|
let(:html) { described_class.new(link).to_html }
|
6
6
|
|
7
|
+
let(:no_content_length_link) { "https://dspace.lboro.ac.uk/dspace-jspui/bitstream/2134/14294/3/greiffenhagen-ca_and_consumption.pdf" }
|
8
|
+
let(:no_filesize_html) { described_class.new(no_content_length_link).to_html }
|
9
|
+
|
7
10
|
before do
|
8
11
|
FakeWeb.register_uri(:head, link, :content_length => "335562")
|
12
|
+
FakeWeb.register_uri(:head, no_content_length_link, :content_length => nil)
|
9
13
|
end
|
10
14
|
|
11
15
|
describe "#to_html" do
|
@@ -16,5 +20,9 @@ describe Onebox::Engine::PdfOnebox do
|
|
16
20
|
it "includes filesize" do
|
17
21
|
expect(html).to include("327.70 KB")
|
18
22
|
end
|
23
|
+
|
24
|
+
it "doesn’t include filesize when unknown" do
|
25
|
+
expect(no_filesize_html).to_not include("<p class='filesize'>")
|
26
|
+
end
|
19
27
|
end
|
20
28
|
end
|
@@ -69,5 +69,11 @@ describe Onebox::Layout do
|
|
69
69
|
html = described_class.new("amazon", record, cache).to_html
|
70
70
|
expect(html).to include(%|"foo"|)
|
71
71
|
end
|
72
|
+
|
73
|
+
it "rewrites relative image path" do
|
74
|
+
record = { image: "/image.png", link: "https://discourse.org" }
|
75
|
+
klass = described_class.new("whitelistedgeneric", record, cache)
|
76
|
+
expect(klass.view.record[:image]).to include("https://discourse.org")
|
77
|
+
end
|
72
78
|
end
|
73
79
|
end
|
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.18
|
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-08-
|
13
|
+
date: 2017-08-17 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: multi_json
|
@@ -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.
|
527
|
+
rubygems_version: 2.6.8
|
528
528
|
signing_key:
|
529
529
|
specification_version: 4
|
530
530
|
summary: A gem for turning URLs into previews.
|