]> jfr.im git - irc/quakenet/qwebirc.git/commitdiff
Cleanup compiling code and add clean/mkstatic.
authorChris Porter <redacted>
Sun, 1 Feb 2009 01:40:27 +0000 (01:40 +0000)
committerChris Porter <redacted>
Sun, 1 Feb 2009 01:40:27 +0000 (01:40 +0000)
Move authgate.

TODO.txt [deleted file]
clean.py [new file with mode: 0644]
cleanpyc.py [new file with mode: 0644]
compile.py
mkstatic.py [new file with mode: 0644]
pagegen.py
pages.py [new file with mode: 0644]
qwebirc/engines/authgateengine.py

diff --git a/TODO.txt b/TODO.txt
deleted file mode 100644 (file)
index bbdf0ce..0000000
--- a/TODO.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-UI:
-  FEAT: tab dragging
-  FEAT: link options, about and embedded wizard somewhere more obvious.
-  FEAT: Last position line
-  FEAT: [ ] style titlebar flashing
-  FEAT: Save last nick/chans in cookies.
-  FEAT: multiline pastes
-  
-Authing:
-  FEAT: Login button should save state on form.
-  TIDY: Fix up state inconsistency if backend is restarted (state is stored in user cookie and not refreshed except on login).
-  FEAT: bind qticket to session to prevent ticket reuse within time limit.
-  FEAT: on startup: if autojoin channels exist and Q invites then the autojoin channels should be focused rather than the Q invited ones.
-  
-IRC:  
-  TIDY: /msg $ goes to status, as does /notice $, should go to active.
-  
-Options pane:
-  FEAT: Store options server side when logged in.
diff --git a/clean.py b/clean.py
new file mode 100644 (file)
index 0000000..e14d027
--- /dev/null
+++ b/clean.py
@@ -0,0 +1,13 @@
+#!/usr/bin/env python
+
+import pages, os, cleanpyc
+from cleanpyc import tryunlink
+  
+for x in pages.UIs:
+  tryunlink("static", "%s.html" % x)
+  tryunlink("static", "%sdebug.html" % x)  
+  tryunlink("static", "js", "%s.js" % x)
+
+if __name__ == "__main__":
+  tryunlink("static", "js", "qwebirc.js")
+  cleanpyc.main()
diff --git a/cleanpyc.py b/cleanpyc.py
new file mode 100644 (file)
index 0000000..b10f173
--- /dev/null
@@ -0,0 +1,18 @@
+#!/usr/bin/env python
+import os
+
+def tryunlink(*args):
+  fn = os.path.join(*args)
+  if os.path.exists(fn):
+    os.unlink(fn)
+    
+def main():
+  for root, dirs, files in os.walk("."):
+    if ".hg" in dirs:
+      dirs.remove(".hg")
+    for x in files:
+      if os.path.splitext(x)[-1] == ".pyc":
+        tryunlink(root, x)
+
+if __name__ == "__main__":
+  main()
\ No newline at end of file
index 8a619534d2cba09c6f96b78b8784ed04570719d0..57f9a27cbc3f85cf74ed338767757fcac02476d9 100644 (file)
@@ -1,18 +1,20 @@
 #!/usr/bin/env python
-import pagegen, os, subprocess
+import pages, os, subprocess, pagegen
+
+COPYRIGHT = open("js/copyright.js", "rb").read()
 
 def jarit(src):
   return subprocess.Popen(["java", "-jar", "bin/yuicompressor-2.3.5.jar", src], stdout=subprocess.PIPE).communicate()[0]
 
-def jmerge_files(output, files, *args):
-  global copyright
+def jmerge_files(prefix, output, files, *args):
+  global COPYRIGHT
   output = output + ".js"
-  o = os.path.join("compiled", output)
+  o = os.path.join(prefix, "compiled", output)
   merge_files(o, files, *args)
   compiled = jarit(o)
   os.unlink(o)
-  f = open(os.path.join("static", "js", output), "wb")
-  f.write(copyright)
+  f = open(os.path.join(prefix, "static", "js", output), "wb")
+  f.write(COPYRIGHT)
   f.write(compiled)
   f.close()
   
@@ -25,23 +27,22 @@ def merge_files(output, files, root_path=lambda x: x):
     f2.close()
   f.close()
 
-def compile():  
-  pagegen.main()
+def main(outputdir="."):
+  pagegen.main(outputdir)
 
+  coutputdir = os.path.join(outputdir, "compiled")
   try:
-    os.mkdir("compiled")
+    os.mkdir(coutputdir)
   except:
     pass
   
-  copyright = open("js/copyright.js", "rb").read()
-
-  jmerge_files("qwebirc", pagegen.DEBUG_BASE, lambda x: os.path.join("js", x + ".js"))
+  jmerge_files(outputdir, "qwebirc", pages.DEBUG_BASE, lambda x: os.path.join("js", x + ".js"))
 
-  for uiname, value in pagegen.UIs.items():
-    jmerge_files(uiname, value["uifiles"], lambda x: os.path.join("js", "ui", "frontends", x + ".js"))
+  for uiname, value in pages.UIs.items():
+    jmerge_files(outputdir, uiname, value["uifiles"], lambda x: os.path.join("js", "ui", "frontends", x + ".js"))
 
-  os.rmdir("compiled")
+  os.rmdir(coutputdir)
   
 if __name__ == "__main__":
-  compile()
+  main()
   
\ No newline at end of file
diff --git a/mkstatic.py b/mkstatic.py
new file mode 100644 (file)
index 0000000..5b2b740
--- /dev/null
@@ -0,0 +1,102 @@
+#!/usr/bin/env python
+import compile, pages, sys, os, shutil, compileall
+
+def trymkdir(*dir):
+  try:
+    os.mkdir(os.path.join(*dir))
+  except:
+    pass
+
+def copywalk(src, dest, visitor):
+  for root, dirs, files in os.walk(src):
+    if ".hg" in dirs:
+      dirs.remove(".hg")
+      
+    newdir = os.path.join(dest, root)
+    if not os.path.exists(newdir):
+      os.mkdir(newdir)
+    for file in files:
+      if not visitor(file):
+        continue
+        
+      destfile = os.path.join(dest, root, file)
+      dir, _ = os.path.split(destfile)
+      if not os.path.exists(dir):
+        os.mkdir(dir)
+      shutil.copy2(os.path.join(root, file), destfile)
+        
+def copypydir(src, dest):
+  copywalk(src, dest, lambda file: os.path.splitext(file)[1] == ".py")
+
+def copypycdir(src, dest):
+  copywalk(src, dest, lambda file: os.path.splitext(file)[1] == ".py")
+
+def copydir(src, dest):
+  copywalk(src, dest, lambda file: os.path.splitext(file)[1] != ".pyc")
+  
+def copy(src, dest):
+  shutil.copy2(src, os.path.join(dest, src))
+
+def compile_python(dest):
+  compileall.compile_dir(dest, quiet=1, force=1)
+  
+def remove_python(dest, ignore=[]):
+  ignore = set(ignore)
+  for root, dirs, files in os.walk(dest):
+    for file in files:
+      if file in ignore:
+        continue
+      if os.path.splitext(file)[1] == ".py":
+        rfile = os.path.join(root, file)
+        os.unlink(rfile)
+        
+def main():
+  if len(sys.argv) < 2:
+    print >>sys.stderr, "syntax: %s [destination directory]" % sys.argv[0]
+    sys.exit(0)
+  DEST = sys.argv[1]
+  
+  trymkdir(DEST)
+  trymkdir(DEST, "static")
+  trymkdir(DEST, "static", "js")
+    
+  compile.main(DEST)
+  
+  for x in "authgate qwebirc simplejson twisted".split(" "):
+    copypydir(x, DEST)
+  for x in "css images panes sound".split(" "):
+    copydir(os.path.join("static", x), DEST)
+    
+  for x in pages.JS_BASE:
+    copy(os.path.join("static", "js", "%s.js" % x), DEST)
+    
+  for x in pages.UIs.values():
+    e = x.get("buildextra")
+    if e is None:
+      continue
+    for x2 in e:
+      file = os.path.join("static", "js", "%s.js" % x2)
+      destfile = os.path.join(DEST, file)
+      dir, _ = os.path.split(destfile)
+      if not os.path.exists(dir):
+        os.mkdir(dir)
+      copy(file, DEST)
+  
+  copy(os.path.join("static/favicon.ico"), DEST)
+  
+  if 0:
+    compile_python(DEST)
+    remove_python(DEST)
+  else:
+    copy("cleanpyc.py", DEST)
+    
+  copy("run.py", DEST)
+  copy("config.py.example", DEST)
+  
+  if os.path.exists("config.py"):
+    print "NOT copying current config.py!"
+    #copy("config.py", DEST)
+  
+if __name__ == "__main__":
+  main()
+  
\ No newline at end of file
index ba901191643aa32e53a8d27a9f59b91c640c9346..7f0a68a3bb35ff498bccfddcdf00e46102e796f5 100644 (file)
@@ -1,80 +1,20 @@
-import os, sys
-
-IRC_BASE = ["ircconnection", "irclib", "numerics", "baseircclient", "irctracker", "commandparser", "commands", "ircclient", "commandhistory"]
-UI_BASE = ["baseui", "baseuiwindow", "colour", "url", "theme", "hilightcontroller", "menuitems", "tabcompleter", "panes/connect", "panes/embed", "panes/options", "panes/about", "panes/privacypolicy", "panes/feedback"]
-
-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"]
-BUILD_BASE = ["qwebirc"]
-JS_BASE = ["mootools-1.2.1-core", "mootools-1.2-more"]
-
-UIs = {
-  "qui": {
-    "class": "QUI",
-    "uifiles": ["qui"],
-    "doctype": "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"" + "\n" \
-      "  \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"
-  },
-  "mochaui": {
-    "class": "MochaUI",
-    "uifiles": ["mochaui"],
-    "extra": ["mochaui/mocha"],
-    "buildextra": ["mochaui/mocha-compressed"],
-    "doctype": "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">",
-    "div": """
-    <div id="desktop">
-      <div id="dockWrapper">
-        <div id="dock">
-          <div id="dockPlacement"></div>
-          <div id="dockAutoHide"></div>
-          <div id="dockSort"><div id="dockClear" class="clear"></div></div>
-        </div>
-      </div>   
-      <div id="pageWrapper"></div>
-    </div>""",
-    "extracss": ["mochaui/ui", "mochaui/content"],
-    "customjs": """
-  <!--[if IE]>
-    <script type="text/javascript" src="js/mochaui/excanvas-compressed.js"></script>           
-  <![endif]-->"""
-  },
-  "swmui": {
-    "class": "SWMUI",
-    "uifiles": ["swmui", "swmlayout"],
-    "doctype": "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">"
-  },
-  "uglyui": {
-    "class": "UglyUI",
-    "uifiles": ["uglyui"],
-    "doctype": "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">"
-  }
-}
-
-def flatten(y):
-  for x in y:
-    if isinstance(x, list):
-      for x in flatten(x):
-        yield x
-    else:
-      yield x
-
-DEBUG_BASE = list(flatten(DEBUG_BASE))
-DEBUG = ["debug/%s" % x for x in DEBUG_BASE]
+import os, sys, pages
 
 def jslist(name, debug):
-  ui = UIs[name]
+  ui = pages.UIs[name]
   if debug:
-    x = [JS_BASE, ui.get("extra", []), DEBUG, ["debug/ui/frontends/%s" % y for y in ui["uifiles"]]]
+    x = [pages.JS_BASE, ui.get("extra", []), pages.DEBUG, ["debug/ui/frontends/%s" % y for y in ui["uifiles"]]]
   else:
-    x = [JS_BASE, ui.get("buildextra", ui.get("extra", [])), BUILD_BASE, name]
+    x = [pages.JS_BASE, ui.get("buildextra", ui.get("extra", [])), pages.BUILD_BASE, name]
     
-  return list("js/%s.js" % y for y in flatten(x))
+  return list("js/%s.js" % y for y in pages.flatten(x))
 
 def csslist(name):
-  ui = UIs[name]
-  return list("css/%s.css" % x for x in flatten([ui.get("extracss", []), "colours", "dialogs", "%s" % name]))
+  ui = pages.UIs[name]
+  return list("css/%s.css" % x for x in pages.flatten([ui.get("extracss", []), "colours", "dialogs", "%s" % name]))
 
 def producehtml(name, debug):
-  ui = UIs[name]
+  ui = pages.UIs[name]
   js = jslist(name, debug)
   css = csslist(name)
   
@@ -106,9 +46,9 @@ def producehtml(name, debug):
 </html>
 """ % (ui["doctype"], csshtml, customjs, jshtml, ui["class"], div)
 
-def main():
-  p = os.path.join(os.path.abspath(os.path.split(sys.argv[0])[0]), "static")
-  for x in UIs:
+def main(outputdir=os.path.abspath(os.path.split(sys.argv[0])[0])):
+  p = os.path.join(outputdir, "static")
+  for x in pages.UIs:
     f = open(os.path.join(p, "%sdebug.html" % x), "wb")
     try:
       f.write(producehtml(x, debug=True))
diff --git a/pages.py b/pages.py
new file mode 100644 (file)
index 0000000..deb21dd
--- /dev/null
+++ b/pages.py
@@ -0,0 +1,60 @@
+#!/usr/bin/env python
+IRC_BASE = ["ircconnection", "irclib", "numerics", "baseircclient", "irctracker", "commandparser", "commands", "ircclient", "commandhistory"]
+UI_BASE = ["baseui", "baseuiwindow", "colour", "url", "theme", "hilightcontroller", "menuitems", "tabcompleter", "panes/connect", "panes/embed", "panes/options", "panes/about", "panes/privacypolicy", "panes/feedback"]
+
+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"]
+BUILD_BASE = ["qwebirc"]
+JS_BASE = ["mootools-1.2.1-core", "mootools-1.2-more"]
+
+UIs = {
+  "qui": {
+    "class": "QUI",
+    "uifiles": ["qui"],
+    "doctype": "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"" + "\n" \
+      "  \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"
+  },
+  "mochaui": {
+    "class": "MochaUI",
+    "uifiles": ["mochaui"],
+    "extra": ["mochaui/mocha"],
+    "buildextra": ["mochaui/mocha-compressed", "mochaui/excanvas-compressed"],
+    "doctype": "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">",
+    "div": """
+    <div id="desktop">
+      <div id="dockWrapper">
+        <div id="dock">
+          <div id="dockPlacement"></div>
+          <div id="dockAutoHide"></div>
+          <div id="dockSort"><div id="dockClear" class="clear"></div></div>
+        </div>
+      </div>   
+      <div id="pageWrapper"></div>
+    </div>""",
+    "extracss": ["mochaui/ui", "mochaui/content"],
+    "customjs": """
+  <!--[if IE]>
+    <script type="text/javascript" src="js/mochaui/excanvas-compressed.js"></script>           
+  <![endif]-->"""
+  },
+  "swmui": {
+    "class": "SWMUI",
+    "uifiles": ["swmui", "swmlayout"],
+    "doctype": "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">"
+  },
+  "uglyui": {
+    "class": "UglyUI",
+    "uifiles": ["uglyui"],
+    "doctype": "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">"
+  }
+}
+
+def flatten(y):
+  for x in y:
+    if isinstance(x, list):
+      for x in flatten(x):
+        yield x
+    else:
+      yield x
+
+DEBUG_BASE = list(flatten(DEBUG_BASE))
+DEBUG = ["debug/%s" % x for x in DEBUG_BASE]
index 46bbd0ca0a7b43fa813fad4f83c4d762aed65234..204b3e7dff95ef711b7c004e895842c7d8f4c588 100644 (file)
@@ -1,4 +1,4 @@
-from qwebirc.authgate import twisted as authgate
+from authgate import twisted as authgate
 from twisted.web import resource, server, static
 import config, urlparse, urllib, hashlib, re
 import qwebirc.util.rijndael, qwebirc.util.ciphers