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: e46a3646e53f3419474f543aff459f7f2c4c4b75
4
- data.tar.gz: baf10d809c943a1ef4ef4629ab45ba69a1379b9e
3
+ metadata.gz: 0f8031763d3695cefd269de23ffe5622d00223f1
4
+ data.tar.gz: 338f8b07c36852db96639a76a0a59d2cbbb1b1cf
5
5
  SHA512:
6
- metadata.gz: ce73f343fecff549f1c155b7b614d34118e423326725e45f411eaf6d7107a4c72ab2f308efca65f128597339d5657fbac576438ab3ba4436afbf0516fb2b64ce
7
- data.tar.gz: 936dc764425670e1eed82ec79c4f843e08d26b0062381d8692ec02825c2e18da40144c463ae8981dc367fc7f2325439fa8a6c0a607e9e270fba3962047291945
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)
@@ -1,3 +1,3 @@
1
1
  module Onebox
2
- VERSION = "1.5.12"
2
+ VERSION = "1.5.13"
3
3
  end
@@ -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.12
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-06 00:00:00.000000000 Z
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.4.3
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: