From: Aurelio A. Heckert (a) Date: Wed, 31 Mar 2010 22:28:27 +0000 (-0300) Subject: some love to webslicer export X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=ebf60d981ec4e6402a6297466837fe579c8164d2;p=inkscape.git some love to webslicer export --- diff --git a/share/extensions/webslicer_export.py b/share/extensions/webslicer_export.py index e722ccb1a..3a1a38135 100755 --- a/share/extensions/webslicer_export.py +++ b/share/extensions/webslicer_export.py @@ -70,6 +70,8 @@ class WebSlicer_Export(WebSlicer_Effect): try: self.html = open(os.path.join(self.options.dir,'layout.html'), 'w') self.css = open(os.path.join(self.options.dir,'style.css'), 'w') + self.html.write('Only a test yet\n\n') + self.css.write('Only a test yet\n\n') except Exception as e: inkex.errormsg( _('Can\'t create code files.') ) inkex.errormsg( _('Error: %s') % e ) @@ -82,33 +84,51 @@ class WebSlicer_Export(WebSlicer_Effect): self.css.close() + def get_el_conf(self, el): + desc = el.find('{http://www.w3.org/2000/svg}desc') + conf = {} + if desc is not None: + #desc = desc.text.split("\n") + for line in desc.text.split("\n"): + if line.find(':') > 0: + line = line.split(':') + conf[line[0].strip()] = line[1].strip() + return conf + + def export_chids_of(self, parent): nmspc = '{http://www.w3.org/2000/svg}' for el in parent.getchildren(): + el_conf = self.get_el_conf( el ) if el.tag == nmspc+'g': if self.options.with_code: - self.register_group_code( el ) + self.register_group_code( el, el_conf ) else: self.export_chids_of( el ) if el.tag in [ nmspc+'rect', nmspc+'path', nmspc+'circle' ]: if self.options.with_code: - self.register_unity_code( el ) - self.export_img( el ) + self.register_unity_code( el, el_conf ) + self.export_img( el, el_conf ) - def register_group_code(self, group): + def register_group_code(self, group, conf): #inkex.errormsg( 'group CSS and HTML' ) self.html.write( '
\n' ) + for att in conf: + self.html.write( ' \n'.format(att=att, val=conf[att]) ) self.export_chids_of( group ) self.html.write( '
\n' ) - def register_unity_code(self, el): + def register_unity_code(self, el, conf): #inkex.errormsg( 'unity CSS and HTML' ) - self.html.write( el.tag + '\n' ) + self.html.write( '
\n' ) + for att in conf: + self.html.write( ' \n'.format(att=att, val=conf[att]) ) + self.html.write( '
\n' ) - def export_img(self, el): + def export_img(self, el, conf): (status, output) = commands.getstatusoutput("inkscape -e ...") #inkex.errormsg( status ) #inkex.errormsg( output )