Skip to content
Browse files

Gemified and added to rubygems

  • Loading branch information...
1 parent 18b3d8f commit 6e40101c344c5a873a204d8cdd04bb576c22bb13 @nathanbertram committed
View
8 Manifest
@@ -0,0 +1,8 @@
+MIT-LICENSE
+README
+Rakefile
+init.rb
+lib/action_view/helpers/safe_video_embed.rb
+lib/init.rb
+lib/safe_video_embed.rb
+Manifest
View
14 Rakefile
@@ -0,0 +1,14 @@
+require 'rubygems'
+require 'rake'
+require 'echoe'
+
+Echoe.new('safe_video_embed', '0.1.0') do |p|
+ p.description = "Safely embed vimeo & youtube videos."
+ p.url = "https://github.com/nathanbertram/safe_video_embed"
+ p.author = "Nathan Bertram"
+ p.email = "nbertram@gmail.com"
+ p.ignore_pattern = ["tmp/*", "script/*"]
+ p.development_dependencies = []
+end
+
+Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
View
1 lib/init.rb
@@ -0,0 +1 @@
+require 'safe_video_embed'
View
BIN pkg/safe_video_embed-0.1.0.gem
Binary file not shown.
View
BIN pkg/safe_video_embed-0.1.0.tar.gz
Binary file not shown.
View
20 pkg/safe_video_embed-0.1.0/MIT-LICENSE
@@ -0,0 +1,20 @@
+Copyright (c) 2011 Nathan Bertram
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
8 pkg/safe_video_embed-0.1.0/Manifest
@@ -0,0 +1,8 @@
+MIT-LICENSE
+README
+Rakefile
+init.rb
+lib/action_view/helpers/safe_video_embed.rb
+lib/init.rb
+lib/safe_video_embed.rb
+Manifest
View
9 pkg/safe_video_embed-0.1.0/README
@@ -0,0 +1,9 @@
+Usage:
+1. Add migration
+ add_column :examples, :video_embed_url, :string
+2. Use helper for associated video_embed_url column safe_video_embed(:width => '800', :height => '600')
+
+
+# TODO:
+# 1. Test
+# 2. Gemify
View
14 pkg/safe_video_embed-0.1.0/Rakefile
@@ -0,0 +1,14 @@
+require 'rubygems'
+require 'rake'
+require 'echoe'
+
+Echoe.new('safe_video_embed', '0.1.0') do |p|
+ p.description = "Safely embed vimeo & youtube videos."
+ p.url = "https://github.com/nathanbertram/safe_video_embed"
+ p.author = "Nathan Bertram"
+ p.email = "nbertram@gmail.com"
+ p.ignore_pattern = ["tmp/*", "script/*"]
+ p.development_dependencies = []
+end
+
+Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
View
1 pkg/safe_video_embed-0.1.0/init.rb
@@ -0,0 +1 @@
+require 'safe_video_embed'
View
26 pkg/safe_video_embed-0.1.0/lib/action_view/helpers/safe_video_embed.rb
@@ -0,0 +1,26 @@
+module ActionView
+ module Helpers
+ module SafeVideoEmbed
+ def safe_video_embed(embed_code, opts = {})
+ video_width = opts[:width] || '560'
+ video_height = opts[:height] || '349'
+
+ if embed_code[/player\.vimeo\.com\/video\/([^\/\?]*)/] || embed_code[/vimeo\.com\/(\d+)/]
+ vimeo_id = $1
+ return "<iframe src=\"http://player.vimeo.com/video/#{vimeo_id}?title=0&amp;byline=0&amp;portrait=0&amp;autoplay=0\" width=\"#{video_width}\" height=\"#{video_height}\" frameborder=\"0\"></iframe>".html_safe
+ else
+ if embed_code[/youtu\.be\/([^\?]*)/]
+ youtube_id = $1
+ else
+ # Regex from # http://stackoverflow.com/questions/3452546/javascript-regex-how-to-get-youtube-video-id-from-url/4811367#4811367
+ embed_code[/^.*((v\/)|(embed\/)|(watch\?))\??v?=?([^\&\?]*).*/]
+ youtube_id = $5
+ end
+
+ return "<iframe width=\"#{video_width}\" height=\"#{video_height}\" src=\"http://www.youtube.com/embed/#{youtube_id}\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"></iframe>".html_safe
+ end
+ end
+
+ end
+ end
+end
View
1 pkg/safe_video_embed-0.1.0/lib/init.rb
@@ -0,0 +1 @@
+require 'safe_video_embed'
View
5 pkg/safe_video_embed-0.1.0/lib/safe_video_embed.rb
@@ -0,0 +1,5 @@
+require 'action_view/helpers/safe_video_embed'
+
+class ActionView::Base
+ include SafeVideoEmbed
+end
View
29 pkg/safe_video_embed-0.1.0/safe_video_embed.gemspec
@@ -0,0 +1,29 @@
+# -*- encoding: utf-8 -*-
+
+Gem::Specification.new do |s|
+ s.name = "safe_video_embed"
+ s.version = "0.1.0"
+
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
+ s.authors = ["Nathan Bertram"]
+ s.date = "2012-02-06"
+ s.description = "Safely embed vimeo & youtube videos."
+ s.email = "nbertram@gmail.com"
+ s.extra_rdoc_files = ["README", "lib/action_view/helpers/safe_video_embed.rb", "lib/init.rb", "lib/safe_video_embed.rb"]
+ 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"]
+ s.homepage = "https://github.com/nathanbertram/safe_video_embed"
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Safe_video_embed", "--main", "README"]
+ s.require_paths = ["lib"]
+ s.rubyforge_project = "safe_video_embed"
+ s.rubygems_version = "1.8.10"
+ s.summary = "Safely embed vimeo & youtube videos."
+
+ if s.respond_to? :specification_version then
+ s.specification_version = 3
+
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
+ else
+ end
+ else
+ end
+end

0 comments on commit 6e40101

Please sign in to comment.
Something went wrong with that request. Please try again.