]> jfr.im git - irc/quakenet/qwebirc.git/blobdiff - bin/pagegen.py
tidy up autobahn support -- now requires 0.17.2
[irc/quakenet/qwebirc.git] / bin / pagegen.py
index 7423a2bd7e2ffb2403ef3d57a9ef2bdfe7e03cbb..b05cd6ec52218f61f1d32a98bfb9a7fa04e490e7 100755 (executable)
@@ -1,53 +1,56 @@
 import os, sys, pages, subprocess, re, optionsgen, config
 
-class HGException(Exception):
+class GitException(Exception):
   pass
   
 def jslist(name, debug):
   ui = pages.UIs[name]
   if debug:
     x = [pages.JS_DEBUG_BASE, ui.get("extra", []), pages.DEBUG, ["debug/ui/frontends/%s" % y for y in ui["uifiles"]]]
-    hgid = ""
+    gitid = ""
   else:
     #x = [pages.JS_BASE, ui.get("buildextra", ui.get("extra", [])), pages.BUILD_BASE, name]
     x = [pages.JS_RAW_BASE, name]
-    hgid = "-" + gethgid()  
+    gitid = "-" + getgitid()  
   
-  return list(y if y.startswith("//") else "js/%s%s.js" % (y, hgid) for y in pages.flatten(x))
+  return list(y if y.startswith("//") else "js/%s%s.js" % (y, gitid) 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())]
-  css = pages.flatten([ui.get("extracss", []), "colours", "dialogs"])
+    return ["css/%s-%s.css" % (name, getgitid())]
+  css = list(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)
+    css+=[name]
+  css = ["%s.css" % x for x in css]
+  if hasattr(config, "CUSTOM_CSS"):
+    css+=[config.CUSTOM_CSS]
+  return list("css/%s%s" % ("debug/" if gen else "", x) for x in css)
 
-def _gethgid():
+def _getgitid():
   try:
-    p = subprocess.Popen(["hg", "id"], stdout=subprocess.PIPE, shell=os.name == "nt")
+    p = subprocess.Popen(["git", "rev-parse", "HEAD"], stdout=subprocess.PIPE, shell=os.name == "nt")
   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)
+      raise GitException, "unable to execute"
+    raise GitException, "unknown exception running git: %s" % repr(e)
     
   data = p.communicate()[0]
   if p.wait() != 0:
-    raise HGException, "unable to get id"
+    raise GitException, "unable to get id"
   return re.match("^([0-9a-f]+).*", data).group(1)
 
-HGID = None
-def gethgid():
-  global HGID
-  if HGID is None:
+GITID = None
+def getgitid():
+  global GITID
+  if GITID is None:
     try:
-      HGID =  _gethgid()
-    except HGException, e:
-      print >>sys.stderr, "warning: hg: %s (using a random id)." % e
-      HGID = os.urandom(10).encode("hex")
-  return HGID
+      GITID =  _getgitid()
+    except GitException, e:
+      print >>sys.stderr, "warning: git: %s (using a random id)." % e
+      GITID = os.urandom(10).encode("hex")
+  return GITID
     
 def producehtml(name, debug):
   ui = pages.UIs[name]
@@ -68,7 +71,9 @@ def producehtml(name, debug):
   <base />
   <title>%s (qwebirc)</title>
   <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
-  <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" />
+  <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" />
+  <meta name="mobile-web-app-capable" content="yes" />
+  <link rel="icon" sizes="192x192" href="%simages/highresicon.png"/>
   <link rel="shortcut icon" type="image/png" href="%simages/favicon.png"/>
 %s<script type="text/javascript">QWEBIRC_DEBUG=%s;</script>%s
 %s
@@ -84,7 +89,7 @@ def producehtml(name, debug):
   </div>
 </body>
 </html>
-""" % (ui["doctype"], config.APP_TITLE, config.STATIC_BASE_URL, csshtml, debug and "true" or "false", customjs, jshtml, ui["class"], optionsgen.get_options(), div)
+""" % (ui["doctype"], config.APP_TITLE, config.STATIC_BASE_URL, config.STATIC_BASE_URL, csshtml, debug and "true" or "false", customjs, jshtml, ui["class"], optionsgen.get_options(), div)
 
 def main(outputdir=".", produce_debug=True):
   p = os.path.join(outputdir, "static")