changeset 392:d858f942a1f6

action SVG-editor: prepared for feeding svg data into SVGcanvas
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Sun, 23 Aug 2009 23:05:57 +0200
parents 6747c16172a2
children d8e48ef248a5
files data/plugin/action/SVG-editor.py htdocs/svg-edit/editor/svg-editor.js
diffstat 2 files changed, 14 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/data/plugin/action/SVG-editor.py	Sun Aug 23 20:23:48 2009 +0200
+++ b/data/plugin/action/SVG-editor.py	Sun Aug 23 23:05:57 2009 +0200
@@ -16,6 +16,11 @@
 
 def execute(pagename, request):
     target = request.values.get('target', 'example.svg')
+    filecontent = ''
+    if AttachFile.exists(request, pagename, target):
+        fpath = AttachFile.getFilename(request, pagename, target).encode(config.charset)
+        filecontent = file(fpath, 'r').readlines()
+        filecontent = base64.b64encode('\n'.join(filecontent))
     do = request.values.get('do', '')
     if do == 'save':
         filecontent = request.values.get('svg_data', '')
@@ -56,7 +61,6 @@
 
     html = """
 <div id="svg_editor">
-
 <div id="workarea">
 <style id="styleoverrides" type="text/css"></style>
 <div id="svgcanvas"></div>
@@ -298,6 +302,7 @@
 </script>
 
 """ % {"htdocs": htdocs,
+       "filecontent": filecontent,
        }
 
     title = "%s:%s" % (pagename, target)
--- a/htdocs/svg-edit/editor/svg-editor.js	Sun Aug 23 20:23:48 2009 +0200
+++ b/htdocs/svg-edit/editor/svg-editor.js	Sun Aug 23 23:05:57 2009 +0200
@@ -11,6 +11,13 @@
 	var isMac = false; //(navigator.platform.indexOf("Mac") != -1);
 	var modKey = ""; //(isMac ? "meta+" : "ctrl+");
 	var svgCanvas = new SvgCanvas(document.getElementById("svgcanvas"));
+    // ToDo feed fielecontent into svgCanvas
+    var filecontent = '';
+    if (filecontent != '') {
+        var svg = filecontent;
+        svgCanvas.setSvgString(svg);
+    }
+
 
 	var setSelectMode = function() {
 		$('.tool_button_current').removeClass('tool_button_current').addClass('tool_button');
@@ -66,6 +73,7 @@
           var svg_data = Utils.encode64(svg);
           var pagename = titlename.split(':')[0];
           var svg_target = titlename.split(':')[1];
+         
           $.post(
                 pagename,
                 {'action': "SVG-editor", 'do': "save", 'target': svg_target, 'svg_data': svg_data}