jekyll-mscgen 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +16 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +50 -0
- data/Rakefile +1 -0
- data/doc/samplemsc.png +0 -0
- data/jekyll-mscgen.gemspec +25 -0
- data/lib/jekyll-mscgen.rb +58 -0
- data/lib/jekyll-mscgen/version.rb +5 -0
- metadata +107 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Wiktor Macura
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# jekyll-mscgen
|
2
|
+
|
3
|
+
A Jekyll plugin for generating message sequence charts using the `mscgen`
|
4
|
+
tool.
|
5
|
+
|
6
|
+
## Usage
|
7
|
+
You need to have `mscgen` installed (it's available through homebrew).
|
8
|
+
|
9
|
+
Expose the mscgen plugin to jekyll through a `_plugins/gems.rb` type file:
|
10
|
+
|
11
|
+
require 'jekyll-mscgen'
|
12
|
+
|
13
|
+
Then you can create a chart as so:
|
14
|
+
|
15
|
+
{% mscgen %}
|
16
|
+
hscale = "0.7";
|
17
|
+
# arcgradient = "2";
|
18
|
+
|
19
|
+
swap1,host1,host2,swap2;
|
20
|
+
|||;
|
21
|
+
|
22
|
+
# proposal
|
23
|
+
--- [ label=" attempt swap " ];
|
24
|
+
|
25
|
+
swap1->host1 [ label="propose swap1" ];
|
26
|
+
swap1<-host1 [ label="ok" ];
|
27
|
+
|
28
|
+
# ...
|
29
|
+
{% endmscgen %}
|
30
|
+
|
31
|
+
Generally you want to use CSS to add some styling, for example:
|
32
|
+
|
33
|
+
svg {
|
34
|
+
line {
|
35
|
+
color: #333;
|
36
|
+
}
|
37
|
+
}
|
38
|
+
|
39
|
+
But expand as you wish:
|
40
|
+
|
41
|
+
![Image](https://raw.github.com/wkm/jekyll-mscgen/master/doc/samplemsc.png)
|
42
|
+
|
43
|
+
|
44
|
+
## Contributing
|
45
|
+
|
46
|
+
1. Fork it
|
47
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
48
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
49
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
50
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/doc/samplemsc.png
ADDED
Binary file
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'jekyll-mscgen/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "jekyll-mscgen"
|
8
|
+
spec.version = Jekyll::Mscgen::VERSION
|
9
|
+
spec.authors = ["Wiktor Macura"]
|
10
|
+
spec.email = ["wmacura@gmail.com"]
|
11
|
+
spec.description = %q{mscgen integration for jekyll to make message sequence charts}
|
12
|
+
spec.summary = %q{mscgen integration for jekyll to make message sequence charts}
|
13
|
+
spec.homepage = "http://github.com/wkm/jekyll-mscgen"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
|
24
|
+
spec.add_runtime_dependency "jekyll"
|
25
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'liquid'
|
2
|
+
require 'jekyll-mscgen/version'
|
3
|
+
require 'open3'
|
4
|
+
require 'cgi'
|
5
|
+
|
6
|
+
module Jekyll
|
7
|
+
# defaults which get stripped out
|
8
|
+
class MscgenBlock < Liquid::Block
|
9
|
+
def initialize(tag_name, text, tokens)
|
10
|
+
super
|
11
|
+
end
|
12
|
+
|
13
|
+
# remove basic styling from output
|
14
|
+
def purify(output)
|
15
|
+
[
|
16
|
+
'stroke="black"', 'font-family="Helvetica"', 'font-size="12"',
|
17
|
+
/textLength="\d+"/
|
18
|
+
].each do |pattern|
|
19
|
+
output.gsub! pattern, ''
|
20
|
+
end
|
21
|
+
|
22
|
+
output
|
23
|
+
end
|
24
|
+
|
25
|
+
def render(context)
|
26
|
+
@text = @nodelist.join('')
|
27
|
+
@text = "msc {\n #{@text} \n}"
|
28
|
+
|
29
|
+
Open3.popen3('mscgen -i- -o- -T svg') do |stdin,out,err|
|
30
|
+
begin
|
31
|
+
stdin.puts(@text)
|
32
|
+
stdin.close
|
33
|
+
rescue Error
|
34
|
+
puts 'error generating mscgen chart'
|
35
|
+
|
36
|
+
ensure
|
37
|
+
errors = err.read.strip
|
38
|
+
output = out.read.strip
|
39
|
+
if errors != "" and errors != nil
|
40
|
+
puts "mscgen error: #{errors}"
|
41
|
+
errors = "<div style='color: red; background: \#ffeeee;'>#{CGI.escapeHTML(errors)}</div>"
|
42
|
+
if output != nil
|
43
|
+
output = CGI.escapeHTML(output)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
output = output.lines.drop(2).join('')
|
48
|
+
output = purify(output)
|
49
|
+
|
50
|
+
return "<div class='mscgen-chart'>#{errors}#{output}</div>"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
Liquid::Template.register_tag('mscgen', Jekyll::MscgenBlock)
|
metadata
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll-mscgen
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
version: 0.1.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Wiktor Macura
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2013-06-17 00:00:00 -04:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: bundler
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ~>
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 1
|
29
|
+
- 3
|
30
|
+
version: "1.3"
|
31
|
+
type: :development
|
32
|
+
version_requirements: *id001
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: rake
|
35
|
+
prerelease: false
|
36
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
segments:
|
41
|
+
- 0
|
42
|
+
version: "0"
|
43
|
+
type: :development
|
44
|
+
version_requirements: *id002
|
45
|
+
- !ruby/object:Gem::Dependency
|
46
|
+
name: jekyll
|
47
|
+
prerelease: false
|
48
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
segments:
|
53
|
+
- 0
|
54
|
+
version: "0"
|
55
|
+
type: :runtime
|
56
|
+
version_requirements: *id003
|
57
|
+
description: mscgen integration for jekyll to make message sequence charts
|
58
|
+
email:
|
59
|
+
- wmacura@gmail.com
|
60
|
+
executables: []
|
61
|
+
|
62
|
+
extensions: []
|
63
|
+
|
64
|
+
extra_rdoc_files: []
|
65
|
+
|
66
|
+
files:
|
67
|
+
- .gitignore
|
68
|
+
- Gemfile
|
69
|
+
- LICENSE.txt
|
70
|
+
- README.md
|
71
|
+
- Rakefile
|
72
|
+
- doc/samplemsc.png
|
73
|
+
- jekyll-mscgen.gemspec
|
74
|
+
- lib/jekyll-mscgen.rb
|
75
|
+
- lib/jekyll-mscgen/version.rb
|
76
|
+
has_rdoc: true
|
77
|
+
homepage: http://github.com/wkm/jekyll-mscgen
|
78
|
+
licenses:
|
79
|
+
- MIT
|
80
|
+
post_install_message:
|
81
|
+
rdoc_options: []
|
82
|
+
|
83
|
+
require_paths:
|
84
|
+
- lib
|
85
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
segments:
|
90
|
+
- 0
|
91
|
+
version: "0"
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
segments:
|
97
|
+
- 0
|
98
|
+
version: "0"
|
99
|
+
requirements: []
|
100
|
+
|
101
|
+
rubyforge_project:
|
102
|
+
rubygems_version: 1.3.6
|
103
|
+
signing_key:
|
104
|
+
specification_version: 3
|
105
|
+
summary: mscgen integration for jekyll to make message sequence charts
|
106
|
+
test_files: []
|
107
|
+
|