5c62a1333e54 webui

Add comments (with avatars) to diffs (not skipped lines yet).
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Wed, 14 Oct 2009 20:10:37 -0400
parents f8adc5c231f3
children 93baa16777e9
branches/tags webui
files review/web_media/style.css review/web_templates/review.html review/web_ui.py

Changes

--- a/review/web_media/style.css	Wed Oct 14 19:39:07 2009 -0400
+++ b/review/web_media/style.css	Wed Oct 14 20:10:37 2009 -0400
@@ -42,12 +42,9 @@
 table tr.odd {
     background: #eee;
 }
-table tr :last-child {
+table tr td.last {
     text-align: right;
 }
-table tr :first-child {
-    text-align: left !important;
-}
 
 /* Diffs. */
 div.diff {
@@ -61,4 +58,22 @@
 }
 table tr.rem {
     background: #FBDBDA;
+}
+table tr td.comment {
+    white-space: normal;
+    background: #F4FF68;
+    border-top: 1px dashed #666;
+    border-bottom: 1px dashed #666;
+    font-family: Consolas, Monaco, "Courier New", Courier, monospace;
+}
+table tr td.comment div.author {
+    
+}
+table tr td.comment div.message {
+    margin-top: 1.5em;
+    white-space: pre;
+}
+table tr td.comment div.avatar {
+    border: 1px solid black;
+    float: right;
 }
\ No newline at end of file
--- a/review/web_templates/review.html	Wed Oct 14 19:39:07 2009 -0400
+++ b/review/web_templates/review.html	Wed Oct 14 20:10:37 2009 -0400
@@ -9,9 +9,19 @@
         <table>
             $ max_line = diff['max']
             $ content = diff['content']
+            $ line_level_comments = filter(lambda c: c.filename == filename, rcset.comments)
             $for n, line in content:
                 $ kind = 'rem' if line[0] == '-' else 'add' if line[0] == '+' else ''
                 <tr class="${ kind }">
                     <td class="diff-line"><code>${ line[1:] or ' ' }</code></td>
                 </tr>
+                $ line_comments = filter(lambda c: max(c.lines) == n, line_level_comments)
+                $for comment in line_comments:
+                    <tr><td class="comment">
+                        <div class="avatar"><img src="http://www.gravatar.com/avatar/${ md5(email(comment.author)).hexdigest() }?s=52"/></div>
+                        <div>
+                            <div class="author">${ comment.author } said:</div>
+                            <div class="message">${ comment.message }</div>
+                        </div>
+                    </td></tr>
         </table>
\ No newline at end of file
--- a/review/web_ui.py	Wed Oct 14 19:39:07 2009 -0400
+++ b/review/web_ui.py	Wed Oct 14 20:10:37 2009 -0400
@@ -24,7 +24,9 @@
 
 
 from mercurial.node import short
-g = { 'node_short': short, 'basename': os.path.basename, }
+from mercurial.util import email
+from hashlib import md5
+g = { 'node_short': short, 'basename': os.path.basename, 'md5': md5, 'email': email }
 render = web.template.render(template_path, globals=g)
 
 LOG_PAGE_LEN = 15