]>
Commit | Line | Data |
---|---|---|
01a3d0e1 | 1 | import os, sys, pages |
ef8a4598 CP |
2 | |
3 | def jslist(name, debug): | |
01a3d0e1 | 4 | ui = pages.UIs[name] |
ef8a4598 | 5 | if debug: |
01a3d0e1 | 6 | x = [pages.JS_BASE, ui.get("extra", []), pages.DEBUG, ["debug/ui/frontends/%s" % y for y in ui["uifiles"]]] |
ef8a4598 | 7 | else: |
60ce7bee CP |
8 | #x = [pages.JS_BASE, ui.get("buildextra", ui.get("extra", [])), pages.BUILD_BASE, name] |
9 | x = [name] | |
ef8a4598 | 10 | |
01a3d0e1 | 11 | return list("js/%s.js" % y for y in pages.flatten(x)) |
ef8a4598 | 12 | |
60ce7bee CP |
13 | def csslist(name, debug, gen=False): |
14 | if not debug: | |
15 | return ["css/%s.css" % name] | |
01a3d0e1 | 16 | ui = pages.UIs[name] |
60ce7bee | 17 | return list("css/%s%s.css" % ("debug/" if gen else "", x) for x in pages.flatten([ui.get("extracss", []), "colours", "dialogs", "%s" % name])) |
ef8a4598 CP |
18 | |
19 | def producehtml(name, debug): | |
01a3d0e1 | 20 | ui = pages.UIs[name] |
ef8a4598 | 21 | js = jslist(name, debug) |
60ce7bee | 22 | css = csslist(name, debug) |
8a56ed4c | 23 | csshtml = "\n".join(" <link rel=\"stylesheet\" href=\"%s\" type=\"text/css\"/>" % x for x in css) |
ef8a4598 CP |
24 | jshtml = "\n".join(" <script type=\"text/javascript\" src=\"%s\"></script>" % x for x in js) |
25 | ||
26 | div = ui.get("div", "") | |
27 | customjs = ui.get("customjs", "") | |
28 | ||
29 | return """%s | |
8a56ed4c | 30 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> |
ef8a4598 CP |
31 | <head> |
32 | <title>QuakeNet Web IRC</title> | |
8a56ed4c CP |
33 | <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/> |
34 | <link rel="icon" type="image/png" href="images/favicon.png"/> | |
ef8a4598 CP |
35 | %s%s |
36 | %s | |
37 | <script type="text/javascript"> | |
38 | var ui = new qwebirc.ui.Interface("ircui", qwebirc.ui.%s); | |
39 | </script> | |
40 | </head> | |
41 | <body> | |
0b638f3c CP |
42 | <div id="ircui"> |
43 | <noscript> | |
44 | <div id="noscript">Javascript is required to use IRC.</div> | |
45 | </noscript>%s | |
ef8a4598 CP |
46 | </div> |
47 | </body> | |
48 | </html> | |
49 | """ % (ui["doctype"], csshtml, customjs, jshtml, ui["class"], div) | |
50 | ||
60ce7bee | 51 | def main(outputdir=".", produce_debug=True): |
01a3d0e1 CP |
52 | p = os.path.join(outputdir, "static") |
53 | for x in pages.UIs: | |
60ce7bee CP |
54 | if produce_debug: |
55 | f = open(os.path.join(p, "%sdebug.html" % x), "wb") | |
56 | try: | |
57 | f.write(producehtml(x, debug=True)) | |
58 | finally: | |
59 | f.close() | |
ef8a4598 CP |
60 | |
61 | f = open(os.path.join(p, "%s.html" % x), "wb") | |
62 | try: | |
63 | f.write(producehtml(x, debug=False)) | |
64 | finally: | |
65 | f.close() | |
66 | ||
67 | if __name__ == "__main__": | |
68 | main() | |
69 |