jekyll-spaceship 0.6.1 → 0.6.2

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: ca3414a157fe1966031e109e08be4805790638d24fa4f7197bf74fc231b69778
4
- data.tar.gz: 95b7d289cd489e28c09902ff5b7f6e35229847cab376df5be9bbab3434f4e41f
3
+ metadata.gz: df761631c9d2636245947978d30acc90b604f9ebd7dbfb047350cff020f80709
4
+ data.tar.gz: 6eb135842d1d1e2f6eb87817a8bbdf7d2c1126a3c0e935e6275ee8ef5dd36a26
5
5
  SHA512:
6
- metadata.gz: 27e7c3291a2994b03b8670a920ff8cb9d8727a1986debc19d1cf1a92989fc651790353cf29811d2cead664bf999fb0cb77ebb676b5af5773192b8d934e3ce90d
7
- data.tar.gz: fde58815d50920a1c1c9b4c6694b0600e7a02102bd2d86edad24db469487942e9fdad477a70c567afbcd8e527275bc093328b7b0e75627ed0c194247155361d4
6
+ metadata.gz: 9675c39c1174d6420d08081d52a802865ef0a3773df936ad01cc29323a7d4287af07176328237de283a087154d86e8a3e92cd19e67a4b9ac1dae38e418a21c47
7
+ data.tar.gz: b3c0d6b610fed90ca7017b25f5e08c880188f5ea9c68f7645e1027f9e8a8fb32b80b0dbc97e446d00a24346f86fbbeb394fea925a2d018af6d68c9e71368f570
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.version = Jekyll::Spaceship::VERSION
10
10
  spec.authors = ["jeffreytse"]
11
11
  spec.email = ["jeffreytse.mail@gmail.com"]
12
- spec.summary = "A Jekyll plugin to provide powerful supports for table, mathjax, plantuml, emoji, youtube, vimeo, dailymotion, etc."
12
+ spec.summary = "A Jekyll plugin to provide powerful supports for table, mathjax, plantuml, emoji, video, youtube, vimeo, dailymotion, etc."
13
13
  spec.homepage = "https://github.com/jeffreytse/jekyll-spaceship"
14
14
  spec.license = "MIT"
15
15
 
@@ -13,19 +13,7 @@ module Jekyll::Spaceship
13
13
  'polyfill-processor',
14
14
  'video-processor',
15
15
  'emoji-processor'
16
- ],
17
- 'mathjax-processor' => {
18
- 'src' => '//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML',
19
- 'config' => {
20
- 'tex2jax' => { 'inlineMath' => [['$','$'], ['\\(','\\)']] }
21
- }
22
- },
23
- 'plantuml-processor' => {
24
- 'src' => 'http://www.plantuml.com/plantuml/png/'
25
- },
26
- 'emoji-processor' => {
27
- 'src' => 'https://github.githubassets.com/images/icons/emoji/'
28
- }
16
+ ]
29
17
  }
30
18
 
31
19
  @@store = {}
@@ -43,8 +31,10 @@ module Jekyll::Spaceship
43
31
  first.merge(second.to_h, &merger)
44
32
  end
45
33
 
46
- def self.store(section)
47
- @@store[section]
34
+ def self.store(section, default)
35
+ return if @@store[section].nil?
36
+ return @@store[section] if default.nil?
37
+ @@store[section] = deep_merge(@@store[section], default)
48
38
  end
49
39
 
50
40
  def self.load(filename = '_config.yml')
@@ -41,7 +41,8 @@ module Jekyll::Spaceship
41
41
  self.initialize_register
42
42
  self.initialize_exclusions
43
43
  @logger = Logger.new(self.name)
44
- @config = Config.store(self.filename)
44
+ @config = Config.store(self.filename, self.class.config)
45
+ @handled_files = {}
45
46
  end
46
47
 
47
48
  def initialize_priority
@@ -56,7 +57,7 @@ module Jekyll::Spaceship
56
57
  def initialize_register
57
58
  if @@_registers.size.zero?
58
59
  self.class.register :pages, :pre_render, :post_render
59
- self.class.register :posts, :pre_render, :post_render
60
+ self.class.register :documents, :pre_render, :post_render
60
61
  end
61
62
  @registers = Array.new @@_registers
62
63
  @@_registers.clear
@@ -82,6 +83,9 @@ module Jekyll::Spaceship
82
83
  @@_exclusions = types
83
84
  end
84
85
 
86
+ def self.config
87
+ end
88
+
85
89
  def process?
86
90
  Type.html?(output_ext) or Type.markdown?(ext)
87
91
  end
@@ -140,7 +144,10 @@ module Jekyll::Spaceship
140
144
  end
141
145
 
142
146
  def on_handled
143
- file = page.path.gsub(/.*_posts\//, '')
147
+ source = page.site.source
148
+ file = page.path.sub(/^#{source}\//, '')
149
+ return if @handled_files.has_key? file
150
+ @handled_files[file] = true
144
151
  logger.log file
145
152
  end
146
153
 
@@ -6,6 +6,10 @@ require 'gemoji'
6
6
 
7
7
  module Jekyll::Spaceship
8
8
  class EmojiProcessor < Processor
9
+ def self.config
10
+ { 'src' => 'https://github.githubassets.com/images/icons/emoji/' }
11
+ end
12
+
9
13
  def on_handle_html(content)
10
14
  # handle emoji markup
11
15
  content.scan(/:([\w\d+-]+):/) do |match|
@@ -18,16 +22,16 @@ module Jekyll::Spaceship
18
22
 
19
23
  content = content.gsub(
20
24
  /(?<!\=")\s*:#{emoji_name}:\s*(?!"\s)/,
21
- "<img class=\"emoji\" \
22
- title=\":#{emoji.name}:\" \
23
- alt=\":#{emoji.name}:\" \
24
- raw=\"#{emoji.raw}\" \
25
- src=\"#{config['src']}#{emoji.image_filename}\" \
26
- style=\"vertical-align: middle; \
27
- max-width: 1em; visibility: hidden;\" \
28
- onload=\"this.style.visibility='visible'\" \
29
- onerror=\"this.replaceWith(this.getAttribute('raw'))\"> \
30
- </img>"
25
+ "<img class=\"emoji\""\
26
+ " title=\":#{emoji.name}:\""\
27
+ " alt=\":#{emoji.name}:\""\
28
+ " raw=\"#{emoji.raw}\""\
29
+ " src=\"#{config['src']}#{emoji.image_filename}\""\
30
+ " style=\"vertical-align: middle;"\
31
+ " max-width: 1em; visibility: hidden;\""\
32
+ " onload=\"this.style.visibility='visible'\""\
33
+ " onerror=\"this.replaceWith(this.getAttribute('raw'))\">"\
34
+ "</img>"
31
35
  )
32
36
  end
33
37
  content
@@ -4,6 +4,15 @@ require "nokogiri"
4
4
 
5
5
  module Jekyll::Spaceship
6
6
  class MathjaxProcessor < Processor
7
+ def self.config
8
+ {
9
+ 'src' => '//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML',
10
+ 'config' => {
11
+ 'tex2jax' => { 'inlineMath' => [['$','$'], ['\\(','\\)']] }
12
+ }
13
+ }
14
+ end
15
+
7
16
  def process?
8
17
  return true if Type.html?(output_ext)
9
18
  end
@@ -7,6 +7,10 @@ module Jekyll::Spaceship
7
7
  class PlantumlProcessor < Processor
8
8
  exclude :none
9
9
 
10
+ def self.config
11
+ { 'src' => 'http://www.plantuml.com/plantuml/png/' }
12
+ end
13
+
10
14
  def on_handle_markdown(content)
11
15
  # match default plantuml block and code block
12
16
  pattern = Regexp.union(
@@ -5,11 +5,23 @@ require 'uri'
5
5
  module Jekyll::Spaceship
6
6
  class VideoProcessor < Processor
7
7
  def on_handle_markdown(content)
8
+ content = handle_normal_video(content)
8
9
  content = handle_youtube(content)
9
10
  content = handle_vimeo(content)
10
11
  content = handle_dailymotion(content)
11
12
  end
12
13
 
14
+ # Examples:
15
+ # ![video](//www.html5rocks.com/en/tutorials/video/basics/devstories.webm)
16
+ # ![video](//techslides.com/demos/sample-videos/small.ogv?allow=autoplay)
17
+ # ![video](//techslides.com/demos/sample-videos/small.mp4?width=400)
18
+ def handle_normal_video(content)
19
+ handle_video(content, {
20
+ host: '(https?:)?\\/\\/.*\\/',
21
+ id: '(.+?\\.(avi|mp4|webm|ogg|ogv|flv|mkv|mov|wmv|3gp|rmvb|asf))',
22
+ })
23
+ end
24
+
13
25
  # Examples:
14
26
  # ![youtube](https://www.youtube.com/watch?v=XA2WjJbmmoM "title")
15
27
  # ![youtube](http://www.youtube.com/embed/w-m_yZCLF5Q)
@@ -29,9 +41,7 @@ module Jekyll::Spaceship
29
41
  handle_video(content, {
30
42
  host: '(https?:)?\\/\\/vimeo\\.com\\/',
31
43
  id: '([0-9]+)',
32
- iframe_url: "https://player.vimeo.com/video/",
33
- width: 600,
34
- height: 350
44
+ iframe_url: "https://player.vimeo.com/video/"
35
45
  })
36
46
  end
37
47
 
@@ -77,25 +87,30 @@ module Jekyll::Spaceship
77
87
  next true if v == id or v == ''
78
88
  end
79
89
 
80
- width = qs['width'] || data[:width] || 600
81
- height = qs['height'] || data[:height] || 400
82
- style = "max-width: 100%" if width.nil?
90
+ css_id = qs['id'] || "video-#{id}"
91
+ css_class = qs['class'] || 'video'
92
+ width = qs['width'] || data[:width] || "100%"
93
+ height = qs['height'] || data[:height] || 350
94
+ frameborder = qs['frameborder'] || 0
95
+ style = qs['style'] || ''
96
+ allow = qs['allow'] || "encrypted-media; picture-in-picture"
83
97
 
84
- url = URI("#{iframe_url}#{id}").tap do |v|
98
+ url = URI(iframe_url ? "#{iframe_url}#{id}" : url).tap do |v|
85
99
  v.query = URI.encode_www_form(qs) if qs.size > 0
86
100
  end
87
101
 
88
- html = "<iframe \
89
- class=\"video\" \
90
- src=\"#{url}\" \
91
- title=\"#{title}\" \
92
- width=\"#{width}\" \
93
- height=\"#{height}\" \
94
- style=\"#{style}\" \
95
- allow=\"autoplay; encrypted-media\" \
96
- frameborder=\"0\" \
97
- allowfullscreen=\"\">\
98
- </iframe>"
102
+ html = "<iframe"\
103
+ " id=\"#{css_id}\""\
104
+ " class=\"#{css_class}\""\
105
+ " src=\"#{url}\""\
106
+ " title=\"#{title}\""\
107
+ " width=\"#{width}\""\
108
+ " height=\"#{height}\""\
109
+ " style=\"#{style}\""\
110
+ " allow=\"#{allow}\""\
111
+ " frameborder=\"#{frameborder}\""\
112
+ " allowfullscreen>" \
113
+ "</iframe>"
99
114
 
100
115
  content = content.gsub(match_data[0], html)
101
116
  self.handled = true
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Jekyll
4
4
  module Spaceship
5
- VERSION = "0.6.1"
5
+ VERSION = "0.6.2"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-spaceship
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - jeffreytse
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-10 00:00:00.000000000 Z
11
+ date: 2020-06-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -172,5 +172,5 @@ rubygems_version: 2.7.7
172
172
  signing_key:
173
173
  specification_version: 4
174
174
  summary: A Jekyll plugin to provide powerful supports for table, mathjax, plantuml,
175
- emoji, youtube, vimeo, dailymotion, etc.
175
+ emoji, video, youtube, vimeo, dailymotion, etc.
176
176
  test_files: []