annotate MoinMoin/action/anywikidraw.py @ 5080:67114f9e3d81

action.anywikidraw: links the image to the drawing action. Any image mapping overwrites the default link for the region which is covered by the mapping. The white around the mapping url links to the action.
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Wed, 02 Sep 2009 19:38:13 +0200
parents 32ad275278d0
children 3e1d3367aeaa
rev   line source
5069
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
1 # -*- coding: iso-8859-2 -*-
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
2 """
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
3 MoinMoin - anywikidraw
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
4
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
5 This action is used to call anywikidraw (http://sourceforge.net/projects/anywikidraw/)
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
6
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
7 @copyright: 2001 by Ken Sugino (sugino@mediaone.net),
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
8 2001-2004 by Juergen Hermann <jh@web.de>,
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
9 2005 MoinMoin:AlexanderSchremmer,
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
10 2005 DiegoOngaro at ETSZONE (diego@etszone.com),
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
11 2007-2008 MoinMoin:ThomasWaldmann,
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
12 2005-2009 MoinMoin:ReimarBauer
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
13 @license: GNU GPL, see COPYING for details.
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
14 """
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
15 import os, re
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
16
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
17 from MoinMoin import log
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
18 logging = log.getLogger(__name__)
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
19
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
20 from MoinMoin import config, wikiutil
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
21 from MoinMoin.action import AttachFile, do_show
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
22 from MoinMoin.Page import Page
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
23
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
24 action_name = __name__.split('.')[-1]
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
25
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
26 def _write_stream(content, stream, bufsize=8192):
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
27 if hasattr(content, 'read'): # looks file-like
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
28 import shutil
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
29 shutil.copyfileobj(content, stream, bufsize)
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
30 elif isinstance(content, str):
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
31 stream.write(content)
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
32 else:
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
33 logging.error("unsupported content object: %r" % content)
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
34 raise
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
35
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
36 def gedit_drawing(self, url, text, **kw):
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
37 # This is called for displaying a drawing image by gui editor.
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
38 _ = self.request.getText
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
39 # TODO: this 'text' argument is kind of superfluous, replace by using alt=... kw arg
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
40 # ToDo: make this clickable for the gui editor
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
41 if 'alt' not in kw or not kw['alt']:
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
42 kw['alt'] = text
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
43 # we force the title here, needed later for html>wiki converter
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
44 kw['title'] = "drawing:%s" % wikiutil.quoteWikinameURL(url)
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
45 pagename, drawing = AttachFile.absoluteName(url, self.page.page_name)
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
46 containername = wikiutil.taintfilename(drawing) + ".tdraw"
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
47 drawing_url = AttachFile.getAttachUrl(pagename, containername, self.request, drawing=drawing, upload=True)
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
48 ci = AttachFile.ContainerItem(self.request, pagename, containername)
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
49 if not ci.exists():
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
50 title = _('Create new drawing "%(filename)s (opens in new window)"') % {'filename': drawing}
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
51 img = self.icon('attachimg') # TODO: we need a new "drawimg" in similar grey style and size
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
52 css = 'nonexistent'
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
53 return self.url(1, drawing_url, css=css, title=title) + img + self.url(0)
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
54 kw['src'] = ci.member_url(drawing + u'.png')
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
55 return self.image(**kw)
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
56
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
57 def attachment_drawing(self, url, text, **kw):
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
58 # This is called for displaying a clickable drawing image by text_html formatter.
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
59 # XXX text arg is unused!
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
60 _ = self.request.getText
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
61 pagename, drawing = AttachFile.absoluteName(url, self.page.page_name)
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
62 containername = wikiutil.taintfilename(drawing) + ".tdraw"
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
63
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
64 drawing_url = AttachFile.getAttachUrl(pagename, containername, self.request, drawing=drawing, upload=True)
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
65 ci = AttachFile.ContainerItem(self.request, pagename, containername)
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
66 if not ci.exists():
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
67 title = _('Create new drawing "%(filename)s (opens in new window)"') % {'filename': drawing}
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
68 img = self.icon('attachimg') # TODO: we need a new "drawimg" in similar grey style and size
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
69 css = 'nonexistent'
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
70 return self.url(1, drawing_url, css=css, title=title) + img + self.url(0)
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
71
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
72 title = _('Edit drawing %(filename)s (opens in new window)') % {'filename': self.text(drawing)}
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
73 kw['src'] = src = ci.member_url(drawing + u'.png')
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
74 kw['css'] = 'drawing'
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
75
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
76 try:
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
77 mapfile = ci.get(drawing + u'.map')
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
78 map = mapfile.read()
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
79 mapfile.close()
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
80 except (KeyError, IOError, OSError):
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
81 map = ''
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
82 if map:
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
83 # XXX check how that is done by josef
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
84 # we have a image map. inline it and add a map ref to the img tag
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
85 mapid = 'ImageMapOf' + drawing
5079
32ad275278d0 action anywikidraw: fixed url mapping bug in attachment_drawing
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5069
diff changeset
86 map = map.replace('id="%s.svg"' % drawing, '')
32ad275278d0 action anywikidraw: fixed url mapping bug in attachment_drawing
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5069
diff changeset
87 map = map.replace('name="%s.svg"' % drawing, 'name="%s"' % mapid)
5069
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
88 # add alt and title tags to areas
5079
32ad275278d0 action anywikidraw: fixed url mapping bug in attachment_drawing
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5069
diff changeset
89 #map = re.sub(r'href\s*=\s*"((?!%TWIKIDRAW%).+?)"', r'href="\1" alt="\1" title="\1"', map)
32ad275278d0 action anywikidraw: fixed url mapping bug in attachment_drawing
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5069
diff changeset
90 #map = map.replace('%TWIKIDRAW%"', '%s" alt="%s" title="%s"' % (drawing_url, title, title))
5069
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
91 # unxml, because 4.01 concrete will not validate />
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
92 map = map.replace('/>', '>')
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
93 title = _('Clickable drawing: %(filename)s') % {'filename': self.text(drawing)}
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
94 if 'title' not in kw:
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
95 kw['title'] = title
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
96 if 'alt' not in kw:
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
97 kw['alt'] = kw['title']
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
98 kw['usemap'] = '#'+mapid
5080
67114f9e3d81 action.anywikidraw: links the image to the drawing action. Any image mapping overwrites the default link for the region which is covered by the mapping. The white around the mapping url links to the action.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5079
diff changeset
99 return self.url(1, drawing_url) + map + self.image(**kw) + self.url(0)
5069
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
100 else:
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
101 if 'title' not in kw:
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
102 kw['title'] = title
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
103 if 'alt' not in kw:
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
104 kw['alt'] = kw['title']
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
105 return self.url(1, drawing_url) + self.image(**kw) + self.url(0)
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
106
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
107 class AnyWikiDraw(object):
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
108 """ anywikidraw action """
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
109 def __init__(self, request, pagename, target):
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
110 self._ = request.getText
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
111 self.request = request
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
112 self.pagename = pagename
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
113 self.target = target
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
114
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
115 def render_msg(self, msg, msgtype):
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
116 """ Called to display some message (can also be the action form) """
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
117 self.request.theme.add_msg(msg, msgtype)
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
118 do_show(self.pagename, self.request)
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
119
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
120 def save(self):
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
121 _ = self._
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
122 pagename = self.pagename
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
123 request = self.request
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
124 target = self.target
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
125 if not request.user.may.write(pagename):
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
126 return _('You are not allowed to save a drawing on this page.')
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
127 file_upload = request.files.get('filepath')
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
128 print "file_upload: %s" % file_upload
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
129 if not file_upload:
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
130 # This might happen when trying to upload file names
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
131 # with non-ascii characters on Safari.
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
132 return _("No file content. Delete non ASCII characters from the file name and try again.")
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
133
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
134 filename = request.form['filename']
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
135 basepath, basename = os.path.split(filename)
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
136 basename, ext = os.path.splitext(basename)
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
137 basename = basename.replace('.svg', '')
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
138
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
139 ci = AttachFile.ContainerItem(request, pagename, basename + '.tdraw')
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
140 filecontent = file_upload.stream
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
141 content_length = None
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
142 if ext == '.svg': # TWikiDraw POSTs this first
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
143 AttachFile._addLogEntry(request, 'ATTDRW', pagename, basename + '.tdraw')
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
144 ci.truncate()
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
145 filecontent = filecontent.read() # read file completely into memory
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
146 filecontent = filecontent.replace("\r", "")
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
147 elif ext == '.map':
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
148 # touch attachment directory to invalidate cache if new map is saved
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
149 attach_dir = AttachFile.getAttachDir(request, pagename)
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
150 os.utime(attach_dir, None)
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
151 filecontent = filecontent.read() # read file completely into memory
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
152 filecontent = filecontent.strip()
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
153 else:
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
154 #content_length = file_upload.content_length
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
155 # XXX gives -1 for wsgiref :( If this is fixed, we could use the file obj,
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
156 # without reading it into memory completely:
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
157 filecontent = filecontent.read()
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
158
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
159 if filecontent:
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
160 ci.put(basename + ext, filecontent, content_length)
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
161
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
162 def render(self):
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
163 _ = self._
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
164 request = self.request
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
165 pagename = self.pagename
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
166 target = self.target
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
167 url = request.getQualifiedURL()
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
168 target_url = ''
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
169 drawing_name = ''
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
170
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
171 htdocs = "%s%s" % (request.cfg.url_prefix_static, '/applets/anywikidraw')
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
172 ci = AttachFile.ContainerItem(request, pagename, target + '.tdraw')
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
173 if ci.exists():
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
174 drawing_name = "%s.svg" % target
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
175 target_url = ci.member_url(target + '.svg')
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
176
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
177 html = """
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
178 <h2> %(editdrawing)s </h2>
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
179 <!--
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
180 Document : anywikidraw_for_twiki_demo
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
181 Created on : May 13, 2008, 7:32:27 AM
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
182 Author : werni
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
183 Version : $Id: anywikidraw_for_twiki_demo.html 107 2009-06-15 19:33:05Z rawcoder $
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
184
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
185 adjusted for MoinMoin 2009-08-29 ReimarBauer
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
186 -->
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
187 <applet codebase="."
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
188 archive="%(htdocs)s/lib/AnyWikiDrawForTWiki.jar"
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
189 code=org.anywikidraw.twiki.TWikiDrawingApplet.class
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
190 width="800" height="600">
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
191
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
192 <!-- The following parameters are used to tell AnyWikiDraw how to communicate with MoinMoin.
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
193 -->
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
194 <param name="DrawingName" value="%(target)s.svg"/>
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
195 <param name="DrawingWidth" value="800"/>
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
196 <param name="DrawingHeight" value="600"/>
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
197 <param name="DrawingURL" value="%(target_url)s"/>
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
198 <param name="PageURL" value="%(url)s/%(pagename)s/">
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
199 <param name="UploadURL" value="%(pagename)s?action=anywikidraw&do=save&target=%(target)s.svg"/>
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
200
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
201 <!-- The following parameters are used to configure the drawing applet -->
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
202 <param name="Locale" value="en"/>
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
203
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
204 <!-- The following parameters are used to configure Sun's Java Plug-In -->
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
205 <param name="codebase_lookup" value="false"/>
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
206 <param name="classloader_cache" value="false"/>
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
207 <param name="java_arguments" value="-Djnlp.packEnabled=true"/>
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
208 <param name="image" value="lib/Splash.gif"/>
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
209 <param name="boxborder" value="false"/>
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
210 <param name="centerimage" value="true"/>
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
211 </applet>
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
212 """ % {'htdocs': htdocs,
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
213 'pagename': pagename,
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
214 'target': target,
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
215 'drawing_name': drawing_name,
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
216 'target_url': target_url,
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
217 'url': url,
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
218 'editdrawing': _('Edit drawing'),
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
219 }
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
220
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
221 title = '%s:%s' % (pagename, target)
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
222 request.theme.send_title(title, page=request.page, pagename=pagename)
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
223 request.write(request.formatter.startContent("content"))
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
224 request.write(request.formatter.rawHTML(html))
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
225 request.write(request.formatter.endContent())
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
226 request.theme.send_footer(pagename)
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
227 request.theme.send_closing_html()
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
228
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
229 def execute(pagename, request):
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
230 _ = request.getText
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
231 msg = None
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
232 if not request.user.may.read(pagename):
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
233 msg = '<p>%s</p>' % _('You are not allowed to view this page.')
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
234 AnyWikiDraw(request, pagename, target).render_msg(msg, 'error')
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
235 return
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
236
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
237 target = request.values.get('target', '')
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
238 if not target:
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
239 msg = '<p>%s</p>' % _("Empty target given.")
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
240 AnyWikiDraw(request, pagename, target).render_msg(msg, 'error')
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
241 return
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
242
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
243 do = request.values.get('do', '')
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
244 if do == 'save' and request.user.may.write(pagename):
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
245 msg = AnyWikiDraw(request, pagename, target).save()
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
246 AnyWikiDraw(request, pagename, target).render_msg(msg, 'error')
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
247 return
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
248
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
249 AnyWikiDraw(request, pagename, target).render()
5ef5bf8910b9 action.anywikidraw: initial vesion for a drawing action based on the AnyWikiDraw java applet
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
250