====== Ditaa-Plugin ======
---- plugin ----
description: Converts ascii-Flowcharts to png-Graphics using ditaa
author : Dennis Ploeger
email : develop@dieploegers.de
type : syntax
lastupdate : 2006-01-18
compatible : devel > 2005-09-22
depends :
conflicts :
similar : Graphviz
tags : flowcharts, graph, vizualisation
----
See [[http://ditaa.sourceforge.net/|ditaa]] for details.
===== Installation =====
You can use the plugin-manager to install this plugin. Use: [[http://www.dieploegers.de/files/plugin-ditaa.zip]].
===== Installation for Windows =====
Since there are some problems with the plugin-manager and getting this to work for Windows (and IIS), do the following:
* Download the file, and unzip it to the directory ''dokuwik\lib\plugins\ditaa'' (this directory contains the files ''ditaa.jar'' and ''syntax.php'' and the directory ''ditaa''.
* Ensure the users IUSR_xxxx and IWAM_xxxx have write permissions on the directory ''dokuwiki\lib\plugins'' (and below)
* Open the file ''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''
* Ensue the users IUSR_xxxx and IWAM_xxxx have Modify permissions on the temp directory (specified above)
===== Syntax =====
{width= height=}>
... (some ditaa-code) ...
===== Example =====
This ascii-art:
+--------+ /--------\
| Test +---->| Test 2 |
+--------+ \--------/
would produce this nice picture:
{{http://www.dieploegers.de/files/ditaa_example.png}}
===== Pros =====
* The flowcharts are in the version history of dokuwiki. You can switch back to older versions of flowcharts
* Generation on the fly - no load of old files lying around on your server.
===== Cons =====
* As ditaa is a java-program, you'll have to install java on your server. (so that java -jar ditaa.jar can be executed)
===== Plugin =====
When not using the plugin manager, download the zip-file and unzip it in your plugins-directory and everything should work.
====== Discussion ======
* I currently have the problem, that the pages are cached and not re-rendered when switching to an old version. Does somebody know, if I can say, that a page must not be cached when the ditaa-plugin is used in it? //[[develop@dieploegers.de|Dennis Ploeger]] 2005-12-15 13:14//
* ... and have it no more. I use the internalmedia-function now instead of directly putting img-tags out. If you've already downloaded it, download it again! I've also corrected a bug where the temporary files weren't removed. ;-) //[[develop@dieploegers.de|Dennis Ploeger]] 2005-12-15 13:59//
* And one more little bugfix where I replaced a "::" with a ":" in the internalmedia-call //[[develop@dieploegers.de|Dennis Ploeger]] 2005-12-15 14:23//
* Some people are reporting problems when installing ditaa on a headless Linux-server (a server without an X-Display installed). It seems to be a recommendation to install the basic X-Libraries and Sun's current JRE. If that doesn't help, try to exchange the line starting ditaa from 'java -jar ditaa' with 'java -jar -Djava.awt.headless=true ditaa'. But this needs the Sun JRE! Thanks to Stein Bjorndal for that. Stathis Sideris, the developer of ditaa is currently looking for the problem, too. //[[develop@dieploegers.de|Dennis Ploeger]] 2005-12-20 09:12//
* I have some trouble when there are nested namespaces. Ditaa creates a media directory using a colon between the namespaces, rather than splitting the namespaces and createing the directory tree. I have a 'People' namespace, and each person creates their own personal namespace (so they can control ACLs) under 'People'. This creates a People:user:* namespace, but the ditaa media are put in data/media/People:user/ rather than /data/media/People/user/ //[[dshackel@arbor.edu | Daniel Shackelford]] 2006-01-17 10:16//
* I have changed some parts of the plugin to speed things up. You can find the changed version [[http://christoph-mertins.de/blog/wp-trackback.php?p=4|here]] // [[c.mertins@gmail.com|Christoph Mertins]] 2006-01-18 08:53 //
* I have updated the plugin with Christoph's additions, that I find quite brilliant (especially the md5-work!). The new version should also fix the thing, Daniel mentioned. Thanks to you all. // [[develop@dieploegers.de|Dennis Ploeger]] 2006-01-18 10:39 //
* Hello, plugin ditaa don't work for me. My hoster has some limitation and I got the following error: //
exec() has been disabled for security reasons in .... ditaa/syntax.php on line 231. //
Do you have an idea how to enable exec()?
* Having some problems....
---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.
* I have updated the plugin to keep //ditaa// images in its own subfolder of the namespace. Here is the patch: \\ This patch will force //ditaa_plugin// to keep all generated image files in its own subfolder of a namespace. Just to keep things organized. \\
--- 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@seidlitz.ca|Alex]] 2006-08-17 17:09 //
* Here are some little additions such that the plugin determines its paths by itself. Also ''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.='DITAA GRAPH: 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.com|Michael Pillwax - PILLWAX Industrial Solutions Consulting]] 2006-11-13 //
----
* hi dennis and all: thankyou for your time. i am familiar with wiki and familiar with installing plugins. this one has me stumped.
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 [[wp>Kingsmill (surname)]] and see example plugin wish [[http://forum.dokuwiki.org/post/7493;?unb855sess=36c44ffe927678169936e745af28ede5|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
http://xxxx.com/xxxx/doku.php
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;
}
----