]>
Commit | Line | Data |
---|---|---|
1 | import os, sys | |
2 | ||
3 | IRC_BASE = ["ircconnection", "irclib", "numerics", "baseircclient", "irctracker", "commandparser", "commands", "ircclient", "commandhistory"] | |
4 | UI_BASE = ["baseui", "baseuiwindow", "colour", "url", "theme", "hilightcontroller", "menuitems", "tabcompleter", "panes/connect", "panes/embed", "panes/options", "panes/about", "panes/privacypolicy", "panes/feedback"] | |
5 | ||
6 | DEBUG_BASE = ["qwebirc", "version", "jslib", "crypto", "md5", ["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", "mootools-1.2-more"] | |
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": ["mochaui/mocha"], | |
21 | "buildextra": ["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", "swmlayout"], | |
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_BASE = list(flatten(DEBUG_BASE)) | |
61 | DEBUG = ["debug/%s" % x for x in DEBUG_BASE] | |
62 | ||
63 | def jslist(name, debug): | |
64 | ui = UIs[name] | |
65 | if debug: | |
66 | x = [JS_BASE, ui.get("extra", []), DEBUG, ["debug/ui/frontends/%s" % y for y in ui["uifiles"]]] | |
67 | else: | |
68 | x = [JS_BASE, ui.get("buildextra", ui.get("extra", [])), BUILD_BASE, name] | |
69 | ||
70 | return list("js/%s.js" % y for y in flatten(x)) | |
71 | ||
72 | def csslist(name): | |
73 | ui = UIs[name] | |
74 | return list("css/%s.css" % x for x in flatten([ui.get("extracss", []), "colours", "dialogs", "%s" % name])) | |
75 | ||
76 | def producehtml(name, debug): | |
77 | ui = UIs[name] | |
78 | js = jslist(name, debug) | |
79 | css = csslist(name) | |
80 | ||
81 | csshtml = "\n".join(" <link rel=\"stylesheet\" href=\"%s\" type=\"text/css\"/>" % x for x in css) | |
82 | jshtml = "\n".join(" <script type=\"text/javascript\" src=\"%s\"></script>" % x for x in js) | |
83 | ||
84 | div = ui.get("div", "") | |
85 | customjs = ui.get("customjs", "") | |
86 | ||
87 | return """%s | |
88 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> | |
89 | <head> | |
90 | <title>QuakeNet Web IRC</title> | |
91 | <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/> | |
92 | <link rel="icon" type="image/png" href="images/favicon.png"/> | |
93 | %s%s | |
94 | %s | |
95 | <script type="text/javascript"> | |
96 | var ui = new qwebirc.ui.Interface("ircui", qwebirc.ui.%s); | |
97 | </script> | |
98 | </head> | |
99 | <body> | |
100 | <div id="ircui"> | |
101 | <noscript> | |
102 | <div id="noscript">Javascript is required to use IRC.</div> | |
103 | </noscript>%s | |
104 | </div> | |
105 | </body> | |
106 | </html> | |
107 | """ % (ui["doctype"], csshtml, customjs, jshtml, ui["class"], div) | |
108 | ||
109 | def main(): | |
110 | p = os.path.join(os.path.abspath(os.path.split(sys.argv[0])[0]), "static") | |
111 | for x in UIs: | |
112 | f = open(os.path.join(p, "%sdebug.html" % x), "wb") | |
113 | try: | |
114 | f.write(producehtml(x, debug=True)) | |
115 | finally: | |
116 | f.close() | |
117 | ||
118 | f = open(os.path.join(p, "%s.html" % x), "wb") | |
119 | try: | |
120 | f.write(producehtml(x, debug=False)) | |
121 | finally: | |
122 | f.close() | |
123 | ||
124 | if __name__ == "__main__": | |
125 | main() | |
126 |