onebox 1.5.12 → 1.5.13
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f8031763d3695cefd269de23ffe5622d00223f1
|
4
|
+
data.tar.gz: 338f8b07c36852db96639a76a0a59d2cbbb1b1cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3d05b05258d6f3c828a5bd5b5993ead4034a4985b0df80150366d46b0e598dc2f6204d153e0538226e1e07a4fc619552e757de3273d1d8c6dfa56bc38a09766
|
7
|
+
data.tar.gz: d27d79ab2efe1ad279c61341d09e675b228dcc7e98ec6c1fce5dae4aec014858a1f0883c229758c40c1d9a2c69a376ac632bc9806c4783ca18532b5f2033217b
|
@@ -4,23 +4,35 @@ module Onebox
|
|
4
4
|
include Engine
|
5
5
|
include LayoutSupport
|
6
6
|
|
7
|
-
matches_regexp /^(https?:)?\/\/(maps\.google\.[\w.]{2,}|goo\.gl)\/maps?.+$/
|
7
|
+
matches_regexp /^(https?:)?\/\/((maps|www)\.google\.[\w.]{2,}|goo\.gl)\/maps?.+$/
|
8
8
|
|
9
9
|
def url
|
10
|
-
@url = get_long_url if @url.include?("//goo.gl/maps/")
|
10
|
+
@url = get_long_url if @url.include?("//goo.gl/maps/")
|
11
|
+
@url = get_canonical_url if @url.include?("www.google")
|
11
12
|
@url
|
12
13
|
end
|
13
14
|
|
14
15
|
def to_html
|
15
|
-
"<iframe src='#{url}&output=embed' width='690px' height='400px' frameborder='0' style='border:0'></iframe>"
|
16
|
+
"<iframe src='#{url}&output=embed' width='690px' height='400px' frameborder='0' style='border:0'></iframe>"
|
16
17
|
end
|
17
18
|
|
18
|
-
private
|
19
|
+
private
|
19
20
|
|
20
21
|
def data
|
21
22
|
{link: url, title: url}
|
22
23
|
end
|
23
24
|
|
25
|
+
def get_canonical_url
|
26
|
+
uri = URI(@url)
|
27
|
+
http = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https')
|
28
|
+
http.open_timeout = timeout
|
29
|
+
http.read_timeout = timeout
|
30
|
+
response = http.head(uri.path)
|
31
|
+
response["Location"].sub(/&?output=classic/, '') if response.code == "302"
|
32
|
+
rescue
|
33
|
+
@url
|
34
|
+
end
|
35
|
+
|
24
36
|
def get_long_url
|
25
37
|
uri = URI(@url)
|
26
38
|
http = Net::HTTP.start(uri.host, uri.port)
|
@@ -69,6 +69,7 @@ module Onebox
|
|
69
69
|
kickstarter.com
|
70
70
|
kinomap.com
|
71
71
|
liveleak.com
|
72
|
+
livestream.com
|
72
73
|
lessonplanet.com
|
73
74
|
mashable.com
|
74
75
|
meetup.com
|
@@ -150,7 +151,7 @@ module Onebox
|
|
150
151
|
end
|
151
152
|
|
152
153
|
def self.default_rewrites
|
153
|
-
%w(slideshare.net imgur.com dailymotion.com)
|
154
|
+
%w(slideshare.net imgur.com dailymotion.com livestream.com)
|
154
155
|
end
|
155
156
|
|
156
157
|
def self.host_matches(uri, list)
|
data/lib/onebox/version.rb
CHANGED
@@ -25,4 +25,14 @@ describe Onebox::Engine::ClassicGoogleMapsOnebox do
|
|
25
25
|
expect(onebox.url).to eq(long_url)
|
26
26
|
end
|
27
27
|
end
|
28
|
+
|
29
|
+
describe 'www form url' do
|
30
|
+
let(:embed_url) { "https://maps.google.de/maps?t=h&ll=48.398499,9.992333&spn=0.0038338,0.0056322&dg=ntvb&output=embed" }
|
31
|
+
|
32
|
+
it "retrieves the canonical url" do
|
33
|
+
onebox = described_class.new("https://www.google.de/maps/@48.3932366,9.992333,663a,20y,41.43t/data=!3m1!1e3")
|
34
|
+
onebox.expects(:get_canonical_url).once.returns(embed_url)
|
35
|
+
expect(onebox.url).to eq(embed_url)
|
36
|
+
end
|
37
|
+
end
|
28
38
|
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.5.
|
4
|
+
version: 1.5.13
|
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: 2015-02-
|
13
|
+
date: 2015-02-24 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: multi_json
|
@@ -407,7 +407,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
407
407
|
version: '0'
|
408
408
|
requirements: []
|
409
409
|
rubyforge_project:
|
410
|
-
rubygems_version: 2.
|
410
|
+
rubygems_version: 2.1.11
|
411
411
|
signing_key:
|
412
412
|
specification_version: 4
|
413
413
|
summary: A gem for turning URLs into previews.
|
@@ -460,3 +460,4 @@ test_files:
|
|
460
460
|
- spec/lib/onebox_spec.rb
|
461
461
|
- spec/spec_helper.rb
|
462
462
|
- spec/support/html_spec_helper.rb
|
463
|
+
has_rdoc:
|