jekyll_oembed 0.0.2 → 0.0.3
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 +4 -4
- data/README.md +5 -0
- data/jekyll_oembed.gemspec +13 -12
- data/lib/jekyll_oembed.rb +36 -30
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa809ae81052fe367f2c46a3e9c11856d4cf9319
|
4
|
+
data.tar.gz: 1c284ea33f034bd3de68c8200330355233d3013d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4a622d553e1069297aa842fc602461380a15402e9a0eba327fd207b10de87ffae3c8b61e8e903450ffeb0a0d1c77221928f781d4e9be98ad6ce5edb4626096c
|
7
|
+
data.tar.gz: c271d836a1e0e882273cecea3295c419adff8262fa1eae88da62d7f1a68c570fcadbd5e8191523addf0731e0007bfc0fdbf073750b3c4d0d6419cd5475718aba
|
data/README.md
CHANGED
@@ -41,6 +41,11 @@ To use an oembed, simply do the following. Pass the embedded url as plain text,
|
|
41
41
|
`jekyll_oembed` does not support customizing width, height, or adding any attributes directly to the embedded HTML.
|
42
42
|
|
43
43
|
|
44
|
+
## Limitations
|
45
|
+
|
46
|
+
Protected URLs: some URLs are private. If this is the case, oembed _may_ not function properly
|
47
|
+
|
48
|
+
|
44
49
|
## Attribution
|
45
50
|
|
46
51
|
Thank you to:
|
data/jekyll_oembed.gemspec
CHANGED
@@ -3,19 +3,20 @@ lib = File.expand_path('../lib', __FILE__)
|
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
4
|
|
5
5
|
Gem::Specification.new do |gem|
|
6
|
-
gem.name =
|
7
|
-
gem.version = '0.0.
|
8
|
-
gem.authors = [
|
6
|
+
gem.name = 'jekyll_oembed'
|
7
|
+
gem.version = '0.0.3'
|
8
|
+
gem.authors = ['18F']
|
9
9
|
gem.license = 'Nonstandard'
|
10
|
-
gem.email = [
|
11
|
-
gem.description =
|
12
|
-
gem.summary =
|
13
|
-
|
14
|
-
gem.
|
15
|
-
gem.
|
10
|
+
gem.email = ['brian.hedberg@gsa.com']
|
11
|
+
gem.description = 'Provides an oembed liquid tag for Jekyll'
|
12
|
+
gem.summary = "A gem that creates a liquid 'oembed'" \
|
13
|
+
'tag for use in Jekyll sites'
|
14
|
+
gem.homepage = 'https://github.com/18F/jekyll-oembed'
|
15
|
+
gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
16
17
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
17
|
-
gem.require_paths = [
|
18
|
+
gem.require_paths = ['lib']
|
18
19
|
|
19
|
-
gem.add_dependency
|
20
|
-
gem.add_dependency
|
20
|
+
gem.add_dependency 'jekyll', '~> 3'
|
21
|
+
gem.add_dependency 'ruby-oembed', '~> 0'
|
21
22
|
end
|
data/lib/jekyll_oembed.rb
CHANGED
@@ -1,48 +1,54 @@
|
|
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
1
|
require 'oembed'
|
21
2
|
|
22
|
-
#
|
23
|
-
::OEmbed::Providers.register_all
|
24
|
-
#
|
25
|
-
|
26
|
-
|
27
|
-
|
3
|
+
# Register all default OEmbed providers
|
4
|
+
::OEmbed::Providers.register_all
|
5
|
+
# Since register_all does not register all default providers,
|
6
|
+
# we need to do this here.
|
7
|
+
# See https://github.com/judofyr/ruby-oembed/issues/18
|
8
|
+
::OEmbed::Providers.register(
|
9
|
+
::OEmbed::Providers::Instagram,
|
10
|
+
::OEmbed::Providers::Slideshare,
|
11
|
+
::OEmbed::Providers::Yfrog,
|
12
|
+
::OEmbed::Providers::MlgTv
|
13
|
+
)
|
14
|
+
::OEmbed::Providers.register_fallback(
|
15
|
+
::OEmbed::ProviderDiscovery,
|
16
|
+
::OEmbed::Providers::Embedly,
|
17
|
+
::OEmbed::Providers::OohEmbed
|
18
|
+
)
|
28
19
|
|
29
20
|
module Jekyll
|
30
21
|
class OEmbedPlugin < Liquid::Tag
|
31
|
-
|
32
22
|
def initialize(tag_name, text, tokens)
|
33
23
|
super
|
34
24
|
@text = text
|
35
25
|
end
|
36
26
|
|
37
27
|
def render(context)
|
38
|
-
#
|
28
|
+
# Pipe param through liquid to make additional replacements possible
|
39
29
|
url = Liquid::Template.parse(@text).render context
|
40
30
|
url = url.strip! || url.strip
|
31
|
+
begin
|
32
|
+
# OEmbed look up
|
33
|
+
result = ::OEmbed::Providers.get(url)
|
34
|
+
|
35
|
+
html_output(result)
|
36
|
+
rescue
|
37
|
+
error_message(url)
|
38
|
+
''
|
39
|
+
end
|
40
|
+
end
|
41
41
|
|
42
|
-
|
43
|
-
result
|
42
|
+
def html_output(result)
|
43
|
+
"<div class=\"embed-container #{result.fields['type']} " \
|
44
|
+
"#{result.fields['provider']}\">#{result.html}</div>"
|
45
|
+
end
|
44
46
|
|
45
|
-
|
47
|
+
def error_message(url)
|
48
|
+
# Silent error. This seems preferable to a hard fail
|
49
|
+
# because a user could make a URL private anytime.
|
50
|
+
puts "OEmbedError: The url, #{url}, is not available as an oembed. " \
|
51
|
+
'Consider using an HTML embed instead.'.red
|
46
52
|
end
|
47
53
|
end
|
48
54
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll_oembed
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 18F
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-02
|
11
|
+
date: 2017-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -74,5 +74,5 @@ rubyforge_project:
|
|
74
74
|
rubygems_version: 2.6.7
|
75
75
|
signing_key:
|
76
76
|
specification_version: 4
|
77
|
-
summary: A gem that creates a liquid 'oembed'
|
77
|
+
summary: A gem that creates a liquid 'oembed'tag for use in Jekyll sites
|
78
78
|
test_files: []
|