ditaa plugin by Dennis Ploeger
Converts ascii-Flowcharts to png-Graphics using ditaa
Last updated on 2006-01-18. Provides Syntax.
Compatible with DokuWiki devel > 2005-09-22.
Similar to graphviz.
See ditaa for details.
You can use the plugin-manager to install this plugin. Use: http://www.dieploegers.de/files/plugin-ditaa.zip.
Since there are some problems with the plugin-manager and getting this to work for Windows (and IIS), do the following:
dokuwik\lib\plugins\ditaa (this directory contains the files ditaa.jar and syntax.php and the directory ditaa.dokuwiki\lib\plugins (and below)dokuwik\lib\plugins\ditaa\syntax.php and modify the following variables to point to the right location:$pathToJava (where java.exe is located, I just specified java because it's located within my search path)$pathToDitaa (where ditaa.jar is located, something like dokuwik\lib\plugins\ditaa\ditaa.jar)$tempdir (for example %windir%\TEMP
<ditaa name=<name> {width=<width> height=<height>}>
... (some ditaa-code) ...
</ditaa>
This ascii-art:
<ditaa name=test> +--------+ /--------\ | Test +---->| Test 2 | +--------+ \--------/ </ditaa>
would produce this nice picture:
When not using the plugin manager, download the zip-file and unzip it in your plugins-directory and everything should work.
Do you have an idea how to enable exec()?
—ERROR CONVERTING DIAGRAM—
Checked command line for ditaa itself and it all works - it creates the .png file but cant get plugin to work. java -jar ditaa dit21.tmp.txt dit.png Windows 2003 and IIS
Its creating files in the temp dir
dit21.tmp - blank dit21.tmp.txt - contains correct syntax for ditta
changed permissions added the java path and also path to ditaa jar.
anything else I can check.
--- syntax_.php Wed Jan 18 10:37:32 2006 +++ syntax.php Thu Aug 17 17:02:12 2006 @@ -22,11 +22,13 @@ var $ditaa_data = ''; - var $pathToJava = "/opt/blackdown-jdk-1.4.2.02/bin/java"; + var $ditaa_subfolder = 'ditaa'; - var $pathToDitaa = "/var/www/sst.intern.editable/dokuwiki/htdocs/ditaa.jar"; + var $pathToJava = "c:\winnt\system32\java.exe"; - var $tempdir = "/tmp"; + var $pathToDitaa = "c:\apps\ditaa.jar"; + + var $tempdir = "c:\tmp"; /** * return some info @@ -222,6 +224,13 @@ mkdir($mediadir,0777); } + # to keep ditaa files in its own subfolder + $mediadir = $mediadir.'/'.$this->ditaa_subfolder; + if (!is_dir($mediadir)) { + umask(002); + mkdir($mediadir,0777); + } + $imagefile = $mediadir.'/ditaa_'.$this->ditaa_name.'_'.$md5.'.png'; if ( !file_exists($imagefile)) { @@ -264,7 +273,7 @@ $height = $this->ditaa_height; } - $renderer->doc .= $renderer->internalmedia($INFO['namespace'].':ditaa_'.$this->ditaa_name.'_'.$md5.'.png', $this->ditaa_name, NULL, $width, $height, false); + $renderer->doc .= $renderer->internalmedia($INFO['namespace'].':'.$this->ditaa_subfolder.':ditaa_'.$this->ditaa_name.'_'.$md5.'.png', $this->ditaa_name, NULL, $width, $height, false); return true;
Thanks. Alex 2006-08-17 17:09
java should always be in path from a correct Java installation. Those changes would allow updates without going back to change code manually after it (which is IMHO a bad thing as often forgotten where the plugin itself is very well capable to determine its own environment). Also the temp directory is kept within the plugins directory (requires creation) as the HTTP daemon has access to it for sure, whereas for other directories it is highly unsure that the set permissions allow R/W access to any other directory.Here are the code changes, the rest of the plugin remains unchanged:
class syntax_plugin_ditaa extends DokuWiki_Syntax_Plugin {
var $ditaa_name = '';
var $ditaa_width = -1;
var $ditaa_height = -1;
var $ditaa_data = '';
var $pathToJava = 'java';
var $pathToDitaa = 'ditaa.jar';
var $tempdir = 'temp';
/**
* Add path to some of the variables
*/
function syntax_plugin_ditaa() {
$this->pathToDitaa = realpath(dirname(__FILE__)).'/'.$this->pathToDitaa;
$this->tempdir = realpath(dirname(__FILE__)).'/'.$this->tempdir;
}
Additionally mkdir() is unable to create paths, only a directory subordinated to a existing one, so that code requires changes too. Plus if the path was unable to get created due to missing privileges, the conversion will be passed.
...
$md5 = md5_file($tempfile.'.txt');
$mediadir = $conf["mediadir"]."/".str_replace(":", "/",$INFO['namespace'] );
// Create path for media
if (!is_dir($mediadir)) {
$dirs = explode('/',$mediadir);
$dir='';
foreach ($dirs as $part) {
$dir.=$part.'/';
if ( !is_dir($dir) && (strlen($dir)>0) ) { mkdir($dir, 0770); }
}
}
// Check if the Media-Directory has been created
if (!is_dir($mediadir)) {
$renderer->doc.='<u>DITAA GRAPH:</u> Unable to create media location in ['.$mediadir.']. Check file system permissions.';
return true;
}
$imagefile = $mediadir.'/ditaa_'.$this->ditaa_name.'_'.$md5.'.png';
if ( !file_exists($imagefile)) {
...
Michael Pillwax - PILLWAX Industrial Solutions Consulting 2006-11-13
i am getting the error —ERROR CONVERTING DIAGRAM—
QUESTIONS about installation to get it working for me …
1 what java is required? any java.exe ?
2 where is the temp directory? i have spent much time looking for it … have given up .. please tell me
# $tempdir (for example %windir%\TEMP
3 where/how do i find the users as below
Ensure the users IUSR_xxxx and IWAM_xxxx have write permissions on the directory
OTHER QUESTIONS
1 would this plugin, in your opinion be the most suitable plugin for a family tree? for an example, see the second tree diagram Kingsmill (surname) and see example plugin wish dokuwiki plugin wish
2 is this plugin compatible with the latest version of dokuwiki?
3 is this plugin compatible with monobook theme?
QUESTION to get the plugin working for me
In the code below, is there anything which i need to change?
for example, in the code below, should i put my directory and if so, what would i put if my directory is
function syntax_plugin_ditaa() {
$this->pathToDitaa = realpath(dirname(__FILE__)).'/'.$this->pathToDitaa;
$this->tempdir = realpath(dirname(__FILE__)).'/'.$this->tempdir;
}
class syntax_plugin_ditaa extends DokuWiki_Syntax_Plugin {
var $ditaa_name = '';
var $ditaa_width = -1;
var $ditaa_height = -1;
var $ditaa_data = '';
var $pathToJava = 'java';
var $pathToDitaa = 'ditaa.jar';
var $tempdir = 'temp';
/**
* Add path to some of the variables
*/
function syntax_plugin_ditaa() {
$this->pathToDitaa = realpath(dirname(__FILE__)).'/'.$this->pathToDitaa;
$this->tempdir = realpath(dirname(__FILE__)).'/'.$this->tempdir;
}