summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAur??lio A. Heckert <aurium@gmail.com>2009-03-25 23:41:59 +0000
committeraurium <aurium@users.sourceforge.net>2009-03-25 23:41:59 +0000
commitcaadf9c118498bc934a0498b7699685c855a491a (patch)
tree4151ddc4ea6d3d977e9fb4d82f71d7e2520f6ccd
parentContinued cleaning unuseful primitives and solved zoom problem with some Bevels (diff)
downloadinkscape-caadf9c118498bc934a0498b7699685c855a491a.tar.gz
inkscape-caadf9c118498bc934a0498b7699685c855a491a.zip
InkWeb is a fetus, but is growing...
(bzr r7560)
-rw-r--r--share/extensions/inkwebeffect.py59
-rw-r--r--share/extensions/web-transmit-att.py29
2 files changed, 71 insertions, 17 deletions
diff --git a/share/extensions/inkwebeffect.py b/share/extensions/inkwebeffect.py
new file mode 100644
index 000000000..65176652f
--- /dev/null
+++ b/share/extensions/inkwebeffect.py
@@ -0,0 +1,59 @@
+#!/usr/bin/env python
+'''
+Copyright (C) 2009 Aurelio A. Heckert, aurium (a) gmail dot com
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+'''
+
+import inkex, sys, os, re
+
+class InkWebEffect(inkex.Effect):
+ def __init__(self):
+ inkex.Effect.__init__(self)
+ self.reUpdateJS = '/\\*\\s* inkweb.js [^*]* InkWebEffect:AutoUpdate \\s*\\*/'
+
+ def mustAddInkWebJSCode(self, scriptEl):
+ if not scriptEl.text: return True
+ if len(scriptEl.text) == 0: return True
+ if re.search(self.reUpdateJS, scriptEl.text): return True
+ return False
+
+ def addInkWebJSCode(self, scriptEl):
+ js = open( os.path.join(sys.path[0], "inkweb.js"), 'r' )
+ scriptEl.text = \
+ inkex.etree.CDATA(
+ "\n/* inkweb.js - InkWebEffect:AutoUpdate */\n" + js.read()
+ )
+ js.close()
+
+ def ensureInkWebSupport(self):
+ # Search for the script tag with the inkweb.js code:
+ scriptEl = False
+ scripts = self.document.xpath('//script', namespaces=inkex.NSS)
+ for s in scripts:
+ inkex.errormsg(s)
+ if re.search(self.reUpdateJS, s.text):
+ inkex.errormsg("OK!")
+ scriptEl = s
+
+ if not scriptEl:
+ root = self.document.getroot()
+ scriptEl = inkex.etree.Element( "script" )
+ scriptEl.set( "id", "inkwebjs" )
+ scriptEl.set( "type", "text/javascript" )
+ root.insert( 0, scriptEl )
+
+ if self.mustAddInkWebJSCode(scriptEl): self.addInkWebJSCode(scriptEl)
+
diff --git a/share/extensions/web-transmit-att.py b/share/extensions/web-transmit-att.py
index eff10f05f..830085fab 100644
--- a/share/extensions/web-transmit-att.py
+++ b/share/extensions/web-transmit-att.py
@@ -16,13 +16,14 @@ You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
'''
-import inkex, sys, os
-#from lxml import etree
+import inkwebeffect, gettext
-class InterpAttG(inkex.Effect):
+_ = gettext.gettext
+
+class InkWebTransmitAtt(inkwebeffect.InkWebEffect):
def __init__(self):
- inkex.Effect.__init__(self)
+ inkwebeffect.InkWebEffect.__init__(self)
self.OptionParser.add_option("-a", "--att",
action="store", type="string",
dest="att", default="fill",
@@ -36,20 +37,13 @@ class InterpAttG(inkex.Effect):
dest="compatibility", default="append",
help="Compatibility with previews code to this event.")
- def ensureInkWebSupport(self):
- if not self.document.xpath('//*[@id="inkwebjs"]', namespaces=inkex.NSS):
- root = self.document.getroot()
- scriptEl = inkex.etree.Element( "script" )
- scriptEl.set( "id", "inkwebjs" )
- scriptEl.set( "type", "text/javascript" )
- js = open( os.path.join(sys.path[0], "inkweb.js"), 'r' )
- scriptEl.text = inkex.etree.CDATA( js.read() )
- js.close()
- root.insert( 0, scriptEl )
-
def effect(self):
self.ensureInkWebSupport()
+ if len(self.options.ids) < 2:
+ inkwebeffect.inkex.errormsg(_("You must to select at least two elements."))
+ exit(1)
+
elFrom = self.selected[ self.options.ids[0] ]
idTo = self.options.ids[1]
@@ -66,5 +60,6 @@ class InterpAttG(inkex.Effect):
elFrom.set( self.options.when, evCode )
if __name__ == '__main__':
- e = InterpAttG()
- e.affect() \ No newline at end of file
+ e = InkWebTransmitAtt()
+ e.affect()
+