jekyll-youtube 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 11ab058f59f7e922bb996948f61a70e50b36e2a5
4
+ data.tar.gz: 56c8c3dd7b401f07f6cc5dcc4babfb30e893a649
5
+ SHA512:
6
+ metadata.gz: eb33d932398173039a4a33b0e531c4e40728207f25838eecaa36b5703f829ba48ee2fa64da5165469aa07ac8db1fbb9e414b2d71f3eab62db373e48bf7a596eb
7
+ data.tar.gz: 725915ac1da5dbc53ff80ccc229f9e8b41be05504a633c3efd5bef63ce952fb2f728352ca2c931e01c192c5198b4f8903ec7265b9441ddb12a8b243f22beefd2
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ .DS_Store
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in jekyllcontentful.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Dommmel
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,50 @@
1
+ # Jekyll Youtube
2
+
3
+ This Jekyll pluging provides a tag that takes a Youtube URL and generates a (responsive) html snippet to embed the video into your site.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your Gemfile:
8
+
9
+ ```ruby
10
+ group :jekyll_plugins do
11
+ gem "jekyll-youtube"
12
+ end
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Alternatively install the gem yourself as:
20
+
21
+ $ gem install jekyll-youtube
22
+
23
+ and put this in your ``_config.yml``
24
+
25
+ ```yaml
26
+ gems: [jekyll-youtube]
27
+ # This will require each of these gems automatically.
28
+ ```
29
+
30
+ ## Usage
31
+
32
+ ```
33
+ {% youtube "https://www.youtube.com/watch?v=ho8-vK0L1_8" %}
34
+ ```
35
+ or using variables/front matter
36
+
37
+ ```
38
+ {% youtube page.youtubeurl %}
39
+ ```
40
+
41
+ ## Result
42
+
43
+ By default the plugin will output the following code
44
+
45
+
46
+ ```markup
47
+ <style>.embed-container { position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden; max-width: 100%; } .embed-container iframe, .embed-container object, .embed-container embed { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }</style><div class='embed-container'> <iframe title="YouTube video player" width="640" height="390" src="http://www.youtube.com/embed/ho8-vK0L1_8" frameborder="0" allowfullscreen></iframe></div>
48
+ ```
49
+
50
+ You can specify your own snippet by creating a partial ``_includes/youtube.html``. Inside that partial the Youtube ID is available as ``{{ youtube_id }}``.
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'jekyll-youtube/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "jekyll-youtube"
8
+ spec.version = Jekyll::Youtube::VERSION
9
+ spec.authors = ["Dommmel"]
10
+ spec.email = ["dommmel@gmail.com"]
11
+
12
+ spec.summary = %q{jekyll plugin to generate html snippets for embedding Youtube videos}
13
+ spec.description = %q{jekyll plugin to generate html snippets for embedding Youtube videos}
14
+ spec.homepage = "https://github.com/dommmel/jekyll-youtube"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_dependency 'jekyll'
21
+ spec.add_development_dependency "bundler", "~> 1.10"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ end
@@ -0,0 +1,31 @@
1
+ require "jekyll"
2
+ require "jekyll-youtube/version"
3
+ class YouTubeEmbed < Liquid::Tag
4
+
5
+ def initialize(tagName, content, tokens)
6
+ super
7
+ @content = content
8
+ end
9
+
10
+ def render(context)
11
+ youtube_url = "#{context[@content.strip]}"
12
+ if youtube_url[/youtu\.be\/([^\?]*)/]
13
+ @youtube_id = $1
14
+ else
15
+ # Regex from # http://stackoverflow.com/questions/3452546/javascript-regex-how-to-get-youtube-video-id-from-url/4811367#4811367
16
+ youtube_url[/^.*((v\/)|(embed\/)|(watch\?))\??v?=?([^\&\?]*).*/]
17
+ @youtube_id = $5
18
+ end
19
+
20
+ tmpl_path = File.join Dir.pwd, "_includes", "youtube.html"
21
+ if File.exist?(tmpl_path)
22
+ tmpl = File.read tmpl_path
23
+ site = context.registers[:site]
24
+ tmpl = (Liquid::Template.parse tmpl).render site.site_payload.merge!({"youtube_id" => @youtube_id})
25
+ else
26
+ %Q{<style>.embed-container { position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden; max-width: 100%; } .embed-container iframe, .embed-container object, .embed-container embed { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }</style><div class='embed-container'> <iframe title="YouTube video player" width="640" height="390" src="http://www.youtube.com/embed/#{ @youtube_id }" frameborder="0" allowfullscreen></iframe></div>}
27
+ end
28
+ end
29
+
30
+ Liquid::Template.register_tag "youtube", self
31
+ end
@@ -0,0 +1,5 @@
1
+ module Jekyll
2
+ module Youtube
3
+ VERSION = "0.0.2"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-youtube
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Dommmel
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-08-24 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: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '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.10'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.10'
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
+ description: jekyll plugin to generate html snippets for embedding Youtube videos
56
+ email:
57
+ - dommmel@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - jekyll-youtube.gemspec
68
+ - lib/jekyll-youtube.rb
69
+ - lib/jekyll-youtube/version.rb
70
+ homepage: https://github.com/dommmel/jekyll-youtube
71
+ licenses:
72
+ - MIT
73
+ metadata: {}
74
+ post_install_message:
75
+ rdoc_options: []
76
+ require_paths:
77
+ - lib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ requirements: []
89
+ rubyforge_project:
90
+ rubygems_version: 2.4.5
91
+ signing_key:
92
+ specification_version: 4
93
+ summary: jekyll plugin to generate html snippets for embedding Youtube videos
94
+ test_files: []