# HG changeset patch # User Steve Losh # Date 1267657493 18000 # Node ID f936bf37db174596948063cb4b911e6b336ce022 # Parent c3a0ea6aa1dfc9ba24d0b35877736e636af1c2ea Checkpoint before the big refactor. diff -r c3a0ea6aa1df -r f936bf37db17 review/web_templates/base.html --- a/review/web_templates/base.html Tue Mar 02 21:59:51 2010 -0500 +++ b/review/web_templates/base.html Wed Mar 03 18:04:53 2010 -0500 @@ -3,7 +3,7 @@ - Reviewing {{ utils["basename"](datastore.target.root) }} + Reviewing {{ utils["basename"](datastore.target.root) }}{% block title %}{% endblock %} @@ -15,11 +15,11 @@

- Reviewing: + Reviewing {{ utils["basename"](datastore.target.root) }} - {% block title %}{% endblock %} + {% block header %}{% endblock %}

diff -r c3a0ea6aa1df -r f936bf37db17 review/web_templates/changeset.html --- a/review/web_templates/changeset.html Tue Mar 02 21:59:51 2010 -0500 +++ b/review/web_templates/changeset.html Wed Mar 03 18:04:53 2010 -0500 @@ -1,135 +1,176 @@ -$def with (rd, rcset) +{% extends "base.html" %} -$ ctx = rd.target[rcset.node] -

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

+{% block title %} at {{ title }}{% endblock %} +{% block header %} at {{ title }}{% endblock %} -$ review_level_comments = rcset.review_level_comments() -$for comment in review_level_comments: -
-
-
- -
${ comment.message }
+{% block content %} +

Changeset {{ rev.rev() }}: {{ rev.description().splitlines()[0] }}

+ + {% for comment in rcset.review_level_comments() %} +
+
+ +
+
+ +
{{ comment.message }}
+
+ {% endfor %} + +
+

Add a comment on this changeset

+
+
+ + +
+
+ +
+
-
-

Add a comment on this changeset

-
-
- - -
-
- -
-
-
- -

Files

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

${ filename }

-
- -
- $ file_level_comments = rcset.file_level_comments(filename) - $for comment in file_level_comments: -
-
- -
-
- -
${ comment.message }
-
-
- - -
-

Add a comment on this file

-
-
- - -
-
- -
- -
+

Files

+ + {% for filename, diff in rcset.diffs().iteritems() %} +
+
+    ↓ +

{{ filename }}

-
- - $ max_line = diff['max'] - $ content = diff['content'] - $ line_level_comments = rcset.line_level_comments(filename) - $ previous_n = -1 - $for n, line in content: - $if n - 1 > previous_n: - $ skipped_count = n - previous_n - $if previous_n == -1: - $ skipped_count -= 1 - - +
+ {% for comment in rcset.file_level_comments(filename) %} +
+
+ +
+
+ +
{{ comment.message }}
+
+
+ {% endfor %} + +
+

Add a comment on this file

+ +
+
+ + +
+
+ +
+ + +
+ +
+
… skipped ${ skipped_count } lines …
+ {% set max_line = diff['max'] %} + {% set content = diff['content'] %} + {% set line_level_comments = rcset.line_level_comments(filename) %} + {% set previous_n = -1 %} + + {% for n, line in content %} + {% if n - 1 < previous_n %} + {% set skipped_count = n - previous_n %} + {% if previous_n == -1 %} + {% set skipped_count = skipped_count - 1 %} + {% endif %} + + + + {% endif %} + + {% for comment in utils['skipped_comments'](n, previous_n, line_level_comments) %} + + {% endfor %} + + + - $ skipped_comments = filter(lambda c: max(c.lines) in range(previous_n + 1, n), line_level_comments) - $for comment in skipped_comments: - - $ kind = 'rem' if line[0] == '-' else 'add' if line[0] == '+' else 'con' - - - - $ line_comments = filter(lambda c: max(c.lines) == n, line_level_comments) - $for comment in line_comments: - - - + {% endfor %} + + + + + + {% set previous_n = n %} + {% endfor %} + + {% if previous_n < max_line %} + + + + + {% for comment in utils['skipped_comments_end'](previous_n, max_line, line_level_comments) %} + - - $ previous_n = n - $if previous_n < max_line: - $ skipped_count = max_line - previous_n - - - - $ skipped_comments = filter(lambda c: max(c.lines) in range(previous_n + 1, max_line), line_level_comments) - $for comment in skipped_comments: - -
… skipped {{ skipped_count }} lines …
+
+
+ +
{{ comment.message }}
+
+
{{ line[1:] }}
-
-
- -
${ comment.message }
-
-
${ line[1:] or ' ' }
-
-
- -
${ comment.message }
-
-
-
-
- - + + {% for comment in utils['line_comments'](n, line_level_comments) %} +
+
+ -
- +
+ +
+ + +
+
+ +
+ + + +
… skipped {{ max_line - previous_n }} lines …
+
+
+ +
{{ comment.message }}
- - - -
… skipped ${ skipped_count } lines …
-
-
- -
${ comment.message }
-
-
+ + {% endfor %} + {% endif %} + +
-
\ No newline at end of file + {% endfor %} +{% endblock %} \ No newline at end of file diff -r c3a0ea6aa1df -r f936bf37db17 review/web_templates/index.html --- a/review/web_templates/index.html Tue Mar 02 21:59:51 2010 -0500 +++ b/review/web_templates/index.html Wed Mar 03 18:04:53 2010 -0500 @@ -1,6 +1,7 @@ {% extends "base.html" %} {% block title %}{% endblock %} +{% block header %}{% endblock %} {% block content %}

Changesets

@@ -11,7 +12,7 @@ {{ rev.rev() }}:{{ node_short }} - {{ rev.description().splitlines()[0] }} + {{ rev.description().splitlines()[0] }} {{ utils['len'](rcset.comments) }} comments, @@ -21,10 +22,3 @@ {% endfor %} {% endblock %} - - - - diff -r c3a0ea6aa1df -r f936bf37db17 review/web_ui.py --- a/review/web_ui.py Tue Mar 02 21:59:51 2010 -0500 +++ b/review/web_ui.py Wed Mar 03 18:04:53 2010 -0500 @@ -30,6 +30,21 @@ LOG_PAGE_LEN = 1000000 +def _comment_gravatar(comment): + return 'http://www.gravatar.com/avatar/%s/' % md5(email(comment.author)).hexdigest() + +def _skipped_comments(n, previous_n, line_level_comments): + return filter(lambda c: max(c.lines) in range(previous_n + 1, n), line_level_comments) + +def _skipped_comments_end(previous_n, max_line, line_level_comments): + return filter(lambda c: max(c.lines) in range(previous_n + 1, max_line), line_level_comments) + +def _line_type(line): + return 'rem' if line[0] == '-' else 'add' if line[0] == '+' else 'con' + +def _line_comments(n, line_level_comments): + return filter(lambda c: max(c.lines) == n, line_level_comments) + utils = { 'node_short': short, 'basename': os.path.basename, @@ -37,6 +52,11 @@ 'email': email, 'templatefilters': templatefilters, 'len': len, + 'comment_gravatar': _comment_gravatar, + 'skipped_comments': _skipped_comments, + 'skipped_comments_end': _skipped_comments_end, + 'line_type': _line_type, + 'line_comments': _line_comments, } class ReviewWebUI(object): @@ -55,6 +75,20 @@ rcsets=rcsets, ) + + @cherrypy.expose + def changeset(self, *args): + if len(args) != 1: + return 'OH GOD HOW DID THIS GET HERE I AM NOT GOOD WITH LINKS' + rev_id = args[0] + rcset = self.datastore[rev_id] + rev = rcset.target[rev_id] + + return jinja_env.get_template('changeset.html').render( + utils=utils, datastore=self.datastore, + title='%s:%s' % (rev.rev(), short(rev.node())), + rcset=rcset, rev=rev, + ) def load_interface(ui, repo, open=False, port=8080):