jekyll_oembed 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7fa364245b94c1bfdc9b6a0e76c7a65940958f4f
4
+ data.tar.gz: 6efbe140f97069e2aa214ca58bb4e2f139e5c4be
5
+ SHA512:
6
+ metadata.gz: ddf5ffd28cf060b7aa80691921d3dbdd2790240fdd88929c0f82f93572dc905af8e5600130ae6cd318604ad5480b93384d077c57dc39f845b74039127745de9d
7
+ data.tar.gz: 1b8bc17a50c862a947e928c04eaf00ac87a85704d4ef79c7aaee398d53a0b248c8c2e2e0a62e0ba17335277ccdd4aba0494b4449952f3d68b86abb2c67ebcc9a
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ Gemfile.lock
2
+ pkg/
3
+ *.gem
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE.md ADDED
@@ -0,0 +1,32 @@
1
+ As a work of the United States Government, this project is in the
2
+ public domain within the United States.
3
+
4
+ Additionally, we waive copyright and related rights in the work
5
+ worldwide through the CC0 1.0 Universal public domain dedication.
6
+
7
+ ## CC0 1.0 Universal Summary
8
+
9
+ This is a human-readable summary of the
10
+ [Legal Code (read the full text)](https://creativecommons.org/publicdomain/zero/1.0/legalcode).
11
+
12
+ ### No Copyright
13
+
14
+ The person who associated a work with this deed has dedicated the work to
15
+ the public domain by waiving all of his or her rights to the work worldwide
16
+ under copyright law, including all related and neighboring rights, to the
17
+ extent allowed by law.
18
+
19
+ You can copy, modify, distribute and perform the work, even for commercial
20
+ purposes, all without asking permission.
21
+
22
+ ### Other Information
23
+
24
+ In no way are the patent or trademark rights of any person affected by CC0,
25
+ nor are the rights that other persons may have in the work or in how the
26
+ work is used, such as publicity or privacy rights.
27
+
28
+ Unless expressly stated otherwise, the person who associated a work with
29
+ this deed makes no warranties about the work, and disclaims liability for
30
+ all uses of the work, to the fullest extent permitted by applicable law.
31
+ When using or citing the work, you should not imply endorsement by the
32
+ author or the affirmer.
data/README.md ADDED
@@ -0,0 +1,63 @@
1
+ # jekyll-oembed
2
+
3
+ oEmbed plugin for jekyll that creates an `oembed` liquid tag
4
+
5
+ ## Installation
6
+
7
+ ### With bundler
8
+ Within your project's `Gemfile`, add the following within the `:jekyll_plugins` group:
9
+
10
+ ```ruby
11
+ # Gemfile
12
+ group :jekyll_plugins do
13
+ gem 'jekyll_oembed'
14
+ end
15
+ ```
16
+
17
+ ### Standalone
18
+
19
+ Add [the code](lib/jekyll_oembed.rb) directly to your `_plugins` directory
20
+ Create the following plugin in your projects _plugins directory.
21
+
22
+ If you do this, you will also need to add [`ruby-oembed`](https://github.com/ruby-oembed/ruby-oembed) to your `Gemfile`
23
+
24
+ ```ruby
25
+ # Gemfile
26
+ gem "ruby-oembed"
27
+ ```
28
+
29
+ ## Usage
30
+
31
+ To use an oembed, simply do the following. Pass the embedded url as plain text, not wrapped in quotes like a string.
32
+
33
+ ```liquid
34
+ # Correct
35
+ {% oembed https://www.youtube.com/watch?v=GPUaUgjbbsA %}
36
+
37
+ # Incorrect
38
+ {% oembed "https://www.youtube.com/watch?v=GPUaUgjbbsA" %}
39
+ ```
40
+
41
+ `jekyll_oembed` does not support customizing width, height, or adding any attributes directly to the embedded HTML.
42
+
43
+
44
+ ## Attribution
45
+
46
+ Thank you to:
47
+ - @vanto for the [plugin code](https://gist.github.com/vanto/1455726) that powers the gem
48
+ - @stereobooster for creating a [different version](https://github.com/stereobooster/jekyll_oembed) of the gem
49
+
50
+ This will automatically require all of the gems specified in your Gemfile.
51
+
52
+ ## Resources
53
+
54
+ - [oEmbed providers](http://www.oembed.com/#section7.1)
55
+ - [`ruby-oembed`](https://github.com/ruby-oembed/ruby-oembed)
56
+
57
+
58
+ ## Contributing
59
+ 1. Fork it
60
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
61
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
62
+ 4. Push to the branch (`git push origin my-new-feature`)
63
+ 5. Create new Pull Request
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |gem|
6
+ gem.name = "jekyll_oembed"
7
+ gem.version = '0.0.2'
8
+ gem.authors = ["18F"]
9
+ gem.license = 'Nonstandard'
10
+ gem.email = ["brian.hedberg@gsa.com"]
11
+ gem.description = %q{Provides an oembed liquid tag for Jekyll}
12
+ gem.summary = %q{A gem that creates a liquid 'oembed' tag for use in Jekyll sites}
13
+ gem.homepage = "https://github.com/18F/jekyll-oembed"
14
+ gem.files = `git ls-files`.split($/)
15
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
16
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
17
+ gem.require_paths = ["lib"]
18
+
19
+ gem.add_dependency "jekyll", '~> 3'
20
+ gem.add_dependency "ruby-oembed", '~> 0'
21
+ end
@@ -0,0 +1,50 @@
1
+ ##
2
+ # OEmbed Liquid Tag for Jekyll
3
+ # - requires https://github.com/judofyr/ruby-oembed/
4
+ #
5
+ # Copyright 2011 Tammo van Lessen
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+ ##
19
+
20
+ require 'oembed'
21
+
22
+ # register all default OEmbed providers
23
+ ::OEmbed::Providers.register_all()
24
+ # since register_all does not register all default providers, we need to do this here. See https://github.com/judofyr/ruby-oembed/issues/18
25
+ ::OEmbed::Providers.register(::OEmbed::Providers::Instagram, ::OEmbed::Providers::Slideshare, ::OEmbed::Providers::Yfrog, ::OEmbed::Providers::MlgTv)
26
+ ::OEmbed::Providers.register_fallback(::OEmbed::ProviderDiscovery, ::OEmbed::Providers::Embedly, ::OEmbed::Providers::OohEmbed)
27
+
28
+
29
+ module Jekyll
30
+ class OEmbedPlugin < Liquid::Tag
31
+
32
+ def initialize(tag_name, text, tokens)
33
+ super
34
+ @text = text
35
+ end
36
+
37
+ def render(context)
38
+ # pipe param through liquid to make additional replacements possible
39
+ url = Liquid::Template.parse(@text).render context
40
+ url = url.strip! || url.strip
41
+
42
+ # oembed look up
43
+ result = ::OEmbed::Providers.get(url)
44
+
45
+ "<div class=\"embed-container #{result.fields['type']} #{result.fields['provider']}\">#{result.html}</div>"
46
+ end
47
+ end
48
+ end
49
+
50
+ Liquid::Template.register_tag('oembed', Jekyll::OEmbedPlugin)
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll_oembed
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - 18F
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-02-23 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: '3'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: ruby-oembed
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Provides an oembed liquid tag for Jekyll
42
+ email:
43
+ - brian.hedberg@gsa.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - LICENSE.md
51
+ - README.md
52
+ - jekyll_oembed.gemspec
53
+ - lib/jekyll_oembed.rb
54
+ homepage: https://github.com/18F/jekyll-oembed
55
+ licenses:
56
+ - Nonstandard
57
+ metadata: {}
58
+ post_install_message:
59
+ rdoc_options: []
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ requirements: []
73
+ rubyforge_project:
74
+ rubygems_version: 2.6.7
75
+ signing_key:
76
+ specification_version: 4
77
+ summary: A gem that creates a liquid 'oembed' tag for use in Jekyll sites
78
+ test_files: []