# HG changeset patch # User Steve Losh # Date 1255481701 14400 # Node ID 590fb7bae0a82f163978c9336c32b92803d45884 # Parent 7b4e78679c9d88e0a9b4b459763470238f0e32ab Add a simple review page in the web UI. Just show diffs for now. diff -r 7b4e78679c9d -r 590fb7bae0a8 review/web_media/aal.css --- a/review/web_media/aal.css Tue Oct 13 20:13:17 2009 -0400 +++ b/review/web_media/aal.css Tue Oct 13 20:55:01 2009 -0400 @@ -25,8 +25,8 @@ header, nav, section, article, aside, footer {display: block;} /* Basic styles */ -body {background: #fff; color: #000; font: 1em/1.5em "Helvetica Neue", Helvetica, Arial, "Liberation Sans", "Bitstream Vera Sans", sans-serif;} -html>body {font-size: 16px;} +body {background: #fff; color: #000; font: 0.875em/1.5em "Helvetica Neue", Helvetica, Arial, "Liberation Sans", "Bitstream Vera Sans", sans-serif;} +html>body {font-size: 14px;} img {display: inline-block; vertical-align: bottom;} @@ -57,7 +57,7 @@ sub {font-size: .834em; line-height: 1em; vertical-align: sub;} sup {font-size: .834em; line-height: 1em; vertical-align: super;} -tt,code,kbd,samp,pre {font-size: 1em; font-family: "Courier New", Courier, monospace;} +tt,code,kbd,samp,pre {font-size: 1em; font-family: Consolas, Monaco, "Courier New", Courier, monospace;} /* Table styles */ table {border-collapse: collapse; border-spacing: 0; margin: 0 0 1.5em;} diff -r 7b4e78679c9d -r 590fb7bae0a8 review/web_media/style.css --- a/review/web_media/style.css Tue Oct 13 20:13:17 2009 -0400 +++ b/review/web_media/style.css Tue Oct 13 20:55:01 2009 -0400 @@ -1,6 +1,6 @@ /* Basic layout and typography. */ div#main-wrap { - width: 40em; + width: 50em; margin: 3em auto; } @@ -10,4 +10,18 @@ } table tr.odd { background: #eee; +} + +/* Diffs. */ +div.diff { + overflow: auto; +} +table tr { + white-space: pre; +} +table tr.add { + background: #dfd; +} +table tr.remove { + background: #fdd; } \ No newline at end of file diff -r 7b4e78679c9d -r 590fb7bae0a8 review/web_templates/index.html --- a/review/web_templates/index.html Tue Oct 13 20:13:17 2009 -0400 +++ b/review/web_templates/index.html Tue Oct 13 20:55:01 2009 -0400 @@ -17,11 +17,14 @@ $for ctx in revs: $ ctx_node = ctx.node() + $ ctx_node_short = node_short(ctx_node) $ ctx_comments = rd[ctx_node].comments $ ctx_signoffs = rd[ctx_node].signoffs - - + + diff -r 7b4e78679c9d -r 590fb7bae0a8 review/web_templates/review.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/review/web_templates/review.html Tue Oct 13 20:55:01 2009 -0400 @@ -0,0 +1,33 @@ +$def with (rd, rcset) + + + + + ${ basename(rd.target.root) } / hg-review + + + + + +
+

${ basename(rd.target.root) }

+ + $ ctx = rd.target[rcset.node] +

Changeset ${ ctx.rev() }: ${ ctx.description() }

+ + $for filename, diff in rcset.diffs().iteritems(): +

${ filename }

+
+
${ ctx.rev() }:${ node_short(ctx_node) }${ ctx.description() }${ ctx.rev() }:${ ctx_node_short } + ${ ctx.description() } + ${ len(ctx_comments) } comments, ${ len(ctx_signoffs) } signoffs
+ $ max_line = diff['max'] + $ content = diff['content'] + $for n, line in content: + + + +
${ line[1:] if line.strip() else ' ' }
+ + + + \ No newline at end of file diff -r 7b4e78679c9d -r 590fb7bae0a8 review/web_ui.py --- a/review/web_ui.py Tue Oct 13 20:13:17 2009 -0400 +++ b/review/web_ui.py Tue Oct 13 20:55:01 2009 -0400 @@ -19,6 +19,7 @@ urls = ( '/', 'index', '/media/([^/]*)', 'media', + '/review/([\da-f]{12})/?', 'review', ) @@ -26,13 +27,21 @@ g = { 'node_short': short, 'basename': os.path.basename, } render = web.template.render(template_path, globals=g) +LOG_PAGE_LEN = 15 + class index: def GET(self): rev_max = _rd.target['tip'].rev() - rev_min = rev_max - 5 if rev_max >= 5 else 0 + rev_min = rev_max - LOG_PAGE_LEN if rev_max >= LOG_PAGE_LEN else 0 revs = (_rd.target[r] for r in xrange(rev_max, rev_min, -1)) return render.index(_rd, revs) + +class review: + def GET(self, node_short): + return render.review(_rd, _rd[node_short]) + + class media: def GET(self, fname): if '..' in fname: @@ -43,13 +52,10 @@ return content -app = web.application(urls, globals()) - def load_interface(ui, repo): global _rd _rd = api.ReviewDatastore(ui, repo) - print sys.argv + sys.argv = sys.argv[:1] # Seriously, web.py? This is such a hack. - sys.argv = [__file__] - print sys.argv + app = web.application(urls, globals()) app.run()