jekyll-drawio 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jekyll-drawio/version.rb +3 -3
- data/lib/jekyll-drawio.rb +21 -19
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 62bdc02bcf3506343b120c054bfdf6662a4afc0234a504a22c18b90b75f7eb11
|
4
|
+
data.tar.gz: 536dd289302a471dac0601b518736a3ab8ca0c105bf5522b0bf46382a4c97386
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9a38fae82bcac537cf5a9e2379270e1f18107024acf66ce6db81289e51eb192e35636f09e4acc539ce14c3e5632eb2785a183745592c7456f148b687ed6da6c
|
7
|
+
data.tar.gz: a845ed537bdf20b61e7e950d80672daf426bfa1e1172580ca0d260e23bacba4838ea22d8ce967fd9d386c4de36650dbd8e0f89c77f012c23447b8e27e894fcf4
|
data/lib/jekyll-drawio.rb
CHANGED
@@ -1,22 +1,24 @@
|
|
1
1
|
require "jekyll"
|
2
2
|
require "jekyll-drawio/version"
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require "nokogiri"
|
4
|
+
require "erb"
|
5
|
+
|
6
|
+
MODULE_TAG_NAME = "drawio"
|
5
7
|
|
6
8
|
class DrawIOConverter < Liquid::Tag
|
9
|
+
attr_accessor :path_to_diagram, :selected_diagram_num, :diagram_height
|
7
10
|
|
8
11
|
def initialize(tagName, variables, tokens)
|
9
12
|
super
|
10
|
-
@variables = variables.split " "
|
11
13
|
@path_to_diagram = ""
|
12
14
|
@selected_diagram_num = nil
|
13
15
|
@diagram_height = 200
|
14
|
-
|
15
|
-
|
16
|
+
|
17
|
+
variables.each do |variable|
|
16
18
|
param_value_pair = variable.split "="
|
17
19
|
if param_value_pair[0] == "path"
|
18
20
|
# TODO: find appropriate method to trim the string
|
19
|
-
@path_to_diagram = param_value_pair[1].tr('\"',
|
21
|
+
@path_to_diagram = param_value_pair[1].tr('\"', "")
|
20
22
|
elsif param_value_pair[0] == "page_number"
|
21
23
|
@selected_diagram_num = param_value_pair[1].to_i
|
22
24
|
elsif param_value_pair[0] == "height"
|
@@ -24,36 +26,36 @@ class DrawIOConverter < Liquid::Tag
|
|
24
26
|
end
|
25
27
|
end
|
26
28
|
|
27
|
-
puts "path=\"#{
|
29
|
+
puts "path=\"#{@path_to_diagram}\" page_num=#{@selected_diagram_num}"
|
28
30
|
end
|
29
31
|
|
30
|
-
def extract_diagram(path
|
32
|
+
def extract_diagram(path)
|
31
33
|
doc = File.open(path) { |f| Nokogiri::XML(f) }
|
32
34
|
diagrams = doc.xpath("//mxfile//diagram")
|
33
|
-
puts "Diagrams found at \"#{
|
34
|
-
"Selected: #{
|
35
|
-
|
36
|
-
diagram = diagrams[selected_diagram_num]
|
35
|
+
puts "Diagrams found at \"#{path}\": #{diagrams.length}. " \
|
36
|
+
"Selected: #{@selected_diagram_num}. "
|
37
|
+
|
38
|
+
diagram = diagrams[@selected_diagram_num]
|
37
39
|
|
38
40
|
diagram_name = diagram["name"]
|
39
|
-
diagram_content = diagram.
|
41
|
+
diagram_content = diagram.to_html
|
40
42
|
|
41
43
|
return diagram_name, diagram_content
|
42
44
|
end
|
43
45
|
|
44
46
|
def render(context)
|
45
|
-
diagram_name, diagram_content = self.extract_diagram @path_to_diagram
|
47
|
+
diagram_name, diagram_content = self.extract_diagram @path_to_diagram
|
46
48
|
encoded_diagram = ERB::Util.url_encode diagram_content
|
47
49
|
encoded_diagram_name = ERB::Util.url_encode diagram_name
|
48
50
|
|
49
|
-
puts "Parsed diagram: name=#{
|
51
|
+
puts "Parsed diagram: name=#{diagram_name} length=#{diagram_content.length} height=#{@diagram_height}"
|
50
52
|
|
51
53
|
viewer_url_base = "https://viewer.diagrams.net/?highlight=0000ff&edit=_blank&layers=1&nav=1"
|
52
|
-
|
53
|
-
viewer_style = "style=\"width:100%;height:#{
|
54
|
+
viewer_url = "#{viewer_url_base}&title=#{encoded_diagram_name}\#R#{encoded_diagram}"
|
55
|
+
viewer_style = "style=\"width:100%;height:#{@diagram_height}px\""
|
54
56
|
|
55
|
-
%Q{<iframe frameborder="0" #{
|
57
|
+
%Q{<iframe frameborder="0" #{viewer_style} src="#{viewer_url}"></iframe>}
|
56
58
|
end
|
57
59
|
|
58
|
-
Liquid::Template.register_tag
|
60
|
+
Liquid::Template.register_tag MODULE_TAG_NAME, self
|
59
61
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-drawio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Illia Gorbatiuk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-04-
|
11
|
+
date: 2023-04-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -30,28 +30,28 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '1.
|
33
|
+
version: '1.12'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '1.
|
40
|
+
version: '1.12'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: erb
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '2.2'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '2.2'
|
55
55
|
description:
|
56
56
|
email:
|
57
57
|
- ilya.gorbatiuk@gmail.com
|
@@ -82,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: '0'
|
84
84
|
requirements: []
|
85
|
-
rubygems_version: 3.
|
85
|
+
rubygems_version: 3.0.9
|
86
86
|
signing_key:
|
87
87
|
specification_version: 4
|
88
88
|
summary: Jekyll plugin to generate HTML snippets for embedding draw.io diagrams
|