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