Description
This parser allows you to embed Graphviz graph visualizations in your wiki pages.
Download
Version |
File |
Notes |
0.2.3 |
Fixed graph attachment detection where no dimension attributes are specified |
|
0.2.2 |
0.2.1 with Moin 1.9 request API fix |
|
0.2.1 |
0.2 with encoding and subprocess fixes |
|
0.2 |
Revised version with SVG support |
|
0.1 |
initial release |
Installation
Be sure to read the list of known bugs found in graphviz.py (or the known issues in README.txt) prior to installation.
Make sure Graphviz is installed and functional.
For the 0.2 and later releases, download the archive above and follow the instructions in the README.txt file.
For the 0.1 release, download graphviz.py, edit BINARY_PATH to point to the directory in which the Graphviz executables reside. See the top of the file for usage examples.
License/Copyright
Released under the terms of the GNU GPL.
Copyright (C) 2008 Wayne Tucker.
Copyright (C) 2011, 2012 Paul Boddie <paul AT boddie DOT org DOT uk>
Copyright (C) 2012 Frederick Capovilla (Libéo) <fcapovilla AT SPAMFREE live DOT ca>
Discussion
I've made a patch which adds support for SVG, since modern browsers are capable of embedding such images without plugins. Unfortunately, the sizing of embedded images isn't right first time, but the browser usually learns the size fairly quickly. This could be overcome by letting the user specify the dimensions of the image (maybe just the width or height) using the comment syntax. -- PaulBoddie 2011-09-19 22:06:08
The above enhancements are now incorporated into the 0.2 release. -- PaulBoddie 2012-01-14 20:04:39
Encoding and Subprocess Problems
Fix incorporated into the 0.2.1 release. The discussion below is for future reference. -- PaulBoddie 2012-03-06 23:50:01
I encountered some character encoding problems when trying to use accented characters in labels and hrefs. Here is a patch that corrects the character encoding problem by always converting the data to utf-8. This patch also uses subprocess.communicate() instead of reading and writing directly to stderr and stdin to avoid random "Broken pipe" errors. -- FrederickCapovilla 2012-03-05 18:26:00
Thanks for pointing that out! And sorry not to have tested the Unicode support - that's something I usually do routinely with my own code. I'll probably apply your patch and upload a new version, but I wonder why you get "Broken pipe" errors. Any ideas? -- PaulBoddie 2012-03-05 20:47:30
We had random "Broken pipe" errors on our server when saving a page with a new graph. I tried using communicate() because it is recommended in the doc (see the warning here). The "Broken pipe" errors stopped, but I got a "Fatal Python error: Couldn't create autoTLSkey mapping" error instead. According to this thread, this error occurs when fork() is called from a sub-interpreter. Adding "WSGIApplicationGroup %{GLOBAL}" in our mod_wsgi config finally corrected the problem on our server. -- FrederickCapovilla 2012-03-06 17:04:00
I suppose the optimal solution would be check for input, read it, then close the input pipes - communicate seems to use a hack based on threads - but I guess it's good enough for this purpose. As for the fatal errors, I'm happy that I'm not the one experiencing them, but weird interactions between sub-interpreters and operating system functionality don't really surprise me any more. I'll incorporate your patch into the repository under the same licence if that's OK, crediting you of course. Thanks for tidying up after me! -- PaulBoddie 2012-03-06 17:39:02
I send this patch here so it could be shared with everyone, so I have no problems with you including it in the repository under the same license. Also, please add the name of my employer ( Libéo ) after my name if you add credit. Thanks for the fast responses. -- FrederickCapovilla 2012-03-06 19:37:00
request.flush() doesn't work in 1.9
Your plugin didn't work for me until I commented out line 80 of graphviz.py
request.flush() # to identify error text
This seems to be in the original code for the parser. I just tried the current version in 1.9 and it worked, but maybe you're using a different kind of server technology: my test was with Moin running under CGI. What are you using? (It helps if I test the right code!) You seem to be right about request.flush not being provided by Moin 1.9, despite there being various wrapper objects that should provide it. I guess we have to test for its presence and just not use it if it isn't there. Indeed, I'm not even sure what the benefit of it is, other than it perhaps producing all the output up to the point of some error or other. -- PaulBoddie 2012-03-20 23:33:30
I've now made a fixed release to avoid this problem. Thanks for pointing it out! -- PaulBoddie 2012-03-22 22:10:38
Using cmapx for image maps
Can you provide instructions on how to use cmapx in your plugin? By reading the source, I gathered that you need to set up something like this.
{{{#!graphviz //format="png" //cmapx="true" digraph DevProcess { URL="http://www.gmail.com"; "Bug Fixed?" [URL="http://www.google.com"]; } }}}
But beyond that, I'm a little stumped.
I'm not the original author, and I didn't even know about the cmapx option until I started testing my changes, but I think you just need to set cmapx to a unique identifier indicating the anchor or id of the client-side imagemap in the generated HTML. If you look at the source for your Wiki page in the browser, you'll see the imagemap and the image's reference to it in the HTML. Note that if you use SVG, you can specify links in the graph nodes without having to set up an imagemap. I think the href and URL node attributes (documentation) are the ones you need to use in your graph description. -- PaulBoddie 2012-04-18 13:36:07
Wow, that was exactly what I needed to know. Now I've switched to SVG and can link all over the place. -- BrettWeir 2012-04-19 01:17:05