This repository was archived by the owner on Sep 24, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbackupx
More file actions
63 lines (55 loc) · 2.41 KB
/
Copy pathbackupx
File metadata and controls
63 lines (55 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# 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 VideoTagMe < 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>"
video = <<GROCERY_LIST
<video width="#{@width}" height="#{@height}" poster="/tv/images/ot-poster.jpg" controls="controls" preload="none">
<!-- MP4 for Safari, IE9, iPhone, iPad, Android, and Windows Phone 7 -->
<source type="video/mp4" src="#{@video}" /><!-- WebM/VP8 for Firefox4, Opera, and Chrome --><source type="video/webm" src="#{@video}" />
<!-- Ogg/Vorbis for older Firefox and Opera versions -->
<source type="video/ogg" src="#{@video}" />
<!-- Flash fallback for non-HTML5 browsers without JavaScript -->
<object width="#{@width}" height="#{@height}" type="application/x-shockwave-flash" data="/tv/javascripts/mediaelement/flashmediaelement.swf"><param name="movie" value="/tv/javascripts/mediaelement/flashmediaelement.swf" /><param name="flashvars" value="controls=true&file=#{@video}" /><!-- Image as a last resort --><img src="/images/ot-poster.jpg" width="#{@width}" height="#{@height}" title="No video playback capabilities" /></object></video>
<script>
// using jQuery
jQuery('video,audio').mediaelementplayer(/* Options */);
</script>
GROCERY_LIST
else
"Error processing input, expected syntax: {% video url/to/video [width height] [url/t
o/poster] %}"
end
end
end
end
Liquid::Template.register_tag('video_me', Jekyll::VideoTagMe)