safe_video_embed 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/Manifest +8 -0
- data/README +9 -0
- data/Rakefile +14 -0
- data/init.rb +1 -0
- data/lib/action_view/helpers/safe_video_embed.rb +26 -0
- data/lib/init.rb +1 -0
- data/lib/safe_video_embed.rb +5 -0
- data/safe_video_embed.gemspec +29 -0
- metadata +63 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Nathan Bertram
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Manifest
ADDED
data/README
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'echoe'
|
4
|
+
|
5
|
+
Echoe.new('safe_video_embed', '0.1.0') do |p|
|
6
|
+
p.description = "Safely embed vimeo & youtube videos."
|
7
|
+
p.url = "https://github.com/nathanbertram/safe_video_embed"
|
8
|
+
p.author = "Nathan Bertram"
|
9
|
+
p.email = "nbertram@gmail.com"
|
10
|
+
p.ignore_pattern = ["tmp/*", "script/*"]
|
11
|
+
p.development_dependencies = []
|
12
|
+
end
|
13
|
+
|
14
|
+
Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
|
data/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'safe_video_embed'
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module ActionView
|
2
|
+
module Helpers
|
3
|
+
module SafeVideoEmbed
|
4
|
+
def safe_video_embed(embed_code, opts = {})
|
5
|
+
video_width = opts[:width] || '560'
|
6
|
+
video_height = opts[:height] || '349'
|
7
|
+
|
8
|
+
if embed_code[/player\.vimeo\.com\/video\/([^\/\?]*)/] || embed_code[/vimeo\.com\/(\d+)/]
|
9
|
+
vimeo_id = $1
|
10
|
+
return "<iframe src=\"http://player.vimeo.com/video/#{vimeo_id}?title=0&byline=0&portrait=0&autoplay=0\" width=\"#{video_width}\" height=\"#{video_height}\" frameborder=\"0\"></iframe>".html_safe
|
11
|
+
else
|
12
|
+
if embed_code[/youtu\.be\/([^\?]*)/]
|
13
|
+
youtube_id = $1
|
14
|
+
else
|
15
|
+
# Regex from # http://stackoverflow.com/questions/3452546/javascript-regex-how-to-get-youtube-video-id-from-url/4811367#4811367
|
16
|
+
embed_code[/^.*((v\/)|(embed\/)|(watch\?))\??v?=?([^\&\?]*).*/]
|
17
|
+
youtube_id = $5
|
18
|
+
end
|
19
|
+
|
20
|
+
return "<iframe width=\"#{video_width}\" height=\"#{video_height}\" src=\"http://www.youtube.com/embed/#{youtube_id}\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"></iframe>".html_safe
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'safe_video_embed'
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = "safe_video_embed"
|
5
|
+
s.version = "0.1.0"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Nathan Bertram"]
|
9
|
+
s.date = "2012-02-06"
|
10
|
+
s.description = "Safely embed vimeo & youtube videos."
|
11
|
+
s.email = "nbertram@gmail.com"
|
12
|
+
s.extra_rdoc_files = ["README", "lib/action_view/helpers/safe_video_embed.rb", "lib/init.rb", "lib/safe_video_embed.rb"]
|
13
|
+
s.files = ["MIT-LICENSE", "README", "Rakefile", "init.rb", "lib/action_view/helpers/safe_video_embed.rb", "lib/init.rb", "lib/safe_video_embed.rb", "Manifest", "safe_video_embed.gemspec"]
|
14
|
+
s.homepage = "https://github.com/nathanbertram/safe_video_embed"
|
15
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Safe_video_embed", "--main", "README"]
|
16
|
+
s.require_paths = ["lib"]
|
17
|
+
s.rubyforge_project = "safe_video_embed"
|
18
|
+
s.rubygems_version = "1.8.10"
|
19
|
+
s.summary = "Safely embed vimeo & youtube videos."
|
20
|
+
|
21
|
+
if s.respond_to? :specification_version then
|
22
|
+
s.specification_version = 3
|
23
|
+
|
24
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
25
|
+
else
|
26
|
+
end
|
27
|
+
else
|
28
|
+
end
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: safe_video_embed
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Nathan Bertram
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-02-06 00:00:00.000000000Z
|
13
|
+
dependencies: []
|
14
|
+
description: Safely embed vimeo & youtube videos.
|
15
|
+
email: nbertram@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files:
|
19
|
+
- README
|
20
|
+
- lib/action_view/helpers/safe_video_embed.rb
|
21
|
+
- lib/init.rb
|
22
|
+
- lib/safe_video_embed.rb
|
23
|
+
files:
|
24
|
+
- MIT-LICENSE
|
25
|
+
- README
|
26
|
+
- Rakefile
|
27
|
+
- init.rb
|
28
|
+
- lib/action_view/helpers/safe_video_embed.rb
|
29
|
+
- lib/init.rb
|
30
|
+
- lib/safe_video_embed.rb
|
31
|
+
- Manifest
|
32
|
+
- safe_video_embed.gemspec
|
33
|
+
homepage: https://github.com/nathanbertram/safe_video_embed
|
34
|
+
licenses: []
|
35
|
+
post_install_message:
|
36
|
+
rdoc_options:
|
37
|
+
- --line-numbers
|
38
|
+
- --inline-source
|
39
|
+
- --title
|
40
|
+
- Safe_video_embed
|
41
|
+
- --main
|
42
|
+
- README
|
43
|
+
require_paths:
|
44
|
+
- lib
|
45
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
46
|
+
none: false
|
47
|
+
requirements:
|
48
|
+
- - ! '>='
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '0'
|
51
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ! '>='
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '1.2'
|
57
|
+
requirements: []
|
58
|
+
rubyforge_project: safe_video_embed
|
59
|
+
rubygems_version: 1.8.10
|
60
|
+
signing_key:
|
61
|
+
specification_version: 3
|
62
|
+
summary: Safely embed vimeo & youtube videos.
|
63
|
+
test_files: []
|