forked from dejan/auto_html
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Derrick Camerino
committed
Nov 8, 2010
1 parent
5b3f2d8
commit 8c3663a
Showing
4 changed files
with
46 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
AutoHtml.add_filter(:metacafe).with(:width => 440, :height => 272, :show_stats => false, :autoplay => false) do |text, options| | ||
text.gsub(/http:\/\/www\.metacafe\.com\/watch\/([A-Za-z0-9._%-]*)\/([A-Za-z0-9._%-]*)(\/)?/) do | ||
metacafe_id = $1 | ||
metacafe_slug = $2 | ||
width = options[:width] | ||
height = options[:height] | ||
show_stats = options[:show_stats] ? "showStats=yes" : "showStats=no" | ||
autoplay = options[:autoplay] ? "autoPlay=yes" : "autoPlay=no" | ||
flash_vars = [show_stats, autoplay].join("|") | ||
|
||
%{<div style="background:#000000;width:#{width}px;height:#{height}px"><embed flashVars="playerVars=#{flash_vars}" src="http://www.metacafe.com/fplayer/#{metacafe_id}/#{metacafe_slug}.swf" width="#{width}" height="#{height}" wmode="transparent" allowFullScreen="true" allowScriptAccess="always" name="Metacafe_#{metacafe_id}" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed></div>} | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
require File.dirname(__FILE__) + '/../unit_test_helper' | ||
|
||
class MetaCafeTest < Test::Unit::TestCase | ||
|
||
def test_transform | ||
result = auto_html("http://www.metacafe.com/watch/5440707/exclusive_tron_evolution_dev_diary_the_art_design") { metacafe } | ||
assert_equal '<div style="background:#000000;width:440px;height:272px"><embed flashVars="playerVars=showStats=no|autoPlay=no" src="http://www.metacafe.com/fplayer/5440707/exclusive_tron_evolution_dev_diary_the_art_design.swf" width="440" height="272" wmode="transparent" allowFullScreen="true" allowScriptAccess="always" name="Metacafe_5440707" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed></div>', result | ||
end | ||
|
||
def test_transform_with_dimensions | ||
result = auto_html("http://www.metacafe.com/watch/5440707/exclusive_tron_evolution_dev_diary_the_art_design") { metacafe(:width => 500, :height => 300) } | ||
assert_equal '<div style="background:#000000;width:500px;height:300px"><embed flashVars="playerVars=showStats=no|autoPlay=no" src="http://www.metacafe.com/fplayer/5440707/exclusive_tron_evolution_dev_diary_the_art_design.swf" width="500" height="300" wmode="transparent" allowFullScreen="true" allowScriptAccess="always" name="Metacafe_5440707" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed></div>', result | ||
end | ||
|
||
def test_transform_with_show_stats | ||
result = auto_html("http://www.metacafe.com/watch/5440707/exclusive_tron_evolution_dev_diary_the_art_design") { metacafe(:width => 500, :height => 300, :show_stats => true) } | ||
assert_equal '<div style="background:#000000;width:500px;height:300px"><embed flashVars="playerVars=showStats=yes|autoPlay=no" src="http://www.metacafe.com/fplayer/5440707/exclusive_tron_evolution_dev_diary_the_art_design.swf" width="500" height="300" wmode="transparent" allowFullScreen="true" allowScriptAccess="always" name="Metacafe_5440707" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed></div>', result | ||
end | ||
|
||
def test_transform_with_autoplay | ||
result = auto_html("http://www.metacafe.com/watch/5440707/exclusive_tron_evolution_dev_diary_the_art_design") { metacafe(:width => 500, :height => 300, :autoplay => true) } | ||
assert_equal '<div style="background:#000000;width:500px;height:300px"><embed flashVars="playerVars=showStats=no|autoPlay=yes" src="http://www.metacafe.com/fplayer/5440707/exclusive_tron_evolution_dev_diary_the_art_design.swf" width="500" height="300" wmode="transparent" allowFullScreen="true" allowScriptAccess="always" name="Metacafe_5440707" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed></div>', result | ||
end | ||
|
||
def test_transform_with_options | ||
result = auto_html("http://www.metacafe.com/watch/5440707/exclusive_tron_evolution_dev_diary_the_art_design") { metacafe(:width => 500, :height => 300, :show_stats => true, :autoplay => true) } | ||
assert_equal '<div style="background:#000000;width:500px;height:300px"><embed flashVars="playerVars=showStats=yes|autoPlay=yes" src="http://www.metacafe.com/fplayer/5440707/exclusive_tron_evolution_dev_diary_the_art_design.swf" width="500" height="300" wmode="transparent" allowFullScreen="true" allowScriptAccess="always" name="Metacafe_5440707" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed></div>', result | ||
end | ||
end |