Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
Conflicts:
	dist/mermaid.full.js
	dist/mermaid.full.min.js
	dist/mermaid.slim.js
	dist/mermaid.slim.min.js
	src/diagrams/gantt/ganttRenderer.js
	test/gantt.html
  • Loading branch information
knsv committed May 9, 2015
2 parents 824a43f + 82dffe0 commit 9face45
Show file tree
Hide file tree
Showing 11 changed files with 92 additions and 193 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -383,5 +383,4 @@
## [0.1.0](https://github.com/knsv/mermaid/tree/0.1.0) (2014-11-16)



\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
1 change: 1 addition & 0 deletions dist/mermaid.forest.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
.mermaid .label {
color: #333333;
}

.node rect,
.node circle,
.node polygon {
Expand Down
10 changes: 9 additions & 1 deletion lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ function cli(options) {
, verbose: 'v'
, phantomPath: 'e'
, sequenceConfig: 'c'
, ganttConfig: 'g'
, css: 't'
}
, 'boolean': ['help', 'png', 'svg']
Expand All @@ -45,6 +46,7 @@ function cli(options) {
, " -e --phantomPath Specify the path to the phantomjs executable"
, " -t --css Specify the path to a CSS file to be included when processing output"
, " -c --sequenceConfig Specify the path to the file with the configuration to be applied in the sequence diagram"
, " -g --ganttConfig Specify the path to the file with the configuration to be applied in the gantt diagram"
, " -h --help Show this message"
, " -v --verbose Show logging"
, " --version Print version and quit"
Expand Down Expand Up @@ -74,7 +76,7 @@ cli.prototype.parse = function(argv, next) {
}

// ensure that parameter-expecting options have parameters
;['outputDir', 'phantomPath', 'sequenceConfig', 'css'].forEach(function(i) {
;['outputDir', 'phantomPath', 'sequenceConfig', 'ganttConfig', 'css'].forEach(function(i) {
if(typeof options[i] !== 'undefined') {
if (typeof options[i] !== 'string' || options[i].length < 1) {
this.errors.push(new Error(i + " expects a value."))
Expand All @@ -94,6 +96,12 @@ cli.prototype.parse = function(argv, next) {
options.sequenceConfig = checkConfig(options.sequenceConfig)
}


if (options.ganttConfig) {
options.ganttConfig = checkConfig(options.ganttConfig)
console.log('Got conf'+options.ganttConfig);
}

if (options.css) {
try {
options.css = fs.readFileSync(options.css, 'utf8')
Expand Down
1 change: 1 addition & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ function processMermaid(files, _options, _next) {
, options.svg
, options.css || ''
, options.sequenceConfig
, options.ganttConfig
, options.verbose
]

Expand Down
27 changes: 23 additions & 4 deletions lib/phantomscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,24 @@ var system = require('system')
, fs = require('fs')
, webpage = require('webpage')


var page = webpage.create()
, files = phantom.args.slice(6, phantom.args.length)
, files = phantom.args.slice(7, phantom.args.length)
, options = {
outputDir: phantom.args[0]
, png: phantom.args[1] === 'true' ? true : false
, svg: phantom.args[2] === 'true' ? true : false
, css: phantom.args[3] !== '' ? phantom.args[3] : '* { margin: 0; padding: 0; }'
, sequenceConfig: phantom.args[4]
, verbose: phantom.args[5] === 'true' ? true : false
, ganttConfig: phantom.args[5]
, verbose: phantom.args[6] === 'true' ? true : false
}
, log = logger(options.verbose)


console.log('options');
console.log(options.ganttConfig);

page.content = [
'<html>'
, '<head>'
Expand Down Expand Up @@ -68,8 +74,9 @@ files.forEach(function(file) {
// look like it. we need to serialize then unserialize the svgContent that's
// taken from the DOM
svgContent = page.evaluate(executeInPage, {
contents: contents,
sequenceConfig: options.sequenceConfig
contents : contents,
ganttConfig : options.ganttConfig,
sequenceConfig : options.sequenceConfig
})
oDOM = oParser.parseFromString(svgContent, "text/xml")

Expand Down Expand Up @@ -193,6 +200,7 @@ function executeInPage(data) {
var xmlSerializer = new XMLSerializer()
, contents = data.contents
, sequenceConfig = data.sequenceConfig
, ganttConfig = data.ganttConfig
, toRemove
, el
, elContent
Expand Down Expand Up @@ -221,6 +229,17 @@ function executeInPage(data) {
document.body.appendChild(sc)
}

if(typeof ganttConfig !== undefined && ganttConfig !== 'undefined'){
console.log('Got ganttConfig');
sc = document.createElement("script")
scContent = document.createTextNode('mermaid.ganttConfig = JSON.parse(' + JSON.stringify(ganttConfig) + ');')
sc.appendChild(scContent)

document.body.appendChild(sc)
}else{
console.log('No gantt config');
}

mermaid.init();

svg = document.querySelector('svg')
Expand Down
2 changes: 1 addition & 1 deletion src/diagrams/gantt/ganttRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ module.exports.draw = function (text, id) {
var h = taskArray.length * (conf.barHeight + conf.barGap) + 2 * conf.topPadding;

elem.style.height = h + 'px';
elem.height = h;
elem.setAttribute('height', h);
var svg = d3.select('#' + id);

// http://codepen.io/anon/pen/azLvWR
Expand Down
51 changes: 27 additions & 24 deletions src/diagrams/sequenceDiagram/sequenceDb.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
/**
* Created by knut on 14-11-19.
*/
var actors = {};
var actors = {};
var actorKeys = [];
var messages = [];
var notes = [];
var messages = [];
var notes = [];

exports.addActor = function(id,name,description){
//console.log('Adding actor: '+id);
actors[id] = {name:name, description:description};
Expand All @@ -16,6 +17,9 @@ exports.addMessage = function(idFrom, idTo, message, answer){
messages.push({from:idFrom, to:idTo, message:message, answer:answer});
};

/**
*
*/
exports.addSignal = function(idFrom, idTo, message, messageType){
//console.log('Adding message from='+idFrom+' to='+idTo+' message='+message+' answer='+answer);
messages.push({from:idFrom, to:idTo, message:message, type:messageType});
Expand All @@ -36,37 +40,36 @@ exports.getActorKeys = function(){
};

exports.clear = function(){
actors = {};
actors = {};
messages = [];
};

exports.LINETYPE = {
SOLID : 0,
DOTTED : 1,
NOTE : 2,
SOLID_CROSS : 3,
DOTTED_CROSS: 4,
SOLID_OPEN : 5,
DOTTED_OPEN : 6,
LOOP_START : 10,
LOOP_END : 11,
ALT_START : 12,
ALT_ELSE : 13,
ALT_END : 14,
OPT_START : 15,
OPT_END : 16

SOLID : 0 ,
DOTTED : 1 ,
NOTE : 2 ,
SOLID_CROSS : 3 ,
DOTTED_CROSS : 4 ,
SOLID_OPEN : 5 ,
DOTTED_OPEN : 6 ,
LOOP_START : 10 ,
LOOP_END : 11 ,
ALT_START : 12 ,
ALT_ELSE : 13 ,
ALT_END : 14 ,
OPT_START : 15 ,
OPT_END : 16
};

exports.ARROWTYPE = {
FILLED : 0,
OPEN : 1
FILLED : 0,
OPEN : 1
};

exports.PLACEMENT = {
LEFTOF : 0,
RIGHTOF : 1,
OVER : 2
LEFTOF : 0,
RIGHTOF : 1,
OVER : 2
};

exports.addNote = function (actor, placement, message){
Expand Down
18 changes: 9 additions & 9 deletions src/diagrams/sequenceDiagram/svgDraw.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,15 +217,15 @@ exports.getTextObj = function(){

exports.getNoteRect = function(){
var rect = {
x: 0,
y: 0,
fill: '#EDF2AE',
stroke: '#666',
width: 100,
anchor:'start',
height: 100,
rx: 0,
ry: 0
x : 0,
y : 0,
fill : '#EDF2AE',
stroke : '#666',
width : 100,
anchor : 'start',
height : 100,
rx : 0,
ry : 0
};
return rect;
};
22 changes: 13 additions & 9 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,21 +186,22 @@ var equals = function (val, variable){
};

global.mermaid = {
startOnLoad:true,
htmlLabels:true,
init:function(sequenceConfig, nodes){
startOnLoad: true,
htmlLabels: true,

init: function(sequenceConfig, nodes) {
init.apply(null, arguments);
},
version:function(){
version: function() {
return exports.version();
},
getParser:function(){
getParser: function() {
return flow.parser;
},
parse:function(text){
parse: function(text) {
return parse(text);
},
parseError:function(err,hash){
parseError: function(err, hash) {
console.log('Mermaid Syntax error:');
console.log(err);
}
Expand All @@ -222,12 +223,12 @@ exports.contentLoaded = function(){
if (typeof mermaid_config !== 'undefined') {
// Check if property startOnLoad is set
if (equals(true, mermaid_config.startOnLoad)) {
global.mermaid.init(mermaid.sequenceConfig);
global.mermaid.init();
}
}
else {
// No config found, do autostart in this simple case
global.mermaid.init(mermaid.sequenceConfig);
global.mermaid.init();
}
}

Expand All @@ -241,3 +242,6 @@ if(typeof document !== 'undefined'){
exports.contentLoaded();
}, false);
}

var apa = 1;
var bapselsin = 2;
4 changes: 3 additions & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ module.exports.cloneCssStyles = function(svg, classes){
catch(err) {
if(typeof console !== 'undefined'){
if(console.warn !== 'undefined'){
console.warn('Invalid CSS selector "' + rule.selectorText + '"', err);
if(rule !== 'undefined'){
console.warn('Invalid CSS selector "' + rule.selectorText + '"', err);
}
}
}
}
Expand Down
Loading

0 comments on commit 9face45

Please sign in to comment.