equal
deleted
inserted
replaced
373 # 4/ js files |
373 # 4/ js files |
374 for jsfile in jsfiles: |
374 for jsfile in jsfiles: |
375 if skiphead: |
375 if skiphead: |
376 # Don't insert <script> tags directly as they would be |
376 # Don't insert <script> tags directly as they would be |
377 # interpreted directly by some browsers (e.g. IE). |
377 # interpreted directly by some browsers (e.g. IE). |
378 # Use <pre class="script"> tags instead and let |
378 # Use <cubicweb:script> tags instead and let |
379 # `loadAjaxHtmlHead` handle the script insertion / execution. |
379 # `loadAjaxHtmlHead` handle the script insertion / execution. |
380 w(u'<pre class="script" src="%s"></pre>\n' % |
380 w(u'<cubicweb:script src="%s"></cubicweb:script>\n' % |
381 xml_escape(jsfile)) |
381 xml_escape(jsfile)) |
382 # FIXME: a probably better implementation might be to add |
382 # FIXME: a probably better implementation might be to add |
383 # JS or CSS urls in a JS list that loadAjaxHtmlHead |
383 # JS or CSS urls in a JS list that loadAjaxHtmlHead |
384 # would iterate on and postprocess: |
384 # would iterate on and postprocess: |
385 # cw._ajax_js_scripts.push('myscript.js') |
385 # cw._ajax_js_scripts.push('myscript.js') |
390 xml_escape(jsfile)) |
390 xml_escape(jsfile)) |
391 # 5/ post inlined scripts (i.e. scripts depending on other JS files) |
391 # 5/ post inlined scripts (i.e. scripts depending on other JS files) |
392 if self.post_inlined_scripts: |
392 if self.post_inlined_scripts: |
393 if skiphead: |
393 if skiphead: |
394 for script in self.post_inlined_scripts: |
394 for script in self.post_inlined_scripts: |
395 w(u'<pre class="script">') |
395 w(u'<cubicweb:script>') |
396 w(xml_escape(script)) |
396 w(xml_escape(script)) |
397 w(u'</pre>') |
397 w(u'</cubicweb:script>') |
398 else: |
398 else: |
399 w(self.script_opening) |
399 w(self.script_opening) |
400 w(u'\n\n'.join(self.post_inlined_scripts)) |
400 w(u'\n\n'.join(self.post_inlined_scripts)) |
401 w(self.script_closing) |
401 w(self.script_closing) |
402 header = super(HTMLHead, self).getvalue() |
402 header = super(HTMLHead, self).getvalue() |
453 @property |
453 @property |
454 def htmltag(self): |
454 def htmltag(self): |
455 attrs = ' '.join('%s="%s"' % (attr, xml_escape(value)) |
455 attrs = ' '.join('%s="%s"' % (attr, xml_escape(value)) |
456 for attr, value in self._htmlattrs) |
456 for attr, value in self._htmlattrs) |
457 if attrs: |
457 if attrs: |
458 return '<html %s>' % attrs |
458 return '<html xmlns:cubicweb="http://www.cubicweb.org" %s>' % attrs |
459 return '<html>' |
459 return '<html xmlns:cubicweb="http://www.cubicweb.org">' |
460 |
460 |
461 def getvalue(self): |
461 def getvalue(self): |
462 """writes HTML headers, closes </head> tag and writes HTML body""" |
462 """writes HTML headers, closes </head> tag and writes HTML body""" |
463 return u'%s\n%s\n%s\n%s\n</html>' % (self.doctype, |
463 return u'%s\n%s\n%s\n%s\n</html>' % (self.doctype, |
464 self.htmltag, |
464 self.htmltag, |