--- 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;}
--- 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
--- 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 @@
<table>
$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
<tr class="${ loop.parity }">
- <td>${ ctx.rev() }:${ node_short(ctx_node) }</td>
- <td>${ ctx.description() }</td>
+ <td>${ ctx.rev() }:${ ctx_node_short }</td>
+ <td>
+ <a href="/review/${ ctx_node_short }/">${ ctx.description() }</a>
+ </td>
<td>${ len(ctx_comments) } comments,
${ len(ctx_signoffs) } signoffs</td>
</tr>
--- /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)
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html>
+ <head>
+ <title>${ basename(rd.target.root) } / hg-review</title>
+ <link rel="stylesheet" href="/media/aal.css" type="text/css" media="screen" />
+ <link rel="stylesheet" href="/media/style.css" type="text/css" media="screen" />
+ </head>
+
+ <body>
+ <div id="main-wrap">
+ <h1>${ basename(rd.target.root) }</h1>
+
+ $ ctx = rd.target[rcset.node]
+ <h2>Changeset ${ ctx.rev() }: ${ ctx.description() }</h2>
+
+ $for filename, diff in rcset.diffs().iteritems():
+ <h3>${ filename }</h3>
+ <div class="diff">
+ <table>
+ $ max_line = diff['max']
+ $ content = diff['content']
+ $for n, line in content:
+ <tr class="${ 'remove' if line[0] == '-' else 'add' if line[0] == '+' else ''}">
+ <td class="diff-line"><code>${ line[1:] if line.strip() else ' ' }</code></td>
+ </tr>
+ </table>
+ </div>
+ </div>
+ </body>
+</html>
\ No newline at end of file
--- 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()