jekyll-oembed 0.0.1
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.
- data/.gitignore +2 -0
- data/Gemfile +3 -0
- data/Rakefile +1 -0
- data/Readme.md +59 -0
- data/jekyll_oembed.gemspec +24 -0
- data/lib/jekyll_oembed.rb +41 -0
- metadata +90 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/Readme.md
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# oEmbed plugin for jekyll. Simple liquid tag
|
2
|
+
|
3
|
+
## Example
|
4
|
+
```liquid
|
5
|
+
{% oembed http://vimeo.com/2696386 width=960 %}
|
6
|
+
```
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
### Bundler
|
10
|
+
Add this line to your application's `Gemfile`:
|
11
|
+
```ruby
|
12
|
+
gem 'jekyll-oembed'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
```bash
|
17
|
+
$ bundle
|
18
|
+
```
|
19
|
+
|
20
|
+
### Standalone
|
21
|
+
Execute:
|
22
|
+
```bash
|
23
|
+
$ gem install jekyll-oembed
|
24
|
+
```
|
25
|
+
|
26
|
+
## Usage
|
27
|
+
|
28
|
+
### With Bundler (recomended)
|
29
|
+
Create the following plugin in your projects _plugins directory.
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
# _plugins/bundler.rb
|
33
|
+
require "rubygems"
|
34
|
+
require "bundler/setup"
|
35
|
+
Bundler.require(:default)
|
36
|
+
```
|
37
|
+
|
38
|
+
This will automatically require all of the gems specified in your Gemfile.
|
39
|
+
|
40
|
+
### Standalone
|
41
|
+
Create the following plugin in your projects _plugins directory.
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
# _plugins/jekyll-oembed-plugin.rb
|
45
|
+
require 'jekyll-oembed'
|
46
|
+
```
|
47
|
+
## Resources
|
48
|
+
- [oEmbed providers](http://www.oembed.com/#section7.1)
|
49
|
+
|
50
|
+
## TODO
|
51
|
+
- add support of passing API key for embedly
|
52
|
+
- cache results (or not?)
|
53
|
+
|
54
|
+
## Contributing
|
55
|
+
1. Fork it
|
56
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
57
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
58
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
59
|
+
5. Create new Pull Request
|
@@ -0,0 +1,24 @@
|
|
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.1'
|
8
|
+
gem.authors = ["stereobooster"]
|
9
|
+
gem.email = ["stereobooster@gmail.com"]
|
10
|
+
gem.description = %q{Provides an oembed liquid tag for Jekyll}
|
11
|
+
gem.summary = %q{Provides an oembed liquid tag for Jekyll}
|
12
|
+
gem.homepage = "https://github.com/stereobooster/jekyll_oembed"
|
13
|
+
|
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"
|
20
|
+
gem.add_dependency "ruby-oembed", "0.8.8"
|
21
|
+
|
22
|
+
gem.add_development_dependency "rake"
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'oembed'
|
2
|
+
require 'shellwords'
|
3
|
+
|
4
|
+
OEmbed::Providers.register_all
|
5
|
+
|
6
|
+
module Jekyll
|
7
|
+
class OEmbedTag < Liquid::Tag
|
8
|
+
|
9
|
+
def initialize(tag_name, text, tokens)
|
10
|
+
super
|
11
|
+
@text = text
|
12
|
+
end
|
13
|
+
|
14
|
+
def render(context)
|
15
|
+
text = Liquid::Template.parse(@text).render context
|
16
|
+
|
17
|
+
params = text.shellsplit
|
18
|
+
url = params.shift
|
19
|
+
params = Hash[*params.map{|val| val.split('=')}.flatten]
|
20
|
+
|
21
|
+
resource = OEmbed::Providers.get(url, params)
|
22
|
+
html = resource.html
|
23
|
+
|
24
|
+
if url =~ /:\/\/(www.youtube.com|youtu.be)\//
|
25
|
+
%w{width height}.each do |name|
|
26
|
+
if params[name]
|
27
|
+
html.gsub! Regexp.new(name+'="\\d+'), name+'="'+params[name]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# resource.video?, resource.thumbnail_url
|
33
|
+
"<div class='oembed #{resource.type}'>#{html}</div>"
|
34
|
+
rescue OEmbed::NotFound
|
35
|
+
warn "No embeddable content at #{url}"
|
36
|
+
"<a href='#{url}'>#{url}</a>"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
Liquid::Template.register_tag('oembed', Jekyll::OEmbedTag)
|
metadata
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll-oembed
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- stereobooster
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-03-04 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: jekyll
|
16
|
+
requirement: &83054130 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *83054130
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: ruby-oembed
|
27
|
+
requirement: &83053720 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - =
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 0.8.8
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *83053720
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rake
|
38
|
+
requirement: &83053340 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *83053340
|
47
|
+
description: Provides an oembed liquid tag for Jekyll
|
48
|
+
email:
|
49
|
+
- stereobooster@gmail.com
|
50
|
+
executables: []
|
51
|
+
extensions: []
|
52
|
+
extra_rdoc_files: []
|
53
|
+
files:
|
54
|
+
- .gitignore
|
55
|
+
- Gemfile
|
56
|
+
- Rakefile
|
57
|
+
- Readme.md
|
58
|
+
- jekyll_oembed.gemspec
|
59
|
+
- lib/jekyll_oembed.rb
|
60
|
+
homepage: https://github.com/stereobooster/jekyll_oembed
|
61
|
+
licenses: []
|
62
|
+
post_install_message:
|
63
|
+
rdoc_options: []
|
64
|
+
require_paths:
|
65
|
+
- lib
|
66
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
68
|
+
requirements:
|
69
|
+
- - ! '>='
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
segments:
|
73
|
+
- 0
|
74
|
+
hash: 293360481
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
+
none: false
|
77
|
+
requirements:
|
78
|
+
- - ! '>='
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
segments:
|
82
|
+
- 0
|
83
|
+
hash: 293360481
|
84
|
+
requirements: []
|
85
|
+
rubyforge_project:
|
86
|
+
rubygems_version: 1.8.11
|
87
|
+
signing_key:
|
88
|
+
specification_version: 3
|
89
|
+
summary: Provides an oembed liquid tag for Jekyll
|
90
|
+
test_files: []
|