Skip to content

Instantly share code, notes, and snippets.

@tabletick
Created September 3, 2012 11:52
Show Gist options
  • Save tabletick/3608790 to your computer and use it in GitHub Desktop.
Save tabletick/3608790 to your computer and use it in GitHub Desktop.
Octopress Plugin for Embedding flv files into the blog
# Title: FLV tag for Jekyll
# Authors: Devin Weaver, Daniel Roos (FLV changes)
# Description: Allows flv tag to place videos from flc files embedded in the post.
#
#
# Syntax {% flv videourl height width %}
#
# Examples:
# {% flv http://www.example.com/video.flv 480 320 %}
#
# Output:
# <p/>
# <center>
# <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" width="480" height="320">
# <param name="allowfullscreen" value="true" />
# <param name="movie" value="http://www.example.com/player.swf" />
# <param name="flashvars" value="file=http://www.example.com/video.flv" />
# <embed width="480" height="320" allowfullscreen="true" type="application/x-shockwave-flash" src="http://www.example.com/player.swf" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="file=http://www.example.com/video.flv" />
# </object>
# </center>
# </p>
require 'digest/md5'
module Jekyll
class FlvTag < Liquid::Tag
def initialize(tag_name, markup, tokens)
# if /(?<flvurl>\S+)?(?:\s+(?<title>.+))?/i =~ markup
if /(?<flvurl>\S+)?(?:\s+(?<flvwidth>\d+))?(?:\s+(?<flvheight>\d+))?/i =~ markup
@flvurl = flvurl
@flvwidth = flvwidth
@flvheight = flvheight
end
super
end
def render(context)
if @flvurl
"<p/>
<center>
<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0\" width=\"#{@flvwidth}\" height=\"#{@flvheight}\">
<param name=\allowfullscreen\" value=\"true\" />
<param name=\"movie\" value=\"http://www.myurl.com/player.swf\" />
<param name=\"flashvars\" value=\"file=#{@flvurl}\" />
<embed width=\"#{@flvwidth}\" height=\"#{@flvheight}\" allowfullscreen=\"true\" type=\"application/x-shockwave-flash\" src=\"http://www.myurl.com/player.swf\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" flashvars=\"file=#{@flvurl}\" />
</object>
</center>
<p/>"
else
"Error processing input, expected syntax: {% flv videourl height width %}"
end
end
end
end
Liquid::Template.register_tag('flv', Jekyll::FlvTag)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment