From Inkscape Wiki
Revision as of 21:04, 12 February 2005 by LionKimbro (talk | contribs) (* SVG element)
Jump to navigation Jump to search

These are LionKimbro's notes on developing a wiki exporter.

Date: 2004-02-12
Inkscape version: 0.40
Target: Oddmuse

That is, a system so that you can load from and save to a wiki.

The wiki targetted by this exporter is Oddmuse. We have an upload script for it.

I imagine it should be possible to use the Wiki XML-RPC interfaces as well, in the future, though they are usually turned off.


This file goes in: /usr/share/inkscape/extensions

  <name>Oddwiki Output</name>
  <dependency type="executable" location="extensions"></dependency>
     <filetypename>Oddmuse Wiki POST (*.odd)</filetypename>
     <filetypetooltip>Oddmuse Wiki proxy (SVG, PNG of Drawing)</filetypetooltip>
     <command reldir="extensions"></command>

What data am I receiving from Inkscape?

To see what you're getting from Inkscape, create the following script, and call it:

echo "hello, world" > /tmp/eraseme.txt
echo "invocation: $@"
echo "$1:"
cat "$1"
echo "- - - - - - - - - - - - - - - - - - - - - - - - - - - -"

It appears that no environment variables are being set. The first (and only) argument is the location of a file in /tmp that contains the Inkscape SVG data.

Now what?

The strategy is this:

  • create a directory, representing the wiki
  • place a file in the directory, "oddmuse.txt", representing necessary details about the wiki
  • when the user saves a file to the directory (.odd extension,) do the following:
    • push the SVG to the wiki
    • render a PNG, and push the PNG to the wiki
    • perhaps append the name of the wikipage containing the SVG to a page on the wiki

We don't have command-line access (bash argument, environment variable) to the filename or directory it was saved in. But we CAN get this data from the Inkscape SVG.

The <svg> element has attributes:

  • "sodipodi:docbase" -- path up to the save location
  • "sodpodi:docname" -- filaname, including extension (".odd", in this case)

Inkscape Export process

  • User hits "Save" in "Save As" dialog
  • Inkscape writes a file with a random name to /tmp
  • Inkscape calls export bash script, with /tmp file as only argument
  • Whatever bash outputs to /dev/stdout, Inkscape records to the file chosen by the user.