jekyll-spaceship 0.7.3 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +93 -33
- data/jekyll-spaceship.gemspec +1 -1
- data/lib/jekyll-spaceship/cores/config.rb +1 -0
- data/lib/jekyll-spaceship/processors/emoji-processor.rb +7 -2
- data/lib/jekyll-spaceship/processors/mermaid-processor.rb +116 -0
- data/lib/jekyll-spaceship/processors/plantuml-processor.rb +55 -24
- data/lib/jekyll-spaceship/processors/video-processor.rb +25 -7
- data/lib/jekyll-spaceship/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26f4057b47af49da27acf7f6d6b26851e9094b70f4c2a939270d8fbb0c49272f
|
4
|
+
data.tar.gz: 64a5c8f08a467de5a67a24d89dba5785d48e2d68add11a8acb10e4199e01922c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: decab1852e2c7f1dc439eee47805ca18d1192657b7ebb2c707737a031734e376f971d1b5e22e3ea435308caf010ad5f90d55fa13353170822cee5c51c0496b3b
|
7
|
+
data.tar.gz: 9d11c7b8437a5047b52370ca49de6f84360a80dcb0021f687b0b817644095ab2086b0157a6b2587bc9041906b698005556d444d8f05719b106bc65ec9b361912
|
data/README.md
CHANGED
@@ -105,17 +105,18 @@ Spaceship is a minimalistic, powerful and extremely customizable [Jekyll](https:
|
|
105
105
|
- [2.1 Performance Optimization](#21-performance-optimization)
|
106
106
|
- [2.2 How to use?](#22-how-to-use)
|
107
107
|
- [3. PlantUML Usage](#3-plantuml-usage)
|
108
|
-
- [4.
|
109
|
-
|
110
|
-
- [
|
111
|
-
- [
|
112
|
-
- [
|
113
|
-
|
114
|
-
- [6. Markdown
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
108
|
+
- [4. Mermaid Usage](#4-mermaid-usage)
|
109
|
+
- [5. Video Usage](#5-video-usage)
|
110
|
+
- [5.1 Youtube Usage](#youtube-usage)
|
111
|
+
- [5.2 Vimeo Usage](#vimeo-usage)
|
112
|
+
- [5.3 DailyMotion Usage](#dailymotion-usage)
|
113
|
+
- [5.4 General Video Usage](#general-video-usage)
|
114
|
+
- [6. Hybrid HTML with Markdown](#6-hybrid-html-with-markdown)
|
115
|
+
- [7. Markdown Polyfill](#7-markdown-polyfill)
|
116
|
+
- [7.1 Escape Ordered List](#71-escape-ordered-list)
|
117
|
+
- [8. Emoji Usage](#8-emoji-usage)
|
118
|
+
- [8.1 Emoji Customizing](#81-emoji-customizing)
|
119
|
+
- [9. Modifying Element Usage](#9-modifying-element-usage)
|
119
120
|
- [Credits](#credits)
|
120
121
|
- [Contributing](#contributing)
|
121
122
|
- [License](#license)
|
@@ -148,10 +149,12 @@ This plugin runs with the following configuration options by default. Alternativ
|
|
148
149
|
```yml
|
149
150
|
# Where things are
|
150
151
|
jekyll-spaceship:
|
152
|
+
# default enabled processors
|
151
153
|
processors:
|
152
154
|
- table-processor
|
153
155
|
- mathjax-processor
|
154
156
|
- plantuml-processor
|
157
|
+
- mermaid-processor
|
155
158
|
- polyfill-processor
|
156
159
|
- video-processor
|
157
160
|
- emoji-processor
|
@@ -164,8 +167,35 @@ jekyll-spaceship:
|
|
164
167
|
- ['$','$']
|
165
168
|
- ['\(','\)']
|
166
169
|
plantuml-processor:
|
170
|
+
mode: default # mode value 'pre-fetch' for fetch image at building stage
|
171
|
+
css:
|
172
|
+
class: plantuml
|
173
|
+
syntax:
|
174
|
+
code: 'plantuml!'
|
175
|
+
custom: ['@startuml', '@enduml']
|
167
176
|
src: http://www.plantuml.com/plantuml/png/
|
177
|
+
mermaid-processor:
|
178
|
+
mode: default # mode value 'pre-fetch' for fetch image at building stage
|
179
|
+
css:
|
180
|
+
class: mermaid
|
181
|
+
syntax:
|
182
|
+
code: 'mermaid!'
|
183
|
+
custom: ['@startmermaid', '@endmermaid']
|
184
|
+
config:
|
185
|
+
theme: default
|
186
|
+
src: https://mermaid.ink/svg/
|
187
|
+
video-processor:
|
188
|
+
default:
|
189
|
+
id: 'video-{id}'
|
190
|
+
class: 'video'
|
191
|
+
width: '100%'
|
192
|
+
height: 350
|
193
|
+
border: 0
|
194
|
+
style: 'max-width: 600px'
|
195
|
+
allow: 'encrypted-media; picture-in-picture'
|
168
196
|
emoji-processor:
|
197
|
+
css:
|
198
|
+
class: emoji
|
169
199
|
src: https://github.githubassets.com/images/icons/emoji/
|
170
200
|
```
|
171
201
|
|
@@ -546,13 +576,13 @@ Code above would be parsed as:
|
|
546
576
|
- class diagram,
|
547
577
|
- activity diagram,
|
548
578
|
- component diagram,
|
549
|
-
- state diagram
|
579
|
+
- state diagram,
|
550
580
|
- object diagram
|
551
581
|
|
552
582
|
There are two ways to create a diagram in your Jekyll blog page:
|
553
583
|
|
554
|
-
````
|
555
|
-
```plantuml
|
584
|
+
````
|
585
|
+
```plantuml!
|
556
586
|
Bob -> Alice : hello world
|
557
587
|
```
|
558
588
|
````
|
@@ -569,7 +599,48 @@ Code above would be parsed as:
|
|
569
599
|
|
570
600
|
![PlantUML Diagram](https://user-images.githubusercontent.com/9413601/82813883-9180b300-9ec8-11ea-8778-f450e0056938.png)
|
571
601
|
|
572
|
-
### 4.
|
602
|
+
### 4. Mermaid Usage
|
603
|
+
|
604
|
+
[Mermaid](https://mermaid-js.github.io/) is a Javascript based diagramming and charting tool. It generates diagrams flowcharts and more, using markdown-inspired text for ease and speed.
|
605
|
+
|
606
|
+
It allows to quickly write:
|
607
|
+
|
608
|
+
- flow chart,
|
609
|
+
- pie chart,
|
610
|
+
- sequence diagram,
|
611
|
+
- class diagram,
|
612
|
+
- state diagram,
|
613
|
+
- entity relationship diagram,
|
614
|
+
- user journey,
|
615
|
+
- gantt
|
616
|
+
|
617
|
+
There are two ways to create a diagram in your Jekyll blog page:
|
618
|
+
|
619
|
+
````
|
620
|
+
```mermaid!
|
621
|
+
pie title Pets adopted by volunteers
|
622
|
+
"Dogs" : 386
|
623
|
+
"Cats" : 85
|
624
|
+
"Rats" : 35
|
625
|
+
```
|
626
|
+
````
|
627
|
+
|
628
|
+
or
|
629
|
+
|
630
|
+
```markdown
|
631
|
+
@startmermaid
|
632
|
+
pie title Pets adopted by volunteers
|
633
|
+
"Dogs" : 386
|
634
|
+
"Cats" : 85
|
635
|
+
"Rats" : 35
|
636
|
+
@endmermaid
|
637
|
+
```
|
638
|
+
|
639
|
+
Code above would be parsed as:
|
640
|
+
|
641
|
+
![Mermaid Diagram](https://user-images.githubusercontent.com/9413601/85282355-2e317300-b4be-11ea-9c30-8f9d61540d14.png)
|
642
|
+
|
643
|
+
### 5. Video Usage
|
573
644
|
|
574
645
|
How often did you find yourself googling "**How to embed a video in markdown?**"
|
575
646
|
|
@@ -603,9 +674,7 @@ the link as below:
|
|
603
674
|
|
604
675
|
```markdown
|
605
676
|
![](https://www.youtube.com/watch?v=Ptk_1Dc2iPY?width=800&height=500)
|
606
|
-
```
|
607
677
|
|
608
|
-
```markdown
|
609
678
|
![](https://www.dailymotion.com/video/x7tfyq3?width=100%&height=400&autoplay=1)
|
610
679
|
```
|
611
680
|
|
@@ -613,9 +682,7 @@ the link as below:
|
|
613
682
|
|
614
683
|
```markdown
|
615
684
|
![](https://www.youtube.com/watch?v=Ptk_1Dc2iPY)
|
616
|
-
```
|
617
685
|
|
618
|
-
```markdown
|
619
686
|
![](//www.youtube.com/watch?v=Ptk_1Dc2iPY?width=800&height=500)
|
620
687
|
```
|
621
688
|
|
@@ -623,9 +690,7 @@ the link as below:
|
|
623
690
|
|
624
691
|
```markdown
|
625
692
|
![](https://vimeo.com/263856289)
|
626
|
-
```
|
627
693
|
|
628
|
-
```markdown
|
629
694
|
![](https://vimeo.com/263856289?width=500&height=320)
|
630
695
|
```
|
631
696
|
|
@@ -633,9 +698,7 @@ the link as below:
|
|
633
698
|
|
634
699
|
```markdown
|
635
700
|
![](https://www.dailymotion.com/video/x7tfyq3)
|
636
|
-
```
|
637
701
|
|
638
|
-
```markdown
|
639
702
|
![](https://dai.ly/x7tgcev?width=100%&height=400)
|
640
703
|
```
|
641
704
|
|
@@ -643,18 +706,14 @@ the link as below:
|
|
643
706
|
|
644
707
|
```markdown
|
645
708
|
![](//www.html5rocks.com/en/tutorials/video/basics/devstories.webm)
|
646
|
-
```
|
647
709
|
|
648
|
-
```markdown
|
649
710
|
![](//techslides.com/demos/sample-videos/small.ogv?allow=autoplay)
|
650
|
-
```
|
651
711
|
|
652
|
-
```markdown
|
653
712
|
![](//techslides.com/demos/sample-videos/small.mp4?width=400)
|
654
713
|
```
|
655
714
|
|
656
715
|
|
657
|
-
###
|
716
|
+
### 6. Hybrid HTML with Markdown
|
658
717
|
|
659
718
|
As markdown is not only a lightweight markup language with plain-text-formatting syntax, but also an easy-to-read and easy-to-write plain text format, so writing a hybrid HTML with markdown is an awesome choice.
|
660
719
|
|
@@ -688,7 +747,7 @@ Bob -> Alice : hello
|
|
688
747
|
</script>
|
689
748
|
```
|
690
749
|
|
691
|
-
###
|
750
|
+
### 7. Markdown Polyfill
|
692
751
|
|
693
752
|
It allows us to polyfill features for extending markdown syntax.
|
694
753
|
|
@@ -696,7 +755,7 @@ It allows us to polyfill features for extending markdown syntax.
|
|
696
755
|
|
697
756
|
- Escape ordered list
|
698
757
|
|
699
|
-
#### Escape Ordered List
|
758
|
+
#### 7.1 Escape Ordered List
|
700
759
|
|
701
760
|
A backslash at begin to escape the ordered list.
|
702
761
|
|
@@ -730,7 +789,7 @@ Escaped:
|
|
730
789
|
10. List item Cafe.
|
731
790
|
```
|
732
791
|
|
733
|
-
###
|
792
|
+
### 8. Emoji Usage
|
734
793
|
GitHub-flavored emoji images and names would allow emojifying content such as: it's raining :cat:s and :dog:s!
|
735
794
|
|
736
795
|
Noted that emoji images are served from the GitHub.com CDN, with a base URL of [https://github.githubassets.com](https://github.githubassets.com), which results in emoji image URLs like [https://github.githubassets.com/images/icons/emoji/unicode/1f604.png](https://github.githubassets.com/images/icons/emoji/unicode/1f604.png).
|
@@ -745,7 +804,7 @@ I give this plugin two :+1:!
|
|
745
804
|
|
746
805
|
I give this plugin two :+1:!
|
747
806
|
|
748
|
-
####
|
807
|
+
#### 8.1 Emoji Customizing
|
749
808
|
|
750
809
|
If you'd like to serve emoji images locally, or use a custom emoji source, you can specify so in your `_config.yml` file:
|
751
810
|
|
@@ -757,7 +816,7 @@ jekyll-spaceship:
|
|
757
816
|
|
758
817
|
See the [Gemoji](https://github.com/github/gemoji) documentation for generating image files.
|
759
818
|
|
760
|
-
###
|
819
|
+
### 9. Modifying Element Usage
|
761
820
|
|
762
821
|
It allows us to modify elements via `CSS3 selectors`. Through it you can easily
|
763
822
|
modify the attributes of an element tag, replace the children nodes and so on,
|
@@ -853,6 +912,7 @@ jekyll-spaceship:
|
|
853
912
|
- [jmoji](https://github.com/jekyll/jemoji) - GitHub-flavored emoji plugin for Jekyll.
|
854
913
|
- [jekyll-target-blank](https://github.com/keithmifsud/jekyll-target-blank) - Automatically opens external links in a new browser for Jekyll Pages, Posts and Docs.
|
855
914
|
- [jekyll-loading-lazy](https://github.com/gildesmarais/jekyll-loading-lazy) - Automatically adds loading="lazy" to img and iframe tags to natively load lazily.
|
915
|
+
- [mermaid](https://github.com/mermaid-js/mermaid) - Generation of diagram and flowchart from text in a similar manner as markdown.
|
856
916
|
|
857
917
|
## Contributing
|
858
918
|
|
data/jekyll-spaceship.gemspec
CHANGED
@@ -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, video, youtube, vimeo, dailymotion, etc."
|
12
|
+
spec.summary = "A Jekyll plugin to provide powerful supports for table, mathjax, plantuml, mermaid, emoji, video, youtube, vimeo, dailymotion, etc."
|
13
13
|
spec.homepage = "https://github.com/jeffreytse/jekyll-spaceship"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
@@ -7,7 +7,12 @@ require 'gemoji'
|
|
7
7
|
module Jekyll::Spaceship
|
8
8
|
class EmojiProcessor < Processor
|
9
9
|
def self.config
|
10
|
-
{
|
10
|
+
{
|
11
|
+
'css' => {
|
12
|
+
'class' => 'emoji'
|
13
|
+
},
|
14
|
+
'src' => 'https://github.githubassets.com/images/icons/emoji/'
|
15
|
+
}
|
11
16
|
end
|
12
17
|
|
13
18
|
def on_handle_html(content)
|
@@ -22,7 +27,7 @@ module Jekyll::Spaceship
|
|
22
27
|
|
23
28
|
content = content.gsub(
|
24
29
|
/(?<!\=")\s*:#{emoji_name}:\s*(?!"\s)/,
|
25
|
-
"<img class=\"
|
30
|
+
"<img class=\"\""\
|
26
31
|
" title=\":#{emoji.name}:\""\
|
27
32
|
" alt=\":#{emoji.name}:\""\
|
28
33
|
" raw=\"#{emoji.raw}\""\
|
@@ -0,0 +1,116 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "net/http"
|
4
|
+
require "base64"
|
5
|
+
|
6
|
+
module Jekyll::Spaceship
|
7
|
+
class MermaidProcessor < Processor
|
8
|
+
exclude :none
|
9
|
+
|
10
|
+
def self.config
|
11
|
+
{
|
12
|
+
'mode' => 'default',
|
13
|
+
'syntax' => {
|
14
|
+
'code' => 'mermaid!',
|
15
|
+
'custom' => ['@startmermaid', '@endmermaid']
|
16
|
+
},
|
17
|
+
'css' => {
|
18
|
+
'class' => 'mermaid'
|
19
|
+
},
|
20
|
+
'config': {
|
21
|
+
'theme' => 'default'
|
22
|
+
},
|
23
|
+
'src' => 'https://mermaid.ink/svg/'
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
def on_handle_markdown(content)
|
28
|
+
# match custom mermaid block and code block
|
29
|
+
syntax = self.config['syntax']
|
30
|
+
code_name = syntax['code']
|
31
|
+
custom = syntax['custom'][-2, 2]
|
32
|
+
|
33
|
+
patterns = [
|
34
|
+
/((`{3,})\s*#{code_name}((?:.|\n)*?)\2)/,
|
35
|
+
/((?<!\\)(#{custom[0]})((?:.|\n)*?)(?<!\\)(#{custom[1]}))/
|
36
|
+
]
|
37
|
+
|
38
|
+
patterns.each do |pattern|
|
39
|
+
content = handle_mermaid_block(pattern, content)
|
40
|
+
end
|
41
|
+
|
42
|
+
# handle escape custom mermaid block
|
43
|
+
content.gsub(/\\(#{custom[0]}|#{custom[1]})/, '\1')
|
44
|
+
end
|
45
|
+
|
46
|
+
def handle_mermaid_block(pattern, content)
|
47
|
+
content.scan pattern do |match|
|
48
|
+
match = match.select { |m| not m.nil? }
|
49
|
+
block = match[0]
|
50
|
+
code = match[2]
|
51
|
+
|
52
|
+
self.handled = true
|
53
|
+
|
54
|
+
content = content.gsub(
|
55
|
+
block,
|
56
|
+
handle_mermaid(code)
|
57
|
+
)
|
58
|
+
end
|
59
|
+
content
|
60
|
+
end
|
61
|
+
|
62
|
+
def handle_mermaid(code)
|
63
|
+
# encode to UTF-8
|
64
|
+
code = code.encode('UTF-8')
|
65
|
+
|
66
|
+
url = get_url(code)
|
67
|
+
|
68
|
+
# render mode
|
69
|
+
case self.config['mode']
|
70
|
+
when 'pre-fetch'
|
71
|
+
url = self.get_mermaid_img_data(url)
|
72
|
+
end
|
73
|
+
|
74
|
+
# return img tag
|
75
|
+
css_class = self.config['css']['class']
|
76
|
+
"<img class=\"#{css_class}\" src=\"#{url}\">"
|
77
|
+
end
|
78
|
+
|
79
|
+
def get_url(code)
|
80
|
+
src = self.config['src']
|
81
|
+
|
82
|
+
# wrap code
|
83
|
+
code = {
|
84
|
+
'code' => code.gsub(/^\s*|\s*$/, ''),
|
85
|
+
'mermaid' => config['config']
|
86
|
+
}.to_json
|
87
|
+
|
88
|
+
# set default method
|
89
|
+
src += '{code}' if src.match(/\{.*\}/).nil?
|
90
|
+
|
91
|
+
# encode to base64 string
|
92
|
+
if src.include?('{code}')
|
93
|
+
code = Base64.urlsafe_encode64(code, padding: false)
|
94
|
+
return src.gsub('{code}', code)
|
95
|
+
else
|
96
|
+
raise "No supported src ! #{src}"
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def get_mermaid_img_data(url)
|
101
|
+
data = ''
|
102
|
+
begin
|
103
|
+
res = Net::HTTP.get_response URI(url)
|
104
|
+
raise res.body unless res.is_a?(Net::HTTPSuccess)
|
105
|
+
data = Base64.encode64(res.body)
|
106
|
+
content_type = res.header['Content-Type']
|
107
|
+
raise 'Unknown content type!' if content_type.nil?
|
108
|
+
data = "data:#{content_type};base64, #{data}"
|
109
|
+
rescue StandardError => msg
|
110
|
+
data = url
|
111
|
+
logger.log msg
|
112
|
+
end
|
113
|
+
data
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
@@ -7,23 +7,37 @@ module Jekyll::Spaceship
|
|
7
7
|
class PlantumlProcessor < Processor
|
8
8
|
exclude :none
|
9
9
|
|
10
|
-
PLANTUML_PATTERNS = [
|
11
|
-
/(\\?(@startuml)((?:.|\n)*?)@enduml)/,
|
12
|
-
/((`{3,})\s*plantuml((?:.|\n)*?)\2)/
|
13
|
-
]
|
14
|
-
|
15
10
|
def self.config
|
16
|
-
{
|
11
|
+
{
|
12
|
+
'mode' => 'default',
|
13
|
+
'syntax' => {
|
14
|
+
'code' => 'plantuml!',
|
15
|
+
'custom' => ['@startuml', '@enduml']
|
16
|
+
},
|
17
|
+
'css' => {
|
18
|
+
'class' => 'plantuml'
|
19
|
+
},
|
20
|
+
'src' => 'http://www.plantuml.com/plantuml/png/'
|
21
|
+
}
|
17
22
|
end
|
18
23
|
|
19
24
|
def on_handle_markdown(content)
|
20
|
-
# match
|
21
|
-
|
25
|
+
# match custom plantuml block and code block
|
26
|
+
syntax = self.config['syntax']
|
27
|
+
code_name = syntax['code']
|
28
|
+
custom = syntax['custom'][-2, 2]
|
29
|
+
|
30
|
+
patterns = [
|
31
|
+
/((`{3,})\s*#{code_name}((?:.|\n)*?)\2)/,
|
32
|
+
/((?<!\\)(#{custom[0]})((?:.|\n)*?)(?<!\\)(#{custom[1]}))/
|
33
|
+
]
|
34
|
+
|
35
|
+
patterns.each do |pattern|
|
22
36
|
content = handle_plantuml_block(pattern, content)
|
23
37
|
end
|
24
38
|
|
25
|
-
# handle escape
|
26
|
-
content.gsub(/\\(
|
39
|
+
# handle escape custom plantuml block
|
40
|
+
content.gsub(/\\(#{custom[0]}|#{custom[1]})/, '\1')
|
27
41
|
end
|
28
42
|
|
29
43
|
def handle_plantuml_block(pattern, content)
|
@@ -32,11 +46,6 @@ module Jekyll::Spaceship
|
|
32
46
|
block = match[0]
|
33
47
|
code = match[2]
|
34
48
|
|
35
|
-
# skip escape default plantuml block
|
36
|
-
if block.match(/(^\\@startuml|\\@enduml$)/)
|
37
|
-
next
|
38
|
-
end
|
39
|
-
|
40
49
|
self.handled = true
|
41
50
|
|
42
51
|
content = content.gsub(
|
@@ -51,21 +60,43 @@ module Jekyll::Spaceship
|
|
51
60
|
# wrap plantuml code
|
52
61
|
code = "@startuml#{code}@enduml".encode('UTF-8')
|
53
62
|
|
54
|
-
|
55
|
-
|
56
|
-
|
63
|
+
url = get_url(code)
|
64
|
+
|
65
|
+
# render mode
|
66
|
+
case self.config['mode']
|
67
|
+
when 'pre-fetch'
|
68
|
+
url = self.get_plantuml_img_data(url)
|
69
|
+
end
|
57
70
|
|
58
71
|
# return img tag
|
59
|
-
|
72
|
+
css_class = self.config['css']['class']
|
73
|
+
"<img class=\"#{css_class}\" src=\"#{url}\">"
|
74
|
+
end
|
75
|
+
|
76
|
+
def get_url(code)
|
77
|
+
src = self.config['src']
|
78
|
+
|
79
|
+
# set default method
|
80
|
+
src += '{hexcode}' if src.match(/\{.*\}/).nil?
|
81
|
+
|
82
|
+
# encode to hex string
|
83
|
+
if src.include?('{hexcode}')
|
84
|
+
code = '~h' + code.unpack("H*").first
|
85
|
+
return src.gsub('{hexcode}', code)
|
86
|
+
else
|
87
|
+
raise "No supported src ! #{src}"
|
88
|
+
end
|
60
89
|
end
|
61
90
|
|
62
|
-
def get_plantuml_img_data(
|
91
|
+
def get_plantuml_img_data(url)
|
63
92
|
data = ''
|
64
|
-
url = "#{config['src']}#{code}"
|
65
93
|
begin
|
66
|
-
|
67
|
-
|
68
|
-
data =
|
94
|
+
res = Net::HTTP.get_response URI(url)
|
95
|
+
raise res.body unless res.is_a?(Net::HTTPSuccess)
|
96
|
+
data = Base64.encode64(res.body)
|
97
|
+
content_type = res.header['Content-Type']
|
98
|
+
raise 'Unknown content type!' if content_type.nil?
|
99
|
+
data = "data:#{content_type};base64, #{data}"
|
69
100
|
rescue StandardError => msg
|
70
101
|
data = url
|
71
102
|
logger.log msg
|
@@ -4,6 +4,20 @@ require 'uri'
|
|
4
4
|
|
5
5
|
module Jekyll::Spaceship
|
6
6
|
class VideoProcessor < Processor
|
7
|
+
def self.config
|
8
|
+
{
|
9
|
+
'default' => {
|
10
|
+
'id' => 'video-{id}',
|
11
|
+
'class' => 'video',
|
12
|
+
'width' => '100%',
|
13
|
+
'height' => 350,
|
14
|
+
'border' => 0,
|
15
|
+
'style' => 'max-width: 600px',
|
16
|
+
'allow' => 'encrypted-media; picture-in-picture',
|
17
|
+
}
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
7
21
|
def on_handle_markdown(content)
|
8
22
|
content = handle_normal_video(content)
|
9
23
|
content = handle_youtube(content)
|
@@ -87,13 +101,17 @@ module Jekyll::Spaceship
|
|
87
101
|
next true if v == id or v == ''
|
88
102
|
end
|
89
103
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
104
|
+
default = self.config['default']
|
105
|
+
css_id = qs['id'] || default['id']
|
106
|
+
css_class = qs['class'] || default['class']
|
107
|
+
width = qs['width'] || data[:width] || default['width']
|
108
|
+
height = qs['height'] || data[:height] || default['height']
|
109
|
+
frameborder = qs['frameborder'] || default['border']
|
110
|
+
style = qs['style'] || default['style']
|
111
|
+
allow = qs['allow'] || default['allow']
|
112
|
+
|
113
|
+
css_id.gsub('{id}', id)
|
114
|
+
css_class.gsub('{id}', id)
|
97
115
|
|
98
116
|
url = URI(iframe_url ? "#{iframe_url}#{id}" : url).tap do |v|
|
99
117
|
v.query = URI.encode_www_form(qs) if qs.size > 0
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-spaceship
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jeffreytse
|
@@ -140,6 +140,7 @@ files:
|
|
140
140
|
- lib/jekyll-spaceship/processors/element-processor.rb
|
141
141
|
- lib/jekyll-spaceship/processors/emoji-processor.rb
|
142
142
|
- lib/jekyll-spaceship/processors/mathjax-processor.rb
|
143
|
+
- lib/jekyll-spaceship/processors/mermaid-processor.rb
|
143
144
|
- lib/jekyll-spaceship/processors/plantuml-processor.rb
|
144
145
|
- lib/jekyll-spaceship/processors/polyfill-processor.rb
|
145
146
|
- lib/jekyll-spaceship/processors/table-processor.rb
|
@@ -173,5 +174,5 @@ rubygems_version: 2.7.7
|
|
173
174
|
signing_key:
|
174
175
|
specification_version: 4
|
175
176
|
summary: A Jekyll plugin to provide powerful supports for table, mathjax, plantuml,
|
176
|
-
emoji, video, youtube, vimeo, dailymotion, etc.
|
177
|
+
mermaid, emoji, video, youtube, vimeo, dailymotion, etc.
|
177
178
|
test_files: []
|