jekyll-embeds 0.0.5 → 0.0.6

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
  SHA256:
3
- metadata.gz: 43eb82570830b85e6dea276d8b0a9956efd21b1370870c18783c05fe340e8250
4
- data.tar.gz: d8bcf3d6c1f5564e97889687a5e28ce53541870ae8ad4b484fd8b75582fa6970
3
+ metadata.gz: c943b31803d9024efed4ca59394ff1c80a4cdd600898397d7fd2b29ab9d5198c
4
+ data.tar.gz: 3f5bb583bfc775502782b329d3c5b0c299b343398471f9953c57e5712b0b1d10
5
5
  SHA512:
6
- metadata.gz: f1701c04e809bc3a9a37b8441d70944c36938d6c72d8c3108435a65553f8bcef9c0e9422725477930d6a26609880e98d458374c36925312961be954da6a12cf5
7
- data.tar.gz: cc703a411946369e4c7e8d1cf20c53a387df5ce84a15f0a848ce98735176bf19ff05e5b2d539f9749f999c7e073862652b95f23e28880e869c88ddcd0a0decad
6
+ metadata.gz: 8512b5f1a52df67ea31e7d8c364dc3c614899ad68af0e45ca6787b924f43ffa6bb10e6a03e0b0478415b753fbf7555c3706db8f83a3ef65b81a22c102914c276
7
+ data.tar.gz: 6bec222152af851b6963899674340b63c27af84228dcc4733234e1a0a58577e7a56bef28399adef0ef3cb064fa732797d119dbba0bdc9ec07633b311b0d78c47
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in jekyllcontentful.gemspec
3
+
4
4
  gemspec
@@ -4,11 +4,11 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "jekyll-embeds"
7
- spec.version = "0.0.5"
7
+ spec.version = "0.0.6"
8
8
  spec.authors = ["SEBAS204"]
9
9
 
10
10
  spec.summary = %q{Jekyll plugin for embedding diferent media elements.}
11
- spec.description = %q{Jekyll plugin to generate html snippets for embedding Youtube, VIMEO, Twitch channels (clips soon), SoundCloud.}
11
+ spec.description = %q{Jekyll plugin to generate html snippets for embedding Youtube; VIMEO; Twitch channels, videos & clips; SoundCloud.}
12
12
  spec.homepage = "https://github.com/ZEBAS204/Jekyll-Embeds"
13
13
  spec.license = "MIT"
14
14
 
data/lib/jekyll-embeds.rb CHANGED
@@ -3,28 +3,22 @@ require 'shellwords'
3
3
 
4
4
  class YouTubeEmbed < Liquid::Tag
5
5
 
6
- def initialize(tagName, content, tokens)
6
+ def initialize(tag_name, markup, tokens)
7
7
  super
8
- @content = content
8
+ params = Shellwords.shellwords markup
9
+ @items = { :url => params[0] }
9
10
  end
10
11
 
11
12
  def render(context)
12
- youtube_url = "#{context[@content.strip]}"
13
+ youtube_url = "#{@items[:url].strip}"
13
14
  if youtube_url[/youtu\.be\/([^\?]*)/]
14
15
  @youtube_id = $1
15
16
  else
16
17
  youtube_url[/^.*((v\/)|(embed\/)|(watch\?))\??v?=?([^\&\?]*).*/]
17
18
  @youtube_id = $5
18
19
  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{<div class='embed-container'><iframe title="YouTube video player" width="640" height="390" src="//www.youtube.com/embed/#{ @youtube_id }" frameborder="0" allowfullscreen></iframe></div>}
27
- end
20
+
21
+ %Q{<div class='embed-container'><iframe width="640" height="390" src="//www.youtube.com/embed/#{@youtube_id}" frameborder="0" allowfullscreen></iframe></div>}
28
22
  end
29
23
 
30
24
  Liquid::Template.register_tag "youtube", self
@@ -33,25 +27,45 @@ end
33
27
 
34
28
  class TwitchEmbed < Liquid::Tag
35
29
 
36
- def initialize(tagName, content, tokens)
30
+ def initialize(tag_name, markup, tokens)
37
31
  super
38
- @content = content
32
+ params = Shellwords.shellwords markup
33
+ @items = { :url => params[0], :type => params[1] || "channel", :aplay => params[2] || false }
39
34
  end
40
35
 
41
36
  def render(context)
42
- twitch_url = "#{context[@content.strip]}"
43
- if twitch_url[/twitch\.tv\/([^\?]*)/]
44
- @twitch_id = $1
45
- end
46
-
47
- tmpl_path = File.join Dir.pwd, "_includes", "twitch.html"
48
- if File.exist?(tmpl_path)
49
- tmpl = File.read tmpl_path
50
- site = context.registers[:site]
51
- tmpl = (Liquid::Template.parse tmpl).render site.site_payload.merge!({"twitch_id" => @twitch_id})
52
- else
53
- %Q{<div class='embed-container'><iframe src="https://player.twitch.tv/?channel=#{ @twitch_id }" frameborder="0" allowfullscreen="true" scrolling="no" autoplay="false" height="390" width="640"></iframe></div>}
54
- end
37
+ tstr = "#{@items[:url].strip}"
38
+
39
+ case @items[:type]
40
+ when "channel" || "0"
41
+ if tstr[/twitch\.tv\/([^\?]*)/]
42
+ @twitch_url = $1
43
+ else
44
+ @twitch_url = "#{@items[:url]}"
45
+ end
46
+ %Q{<div class='embed-container'><iframe src="https://player.twitch.tv/?channel=#{@twitch_url}" frameborder="0" allowfullscreen="true" scrolling="no" autoplay="#{@items[:aplay]}" height="390" width="640"></iframe></div>}
47
+
48
+ when "video" || "1"
49
+ if tstr[/twitch\.tv\/videos\/([^\?]*)/]
50
+ @twitch_url = $1
51
+ else
52
+ @twitch_url = "#{@items[:url]}"
53
+ end
54
+ %Q{<div class='embed-container'><iframe src="https://player.twitch.tv/?video=#{@twitch_url}&autoplay=#{@items[:aplay]}" frameborder="0" allowfullscreen="true" scrolling="no" autoplay="#{@items[:aplay]}" height="390" width="640"></iframe></div>}
55
+
56
+ when "clip" || "2"
57
+ if tstr[/clips\.twitch\.tv\/([^\?]*)/]
58
+ @twitch_url = $1
59
+ elsif tstr[/twitch\.tv\/([^\?]*)\/clip\/([^\?]*)\?/]
60
+ @twitch_url = $2
61
+ else
62
+ @twitch_url = "#{@items[:url]}"
63
+ end
64
+ %Q{<div class='embed-container'><iframe src="https://clips.twitch.tv/embed?clip=#{@twitch_url}&autoplay=#{@items[:aplay]}" frameborder="0" allowfullscreen="true" scrolling="no" autoplay="#{@items[:aplay]}" height="390" width="640"></iframe></div>}
65
+
66
+ else
67
+ ""
68
+ end
55
69
  end
56
70
 
57
71
  Liquid::Template.register_tag "twitch", self
@@ -90,7 +104,7 @@ class SoundCloudEmbed < Liquid::Tag
90
104
  def initialize(tag_name, markup, tokens)
91
105
  super
92
106
  params = Shellwords.shellwords markup
93
- @items = { :id => params[0], :color => params[1] || "ff7700", :aplay => params[2] || "false" }
107
+ @items = { :id => params[0], :color => params[1] || "ff7700", :aplay => params[2] || false }
94
108
  end
95
109
 
96
110
  def render(context)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-embeds
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - SEBAS204
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-31 00:00:00.000000000 Z
11
+ date: 2019-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -52,8 +52,8 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '10.0'
55
- description: Jekyll plugin to generate html snippets for embedding Youtube, VIMEO,
56
- Twitch channels (clips soon), SoundCloud.
55
+ description: Jekyll plugin to generate html snippets for embedding Youtube; VIMEO;
56
+ Twitch channels, videos & clips; SoundCloud.
57
57
  email:
58
58
  executables: []
59
59
  extensions: []