jekyll-drawio 0.0.5 → 1.1.0

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: 6fbe444671f6cfd66efe7239cede4745a9b444ef7b03425ff24283d198dbb34a
4
- data.tar.gz: b8c9ce1eab7b0f9ed73253b45fe36680c0661f0a6a2406540ba76bb1a8985bad
3
+ metadata.gz: 62bdc02bcf3506343b120c054bfdf6662a4afc0234a504a22c18b90b75f7eb11
4
+ data.tar.gz: 536dd289302a471dac0601b518736a3ab8ca0c105bf5522b0bf46382a4c97386
5
5
  SHA512:
6
- metadata.gz: 54b62ade3690caecbe6825c8615822c9fe9d509ccb546167561ef89aa905550341d92d994433a52c0d618761ce4353051618e15a98e2128381fa577f36b055f1
7
- data.tar.gz: 6e5939e5b0b38ecd2b29ba4e34ab76889ba7010ad393189b04581444cfd60cf1c924e12a3024e5df7ca04d3633d2ce5a3a2775a232f5b167caa45d076cf303e4
6
+ metadata.gz: d9a38fae82bcac537cf5a9e2379270e1f18107024acf66ce6db81289e51eb192e35636f09e4acc539ce14c3e5632eb2785a183745592c7456f148b687ed6da6c
7
+ data.tar.gz: a845ed537bdf20b61e7e950d80672daf426bfa1e1172580ca0d260e23bacba4838ea22d8ce967fd9d386c4de36650dbd8e0f89c77f012c23447b8e27e894fcf4
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
- module DrawIO
3
- VERSION = "0.0.5"
4
- end
2
+ module DrawIO
3
+ VERSION = "1.1.0"
5
4
  end
5
+ end
data/lib/jekyll-drawio.rb CHANGED
@@ -1,22 +1,24 @@
1
1
  require "jekyll"
2
2
  require "jekyll-drawio/version"
3
- require 'nokogiri'
4
- require 'erb'
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
- @variables.each do |variable|
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,34 +26,36 @@ class DrawIOConverter < Liquid::Tag
24
26
  end
25
27
  end
26
28
 
27
- puts "path=\"#{ @path_to_diagram}\" page_num=#{ @selected_diagram_num }"
29
+ puts "path=\"#{@path_to_diagram}\" page_num=#{@selected_diagram_num}"
28
30
  end
29
31
 
30
- def extract_diagram(path, selected_diagram_num)
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 \"#{ path }\": #{ diagrams.length }. " \
34
- "Selected: #{ @selected_diagram_num }. " \
35
- "Height: #{ @diagram_height }"
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.content
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, @selected_diagram_num
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
 
51
+ puts "Parsed diagram: name=#{diagram_name} length=#{diagram_content.length} height=#{@diagram_height}"
52
+
49
53
  viewer_url_base = "https://viewer.diagrams.net/?highlight=0000ff&edit=_blank&layers=1&nav=1"
50
- viewer_url = "#{ viewer_url_base }&title=#{ encoded_diagram_name }\#R#{ encoded_diagram }"
51
- viewer_style = "style=\"width:100%;height:#{ @diagram_height }px\""
54
+ viewer_url = "#{viewer_url_base}&title=#{encoded_diagram_name}\#R#{encoded_diagram}"
55
+ viewer_style = "style=\"width:100%;height:#{@diagram_height}px\""
52
56
 
53
- %Q{<iframe frameborder="0" #{ viewer_style } src="#{ viewer_url }"></iframe>}
57
+ %Q{<iframe frameborder="0" #{viewer_style} src="#{viewer_url}"></iframe>}
54
58
  end
55
59
 
56
- Liquid::Template.register_tag "drawio", self
60
+ Liquid::Template.register_tag MODULE_TAG_NAME, self
57
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: 0.0.5
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: 2020-10-26 00:00:00.000000000 Z
11
+ date: 2023-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '3.9'
19
+ version: '4.3'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '3.9'
26
+ version: '4.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: nokogiri
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.10'
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.10'
40
+ version: '1.12'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: erb
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -82,8 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
82
82
  - !ruby/object:Gem::Version
83
83
  version: '0'
84
84
  requirements: []
85
- rubyforge_project:
86
- rubygems_version: 2.7.6
85
+ rubygems_version: 3.0.9
87
86
  signing_key:
88
87
  specification_version: 4
89
88
  summary: Jekyll plugin to generate HTML snippets for embedding draw.io diagrams