]> jfr.im git - irc/quakenet/qwebirc.git/blobdiff - bin/pagegen.py
fix debug javascript ending up in css
[irc/quakenet/qwebirc.git] / bin / pagegen.py
index 008ee718a48754084c6a6df366faa16e19d4c5a8..4bd950d8841b6929503f20889daeadfb5287f4cf 100755 (executable)
@@ -16,10 +16,14 @@ def jslist(name, debug):
   return list("js/%s%s.js" % (y, hgid) for y in pages.flatten(x))
 
 def csslist(name, debug, gen=False):
+  ui = pages.UIs[name]
+  nocss = ui.get("nocss")
   if not debug:
     return ["css/%s-%s.css" % (name, gethgid())]
-  ui = pages.UIs[name]
-  return list("css/%s%s.css" % ("debug/" if gen else "", x) for x in pages.flatten([ui.get("extracss", []), "colours", "dialogs", "%s" % name]))
+  css = pages.flatten([ui.get("extracss", []), "colours", "dialogs"])
+  if not nocss:
+    css = list(css) + [name]
+  return list("css/%s%s.css" % ("debug/" if gen else "", x) for x in css)
 
 def _gethgid():
   try:
@@ -27,7 +31,8 @@ def _gethgid():
   except Exception, e:
     if hasattr(e, "errno") and e.errno == 2:
       raise HGException, "unable to execute"
-      
+    raise HGException, "unknown exception running hg: %s" % repr(e)
+    
   data = p.communicate()[0]
   if p.wait() != 0:
     raise HGException, "unable to get id"
@@ -48,18 +53,28 @@ def producehtml(name, debug):
   ui = pages.UIs[name]
   js = jslist(name, debug)
   css = csslist(name, debug, gen=True)
-  csshtml = "\n".join("  <link rel=\"stylesheet\" href=\"%s\" type=\"text/css\"/>" % x for x in css)
-  jshtml = "\n".join("  <script type=\"text/javascript\" src=\"%s\"></script>" % x for x in js)
+  csshtml = "\n".join("  <link rel=\"stylesheet\" href=\"%s%s\" type=\"text/css\"/>" % (config.STATIC_BASE_URL, x) for x in css)
+  jshtml = "\n".join("  <script type=\"text/javascript\" src=\"%s%s\"></script>" % (config.STATIC_BASE_URL, x) for x in js)
+
+  if hasattr(config, "ANALYTICS_HTML"):
+    jshtml+="\n" + config.ANALYTICS_HTML
 
   div = ui.get("div", "")
   customjs = ui.get("customjs", "")
 
+  if debug:
+    customjs = """<script type="text/javascript">
+QWEBIRC_DEBUG = true;
+</script>
+""" + customjs
+
   return """%s
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 <head>
+  <base />
   <title>%s (qwebirc)</title>
   <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
-  <link rel="icon" type="image/png" href="images/favicon.png"/>
+  <link rel="shortcut icon" type="image/png" href="%simages/favicon.png"/>
 %s%s
 %s
   <script type="text/javascript">
@@ -74,7 +89,7 @@ def producehtml(name, debug):
   </div>
 </body>
 </html>
-""" % (ui["doctype"], config.APP_TITLE, csshtml, customjs, jshtml, ui["class"], optionsgen.get_options(), div)
+""" % (ui["doctype"], config.APP_TITLE, config.STATIC_BASE_URL, csshtml, customjs, jshtml, ui["class"], optionsgen.get_options(), div)
 
 def main(outputdir=".", produce_debug=True):
   p = os.path.join(outputdir, "static")
@@ -94,4 +109,4 @@ def main(outputdir=".", produce_debug=True):
 
 if __name__ == "__main__":
   main()
-  
\ No newline at end of file
+