changeset 254:91330de48b9c

items: implemented 2.6 r:2031 alpha of svg-edit using a save extension for doing a single post for svg and png data.
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Tue, 21 Jun 2011 14:10:42 +0200
parents 37c117ad8f7e
children 76a4e3cc8705
files MoinMoin/items/__init__.py MoinMoin/templates/modify_svg-edit.html
diffstat 2 files changed, 10 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/items/__init__.py	Sun Jun 12 15:16:46 2011 +0200
+++ b/MoinMoin/items/__init__.py	Tue Jun 21 14:10:42 2011 +0200
@@ -1,5 +1,5 @@
 # Copyright: 2009 MoinMoin:ThomasWaldmann
-# Copyright: 2009 MoinMoin:ReimarBauer
+# Copyright: 2009-2011 MoinMoin:ReimarBauer
 # Copyright: 2009 MoinMoin:ChristopherDenter
 # Copyright: 2008,2009 MoinMoin:BastianBlank
 # Copyright: 2010 MoinMoin:ValentinJaniaut
@@ -1510,16 +1510,16 @@
 
     def modify(self):
         # called from modify UI/POST
-        file_upload = request.values.get('data')
+        png_upload = request.values.get('png_data')
+        svg_upload = request.values.get('filepath')
         filename = request.form['filename']
-        filecontent = file_upload.decode('base_64')
-        basepath, basename = os.path.split(filename)
-        basename, ext = os.path.splitext(basename)
+        png_content = png_upload.decode('base_64')
+        png_content = base64.urlsafe_b64decode(png_content.split(',')[1])
+        svg_content = svg_upload.decode('base_64')
         content_length = None
-
-        if ext == '.png':
-            filecontent = base64.urlsafe_b64decode(filecontent.split(',')[1])
-        self.put_member(filename, filecontent, content_length,
+        self.put_member("drawing.svg", svg_content, content_length,
+                        expected_members=set(['drawing.svg', 'drawing.png']))
+        self.put_member("drawing.png", png_content, content_length,
                         expected_members=set(['drawing.svg', 'drawing.png']))
 
     def do_modify(self, contenttype, template_name):
--- a/MoinMoin/templates/modify_svg-edit.html	Sun Jun 12 15:16:46 2011 +0200
+++ b/MoinMoin/templates/modify_svg-edit.html	Tue Jun 21 14:10:42 2011 +0200
@@ -1,7 +1,7 @@
 {% extends "modify_applet.html" %}
 {% block data_editor %}
 <p>
-<object data="{{ url_for('serve.files', name='svgedit', filename='svg-editor.html') }}?paramurl={{ url_for('frontend.get_item', item_name=item_name, member='drawing.svg') }}&amp;savepath={{ url_for('frontend.modify_item', item_name=item_name) }}&amp;viewpath={{ url_for('frontend.show_item', item_name=item_name) }}" width="100%" height="600">
+<object data="{{ url_for('serve.files', name='svgedit', filename='editor/svg-editor.html') }}?paramurl={{ url_for('frontend.get_item', item_name=item_name, member='drawing.svg') }}" width="100%" height="600">
 </object>
 </p>
 <br />