review/web_ui.py @ 22906da596df webui
Get a barely functional webui running.
| author | Steve Losh <steve@stevelosh.com> | 
|---|---|
| date | Tue, 13 Oct 2009 19:46:03 -0400 | 
| parents | 9539fb54320e | 
| children | 73284798e9e9 | 
"""The review extension's web UI.""" import sys, os import api from mercurial import cmdutil package_path = os.path.split(os.path.realpath(__file__))[0] template_path = os.path.join(package_path, 'web_templates') top_path = os.path.split(package_path)[0] bundled_path = os.path.join(top_path, 'bundled') webpy_path = os.path.join(bundled_path, 'webpy') sys.path.insert(0, webpy_path) import web _rd = None urls = ( '/', 'index' ) from mercurial.node import short g = { 'node_short': short, 'basename': os.path.basename, } render = web.template.render(template_path, globals=g) class index: def GET(self): rev_max = _rd.target['tip'].rev() rev_min = rev_max - 5 if rev_max >= 5 else 0 revs = (_rd.target[r] for r in xrange(rev_max, rev_min, -1)) return render.index(_rd, revs) app = web.application(urls, globals()) def load_interface(ui, repo): global _rd _rd = api.ReviewDatastore(ui, repo) sys.argv = sys.argv[:1] # Seriously, web.py? This is such a hack. app.run()