360 (media, xml_escape(cssfile))) |
360 (media, xml_escape(cssfile))) |
361 w(u'<![endif]--> \n') |
361 w(u'<![endif]--> \n') |
362 # 4/ js files |
362 # 4/ js files |
363 jsfiles = ((x, None) for x in self.jsfiles) |
363 jsfiles = ((x, None) for x in self.jsfiles) |
364 for jsfile, media in self.group_urls(jsfiles) if self.datadir_url else jsfiles: |
364 for jsfile, media in self.group_urls(jsfiles) if self.datadir_url else jsfiles: |
365 w(u'<script type="text/javascript" src="%s"></script>\n' % |
365 if skiphead: |
366 xml_escape(jsfile)) |
366 # Don't insert <script> tags directly as they would be |
|
367 # interpreted directly by some browsers (e.g. IE). |
|
368 # Use <pre class="script"> tags instead and let |
|
369 # `loadAjaxHtmlHead` handle the script insertion / execution. |
|
370 w(u'<pre class="script" src="%s"></pre>\n' % |
|
371 xml_escape(jsfile)) |
|
372 # FIXME: a probably better implementation might be to add |
|
373 # JS or CSS urls in a JS list that loadAjaxHtmlHead |
|
374 # would iterate on and postprocess: |
|
375 # cw._ajax_js_scripts.push('myscript.js') |
|
376 # Then, in loadAjaxHtmlHead, do something like: |
|
377 # jQuery.each(cw._ajax_js_script, jQuery.getScript) |
|
378 else: |
|
379 w(u'<script type="text/javascript" src="%s"></script>\n' % |
|
380 xml_escape(jsfile)) |
367 # 5/ post inlined scripts (i.e. scripts depending on other JS files) |
381 # 5/ post inlined scripts (i.e. scripts depending on other JS files) |
368 if self.post_inlined_scripts: |
382 if self.post_inlined_scripts: |
369 w(self.xhtml_safe_script_opening) |
383 if skiphead: |
370 w(u'\n\n'.join(self.post_inlined_scripts)) |
384 for script in self.post_inlined_scripts: |
371 w(self.xhtml_safe_script_closing) |
385 w(u'<pre class="script">') |
|
386 w(script) |
|
387 w(u'</pre>') |
|
388 else: |
|
389 w(self.xhtml_safe_script_opening) |
|
390 w(u'\n\n'.join(self.post_inlined_scripts)) |
|
391 w(self.xhtml_safe_script_closing) |
372 header = super(HTMLHead, self).getvalue() |
392 header = super(HTMLHead, self).getvalue() |
373 if skiphead: |
393 if skiphead: |
374 return header |
394 return header |
375 return u'<head>\n%s</head>\n' % header |
395 return u'<head>\n%s</head>\n' % header |
376 |
396 |