On Feb 13, 2009, at 4:00 PM, Ryan Lane wrote:
> I'd like to add support for graphviz, and can't figure out how to do
> I'm assuming I need to add a graphviz class to tagext.py, and return
> something inside of __call__. I can't figure out what I need to return
> though. The example says "this function builds wikimarkup and returns
> a parse tree for this". I'm not exactly sure what this means.
> What I need to do it take the source, put it into a file, run graphviz
> on the file (depending on the attributes), and include the outputted
> file (png, svg, etc) into whatever the output is.
there are two possibilites:
1) Either support the tag (see other examples like <source/>) and
implement a method in the PDF writer, which triggers graphviz and
includes the image.
2) Extend the extension to serve images via HTTP-GET requests. You
then could return [[Image:]] markup with a name that encodes the
location and the parameter for the graphviz server. We'd probably need
to add support for arbitrary URLs in images, but this shouldn't be too
hard. I'd prefer this option because it can be used as a webservice
by other applications as well. This approach would also work for
other extensions such as <hiero/> or <timeline/>.
I assume both option to be some work but we'd assist you in that if
It needs to be a GET request and these are limited to 50K in the
client library we are using (could probably be patched) and 15K in MW/
PHP/or the Webserver (didn't check who generated the 413 response).
> I'm thinking I could make a special page that takes the content, and
> attributes, and returns the location of the image. Should I be posting
> and returning XML? API-like work is fairly new to me.
I assume that your extension (did not find a working demo) uses some
hashing to store and reference generated images. If this is the case
you could use this hash to identify these images for the PDFs.
First of all we probably will have to hack the handling of the
[[Image:]] construct to support external links:
we currently don't if I got the source right:
( note to self: what about the involved attribution issues?)
It then depends, whether 15K is enough for most of the graphviz
descriptions and can be handled by the majority of servers, PHP and
If so, construct an URL like the 1st one in your example 1), put it
into an image construct [[Image:Pic.jpg|link=<your url>]], return this
from your function in tagext.py and patch the extension to directly
return an image from this URLs location based on the parametrized data.
If there are problems with the 15K limit, hash the graphviz-
description, construct an URL like the second one in your example 1)
put it into an image construct [[Image:Pic.jpg|link=<your url>]],
return this from your function in tagext.py and patch the extension to
directly return an image from this URLs location based on the
parametrized data. In this case you'll probably depend on a cached
version of this image. Also there obviously needs to be a consistent
mapping of the graphviz description and the md5 hash. You could
implement this approach as a fallback if the former exceeds the GET
Please consider to open an issue for this on http://
code.pediapress.com that bothers us to implement the [[Image:|link=]]
Sorry, I did not look at this construct long enough.
So we'll need to find a different solution to fetch these images. I'll
discuss this with my colleagues on Monday. I think besides of this we
can stick to the old plan to serve images via HTTP.