]> jfr.im git - irc/quakenet/qwebirc.git/blob - pagegen.py
Better hilighting.
[irc/quakenet/qwebirc.git] / pagegen.py
1 import os, sys
2
3 IRC_BASE = ["ircconnection", "irclib", "numerics", "baseircclient", "irctracker", "commandparser", "ircclient", "commandhistory"]
4 UI_BASE = ["baseui", "baseuiwindow", "colour", "url", "theme", "genericlogin", "embedwizard", "hilightcontroller"]
5
6 DEBUG_BASE = ["qwebirc", "version", "jslib", ["irc/%s" % x for x in IRC_BASE], ["ui/%s" % x for x in UI_BASE], "qwebircinterface"]
7 BUILD_BASE = ["qwebirc"]
8 JS_BASE = ["mootools-1.2-core"]
9
10 UIs = {
11 "qui": {
12 "class": "QUI",
13 "uifiles": ["qui"],
14 "doctype": "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"" + "\n" \
15 " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"
16 },
17 "mochaui": {
18 "class": "MochaUI",
19 "uifiles": ["mochaui"],
20 "extra": ["mootools-1.2-more", "mochaui/mocha"],
21 "buildextra": ["mootools-1.2-more", "mochaui/mocha-compressed"],
22 "doctype": "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">",
23 "div": """
24 <div id="desktop">
25 <div id="dockWrapper">
26 <div id="dock">
27 <div id="dockPlacement"></div>
28 <div id="dockAutoHide"></div>
29 <div id="dockSort"><div id="dockClear" class="clear"></div></div>
30 </div>
31 </div>
32 <div id="pageWrapper"></div>
33 </div>""",
34 "extracss": ["mochaui/ui", "mochaui/content"],
35 "customjs": """
36 <!--[if IE]>
37 <script type="text/javascript" src="js/mochaui/excanvas-compressed.js"></script>
38 <![endif]-->"""
39 },
40 "swmui": {
41 "class": "SWMUI",
42 "uifiles": ["swmui", "swmuilayout"],
43 "doctype": "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">"
44 },
45 "uglyui": {
46 "class": "UglyUI",
47 "uifiles": ["uglyui"],
48 "doctype": "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">"
49 }
50 }
51
52 def flatten(y):
53 for x in y:
54 if isinstance(x, list):
55 for x in flatten(x):
56 yield x
57 else:
58 yield x
59
60 DEBUG = ["debug/%s" % x for x in flatten(DEBUG_BASE)]
61
62 def jslist(name, debug):
63 ui = UIs[name]
64 if debug:
65 x = [JS_BASE, ui.get("extra", []), DEBUG, ["debug/ui/%s" % y for y in ui["uifiles"]]]
66 else:
67 x = [JS_BASE, ui.get("buildextra", ui.get("extra", [])), BUILD_BASE, name]
68
69 return list("js/%s.js" % y for y in flatten(x))
70
71 def csslist(name):
72 ui = UIs[name]
73 return list("css/%s.css" % x for x in flatten(["colours", ui.get("extracss", []), "%s" % name]))
74
75 def producehtml(name, debug):
76 ui = UIs[name]
77 js = jslist(name, debug)
78 css = csslist(name)
79
80 csshtml = "\n".join(" <link rel=\"stylesheet\" href=\"%s\" type=\"text/css\"/>" % x for x in css)
81 jshtml = "\n".join(" <script type=\"text/javascript\" src=\"%s\"></script>" % x for x in js)
82
83 div = ui.get("div", "")
84 customjs = ui.get("customjs", "")
85
86 return """%s
87 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
88 <head>
89 <title>QuakeNet Web IRC</title>
90 <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
91 <link rel="icon" type="image/png" href="images/favicon.png"/>
92 %s%s
93 %s
94 <script type="text/javascript">
95 var ui = new qwebirc.ui.Interface("ircui", qwebirc.ui.%s);
96 </script>
97 </head>
98 <body>
99 <div id="ircui">%s
100 </div>
101 </body>
102 </html>
103 """ % (ui["doctype"], csshtml, customjs, jshtml, ui["class"], div)
104
105 def main():
106 p = os.path.join(os.path.abspath(os.path.split(sys.argv[0])[0]), "static")
107 for x in UIs:
108 f = open(os.path.join(p, "%sdebug.html" % x), "wb")
109 try:
110 f.write(producehtml(x, debug=True))
111 finally:
112 f.close()
113
114 f = open(os.path.join(p, "%s.html" % x), "wb")
115 try:
116 f.write(producehtml(x, debug=False))
117 finally:
118 f.close()
119
120 if __name__ == "__main__":
121 main()
122