comparison data/plugin/action/SVG-editor.py @ 391:6747c16172a2

action SVG-editor: save on pagename and target. uri parameter target added. default is example.svg.
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Sun, 23 Aug 2009 20:23:48 +0200
parents 764834d3a461
children d858f942a1f6
comparison
equal deleted inserted replaced
390:8b7ec5e404c2 391:6747c16172a2
1 # -*- coding: iso-8859-1 -*- 1 # -*- coding: iso-8859-1 -*-
2 """ 2 """
3 MoinMoin - mathtran 3 MoinMoin - SVG-editor
4 4
5 This macro is used to call the mathtran parser, 5 This action is used to call svg-edit, (http://code.google.com/p/svg-edit/)
6 it is just a thin wrapper around it. 6 it is just a thin wrapper around it.
7 7 svg-edit pre alpha is called (this is currently a mockup for an implementation in moin-2.0)
8 @copyright: 2008-2009 by MoinMoin:ReimarBauer 8
9 @copyright: 2009 by MoinMoin:ReimarBauer
9 @license: GNU GPL, see COPYING for details. 10 @license: GNU GPL, see COPYING for details.
10 """ 11 """
12 import base64
13 from MoinMoin import config
14 from MoinMoin.action import AttachFile
15
16
11 def execute(pagename, request): 17 def execute(pagename, request):
18 target = request.values.get('target', 'example.svg')
19 do = request.values.get('do', '')
20 if do == 'save':
21 filecontent = request.values.get('svg_data', '')
22 target = request.values.get('target', 'example.svg')
23 if filecontent:
24 # get directory, and possibly create it
25 attach_dir = AttachFile.getAttachDir(request, pagename, create=1)
26 # save file
27 fpath = AttachFile.getFilename(request, pagename, target).encode(config.charset)
28 file(fpath, 'w').write(filecontent.decode('base_64'))
29 return None, None
30
31
12 url = request.getQualifiedURL() 32 url = request.getQualifiedURL()
13 htdocs = "%s%s" % (request.cfg.url_prefix_static, '/svg-edit/editor') 33 htdocs = "%s%s" % (request.cfg.url_prefix_static, '/svg-edit/editor')
14 34
15 meta = """ 35 meta = """
16 <meta http-equiv="Content-type" content="text/html;charset=UTF-8" /> 36 <meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
275 295
276 <script type="text/javascript"> 296 <script type="text/javascript">
277 $(document).ready(svg_edit_setup); 297 $(document).ready(svg_edit_setup);
278 </script> 298 </script>
279 299
280 """ % {"htdocs": htdocs} 300 """ % {"htdocs": htdocs,
281 301 }
282 title = "SVG Editor" 302
303 title = "%s:%s" % (pagename, target)
283 request.theme.send_title(title, page=request.page, pagename=pagename) 304 request.theme.send_title(title, page=request.page, pagename=pagename)
284 request.write(request.formatter.startContent("content")) 305 request.write(request.formatter.startContent("content"))
285 request.write(request.formatter.rawHTML(meta)) 306 request.write(request.formatter.rawHTML(meta))
286 307
287 request.write(request.formatter.rawHTML(html)) 308 request.write(request.formatter.rawHTML(html))