octopress-video-tag 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 645e8f6db5255d2289f6866db44bf4c2d40d597f
4
+ data.tar.gz: 8ccc182de25e86c1ac7d5e9f0489b9fc010403c3
5
+ SHA512:
6
+ metadata.gz: 6a058f9063a78d5da710858e3dd75bbb6b7aad577ae73f913a0c995827a18be8ced928f12651e64043f56fcbc9fc61750aaf49498f5ad2dcce93be7f05be8eae
7
+ data.tar.gz: cd7eb9f28978b8014e6e654c626d33c75f2b6fe7ec49c6501f60e764350c217dca11d7b613aa5779645807694363dad236e36b72240fc12d35669e8cdf6b51b0
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Brandon Mathis
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,91 @@
1
+ # Octopress Video Tag
2
+
3
+ Easy HTML5 video tags for Jekyll sites.
4
+
5
+ [![Build Status](http://img.shields.io/travis/octopress/video-tag.svg)](https://travis-ci.org/octopress/video-tag)
6
+ [![Gem Version](http://img.shields.io/gem/v/octopress-video-tag.svg)](https://rubygems.org/gems/octopress-video-tag)
7
+ [![License](http://img.shields.io/:license-mit-blue.svg)](http://octopress.mit-license.org)
8
+
9
+ ## Installation
10
+
11
+ ### Using Bundler
12
+
13
+ Add this gem to your site's Gemfile in the `:jekyll_plugins` group:
14
+
15
+ group :jekyll_plugins do
16
+ gem 'octopress-video-tag'
17
+ end
18
+
19
+ Then install the gem with Bundler
20
+
21
+ $ bundle
22
+
23
+ ### Manual Installation
24
+
25
+ $ gem install octopress-video-tag
26
+
27
+ Then add the gem to your Jekyll configuration.
28
+
29
+ gems:
30
+ -octopress-video-tag
31
+
32
+ ## Syntax
33
+
34
+ Creating a proper HTML5 video tag couldn't be simpler.
35
+
36
+ {% video urls [class names] [width height] [preload:auto|metadata|none] %}
37
+
38
+ ### URLs
39
+
40
+ URLs must include a protocol `http` or `https` or begin with a `/`. URLs for videos should point to mp4, ogv, and/or webm. Adding a url to an image will set that image as the video's poster frame.
41
+
42
+ ### Preload
43
+
44
+ Preload has three settings:
45
+
46
+ - `auto` - The Video should start downloading when the page is loaded.
47
+ - `metadata` - Only the videos metadata is downloaded when the page is loaded.
48
+ - `none` - The video will only be downloaded when the viewer clicks.
49
+
50
+ This plugin defaults to preloading `metadata`. This uses minimal bandwidth while still allowing the video to start playing quickly.
51
+
52
+ ### Click to play
53
+
54
+ Each video is embedded with a minuscule bit of javascript which plays videos when they are clicked. If you'd prefer to disable this feature, set `click_to_play_video: false` in your site's configuration.
55
+
56
+ ## Examples:
57
+
58
+ ```
59
+ {% video /videos/clouds.mp4 %}
60
+ {% video featured wide /images/clouds.jpg /videos/clouds.mp4 /videos/clouds.webm /videos/clouds.ogv 1080px 608px preload:auto %}
61
+ ```
62
+
63
+ This would output the following HTML
64
+
65
+ ```html
66
+ <video controls poster='' width='' height='' preload='metadata'
67
+ onclick='(function(el){ if(el.paused) el.play(); else el.pause() })(this)'>
68
+ <source src='/videos/clouds.mp4' type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"'>
69
+ </video>
70
+
71
+ <video class='featured wide' controls poster='/images/clouds.jpg' width='1080px' height='608px' preload='auto'
72
+ onclick='(function(el){ if(el.paused) el.play(); else el.pause() })(this)'>
73
+ <source src='/videos/clouds.mp4' type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"'>
74
+ <source src='/videos/clouds.webm' type='video/webm; codecs="vp8, vorbis"'>
75
+ <source src='/videos/clouds.ogv' type='video/ogg; codecs="theora, vorbis"'>
76
+ </video>
77
+ ```
78
+
79
+ <video controls poster='http://s3.imathis.com/video/clouds.jpg' width='' height='' preload='metadata' onclick='(function(el){ if(el.paused) el.play(); else el.pause() })(this)'>
80
+ <source src='http://s3.imathis.com/video/clouds.mp4' type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"'>
81
+ <source src='http://s3.imathis.com/video/clouds.webm' type='video/webm; codecs="vp8, vorbis"'>
82
+ <source src='http://s3.imathis.com/video/clouds.ogv' type='video/ogg; codecs="theora, vorbis"'>
83
+ </video>
84
+
85
+ ## Contributing
86
+
87
+ 1. Fork it ( https://github.com/octopress/video-tag/fork )
88
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
89
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
90
+ 4. Push to the branch (`git push origin my-new-feature`)
91
+ 5. Create a new Pull Request
@@ -0,0 +1,7 @@
1
+ module Octopress
2
+ module Tags
3
+ module VideoTag
4
+ VERSION = "1.0.0"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,81 @@
1
+ require "octopress-video-tag/version"
2
+
3
+ module Octopress
4
+ module Tags
5
+ module VideoTag
6
+ class Tag < Liquid::Tag
7
+ @video = nil
8
+ @poster = ''
9
+ @height = ''
10
+ @width = ''
11
+ Preload = /(:?preload: *(:?\S+))/i
12
+ Size = /\s(auto|\d\S+)\s?(auto|\d\S+)?/i
13
+ URLs = /((https?:\/)?\/\S+)/i
14
+
15
+ def initialize(tag_name, tag_markup, tokens)
16
+ @markup = tag_markup
17
+ markup = tag_markup.dup
18
+
19
+ @preload = markup.scan(Preload).flatten.compact.last || "metadata"
20
+ markup.sub!(Preload, '')
21
+
22
+ @sizes = markup.scan(Size).flatten.compact
23
+ markup.sub!(Size, '')
24
+
25
+ urls = markup.scan(URLs).map{ |m| m.first }
26
+ @videos = urls.select {|u| u.match /mp4|ogv|webm/i}
27
+ @poster = urls.select {|u| u.match /jpe?g|png|gif/i}.first
28
+ markup.gsub!(URLs, '')
29
+
30
+ if !(@classes = markup.strip).empty?
31
+ @classes = "class='#{@classes}' "
32
+ end
33
+
34
+ super
35
+ end
36
+
37
+ def render(context)
38
+
39
+ output = super
40
+ type = {
41
+ 'mp4' => "type='video/mp4; codecs=\"avc1.42E01E, mp4a.40.2\"'",
42
+ 'ogv' => "type='video/ogg; codecs=\"theora, vorbis\"'",
43
+ 'webm' => "type='video/webm; codecs=\"vp8, vorbis\"'"
44
+ }
45
+
46
+ if context.environments.first['site']['click_to_play_video'] != false
47
+ clickToPlay = "onclick='(function(el){ if(el.paused) el.play(); else el.pause() })(this)'"
48
+ else
49
+ clickToPlay = ''
50
+ end
51
+
52
+ if @videos && @videos.size > 0
53
+ video = "<video #{@classes}controls poster='#{@poster}' width='#{@sizes[0]}' height='#{@sizes[1]}' preload='#{@preload}' #{clickToPlay}>"
54
+ @videos.each do |v|
55
+ t = v.match(/([^\.]+)$/)[1]
56
+ video += "<source src='#{v}' #{type[t]}>"
57
+ end
58
+ video += "</video>"
59
+ else
60
+ raise "No video mp4, ogv, or webm urls found in {% video #{@markup} %}"
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
67
+
68
+ Liquid::Template.register_tag('video', Octopress::Tags::VideoTag::Tag)
69
+
70
+
71
+ if defined? Octopress::Docs
72
+ Octopress::Docs.add({
73
+ name: "Octopress Video Tag",
74
+ gem: "octopress-video-tag",
75
+ version: Octopress::Tags::VideoTag::VERSION,
76
+ description: "Easy HTML5 video tags for Jekyll sites",
77
+ path: File.expand_path(File.join(File.dirname(__FILE__), "../")),
78
+ source_url: "https://github.com/octopress/video-tag",
79
+ })
80
+ end
81
+
metadata ADDED
@@ -0,0 +1,118 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: octopress-video-tag
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Brandon Mathis
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: jekyll
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.7'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: clash
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry-byebug
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Easy HTML5 video tags for Jekyll sites.
84
+ email:
85
+ - brandon@imathis.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - LICENSE.txt
91
+ - README.md
92
+ - lib/octopress-video-tag.rb
93
+ - lib/octopress-video-tag/version.rb
94
+ homepage: https://github.com/octopress/video-tag
95
+ licenses:
96
+ - MIT
97
+ metadata: {}
98
+ post_install_message:
99
+ rdoc_options: []
100
+ require_paths:
101
+ - lib
102
+ required_ruby_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ required_rubygems_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ requirements: []
113
+ rubyforge_project:
114
+ rubygems_version: 2.2.2
115
+ signing_key:
116
+ specification_version: 4
117
+ summary: Easy HTML5 video tags for Jekyll sites.
118
+ test_files: []