# HG changeset patch # User Steve Losh # Date 1255477563 14400 # Node ID 22906da596dfa37ff2fc5377dac5f0bc349c7183 # Parent 9539fb54320e3971117034ce81c4fc077ff9a7dd Get a barely functional webui running. diff -r 9539fb54320e -r 22906da596df review/extension_ui.py --- a/review/extension_ui.py Tue Oct 13 19:02:45 2009 -0400 +++ b/review/extension_ui.py Tue Oct 13 19:46:03 2009 -0400 @@ -15,7 +15,7 @@ ui.note(messages.WEB_START) import web_ui - web_ui.load_interface(repo) + web_ui.load_interface(ui, repo) def _init_command(ui, repo, **opts): ui.note(messages.INIT_START) diff -r 9539fb54320e -r 22906da596df review/web_templates/index.html --- a/review/web_templates/index.html Tue Oct 13 19:02:45 2009 -0400 +++ b/review/web_templates/index.html Tue Oct 13 19:46:03 2009 -0400 @@ -1,13 +1,27 @@ -$def with (repo) +$def with (rd, revs) - Code Review + ${ basename(rd.target.root) } / hg-review -

Reviewing: $repo.root

+

${ basename(rd.target.root) }

+ +

Changesets

+ + $for ctx in revs: + $ ctx_node = ctx.node() + $ ctx_comments = rd[ctx_node].comments + $ ctx_signoffs = rd[ctx_node].signoffs + + + + + +
${ ctx.rev() }:${ node_short(ctx_node) }${ ctx.description() }${ len(ctx_comments) } comments, + ${ len(ctx_signoffs) } signoffs
\ No newline at end of file diff -r 9539fb54320e -r 22906da596df review/web_ui.py --- a/review/web_ui.py Tue Oct 13 19:02:45 2009 -0400 +++ b/review/web_ui.py Tue Oct 13 19:46:03 2009 -0400 @@ -1,6 +1,8 @@ """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') @@ -12,22 +14,29 @@ import web -_repo = None +_rd = None urls = ( '/', 'index' ) -render = web.template.render(template_path) + + +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): - return render.index(_repo) + 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(repo): - global _repo - _repo = repo +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()