jekyll-plantuml-url 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 704560f8d6bdb811e639567dc5f3ab37c698e90f
4
+ data.tar.gz: 215487c4f41a3708423961be71751a4f850113ca
5
+ SHA512:
6
+ metadata.gz: 8f3fa6599ff1ab107155ada87c30d23c24b065c7ce37654188e18e0ac0141fe98f0793d8a8e94a6dc912b36618c94a7bb13f357eea6ce3e7d424ae6aebd4ae8b
7
+ data.tar.gz: 45fbda79d8d3888c708cc2f554c067c2ebae3922c84679b768449e9194f8593cf7cfbee0e521694160038c9d7ec2784dc7595e7d38aaa080156c7b641e1d82f2
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ Gemfile.lock
2
+ *.gem
3
+ .bundle/
4
+ .DS_Store
data/.gitlab-ci.yml ADDED
@@ -0,0 +1,51 @@
1
+ image: "ruby:2.3"
2
+
3
+ stages:
4
+ - build
5
+ - staging
6
+ - production
7
+
8
+ Buid:
9
+ stage: build
10
+ script:
11
+ - bundle install
12
+ - rake set_git_tag
13
+ - rake
14
+ - gem build jekyll-plantuml-url.gemspec
15
+ artifacts:
16
+ paths:
17
+ - ./*.gem
18
+ expire_in: 1 week
19
+ tags:
20
+ - docker
21
+
22
+ Release_Staging:
23
+ stage: staging
24
+ script:
25
+ - ls -la
26
+ # - deployctl release .... need to build the website for release, who? deployd ?
27
+ artifacts:
28
+ paths:
29
+ - ./*.gem
30
+ only:
31
+ - tags
32
+ except:
33
+ - branches
34
+ tags:
35
+ - docker
36
+
37
+ Release_Production:
38
+ stage: production
39
+ environment: production
40
+ script:
41
+ - ls -la
42
+ - gem push *.gem -k $GEM_API_PUSH
43
+ only:
44
+ - tags
45
+ except:
46
+ - branches
47
+ tags:
48
+ - docker
49
+ when: manual
50
+
51
+
data/.pdd ADDED
@@ -0,0 +1,7 @@
1
+ --source=.
2
+ --verbose
3
+ --exclude target/**/*
4
+ --exclude src/main/resources/images/**/*
5
+ --rule min-words:20
6
+ --rule min-estimate:15
7
+ --rule max-estimate:90
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
3
+
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2017 dgoo2308 @ GiOXA Ltd.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the 'Software'), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,66 @@
1
+ [![Gem Version](https://badge.fury.io/rb/jekyll-plantuml-url.svg)](http://badge.fury.io/rb/jekyll-plantuml-url)
2
+
3
+ A plugin for jekyll to use plantuml diagram inside your Jekyll for you website.
4
+
5
+ This will use external resource to build plantuml diagram.
6
+
7
+ Once created, the diagram is store on the filesystem to prevent any unnecessary diagram generation. So, using this plugin, provide a simple way to integrate plantuml diagramm without the Graphiz software or the using the plantuml jar file.
8
+
9
+ ## Install Jekyll plugin
10
+
11
+ Install it first:
12
+
13
+ ```
14
+ gem install jekyll-plantuml-url
15
+ ```
16
+
17
+ With Jekyll 2, simply add the gem to your `_config.yml` gems list:
18
+
19
+ ```yaml
20
+ gems:
21
+ - 'jekyll-plantuml-url'
22
+ - ...
23
+ ```
24
+
25
+ Or for previous versions,
26
+ create a plugin file within your Jekyll project's `_plugins` directory:
27
+
28
+ ```ruby
29
+ # _plugins/plantuml-plugin.rb
30
+
31
+ require "jekyll-plantuml-url"
32
+ ```
33
+
34
+ Highly recommend to use Bundler. If you're using it, add this line
35
+ to your `Gemfile`:
36
+
37
+ ```
38
+ gem "jekyll-plantuml-url"
39
+ ```
40
+
41
+ ## choose a PlantUML-Server
42
+
43
+ Checkout [PlantUML-Server](https://github.com/plantuml/plantuml-server) to install your own plantUML server or use http://www.plantuml.com/plantuml.
44
+
45
+ and setup the `_config.yml`
46
+
47
+ ```yaml
48
+ Plantuml:
49
+ url: 'http://www.plantuml.com/plantuml/'
50
+ type: 'svg'
51
+ ssl_noverify: '0'
52
+ http_debug: '0'
53
+ ```
54
+
55
+ If above settings are not defined, the above values are the default settings.
56
+
57
+ ## Test
58
+
59
+ Now, it's time to create a diagram, in your Jekyll blog page:
60
+
61
+ ```
62
+ {% plantuml %}
63
+ [First] - [Second]
64
+ {% endplantuml %}
65
+ ```
66
+
data/Rakefile ADDED
@@ -0,0 +1,62 @@
1
+ # (The MIT License)
2
+ #
3
+ # Copyright (c) 2014-2017 Danny Goossen GiOxa Ltd.
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the 'Software'), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
22
+
23
+ require 'rubygems'
24
+ require 'rake'
25
+ require 'rdoc'
26
+ require 'rake/clean'
27
+
28
+ def name
29
+ @name ||= File.basename(Dir['*.gemspec'].first, '.*')
30
+ end
31
+
32
+ def version
33
+ Gem::Specification.load(Dir['*.gemspec'].first).version
34
+ end
35
+
36
+
37
+ task default: [:clean]
38
+
39
+ require 'rdoc/task'
40
+ desc 'Build RDoc documentation'
41
+ Rake::RDocTask.new do |rdoc|
42
+ rdoc.rdoc_dir = 'rdoc'
43
+ rdoc.title = "#{name} #{version}"
44
+ rdoc.rdoc_files.include('README*')
45
+ rdoc.rdoc_files.include('lib/**/*.rb')
46
+ end
47
+
48
+ task set_git_tag: [:tagit]
49
+ desc 'Set git tag as version'
50
+ task :tagit do
51
+ f = open("|git describe --always --tags")
52
+ git_version = f.read()
53
+ git_version = git_version.chomp
54
+ git_version = git_version.gsub('-', '.')
55
+
56
+ puts " Version: #{git_version}"
57
+ version_file=Dir['lib/version.rb'].first
58
+ puts version_file
59
+ fh = File.open(version_file, 'w')
60
+ fh.puts "module PlantUML\nVERSION = \'#{git_version}\'\nend\n"
61
+ fh.close
62
+ end
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+
3
+ lib = File.expand_path('../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'version'
6
+
7
+ Gem::Specification.new do |s|
8
+ s.specification_version = 2 if s.respond_to? :specification_version=
9
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
10
+ s.rubygems_version = '2.2.2'
11
+ s.required_ruby_version = '>= 1.9.3'
12
+ s.name = 'jekyll-plantuml-url'
13
+ s.version = PlantUML::VERSION
14
+ s.license = 'MIT'
15
+ s.summary = "Jekyll PlantUML url Automation"
16
+ s.description = "PlantUML diagrams in Jekyll pages from plantUML-url"
17
+ s.authors = ["dgoo2308"]
18
+ s.email = 'danny@gioxa.com'
19
+ s.homepage = 'https://gitlab.com/dgoo2308/jekyll-plantuml-url'
20
+ s.files = `git ls-files`.split($/)
21
+ s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
22
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
23
+ s.rdoc_options = ["--charset=UTF-8"]
24
+ s.extra_rdoc_files = %w[README.md LICENSE.txt]
25
+ s.add_runtime_dependency('jekyll', '>2.0')
26
+ s.add_development_dependency('rake', ["~> 0"])
27
+ end
@@ -0,0 +1,134 @@
1
+ # (The MIT License)
2
+ #
3
+ # Copyright (c) 2014-2017 Yegor Bugayenko
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the 'Software'), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
22
+
23
+ require 'digest'
24
+ require 'fileutils'
25
+ require 'net/http'
26
+ require 'uri'
27
+ require 'openssl'
28
+ require 'open-uri'
29
+
30
+ module Jekyll
31
+ class PlantumlBlock < Liquid::Block
32
+ def initialize(tag_name, markup, tokens)
33
+ super
34
+ @html = (markup or '').strip
35
+ end
36
+
37
+ def render(context)
38
+ site = context.registers[:site]
39
+ name = Digest::MD5.hexdigest(super)
40
+ if site.config['plantuml']
41
+ uml_config=site.config['plantuml']
42
+ else
43
+ puts "** No configuration for plantuml in present in _config.yml, using default"
44
+ uml_config={
45
+ 'type' => 'svg',
46
+ 'url' => 'http://www.plantuml.com/plantuml',
47
+ 'ssl_noverify' => '0',
48
+ 'http_debug' => '0'
49
+ }
50
+ end
51
+ if uml_config['type'] == ""
52
+ uml_type="svg"
53
+ else
54
+ uml_type=uml_config['type']
55
+ end
56
+ if !File.exists?(File.join(site.dest, "uml/#{name}.#{uml_type}"))
57
+ uml_out_file = File.join(site.source, "uml/#{name}.#{uml_type}")
58
+ if File.exists?(uml_out_file)
59
+ puts "File #{uml_out_file} already exists (#{File.size(uml_out_file)} bytes)"
60
+ else
61
+ if uml_config['url'] == ""
62
+ uml_url="http://www.plantuml.com/plantuml"
63
+ puts "using default url: #{uml_url}"
64
+ else
65
+ uml_url=uml_config['url']
66
+ puts "using config url: #{uml_url}"
67
+ end
68
+ uri = URI.parse(uml_url)
69
+ http = Net::HTTP.new(uri.host, uri.port)
70
+ if uri.scheme == "https"
71
+ http.use_ssl = true
72
+ if uml_config['ssl_noverify'] == "1"
73
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
74
+ end
75
+ end
76
+ if uml_config['http_debug'] == "1"
77
+ puts "*** http debug on ***"
78
+ http.set_debug_output $stderr
79
+ end
80
+
81
+ request = Net::HTTP::Post.new("#{uri.path}/form")
82
+ request.add_field('Content-Type', 'application/x-www-form-urlencoded')
83
+ request.body = "text=" + URI::encode("@startuml\n"+super+"\n@enduml\n".force_encoding('ASCII-8BIT'))
84
+ response = http.request(request)
85
+
86
+ if response.code == "302" or response.code == "301"
87
+ # expected redirect of 302 with a new url with code-hash
88
+ newlocation=response["Location"]
89
+ newlocation["/uml/"]= "/#{uml_type}/"
90
+ begin # loop for 301 and 302 of the code request
91
+ newuri = URI.parse(newlocation)
92
+ if newuri.host != uri.host or newuri.port != uri.port or newuri.scheme != uri.scheme
93
+ http = Net::HTTP.new(newuri.host, newuri.port)
94
+ if newuri.scheme == "https"
95
+ http.use_ssl = true
96
+ if uml_config['ssl_noverify'] == "1"
97
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
98
+ end
99
+ end
100
+ if uml_config['http_debug'] == "1"
101
+ puts "*** http debug on ***"
102
+ http.set_debug_output $stderr
103
+ end
104
+ end
105
+ request_img = Net::HTTP::Get.new(newuri.path)
106
+ response_img = http.request(request_img)
107
+ if response_img.code == "200"
108
+ #puts response_img.body
109
+ FileUtils.mkdir_p(File.dirname(uml_out_file))
110
+ File.open(uml_out_file, 'w') { |f|
111
+ f.write(response_img.body)
112
+ }
113
+ site.static_files << Jekyll::StaticFile.new( site, site.source, 'uml', "#{name}.#{uml_type}")
114
+ puts "File #{uml_out_file} created (#{File.size(uml_out_file)} bytes)"
115
+ elsif response_img.code == "302" or response_img.code == "301"
116
+ # not expected www.plantuml.com redirect to plantuml.com, what a waste of time
117
+ # it is what it is
118
+ newlocation=response_img["Location"]
119
+ else
120
+ puts "error #{response_img.code} getting #{uri.host}#{request_img}"
121
+ end
122
+ end while response_img.code == "302" or response_img.code == "301"
123
+ else
124
+ puts "Error #{response.code} getting #{uri.host}/plantuml/form "
125
+ end
126
+ end
127
+ end
128
+ "<p><img src='/uml/#{name}.#{uml_type}' #{@html}
129
+ alt='PlantUML #{uml_type} diagram' class='plantuml'/></p>"
130
+ end
131
+ end
132
+ end
133
+
134
+ Liquid::Template.register_tag('plantuml', Jekyll::PlantumlBlock)
data/lib/version.rb ADDED
@@ -0,0 +1,3 @@
1
+ module PlantUML
2
+ VERSION = '0.1.0'
3
+ end
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-plantuml-url
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - dgoo2308
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-02-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: jekyll
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>'
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>'
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: PlantUML diagrams in Jekyll pages from plantUML-url
42
+ email: danny@gioxa.com
43
+ executables: []
44
+ extensions: []
45
+ extra_rdoc_files:
46
+ - README.md
47
+ - LICENSE.txt
48
+ files:
49
+ - .gitignore
50
+ - .gitlab-ci.yml
51
+ - .pdd
52
+ - Gemfile
53
+ - LICENSE.txt
54
+ - README.md
55
+ - Rakefile
56
+ - jekyll-plantuml-url.gemspec
57
+ - lib/jekyll-plantuml-url.rb
58
+ - lib/version.rb
59
+ homepage: https://gitlab.com/dgoo2308/jekyll-plantuml-url
60
+ licenses:
61
+ - MIT
62
+ metadata: {}
63
+ post_install_message:
64
+ rdoc_options:
65
+ - --charset=UTF-8
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - '>='
71
+ - !ruby/object:Gem::Version
72
+ version: 1.9.3
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ requirements: []
79
+ rubyforge_project:
80
+ rubygems_version: 2.0.14
81
+ signing_key:
82
+ specification_version: 2
83
+ summary: Jekyll PlantUML url Automation
84
+ test_files: []