From d5aa08d3f3b25195beb9d1a85f972a68cf6c1e11 Mon Sep 17 00:00:00 2001 From: Brandon Mathis Date: Sat, 23 Jul 2011 17:39:49 -0400 Subject: added video tag plugin --- plugins/video_tag.rb | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 plugins/video_tag.rb (limited to 'plugins') diff --git a/plugins/video_tag.rb b/plugins/video_tag.rb new file mode 100644 index 00000000..6b93be82 --- /dev/null +++ b/plugins/video_tag.rb @@ -0,0 +1,47 @@ +# Title: Simple Video tag for Jekyll +# Author: Brandon Mathis http://brandonmathis.com +# Description: Easily output MPEG4 HTML5 video with a flash backup. +# +# Syntax {% video url/to/video [width height] [url/to/poster] %} +# +# Example: +# {% video http://site.com/video.mp4 720 480 http://site.com/poster-frame.jpg %} +# +# Output: +# +# + +module Jekyll + + class VideoTag < Liquid::Tag + @video = nil + @poster = '' + @height = '' + @width = '' + + def initialize(tag_name, markup, tokens) + if markup =~ /((https?:\/\/|\/)(\S+))(\s+(\d+)\s(\d+))?(\s+(https?:\/\/|\/)(\S+))?/i + @video = $1 + @width = $5 + @height = $6 + @poster = $7 + end + super + end + + def render(context) + output = super + if @video + video = "" + else + "Error processing input, expected syntax: {% video url/to/video [width height] [url/to/poster] %}" + end + end + end +end + +Liquid::Template.register_tag('video', Jekyll::VideoTag) + -- cgit v1.2.1