# HG changeset patch # User Steve Losh <steve@stevelosh.com> # Date 1276556806 14400 # Node ID c92ca10967c3b7d0158bdd553d9f9f2c8f48296e # Parent 1a2f5b8da6efe9b6c20b349691c0397cc7100fd7 web: refactor the templates a bit diff -r 1a2f5b8da6ef -r c92ca10967c3 review/static/style.css --- a/review/static/style.css Mon Jun 14 18:53:02 2010 -0400 +++ b/review/static/style.css Mon Jun 14 19:06:46 2010 -0400 @@ -120,7 +120,7 @@ body .content .navigation { line-height: 1; width: 780px; - margin: 10px auto; + margin: 15px auto; } body .content .wrap { border: 1px solid #d8d685; diff -r 1a2f5b8da6ef -r c92ca10967c3 review/static/style.less --- a/review/static/style.less Mon Jun 14 18:53:02 2010 -0400 +++ b/review/static/style.less Mon Jun 14 19:06:46 2010 -0400 @@ -153,7 +153,7 @@ .navigation { line-height: 1; width: @content-width - 20px; - margin: 10px auto; + margin: 15px auto; } .wrap { border: 1px solid darken(@c-cream, 20%); diff -r 1a2f5b8da6ef -r c92ca10967c3 review/templates/base.html --- a/review/templates/base.html Mon Jun 14 18:53:02 2010 -0400 +++ b/review/templates/base.html Mon Jun 14 19:06:46 2010 -0400 @@ -1,8 +1,6 @@ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -{% import 'macros.html' as macros %} - <html> <head> <title>{% block title %}{% endblock %}Reviewing {{ title }} with hg-review</title> diff -r 1a2f5b8da6ef -r c92ca10967c3 review/templates/changeset.html --- a/review/templates/changeset.html Mon Jun 14 18:53:02 2010 -0400 +++ b/review/templates/changeset.html Mon Jun 14 19:06:46 2010 -0400 @@ -44,16 +44,7 @@ {% if comments %} <div class="review-level-comments item-listing"> {% for comment in comments %} - <div class="comment group"> - {{ macros.gravatar(comment, utils) }} - <div> - <div class="author"> - <a href="mailto:{{ utils['email'](comment.author) }}">{{ utils['templatefilters'].person(comment.author) }}</a> - said: - </div> - <div class="message">{{ comment.message }}</div> - </div> - </div> + {% include "pieces/comment.html" %} {% endfor %} </div> {% else %} @@ -84,7 +75,10 @@ <div class="signoffs item-listing"> {% for signoff in signoffs %} <div class="signoff group {{ signoff.opinion or 'neutral' }}"> - {{ macros.gravatar(signoff, utils) }} + <div class="avatar"> + <img src="{{ utils['item_gravatar'](signoff, 30) }}" /> + </div> + <div class="signoff-opinion {{ signoff.opinion or "neutral" }}">{{ signoff.opinion or "meh" }}</div> <div> @@ -147,17 +141,7 @@ {% if comments %} <div class="comments item-listing"> {% for comment in comments %} - <div class="comment"> - {{ macros.gravatar(comment, utils) }} - <div> - <div class="author"> - <a href="mailto:{{ utils['email'](comment.author) }}"> - {{ utils['templatefilters'].person(comment.author) }}</a> - said: - </div> - <div class="message">{{ comment.message }}</div> - </div> - </div> + {% include "pieces/comment.html" %} {% endfor %} </div> {% endif %} @@ -180,7 +164,7 @@ </div> {% endif %} - {% include "diff.html" %} + {% include "pieces/diff.html" %} </div> </div> {% endfor %} diff -r 1a2f5b8da6ef -r c92ca10967c3 review/templates/diff.html --- a/review/templates/diff.html Mon Jun 14 18:53:02 2010 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,77 +0,0 @@ -{% import 'macros.html' as macros %} - -<div class="diff"> - -<table> - <tbody> - {% set annotated_diff = rcset.annotated_diff(filename) %} - {# We need to ignore the first item from this generator, because - 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"> - <td colspan="3" class="skip"> - … skipped {{ line['skipped'] }} lines … - </td> - </tr> - - {% for comment in line['comments'] %} - <tr><td class="comment"> - {{ macros.gravatar(comment, utils) }} - <div> - <div class="author"> - <a href="mailto:{{ utils['email'](comment.author) }}"> - {{ utils['templatefilters'].person(comment.author) }} - </a> - said (on a skipped line): - </div> - <div class="message">{{ comment.message|escape }}</div> - </div> - </td></tr> - {% endfor %} - {% else %} - {% with %} - {% set line_type = utils['line_type'](line['content']) %} - - <tr class="{{ line_type }} {% if not read_only or allow_anon %} commentable {% endif %} line-{{ line['number'] }}"> - <td class="linenumber">{{ line['number'] }}</td> - <td class="addrem-{{ line_type }}">{% if line_type == 'add' %}+{% elif line_type == 'rem' %}-{% endif %}</td> - <td class="code"><code>{{ utils['decode'](line['content'][1:])|escape }}</code></td> - </tr> - {% endwith %} - - {% with %} - {% set comments = line['comments'] %} - - {% for comment in comments %} - <tr class="comment"> - <td class="comment group" colspan="3"> - <span class="commentlines disabled">{{ ','.join(utils['map'](utils['str'], comment.lines)) }}</span> - {{ macros.gravatar(comment, utils) }} - <div> - <div class="author"> - <a href="mailto:{{ utils['email'](comment.author) }}"> - {{ utils['templatefilters'].person(comment.author) }} - </a> - said: - </div> - <div class="message">{{ comment.message }}</div> - </div> - </td> - </tr> - {% endfor %} - {% endwith %} - {% endif %} - {% else %} - <tr class="skipped"> - <td colspan="3" class="skip"> - … no lines to show … - </td> - </tr> - {% endfor %} - </tbody> -</table> - -</div> diff -r 1a2f5b8da6ef -r c92ca10967c3 review/templates/macros.html --- a/review/templates/macros.html Mon Jun 14 18:53:02 2010 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,5 +0,0 @@ -{% macro gravatar(item, utils, size=30) -%} - <div class="avatar"> - <img src="{{ utils['item_gravatar'](item, size) }}" /> - </div> -{%- endmacro %} diff -r 1a2f5b8da6ef -r c92ca10967c3 review/templates/pieces/comment.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/review/templates/pieces/comment.html Mon Jun 14 19:06:46 2010 -0400 @@ -0,0 +1,12 @@ +<div class="comment group"> + <div class="avatar"> + <img src="{{ utils['item_gravatar'](comment, 30) }}" /> + </div> + <div> + <div class="author"> + <a href="mailto:{{ utils['email'](comment.author) }}">{{ utils['templatefilters'].person(comment.author) }}</a> + said: + </div> + <div class="message">{{ comment.message }}</div> + </div> +</div> diff -r 1a2f5b8da6ef -r c92ca10967c3 review/templates/pieces/diff.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/review/templates/pieces/diff.html Mon Jun 14 19:06:46 2010 -0400 @@ -0,0 +1,81 @@ +<div class="diff"> + +<table> + <tbody> + {% set annotated_diff = rcset.annotated_diff(filename) %} + {# We need to ignore the first item from this generator, because + 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"> + <td colspan="3" class="skip"> + … skipped {{ line['skipped'] }} lines … + </td> + </tr> + + {% for comment in line['comments'] %} + <tr><td class="comment"> + <div class="avatar"> + <img src="{{ utils['item_gravatar'](comment, 30) }}" /> + </div> + + <div> + <div class="author"> + <a href="mailto:{{ utils['email'](comment.author) }}"> + {{ utils['templatefilters'].person(comment.author) }} + </a> + said (on a skipped line): + </div> + <div class="message">{{ comment.message|escape }}</div> + </div> + </td></tr> + {% endfor %} + {% else %} + {% with %} + {% set line_type = utils['line_type'](line['content']) %} + + <tr class="{{ line_type }} {% if not read_only or allow_anon %} commentable {% endif %} line-{{ line['number'] }}"> + <td class="linenumber">{{ line['number'] }}</td> + <td class="addrem-{{ line_type }}">{% if line_type == 'add' %}+{% elif line_type == 'rem' %}-{% endif %}</td> + <td class="code"><code>{{ utils['decode'](line['content'][1:])|escape }}</code></td> + </tr> + {% endwith %} + + {% with %} + {% set comments = line['comments'] %} + + {% for comment in comments %} + <tr class="comment"> + <td class="comment group" colspan="3"> + <span class="commentlines disabled">{{ ','.join(utils['map'](utils['str'], comment.lines)) }}</span> + <div class="avatar"> + <img src="{{ utils['item_gravatar'](comment, 30) }}" /> + </div> + + <div> + <div class="author"> + <a href="mailto:{{ utils['email'](comment.author) }}"> + {{ utils['templatefilters'].person(comment.author) }} + </a> + said: + </div> + <div class="message">{{ comment.message }}</div> + </div> + </td> + </tr> + {% endfor %} + {% endwith %} + {% endif %} + {% else %} + <tr class="skipped"> + <td colspan="3" class="skip"> + … no lines to show … + </td> + </tr> + {% endfor %} + </tbody> +</table> + +</div>