]>
jfr.im git - irc/quakenet/qwebirc.git/blob - bin/pagegen.py
1 import os
, sys
, pages
, subprocess
, re
3 def jslist(name
, debug
):
6 x
= [pages
.JS_BASE
, ui
.get("extra", []), pages
.DEBUG
, ["debug/ui/frontends/%s" % y
for y
in ui
["uifiles"]]]
9 #x = [pages.JS_BASE, ui.get("buildextra", ui.get("extra", [])), pages.BUILD_BASE, name]
11 hgid
= "-" + gethgid()
13 return list("js/%s%s.js" % (y
, hgid
) for y
in pages
.flatten(x
))
15 def csslist(name
, debug
, gen
=False):
17 return ["css/%s-%s.css" % (name
, gethgid())]
19 return list("css/%s%s.css" % ("debug/" if gen
else "", x
) for x
in pages
.flatten([ui
.get("extracss", []), "colours", "dialogs", "%s" % name
]))
25 hgid
= subprocess
.Popen(["hg", "id"], stdout
=subprocess
.PIPE
).communicate()[0]
26 HGID
= re
.match("^([0-9a-f]+).*", hgid
).group(1)
29 def producehtml(name
, debug
):
31 js
= jslist(name
, debug
)
32 css
= csslist(name
, debug
, gen
=True)
33 csshtml
= "\n".join(" <link rel=\"stylesheet\" href=\"%s\" type=\"text/css\"/>" % x
for x
in css
)
34 jshtml
= "\n".join(" <script type=\"text/javascript\" src=\"%s\"></script>" % x
for x
in js
)
36 div
= ui
.get("div", "")
37 customjs
= ui
.get("customjs", "")
40 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
42 <title>QuakeNet Web IRC</title>
43 <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
44 <link rel="icon" type="image/png" href="images/favicon.png"/>
47 <script type="text/javascript">
48 var ui = new qwebirc.ui.Interface("ircui", qwebirc.ui.%s);
54 <div id="noscript">Javascript is required to use IRC.</div>
59 """ % (ui
["doctype"], csshtml
, customjs
, jshtml
, ui
["class"], div
)
61 def main(outputdir
=".", produce_debug
=True):
62 p
= os
.path
.join(outputdir
, "static")
65 f
= open(os
.path
.join(p
, "%sdebug.html" % x
), "wb")
67 f
.write(producehtml(x
, debug
=True))
71 f
= open(os
.path
.join(p
, "%s.html" % x
), "wb")
73 f
.write(producehtml(x
, debug
=False))
77 if __name__
== "__main__":