utils.py
branchstable
changeset 3091 c3d73cecb29e
parent 2678 0308dc159b96
child 3094 978ed8c2c0e4
equal deleted inserted replaced
3055:06814d57514f 3091:c3d73cecb29e
     4 :copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2.
     4 :copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2.
     5 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
     5 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
     6 :license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
     6 :license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
     7 """
     7 """
     8 __docformat__ = "restructuredtext en"
     8 __docformat__ = "restructuredtext en"
       
     9 
       
    10 from logilab.mtconverter import xml_escape
     9 
    11 
    10 import locale
    12 import locale
    11 from md5 import md5
    13 from md5 import md5
    12 from datetime import datetime, timedelta, date
    14 from datetime import datetime, timedelta, date
    13 from time import time, mktime
    15 from time import time, mktime
   260                 w(u'%s = %s;\n' % (var, dumps(value)))
   262                 w(u'%s = %s;\n' % (var, dumps(value)))
   261             w(u'//--><!]]></script>\n')
   263             w(u'//--><!]]></script>\n')
   262         # 2/ css files
   264         # 2/ css files
   263         for cssfile, media in self.cssfiles:
   265         for cssfile, media in self.cssfiles:
   264             w(u'<link rel="stylesheet" type="text/css" media="%s" href="%s"/>\n' %
   266             w(u'<link rel="stylesheet" type="text/css" media="%s" href="%s"/>\n' %
   265               (media, cssfile))
   267               (media, xml_escape(cssfile)))
   266         # 3/ ie css if necessary
   268         # 3/ ie css if necessary
   267         if self.ie_cssfiles:
   269         if self.ie_cssfiles:
   268             w(u'<!--[if lt IE 8]>\n')
   270             w(u'<!--[if lt IE 8]>\n')
   269             for cssfile, media in self.ie_cssfiles:
   271             for cssfile, media in self.ie_cssfiles:
   270                 w(u'<link rel="stylesheet" type="text/css" media="%s" href="%s"/>\n' %
   272                 w(u'<link rel="stylesheet" type="text/css" media="%s" href="%s"/>\n' %
   271                   (media, cssfile))
   273                   (media, xml_escape(cssfile)))
   272             w(u'<![endif]--> \n')
   274             w(u'<![endif]--> \n')
   273         # 4/ js files
   275         # 4/ js files
   274         for jsfile in self.jsfiles:
   276         for jsfile in self.jsfiles:
   275             w(u'<script type="text/javascript" src="%s"></script>\n' % jsfile)
   277             w(u'<script type="text/javascript" src="%s"></script>\n' %
       
   278               xml_escape(jsfile))
   276         # 5/ post inlined scripts (i.e. scripts depending on other JS files)
   279         # 5/ post inlined scripts (i.e. scripts depending on other JS files)
   277         if self.post_inlined_scripts:
   280         if self.post_inlined_scripts:
   278             w(u'<script type="text/javascript">\n')
   281             w(u'<script type="text/javascript">\n')
   279             w(u'\n\n'.join(self.post_inlined_scripts))
   282             w(u'\n\n'.join(self.post_inlined_scripts))
   280             w(u'\n</script>\n')
   283             w(u'\n</script>\n')