onebox 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -1
- data/lib/onebox/engine/audio_onebox.rb +2 -4
- data/lib/onebox/engine/github_gist_onebox.rb +1 -1
- data/lib/onebox/engine/image_onebox.rb +1 -1
- data/lib/onebox/engine/video_onebox.rb +1 -2
- data/lib/onebox/engine/whitelisted_generic_onebox.rb +2 -0
- data/lib/onebox/version.rb +1 -1
- data/onebox.gemspec +0 -1
- data/spec/lib/onebox/engine/audio_onebox_spec.rb +27 -0
- data/spec/lib/onebox/engine/image_onebox_spec.rb +39 -0
- data/spec/lib/onebox/engine/video_onebox_spec.rb +31 -0
- metadata +8 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9fa2ea983edc182dc92968e18b0c802e4c68f5a9
|
4
|
+
data.tar.gz: eb69673c515f8099e8e3da8177df5458f0aab925
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92db3996ec6a7fd71d0cca3fc3da1750f643a8d9b1cd1a61a415deceffe92c693d3f62c2a855966502320e12a405cc3ba4a33d4a7e33569636db6d3de37e1f1c
|
7
|
+
data.tar.gz: fefd85244ebab551ebc2fb66845d5e94a90079796fdd3df8986ae854ab8dab1012c33d8b882c40fa745ec164cd7b056c116b0d05ed668b37b524c5b7580b2e59
|
data/README.md
CHANGED
@@ -5,7 +5,6 @@ onebox
|
|
5
5
|
- [![Code Climate](https://codeclimate.com/github/dysania/onebox.png)](https://codeclimate.com/github/dysania/onebox)
|
6
6
|
- [![Build Status](https://travis-ci.org/dysania/onebox.png)](https://travis-ci.org/dysania/onebox)
|
7
7
|
- [![Dependency Status](https://gemnasium.com/dysania/onebox.png)](https://gemnasium.com/dysania/onebox)
|
8
|
-
- [![Coverage Status](https://coveralls.io/repos/dysania/onebox/badge.png)](https://coveralls.io/r/dysania/onebox)
|
9
8
|
|
10
9
|
|
11
10
|
Onebox is a library for turning media URLs into simple HTML previews of the resource.
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module Onebox
|
2
2
|
module Engine
|
3
|
-
class
|
3
|
+
class AudioOnebox
|
4
4
|
include Engine
|
5
5
|
|
6
|
-
matches_regexp /^https
|
6
|
+
matches_regexp /^(https?:)?\/\/.*\.(mp3|ogg|wav)(\?.*)?$/
|
7
7
|
|
8
8
|
def to_html
|
9
9
|
"<audio controls><source src='#{@url}'><a href='#{@url}'>#{@url}</a></audio>"
|
@@ -11,5 +11,3 @@ module Onebox
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
14
|
-
|
15
|
-
|
@@ -3,7 +3,7 @@ module Onebox
|
|
3
3
|
class ImageOnebox
|
4
4
|
include Engine
|
5
5
|
|
6
|
-
matches_regexp /^(https?:)?\/\/.+\.(png|jpg|jpeg|gif|bmp|tif|tiff)
|
6
|
+
matches_regexp /^(https?:)?\/\/.+\.(png|jpg|jpeg|gif|bmp|tif|tiff)(\?.*)?$/i
|
7
7
|
|
8
8
|
def to_html
|
9
9
|
"<a href='#{@url}' target='_blank'><img src='#{@url}'></a>"
|
@@ -3,7 +3,7 @@ module Onebox
|
|
3
3
|
class VideoOnebox
|
4
4
|
include Engine
|
5
5
|
|
6
|
-
matches_regexp /^https
|
6
|
+
matches_regexp /^(https?:)?\/\/.*\.(mov|mp4|webm|ogv)(\?.*)?$/
|
7
7
|
|
8
8
|
def to_html
|
9
9
|
"<video width='100%' height='100%' controls><source src='#{@url}'><a href='#{@url}'>#{@url}</a></video>"
|
@@ -11,4 +11,3 @@ module Onebox
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
14
|
-
|
@@ -47,6 +47,7 @@ module Onebox
|
|
47
47
|
etsy.com
|
48
48
|
findery.com
|
49
49
|
flickr.com
|
50
|
+
folksy.com
|
50
51
|
forbes.com
|
51
52
|
foxnews.com
|
52
53
|
funnyordie.com
|
@@ -66,6 +67,7 @@ module Onebox
|
|
66
67
|
kickstarter.com
|
67
68
|
kinomap.com
|
68
69
|
liveleak.com
|
70
|
+
lessonplanet.com
|
69
71
|
mashable.com
|
70
72
|
mlb.com
|
71
73
|
myspace.com
|
data/lib/onebox/version.rb
CHANGED
data/onebox.gemspec
CHANGED
@@ -27,7 +27,6 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.add_development_dependency "bundler", "~> 1.3"
|
28
28
|
spec.add_development_dependency "rake", "~> 10.0"
|
29
29
|
spec.add_development_dependency "rspec", "~> 2.14"
|
30
|
-
spec.add_development_dependency "coveralls", "~> 0.6"
|
31
30
|
spec.add_development_dependency "yard", "~> 0.8"
|
32
31
|
spec.add_development_dependency "fakeweb", "~> 1.3"
|
33
32
|
spec.add_development_dependency "pry", "~> 0.9"
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Onebox::Engine::AudioOnebox do
|
4
|
+
it "supports ogg" do
|
5
|
+
Onebox.preview('http://upload.wikimedia.org/wikipedia/commons/c/c8/Example.ogg').to_s.should match(/<audio/)
|
6
|
+
end
|
7
|
+
|
8
|
+
it "supports mp3" do
|
9
|
+
Onebox.preview('http://kolber.github.io/audiojs/demos/mp3/juicy.mp3').to_s.should match(/<audio/)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "supports wav" do
|
13
|
+
Onebox.preview('http://download.wavetlan.com/SVV/Media/HTTP/sample14.wav').to_s.should match(/<audio/)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "supports URLs with query parameters" do
|
17
|
+
Onebox.preview('https://upload.wikimedia.org/wikipedia/commons/c/c8/Example.ogg?foo=bar').to_s.should match(/<audio/)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "supports protocol relative URLs" do
|
21
|
+
Onebox.preview('//upload.wikimedia.org/wikipedia/commons/c/c8/Example.ogg').to_s.should match(/<audio/)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "includes a fallback direct link to the audio" do
|
25
|
+
Onebox.preview('http://kolber.github.io/audiojs/demos/mp3/juicy.mp3').to_s.should match(/<a.*mp3/)
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Onebox::Engine::ImageOnebox do
|
4
|
+
it "supports png" do
|
5
|
+
Onebox.preview('http://www.discourse.org/images/logo.png').to_s.should match(/<img/)
|
6
|
+
end
|
7
|
+
|
8
|
+
it "supports jpg" do
|
9
|
+
Onebox.preview('http://upload.wikimedia.org/wikipedia/en/a/a9/Example.jpg').to_s.should match(/<img/)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "supports jpeg" do
|
13
|
+
Onebox.preview('http://upload.wikimedia.org/wikipedia/en/b/bb/Poster.jpeg').to_s.should match(/<img/)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "supports gif" do
|
17
|
+
Onebox.preview('http://upload.wikimedia.org/wikipedia/commons/5/55/Tesseract.gif').to_s.should match(/<img/)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "supports tif" do
|
21
|
+
Onebox.preview('http://www.fileformat.info/format/tiff/sample/1f37bbd5603048178487ec88b1a6425b/MARBLES.tif').to_s.should match(/<img/)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "supports bmp" do
|
25
|
+
Onebox.preview('http://www.fileformat.info/format/bmp/sample/d4202a5fc22a48c388d9e1c636792cc6/LAND.BMP').to_s.should match(/<img/)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "supports image URLs with query parameters" do
|
29
|
+
Onebox.preview('https://www.google.com/logos/doodles/2014/percy-julians-115th-birthday-born-1899-5688801926053888-hp.jpg?foo=bar').to_s.should match(/<img/)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "supports protocol relative image URLs" do
|
33
|
+
Onebox.preview('//www.google.com/logos/doodles/2014/percy-julians-115th-birthday-born-1899-5688801926053888-hp.jpg').to_s.should match(/<img/)
|
34
|
+
end
|
35
|
+
|
36
|
+
it "includes a direct link to the image" do
|
37
|
+
Onebox.preview('http://www.discourse.org/images/logo.png').to_s.should match(/<a.*png/)
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Onebox::Engine::VideoOnebox do
|
4
|
+
it "supports ogv" do
|
5
|
+
Onebox.preview('http://upload.wikimedia.org/wikipedia/commons/3/37/STS-134_launch_2.ogv').to_s.should match(/<video/)
|
6
|
+
end
|
7
|
+
|
8
|
+
it "supports mp4" do
|
9
|
+
Onebox.preview('http://download.wavetlan.com/svv/dev/test.mp4').to_s.should match(/<video/)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "supports mov" do
|
13
|
+
Onebox.preview('http://download.wavetlan.com/SVV/Media/HTTP/BlackBerry.mov').to_s.should match(/<video/)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "supports webm" do
|
17
|
+
Onebox.preview('http://video.webmfiles.org/big-buck-bunny_trailer.webm').to_s.should match(/<video/)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "supports URLs with query parameters" do
|
21
|
+
Onebox.preview('http://video.webmfiles.org/big-buck-bunny_trailer.webm?foo=bar').to_s.should match(/<video/)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "supports protocol relative URLs" do
|
25
|
+
Onebox.preview('//video.webmfiles.org/big-buck-bunny_trailer.webm').to_s.should match(/<video/)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "includes a fallback direct link to the video" do
|
29
|
+
Onebox.preview('http://download.wavetlan.com/svv/dev/test.mp4').to_s.should match(/<a.*mp4/)
|
30
|
+
end
|
31
|
+
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.3.
|
4
|
+
version: 1.3.1
|
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: 2014-04-
|
13
|
+
date: 2014-04-14 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: multi_json
|
@@ -124,20 +124,6 @@ dependencies:
|
|
124
124
|
- - ~>
|
125
125
|
- !ruby/object:Gem::Version
|
126
126
|
version: '2.14'
|
127
|
-
- !ruby/object:Gem::Dependency
|
128
|
-
name: coveralls
|
129
|
-
requirement: !ruby/object:Gem::Requirement
|
130
|
-
requirements:
|
131
|
-
- - ~>
|
132
|
-
- !ruby/object:Gem::Version
|
133
|
-
version: '0.6'
|
134
|
-
type: :development
|
135
|
-
prerelease: false
|
136
|
-
version_requirements: !ruby/object:Gem::Requirement
|
137
|
-
requirements:
|
138
|
-
- - ~>
|
139
|
-
- !ruby/object:Gem::Version
|
140
|
-
version: '0.6'
|
141
127
|
- !ruby/object:Gem::Dependency
|
142
128
|
name: yard
|
143
129
|
requirement: !ruby/object:Gem::Requirement
|
@@ -314,6 +300,7 @@ files:
|
|
314
300
|
- spec/fixtures/youtube-json.response
|
315
301
|
- spec/fixtures/youtube.response
|
316
302
|
- spec/lib/onebox/engine/amazon_onebox_spec.rb
|
303
|
+
- spec/lib/onebox/engine/audio_onebox_spec.rb
|
317
304
|
- spec/lib/onebox/engine/classic_google_maps_onebox_spec.rb
|
318
305
|
- spec/lib/onebox/engine/github_blob_onebox_spec.rb
|
319
306
|
- spec/lib/onebox/engine/github_commit_onebox_spec.rb
|
@@ -321,10 +308,12 @@ files:
|
|
321
308
|
- spec/lib/onebox/engine/github_pullrequest_onebox_spec.rb
|
322
309
|
- spec/lib/onebox/engine/google_play_app_onebox_spec.rb
|
323
310
|
- spec/lib/onebox/engine/html_spec.rb
|
311
|
+
- spec/lib/onebox/engine/image_onebox_spec.rb
|
324
312
|
- spec/lib/onebox/engine/json_spec.rb
|
325
313
|
- spec/lib/onebox/engine/pubmed_onebox_spec.rb
|
326
314
|
- spec/lib/onebox/engine/stack_exchange_onebox_spec.rb
|
327
315
|
- spec/lib/onebox/engine/twitter_status_onebox_spec.rb
|
316
|
+
- spec/lib/onebox/engine/video_onebox_spec.rb
|
328
317
|
- spec/lib/onebox/engine/whitelisted_generic_onebox_spec.rb
|
329
318
|
- spec/lib/onebox/engine/wikipedia_onebox_spec.rb
|
330
319
|
- spec/lib/onebox/engine/youtube_onebox_spec.rb
|
@@ -387,6 +376,7 @@ test_files:
|
|
387
376
|
- spec/fixtures/youtube-json.response
|
388
377
|
- spec/fixtures/youtube.response
|
389
378
|
- spec/lib/onebox/engine/amazon_onebox_spec.rb
|
379
|
+
- spec/lib/onebox/engine/audio_onebox_spec.rb
|
390
380
|
- spec/lib/onebox/engine/classic_google_maps_onebox_spec.rb
|
391
381
|
- spec/lib/onebox/engine/github_blob_onebox_spec.rb
|
392
382
|
- spec/lib/onebox/engine/github_commit_onebox_spec.rb
|
@@ -394,10 +384,12 @@ test_files:
|
|
394
384
|
- spec/lib/onebox/engine/github_pullrequest_onebox_spec.rb
|
395
385
|
- spec/lib/onebox/engine/google_play_app_onebox_spec.rb
|
396
386
|
- spec/lib/onebox/engine/html_spec.rb
|
387
|
+
- spec/lib/onebox/engine/image_onebox_spec.rb
|
397
388
|
- spec/lib/onebox/engine/json_spec.rb
|
398
389
|
- spec/lib/onebox/engine/pubmed_onebox_spec.rb
|
399
390
|
- spec/lib/onebox/engine/stack_exchange_onebox_spec.rb
|
400
391
|
- spec/lib/onebox/engine/twitter_status_onebox_spec.rb
|
392
|
+
- spec/lib/onebox/engine/video_onebox_spec.rb
|
401
393
|
- spec/lib/onebox/engine/whitelisted_generic_onebox_spec.rb
|
402
394
|
- spec/lib/onebox/engine/wikipedia_onebox_spec.rb
|
403
395
|
- spec/lib/onebox/engine/youtube_onebox_spec.rb
|