TwikiDrawPlugin? is a java applet from the twiki community that allows to create editable drawings with a java applet.


1) download TWikiDrawPlugin?.zexp and import it in the wiki-root. It contains a folder that holds the java applet.

2) create a script (Python) called Drawing in the wiki root with the following content. It additionally need a parameter called 'name':

        request = context.REQUEST

        GifName = str(name + '.gif')
        exists = 0

        for ImageFile in container.objectValues('Image'):
          if == GifName:
            exists = 1

        print """<br><span style="font-size:9px;">%s</span><br>""" % (GifName)

        if exists == 1:
          print """<a href="%s/twikidraw?name=%s"><img src="%s.gif"></a>""" % (context.absolute_url(),name,name)
          print """<a href="%s/twikidraw?name=%s"><img src="images/placeholder.gif"></a>""" % (context.absolute_url(),name)

        print """<br><span style="font-size:8px;"> click on the picture to edit (java applet)</span>"""
        return printed

3) Create a dtml method called upload in the wiki root with the following content:

         <dtml-if "REQUEST['filecomment']=='TWikiDraw draw file'">
             <dtml-call "_[REQUEST['QUERY_STRING'] + '.draw'].manage_upload(REQUEST['filepath'])">
             <dtml-call "manage_addFile(REQUEST['QUERY_STRING'] + '.draw',REQUEST['filepath'],'')">

           <dtml-let ProcessedText="str(_[REQUEST['QUERY_STRING'] + '.draw']).replace('\r\\n','\\n').replace('\n\\n','\\n')">
             <dtml-var "ProcessedText">
             <dtml-call "_[REQUEST['QUERY_STRING'] + '.draw'].update_data(ProcessedText, content_type='text/plain')">


         <dtml-if "REQUEST['filecomment']=='TWikiDraw map file'">
             <dtml-call "_[REQUEST['QUERY_STRING'] + '.map'].manage_upload(REQUEST['filepath'])">
             <dtml-call "manage_addFile(REQUEST['QUERY_STRING'] + '.map',REQUEST['filepath'],'')">

         <dtml-if "REQUEST['filecomment']=='TWikiDraw GIF file'">
             <dtml-call "_[REQUEST['QUERY_STRING'] + '.gif'].manage_upload(REQUEST['filepath'])">
             <dtml-call "manage_addImage(REQUEST['QUERY_STRING'] + '.gif',REQUEST['filepath'],'')">

4) Create a dtml method called twikidraw in the wiki root with the following content:

        <dtml-var standard_html_header>

        <applet code="CH.ifa.draw.twiki.TWikiDraw.class" archive="TWikiDrawPlugin/twikidraw.jar" width=500 height=500>
                <param name="drawpath" value="<dtml-var "REQUEST['name']">.draw">
                <param name="gifpath"  value="<dtml-var "REQUEST['name']">.gif">
                <param name="mappath"  value="<dtml-var "REQUEST['name']">.map">
                <param name="svgpath"  value="<dtml-var "REQUEST['name']">.svg">
                <param name="extracolors" value="Aquamarine=#70DB93,New Tan=EBC79E,Sea Green=238E68,Motorola Blue=#3ff">
                <param name="shortdescription" value="Editing <dtml-var "REQUEST['name']">">
                <param name="savepath" value="/upload?<dtml-var "REQUEST['name']">">
                <param name="viewpath" value="<dtml-var absolute_url>">
                <param name="helppath" value="WiHiZeichnen">

        <dtml-var standard_html_footer>

5) Add a picture called placeholder.gif in the wiki root


Obviously Java needs to be activated for this to work. Some of the methods are not optimal in any way... It was just a quick hack to get it working. Especially the testing for existing/not-existing images in the script Drawing is quite expensive in large wikis.

To place a drawing in a wikipage use the following:

    <dtml-var "Drawing('MyDrawingName')">

This will be replaced by the script Drawing with the image (if existant) which when clicked on will open the java applet. Within the applet do your edits and select Save and Exit. You will then see you Drawing in the wikipage that can be edited anytime with the java applet. For this to work the java applet also sends a .map file that contains the drawing metadata.

The java applet will need authentication if your wiki is protected. Some scripts need proxy roles for this to work. I didnt work it out since in our wiki only managers are at work and it is private anyway.


Twiki and the author(s) of the java applet.