Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
beamercola committed Nov 12, 2008
0 parents commit 9e61607
Show file tree
Hide file tree
Showing 13 changed files with 183 additions and 0 deletions.
20 changes: 20 additions & 0 deletions MIT-LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Copyright (c) 2008 [name of plugin creator]

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.
24 changes: 24 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
VideoFu
=======

Converts a URL into an embedded video object. (http://www.youtube.com/watch?v=5pFv8CAniYQ)

Currently works with: YouTube, KyteTV, Vimeo


Example
=======

<%= video_fu "http://www.youtube.com/watch?v=5pFv8CAniYQ" %>

Outputs:
<object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/5pFv8CAniYQ&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><embed src="http://www.youtube.com/v/5pFv8CAniYQ&hl=en&fs=1" type="application/x-shockwave-flash" allowfullscreen="true" width="425" height="344"></embed></object>


<%= video_fu "http://vimeo.com/2040753" %>

Outputs:
<object width="400" height="300"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=2040753&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=2040753&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="300"></embed></object>


Copyright (c) 2008 Beamer W., released under the MIT license
22 changes: 22 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'

desc 'Default: run unit tests.'
task :default => :test

desc 'Test the video_fu plugin.'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.pattern = 'test/**/*_test.rb'
t.verbose = true
end

desc 'Generate documentation for the video_fu plugin.'
Rake::RDocTask.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'VideoFu'
rdoc.options << '--line-numbers' << '--inline-source'
rdoc.rdoc_files.include('README')
rdoc.rdoc_files.include('lib/**/*.rb')
end
5 changes: 5 additions & 0 deletions init.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require "video_fu"
require "kyte"
require "youtube"
require "vimeo"
require "view_helpers"
1 change: 1 addition & 0 deletions install.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Install hook code here
21 changes: 21 additions & 0 deletions lib/kyte.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
class VideoFu::Kyte
attr_accessor :id, :channel
EMBED_TEMPLATE = %Q|<embed type="application/x-shockwave-flash" allowScriptAccess="always" allowFullScreen="true" style="display:block;margin:0" width="425" height="445" src="http://www.kyte.tv/flash.swf?v=2&uri=channels/107342/243203" flashVars="uri=channels/{channel}/{id}&appKey=MarbachViewerEmbedded"></embed><embed type="application/x-shockwave-flash" allowScriptAccess="always" style="display:block;margin:0"width="425" height="20" src="http://media01.kyte.tv/images/updatenotice.swf" flashvars="requiredversion=9.0.28" wmode="transparent"></embed>|

def initialize(url)
self.extract_params(url)
end


def extract_params(url)
parsed_url = /.*\/ch\/([0-9]*).*\/([0-9]*).*/.match(url)
self.id, self.channel = parsed_url[2], parsed_url[1]
return self
end


def to_s
EMBED_TEMPLATE.gsub("{channel}", self.channel).gsub("{id}", self.id)
end

end
24 changes: 24 additions & 0 deletions lib/video_fu.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
class VideoFu
attr_accessor :url

def initialize(url)
self.url = url
end


def source
/http:\/\/(.*?)\/.*?/.match(self.url)[1].to_s.gsub("www.","")
end


def klass
case self.source
when "kyte.tv" : VideoFu::Kyte.new(self.url)
when "youtube.com" : VideoFu::YouTube.new(self.url)
when "vimeo.com" : VideoFu::Vimeo.new(self.url)
else
nil
end
end

end
11 changes: 11 additions & 0 deletions lib/view_helpers.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module ActionView
module Helpers
module TagHelper

def video_fu(url, options={})
VideoFu.new(url).klass.to_s
end

end
end
end
21 changes: 21 additions & 0 deletions lib/vimeo.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
class VideoFu::Vimeo
attr_accessor :id
EMBED_TEMPLATE = %Q|<object width="400" height="300"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id={id}&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id={id}&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="300"></embed></object>|

def initialize(url)
self.extract_params(url)
end


def extract_params(url)
parsed_url = /.com\/([0-9]*)/.match(url)
self.id = parsed_url[1]
return self
end


def to_s
EMBED_TEMPLATE.gsub("{id}", self.id)
end

end
21 changes: 21 additions & 0 deletions lib/youtube.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
class VideoFu::YouTube
attr_accessor :id
EMBED_TEMPLATE = %Q|<object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/{id}&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><embed src="http://www.youtube.com/v/{id}&hl=en&fs=1" type="application/x-shockwave-flash" allowfullscreen="true" width="425" height="344"></embed></object>|

def initialize(url)
self.extract_params(url)
end


def extract_params(url)
parsed_url = /v=([a-zA-Z0-9]*)/.match(url)
self.id = parsed_url[1]
return self
end


def to_s
EMBED_TEMPLATE.gsub("{id}", self.id)
end

end
4 changes: 4 additions & 0 deletions tasks/video_fu_tasks.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# desc "Explaining what the task does"
# task :video_fu do
# # Task goes here
# end
8 changes: 8 additions & 0 deletions test/video_fu_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
require 'test/unit'

class VideoFuTest < Test::Unit::TestCase
# Replace this with your real tests.
def test_this_plugin
flunk
end
end
1 change: 1 addition & 0 deletions uninstall.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Uninstall hook code here

0 comments on commit 9e61607

Please sign in to comment.