daf7418e0d28

web: add navigation links and support empty diffs
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Sun, 13 Jun 2010 16:56:35 -0400
parents ef7d67f71293
children 3ad9a898bc0d
branches/tags (none)
files review/static/style.css review/static/style.less review/templates/base.html review/templates/changeset.html review/templates/diff.html review/web_ui.py

Changes

--- a/review/static/style.css	Sun Jun 13 16:12:22 2010 -0400
+++ b/review/static/style.css	Sun Jun 13 16:56:35 2010 -0400
@@ -117,6 +117,11 @@
 body .content {
   border-top: 1px solid #f8f7e8;
 }
+body .content .navigation {
+  line-height: 1;
+  width: 780px;
+  margin: 10px auto;
+}
 body .content .wrap {
   border: 1px solid #d8d685;
   -webkit-border-radius: 7px;
@@ -125,7 +130,6 @@
   box-shadow: 0px 5px 10px rgba(0, 0, 0, 0.05);
   -moz-box-shadow: 0px 5px 10px rgba(0, 0, 0, 0.05);
   -webkit-box-shadow: 0px 5px 10px rgba(0, 0, 0, 0.05);
-  margin-top: 20px;
   padding: 21px 20px;
   width: 760px;
   background-color: #fafafa;
@@ -251,6 +255,20 @@
 #index .content .pagination a.older {
   float: right;
 }
+#changeset .content .navigation .middle {
+  display: inline-block;
+  width: 49%;
+  text-align: center;
+}
+#changeset .content .navigation .right {
+  display: inline-block;
+  width: 25%;
+  text-align: right;
+}
+#changeset .content .navigation .left {
+  display: inline-block;
+  width: 25%;
+}
 #changeset .content .head {
   position: relative;
 }
--- a/review/static/style.less	Sun Jun 13 16:12:22 2010 -0400
+++ b/review/static/style.less	Sun Jun 13 16:56:35 2010 -0400
@@ -150,13 +150,17 @@
     .content {
         border-top: 1px solid lighten(@c-cream, 10%);
 
+        .navigation {
+            line-height: 1;
+            width: @content-width - 20px;
+            margin: 10px auto;
+        }
         .wrap {
             border: 1px solid darken(@c-cream, 20%);
             .border-radius(7px);
             .box-shadow(0px, 5px, 10px, rgba(0, 0, 0, 0.05));
             @content-padding-horiz: 20px;
 
-            margin-top: 20px;
             padding: 21px @content-padding-horiz;
             width: @content-width - (@content-padding-horiz * 2);
             background-color: @content-background;
@@ -302,6 +306,22 @@
     }
 }
 #changeset .content {
+    .navigation {
+        .middle {
+            display: inline-block;
+            width: 49%;
+            text-align: center;
+        }
+        .right {
+            display: inline-block;
+            width: 25%;
+            text-align: right;
+        }
+        .left {
+            display: inline-block;
+            width: 25%;
+        }
+    }
     .head {
         position: relative;
 
--- a/review/templates/base.html	Sun Jun 13 16:12:22 2010 -0400
+++ b/review/templates/base.html	Sun Jun 13 16:56:35 2010 -0400
@@ -49,6 +49,10 @@
             </div>
         </div>
         <div class="content">
+            {% block navigation %}
+                <div class="navigation">&nbsp;</div>
+            {% endblock %}
+
             <div class="wrap">
                 {% block content %}{% endblock %}
             </div>
--- a/review/templates/changeset.html	Sun Jun 13 16:12:22 2010 -0400
+++ b/review/templates/changeset.html	Sun Jun 13 16:56:35 2010 -0400
@@ -3,6 +3,25 @@
 {% block id %}changeset{% endblock %}
 {% block title %}Changeset {{ rev.rev() }} - {% endblock %}
 
+{% block navigation %}
+    <div class="navigation group">
+        <div class="left">
+            {% if newer != None %}
+                <a class="newer" href="/changeset/{{ utils['node_short'](newer.node()) }}/">&lArr; Newer Changeset ({{ newer.rev() }})</a>
+            {% endif %}
+        </div>
+        <div class="middle">
+            <a class="up" href="/{{ rev.rev() + 7 }}/">Back to Index &uarr;</a>
+        </div>
+        <div class="right">
+            {% if older != None %}
+                <a class="older" href="/changeset/{{ utils['node_short'](older.node()) }}/">Older Changeset ({{ older.rev() }}) &rArr;</a>
+            {% endif %}
+        </div>
+    </div>
+{% endblock %}
+
+
 {% 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>
--- a/review/templates/diff.html	Sun Jun 13 16:12:22 2010 -0400
+++ b/review/templates/diff.html	Sun Jun 13 16:56:35 2010 -0400
@@ -9,6 +9,8 @@
            we don't care about providing a line-number prefix (for now!). #}
         {% set ignore_this_variable = annotated_diff.next() %}
 
+
+
         {% for line in annotated_diff %}
             {% if line['skipped'] %}
                 <tr class="skipped">
@@ -64,6 +66,12 @@
                     {% endfor %}
                 {% endwith %}
             {% endif %}
+        {% else %}
+            <tr class="skipped">
+                <td colspan="3" class="skip">
+                    &hellip; no lines to show &hellip;
+                </td>
+            </tr>
         {% endfor %}
     </tbody>
 </table>
--- a/review/web_ui.py	Sun Jun 13 16:12:22 2010 -0400
+++ b/review/web_ui.py	Sun Jun 13 16:56:35 2010 -0400
@@ -140,9 +140,12 @@
     cu_signoffs = rcset.signoffs_for_current_user()
     cu_signoff = cu_signoffs[0] if cu_signoffs else None
     
-    return _render('changeset.html',
-        rcset=rcset, rev=rev, cu_signoff=cu_signoff
-    )
+    tip = g.datastore.target['tip'].rev()
+    newer = rcset.target[rev.rev() + 1] if rev.rev() < tip else None
+    older = rcset.target[rev.rev() - 1] if rev.rev() > 0 else None
+    
+    return _render('changeset.html', rcset=rcset, rev=rev, cu_signoff=cu_signoff,
+        newer=newer, older=older)
 
 
 @app.route('/pull/', methods=['POST'])