aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorBrandon Mathis <brandon@imathis.com>2013-01-12 19:23:34 -0600
committerBrandon Mathis <brandon@imathis.com>2013-01-12 19:24:10 -0600
commit8bf09b178d513a264b900186d20f5c0b928c7287 (patch)
tree81ed9f32487a3b324ab58fa6be6b3aeec870af3b /plugins
parentcd6926e41bdd9b7170518648dae551b605ffbe73 (diff)
downloadmy_new_personal_website-8bf09b178d513a264b900186d20f5c0b928c7287.tar.xz
my_new_personal_website-8bf09b178d513a264b900186d20f5c0b928c7287.zip
Video tag plugin now supports mp4,ogv,webm formats, closes #931
Diffstat (limited to '')
-rw-r--r--plugins/video_tag.rb25
1 files changed, 17 insertions, 8 deletions
diff --git a/plugins/video_tag.rb b/plugins/video_tag.rb
index 6b93be82..c6e67b77 100644
--- a/plugins/video_tag.rb
+++ b/plugins/video_tag.rb
@@ -22,22 +22,31 @@ module Jekyll
@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
+ if markup =~ /(https?:\S+)(\s+(https?:\S+))?(\s+(https?:\S+))?(\s+(\d+)\s(\d+))?(\s+(https?:\S+))?/i
+ @video = [$1, $3, $5].compact
+ @width = $7
+ @height = $8
+ @poster = $10
end
super
end
def render(context)
output = super
- if @video
+ type = {
+ 'mp4' => "type='video/mp4; codecs=\"avc1.42E01E, mp4a.40.2\"'",
+ 'ogv' => "type='video/ogg; codecs=theora, vorbis'",
+ 'webm' => "type='video/webm; codecs=vp8, vorbis'"
+ }
+ if @video.size > 0
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>"
+ @video.each do |v|
+ t = v.match(/([^\.]+)$/)[1]
+ video += "<source src='#{v}' #{type[t]}>"
+ end
+ video += "</video>"
else
- "Error processing input, expected syntax: {% video url/to/video [width height] [url/to/poster] %}"
+ "Error processing input, expected syntax: {% video url/to/video [url/to/video] [url/to/video] [width height] [url/to/poster] %}"
end
end
end