jekyll_oembed 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7fa364245b94c1bfdc9b6a0e76c7a65940958f4f
4
- data.tar.gz: 6efbe140f97069e2aa214ca58bb4e2f139e5c4be
3
+ metadata.gz: fa809ae81052fe367f2c46a3e9c11856d4cf9319
4
+ data.tar.gz: 1c284ea33f034bd3de68c8200330355233d3013d
5
5
  SHA512:
6
- metadata.gz: ddf5ffd28cf060b7aa80691921d3dbdd2790240fdd88929c0f82f93572dc905af8e5600130ae6cd318604ad5480b93384d077c57dc39f845b74039127745de9d
7
- data.tar.gz: 1b8bc17a50c862a947e928c04eaf00ac87a85704d4ef79c7aaee398d53a0b248c8c2e2e0a62e0ba17335277ccdd4aba0494b4449952f3d68b86abb2c67ebcc9a
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:
@@ -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 = "jekyll_oembed"
7
- gem.version = '0.0.2'
8
- gem.authors = ["18F"]
6
+ gem.name = 'jekyll_oembed'
7
+ gem.version = '0.0.3'
8
+ gem.authors = ['18F']
9
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) }
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 = ["lib"]
18
+ gem.require_paths = ['lib']
18
19
 
19
- gem.add_dependency "jekyll", '~> 3'
20
- gem.add_dependency "ruby-oembed", '~> 0'
20
+ gem.add_dependency 'jekyll', '~> 3'
21
+ gem.add_dependency 'ruby-oembed', '~> 0'
21
22
  end
@@ -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
- # 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
-
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
- # pipe param through liquid to make additional replacements possible
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
- # oembed look up
43
- result = ::OEmbed::Providers.get(url)
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
- "<div class=\"embed-container #{result.fields['type']} #{result.fields['provider']}\">#{result.html}</div>"
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.2
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-23 00:00:00.000000000 Z
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' tag for use in Jekyll sites
77
+ summary: A gem that creates a liquid 'oembed'tag for use in Jekyll sites
78
78
  test_files: []