From 2b5ea7970655ba51989005ca507c60e74928ce3f Mon Sep 17 00:00:00 2001 From: Dan Barber Date: Thu, 25 Sep 2014 10:33:17 +0100 Subject: [PATCH] First commit. --- .gitignore | 1 + LICENCE.txt | 21 +++++++++++++++++++++ README.md | 19 +++++++++++++++++++ video.css | 8 ++++++++ video.css.sass | 8 ++++++++ video_tag.rb | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 103 insertions(+) create mode 100644 .gitignore create mode 100644 LICENCE.txt create mode 100644 README.md create mode 100644 video.css create mode 100644 video.css.sass create mode 100644 video_tag.rb diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5df1b9b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.sass-cache diff --git a/LICENCE.txt b/LICENCE.txt new file mode 100644 index 0000000..19a121d --- /dev/null +++ b/LICENCE.txt @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2014 Dan Barber + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..11f6a77 --- /dev/null +++ b/README.md @@ -0,0 +1,19 @@ +Video Tag + +**Easy responsive videos for Jekyll.** + +Jekyll Video Tag is a liquid tag that adds responsive videos to your [Jekyll](http://jekyllrb.com) static site. + +### Usage + +Add the CSS or Sass file to your site. + +```liquid +{% video {embed-url} width={width} height={height} %} +``` + +### Example + +```liquid +{% video //www.youtube.com/embed/7eP4pw03PCg width=560 height=315 %} +``` diff --git a/video.css b/video.css new file mode 100644 index 0000000..4c3bfa9 --- /dev/null +++ b/video.css @@ -0,0 +1,8 @@ +.video-container { + position: relative; + width: 100%; + height: 0; } + .video-container iframe { + position: absolute; + width: 100%; + height: 100%; } diff --git a/video.css.sass b/video.css.sass new file mode 100644 index 0000000..d0bd09d --- /dev/null +++ b/video.css.sass @@ -0,0 +1,8 @@ +.video-container + position: relative + width: 100% + height: 0 + iframe + position: absolute + width: 100% + height: 100% diff --git a/video_tag.rb b/video_tag.rb new file mode 100644 index 0000000..7814e84 --- /dev/null +++ b/video_tag.rb @@ -0,0 +1,46 @@ +# Plugin for rendering responsive video in Jekyll +# Written by: Dan Barber +# Version: 0.0.1 +# =============================================== +# Usage: +# ------ +# {% video {embed-url} width={width} height={height} %} +# +# The embed URL is the one that is referenced by the iframe in the video embed code. +# +# Example: +# {% video //www.youtube.com/embed/7eP4pw03PCg width=560 height=315 %} + +module Jekyll + class VideoTag < Liquid::Tag + def initialize(tag_name, input, tokens) + super + @url = input.slice!(/[^ ]+/) + @options = parse_options(input) + end + + def render(context) + %(
#{video_iframe(@url)}
) + end + + private + + def video_iframe(url) + %(