]>
Commit | Line | Data |
---|---|---|
ef8a4598 CP |
1 | import os, sys |
2 | ||
3 | IRC_BASE = ["ircconnection", "irclib", "numerics", "baseircclient", "irctracker", "commandparser", "ircclient", "commandhistory"] | |
96f28062 | 4 | UI_BASE = ["baseui", "baseuiwindow", "colour", "url", "theme", "genericlogin", "embedwizard", "hilightcontroller"] |
ef8a4598 CP |
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" \ | |
8a56ed4c | 15 | " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">" |
ef8a4598 CP |
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 | ||
8a56ed4c | 80 | csshtml = "\n".join(" <link rel=\"stylesheet\" href=\"%s\" type=\"text/css\"/>" % x for x in css) |
ef8a4598 CP |
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 | |
8a56ed4c | 87 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> |
ef8a4598 CP |
88 | <head> |
89 | <title>QuakeNet Web IRC</title> | |
8a56ed4c CP |
90 | <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/> |
91 | <link rel="icon" type="image/png" href="images/favicon.png"/> | |
ef8a4598 CP |
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> | |
0b638f3c CP |
99 | <div id="ircui"> |
100 | <noscript> | |
101 | <div id="noscript">Javascript is required to use IRC.</div> | |
102 | </noscript>%s | |
ef8a4598 CP |
103 | </div> |
104 | </body> | |
105 | </html> | |
106 | """ % (ui["doctype"], csshtml, customjs, jshtml, ui["class"], div) | |
107 | ||
108 | def main(): | |
109 | p = os.path.join(os.path.abspath(os.path.split(sys.argv[0])[0]), "static") | |
110 | for x in UIs: | |
111 | f = open(os.path.join(p, "%sdebug.html" % x), "wb") | |
112 | try: | |
113 | f.write(producehtml(x, debug=True)) | |
114 | finally: | |
115 | f.close() | |
116 | ||
117 | f = open(os.path.join(p, "%s.html" % x), "wb") | |
118 | try: | |
119 | f.write(producehtml(x, debug=False)) | |
120 | finally: | |
121 | f.close() | |
122 | ||
123 | if __name__ == "__main__": | |
124 | main() | |
125 |