a88dd00c4079

web: add diff line backgrounds and show file comment counts
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Mon, 14 Jun 2010 19:28:37 -0400
parents c92ca10967c3
children 62c034fdeed2
branches/tags (none)
files review/static/comments.js review/static/style.css review/static/style.less review/templates/changeset.html

Changes

--- a/review/static/comments.js	Mon Jun 14 19:06:46 2010 -0400
+++ b/review/static/comments.js	Mon Jun 14 19:28:37 2010 -0400
@@ -18,7 +18,7 @@
                     </form>\
                 </td>\
             </tr>';
-    comment_form = comment_form.replace('<<<FILENAME>>>', line.closest(".file").find(".filename h3 a").html());
+    comment_form = comment_form.replace('<<<FILENAME>>>', line.closest(".file").find(".filename h3 a .name").html());
     comment_form = comment_form.replace('<<<LINENUMBER>>>', currNum);
     return comment_form;
 }
--- a/review/static/style.css	Mon Jun 14 19:06:46 2010 -0400
+++ b/review/static/style.css	Mon Jun 14 19:28:37 2010 -0400
@@ -557,10 +557,24 @@
   line-height: 1;
 }
 #changeset .content .diff table tr.rem {
-  color: #800;
+  color: black;
+  background-color: #f7cdcd;
+}
+#changeset .content .diff table tr.rem td.code:after {
+  color: white;
+}
+#changeset .content .diff table tr.rem td.linenumber {
+  color: #292620;
 }
 #changeset .content .diff table tr.add {
-  color: #040;
+  color: black;
+  background-color: #c5e5ce;
+}
+#changeset .content .diff table tr.add td.code:after {
+  color: white;
+}
+#changeset .content .diff table tr.add td.linenumber {
+  color: #292620;
 }
 #changeset .content .diff table tr.viewing {
   background-color: #f2f2d7;
--- a/review/static/style.less	Mon Jun 14 19:06:46 2010 -0400
+++ b/review/static/style.less	Mon Jun 14 19:28:37 2010 -0400
@@ -13,6 +13,9 @@
 @c-metal: #eaeaea;
 @c-soft-cream: lighten(@c-cream, 12%);
 
+@c-diff-add: #c5e5ce;
+@c-diff-rem: #f7cdcd;
+
 @content-width: 800px;
 @content-background: rgb(250, 250, 250);
 
@@ -500,10 +503,26 @@
             }
             tr {
                 &.rem {
-                    color: #800;
+                    color: black;
+                    background-color: @c-diff-rem;
+
+                    td.code:after {
+                        color: white;
+                    }
+                    td.linenumber {
+                        color: @c-dark;
+                    }
                 }
                 &.add {
-                    color: #040;
+                    color: black;
+                    background-color: @c-diff-add;
+
+                    td.code:after {
+                        color: white;
+                    }
+                    td.linenumber {
+                        color: @c-dark;
+                    }
                 }
                 &.viewing {
                     background-color: lighten(@c-cream, 5%);
--- a/review/templates/changeset.html	Mon Jun 14 19:06:46 2010 -0400
+++ b/review/templates/changeset.html	Mon Jun 14 19:28:37 2010 -0400
@@ -25,14 +25,14 @@
 {% block content %}
     <div class="group head">
         <div class="committer-avatar" style="background: transparent url('{{ utils['cset_gravatar'](rev, 60) }}') top left no-repeat">&nbsp;</div>
-    
+
         <h2>
             {{ rev.rev() }}:
             <span class="desc">{{ rev.description().splitlines()[0] }}</span>
             <span class="by">by</span>
             <a href="mailto:{{ utils['email'](rev.user()) }}">{{ utils['templatefilters'].person(rev.user()) }}</a>
         </h2>
-    
+
         {% if utils['len'](rev.description().splitlines()) > 1 %}
             <div class="fulldesc">{{ "\n".join(rev.description().splitlines()[1:]).strip() }}</div>
         {% endif %}
@@ -80,7 +80,7 @@
                         </div>
 
                         <div class="signoff-opinion {{ signoff.opinion or "neutral" }}">{{ signoff.opinion or "meh" }}</div>
-                        
+
                         <div>
                             <div class="author">
                                 <a href="mailto:{{ utils['email'](signoff.author) }}">{{ utils['templatefilters'].person(signoff.author) }}</a>
@@ -129,23 +129,26 @@
     <h2>Files</h2>
 
     {% for filename in rcset.files() %}
+        {% set comments = rcset.file_level_comments(filename) %}
+        {% set commentcount = utils['len'](comments) + utils['len'](rcset.line_level_comments(filename)) %}
+
         <div class="file">
             <div class="filename group">
-                <h3><a class="fold" href="#">{{ filename }}</a> <span class="status">&rarr;</span> </h3>
+                <h3>
+                    <a class="fold" href="#"><span class="name">{{ filename }}</span>{% if commentcount %} ({{ commentcount }} comment{% if commentcount != 1 %}s{% endif %}){% endif %}</a>
+                    <span class="status">&rarr;</span>
+                </h3>
             </div>
 
             <div class="file-review-contents disabled">
-                {% with %}
-                    {% set comments = rcset.file_level_comments(filename) %}
+                {% if comments %}
+                    <div class="comments item-listing">
+                        {% for comment in comments %}
+                            {% include "pieces/comment.html" %}
+                        {% endfor %}
+                    </div>
+                {% endif %}
 
-                    {% if comments %}
-                        <div class="comments item-listing">
-                            {% for comment in comments %}
-                                {% include "pieces/comment.html" %}
-                            {% endfor %}
-                        </div>
-                    {% endif %}
-                {% endwith %}
                 {% if not read_only or allow_anon %}
                     <div class="add-file-comment togglebox group">
                         <span class="activate"><a class="button" href=""><span>Add a comment on this file</span></a></span>