Difference between revisions of "WikiExporter"

From Inkscape Wiki
Jump to navigation Jump to search
(* getting path and filename from Inkscape SVG)
 
m (* SVG element)
Line 61: Line 61:
 
directory it was saved in. But we CAN get this data from the Inkscape SVG.
 
directory it was saved in. But we CAN get this data from the Inkscape SVG.
  
The document has attributes:
+
The <svg> element has attributes:
 
* "sodipodi:docbase" -- path up to the save location
 
* "sodipodi:docbase" -- path up to the save location
 
* "sodpodi:docname" -- filaname, including extension (".odd", in this case)
 
* "sodpodi:docname" -- filaname, including extension (".odd", in this case)

Revision as of 21:04, 12 February 2005

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.

odd_output.inx

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

<inkscape-extension>
  <name>Oddwiki Output</name>
  <id>org.inkscape.output.odd</id>
  <dependency type="executable" location="extensions">svg2oddmuse.sh</dependency>
  <output>
     <extension>.odd</extension>
     <mimetype>image/x-svgz</mimetype>
     <filetypename>Oddmuse Wiki POST (*.odd)</filetypename>
     <filetypetooltip>Oddmuse Wiki proxy (SVG, PNG of Drawing)</filetypetooltip>
     <dataloss>FALSE</dataloss>
  </output>
  <script>
     <command reldir="extensions">svg2oddmuse.sh</command>
     <helper_extension>org.inkscape.output.svg.inkscape</helper_extension>
  </script>
</inkscape-extension>

What data am I receiving from Inkscape?

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

#!/bin/bash
echo "hello, world" > /tmp/eraseme.txt
echo "invocation: $@"
echo
echo "$1:"
cat "$1"
echo "- - - - - - - - - - - - - - - - - - - - - - - - - - - -"
env

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.