aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorBrandon Mathis <brandon@imathis.com>2011-07-23 17:39:49 -0400
committerBrandon Mathis <brandon@imathis.com>2011-07-23 17:41:08 -0400
commitd5aa08d3f3b25195beb9d1a85f972a68cf6c1e11 (patch)
treee1d85794e2b9fb00931dfcf0f05fc2cf84130124 /plugins
parenta80cb12c8c0d5e5106c3698bdcf5338559d09bf3 (diff)
downloadmy_new_personal_website-d5aa08d3f3b25195beb9d1a85f972a68cf6c1e11.tar.xz
my_new_personal_website-d5aa08d3f3b25195beb9d1a85f972a68cf6c1e11.zip
added video tag plugin
Diffstat (limited to 'plugins')
-rw-r--r--plugins/video_tag.rb47
1 files changed, 47 insertions, 0 deletions
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:
+# <video width='720' height='480' preload='none' controls poster='http://site.com/poster-frame.jpg'>
+# <source src='http://site.com/video.mp4' type='video/mp4; codecs=\"avc1.42E01E, mp4a.40.2\"'/>
+# </video>
+#
+
+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 = "<video width='#{@width}' height='#{@height}' preload='none' controls poster='#{@poster}'>"
+ video += "<source src='#{@video}' type='video/mp4; codecs=\"avc1.42E01E, mp4a.40.2\"'/></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)
+