webslicer_export.py revision e6a258b8910fb71759c713284d34dead0a5457f0
'''
Copyright (C) 2010 Aurelio A. Heckert, aurium (a) gmail dot com
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
'''
from webslicer_effect import *
import inkex
import gettext
import os
import sys
import tempfile
class WebSlicer_Export(WebSlicer_Effect):
dest="dir",
help="")
dest="create_dir",
help="")
dest="with_code",
help="")
def validate_inputs(self):
# The user must supply a directory to export:
return {'error':'You must give a directory to export the slices.'}
# No directory separator at the path end:
# Test if the directory exists:
# Try to create it:
try:
except Exception, e:
return {'error':'Can\'t create the directory to export.'}
else:
return
return None
# This solution comes from Andrew Reedick <jr9445 at ATT.COM>
# This method replaces the commands.getstatusoutput() usage, with the
# hope to correct the windows exporting bug:
_html_ids = []
_('You have more than one element with "%s" html-id.') %
conf['html-id'] )
n = 2
def test_if_has_imagemagick(self):
# Register the basic CSS code:
# Create the temporary SVG with invisible Slicer layer to export image pieces
# Start what we really want!
# Write the HTML and CSS files if asked for:
# Delete the temporary SVG with invisible Slicer layer
#TODO: prevent inkex to return svg code to update Inkscape
def make_html_file(self):
f.write(
'<html>\n<head>\n' +\
' <title>Web Layout Testing</title>\n' +\
' @import url("style.css")\n' +\
' </style>\n' +\
'</head>\n<body>\n' +\
' <p style="position:absolute; bottom:10px">\n' +\
' This HTML code is not done to the web. <br/>\n' +\
' The automatic HTML and CSS code are only a helper.' +\
'</p>\n</body>\n</html>' )
f.close()
def make_css_file(self):
f.write(
'/*\n' +\
'** This CSS code is not done to the web.\n' +\
'** The automatic HTML and CSS code are only a helper.\n' +\
'*/\n' +\
f.close()
def create_the_temporary_svg(self):
def delete_the_temporary_svg(self):
conf = {}
if desc is None:
if not 'html-id' in conf:
return {'html-id':'#body#'}
else:
return conf
if desc is not None:
conf_a = []
for k in conf:
else:
if not 'layout-disposition' in conf:
if not 'layout-position-anchor' in conf:
return conf
bg_repeat = 'no-repeat'
if parent_id == '#body#':
css_selector = 'body'
else:
bg_repeat = 'repeat'
bg_repeat = 'repeat-x'
bg_repeat = 'repeat-y'
else: # conf['layout-disposition'][0:9] == 'bg-el...'
else: # conf['layout-disposition'] == 'img...'
el_geo = { }
if status == 0:
# This method return a dictionary with x, y, w and h keys.
# All values are float, if value_to_css is False, otherwise
# that is a string ended with "px". The x and y values are
# relative to parent position.
if value_to_css:
return geometry
if not self.has_magick:
opts = ''
if 'dimension' in conf:
'inkscape %s -i "%s" -e "%s" "%s"' % (
)
)
opts = ''
opts += ' -type Grayscale'
else:
opts += ' -type Palette'
)
if status != 0:
_html = {}
if 'html-class' in conf:
else:
el_class = ''
#inkex.errormsg( self._html )
code = ''
tag_class = ''
else:
if child_code:
code += child_code
else:
return code
_css = []
pos = i = -1
i += 1
if pos == -1:
pos = i + 1
code = ''
for att in s['atts']:
code += ' /* the next attribute needs a CSS3 enabled browser */\n'
code += '}\n'
return code
# Cancel document serialization to stdout
pass
if __name__ == '__main__':
e = WebSlicer_Export()
e.affect()