1. bsx
  2. moin-2.0

Commits

Reimar Bauer  committed 91330de

items: implemented 2.6 r:2031 alpha of svg-edit using a save extension for doing a single post for svg and png data.

  • Participants
  • Parent commits 37c117a
  • Branches default

Comments (0)

Files changed (2)

File MoinMoin/items/__init__.py

View file
  • Ignore whitespace
 # 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
 
     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):

File MoinMoin/templates/modify_svg-edit.html

View file
  • Ignore whitespace
 {% 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 />