web: pull the forms into separate templates
The changeset.html was getting pretty hairy until this change.
Changes
--- a/review/templates/changeset.html Fri Jun 18 22:28:46 2010 -0400
+++ b/review/templates/changeset.html Fri Jun 18 22:36:26 2010 -0400
@@ -53,22 +53,7 @@
{% endwith %}
{% if not read_only or allow_anon %}
- <div class="add-review-comment togglebox group">
- <span class="activate"><a class="button" href="#"><span>Add a comment on this changeset</span></a></span>
- <form class="disabled" id="comment-review-form" method="POST" action="">
- <div class="field">
- <label class="infield" for="id_comment-review-form_body">Comment</label>
- <textarea autocomplete="off" id="id_comment-review-form_body" cols="60" rows="6" name="new-comment-body"></textarea>
- </div>
- <div class="field cuddly">
- <input type="checkbox" class="checkbox" name="comment-markdown" id="id_comment-review-form_markdown" checked="checked" />
- <label for="id_comment-review-form_markdown">Use Markdown to format this comment.</label>
-
- </div>
- <a class="submit button" href="#"><span>Post Comment</span></a>
- <a class="cancel button" href="#"><span>Cancel</span></a>
- </form>
- </div>
+ {% include "pieces/forms/review-comment.html" %}
{% endif %}
<h2>Signoffs</h2>
@@ -79,30 +64,7 @@
{% if signoffs %}
<div class="signoffs item-listing">
{% for signoff in signoffs %}
- {% if signoff.style == 'markdown' %}
- {% set rendered = utils['markdown'](signoff.message) %}
- {% endif %}
-
- <div class="signoff group {{ signoff.opinion or 'neutral' }}">
- <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>
- <div class="author">
- <a href="mailto:{{ utils['email'](signoff.author) }}">{{ utils['templatefilters'].person(signoff.author) }}</a>
- signed off as <span class="opinion">{{ signoff.opinion or "neutral" }}</span> on this changeset, saying:
- </div>
-
- {% if signoff.style == 'markdown' %}
- <div class="message markdown">{{ rendered|safe }}</div>
- {% else %}
- <div class="message plain">{{ signoff.message }}</div>
- {% endif %}
- </div>
- </div>
+ {% include "pieces/signoff.html" %}
{% endfor %}
</div>
{% else %}
@@ -111,41 +73,7 @@
{% endwith %}
{% if not read_only %}
- <div class="add-signoff togglebox group">
- <span class="activate">
- {% if cu_signoff %}
- <a class="button" href="#"><span>Change your signoff</span></a>
- {% else %}
- <a class="button" href="#"><span>Sign off on this changeset</span></a>
- {% endif %}
- </span>
- <form id="signoff-form" class="disabled" method="POST" action="">
- <p class="sign-off-as">Sign off as:</p>
-
- <div class="field">
- <input id="id_signoff-form_yes" type="radio" name="signoff" value="yes" {% if cu_signoff and cu_signoff.opinion == 'yes' %}checked{% endif %}/><label class="radio" for="id_signoff-form_yes">Yes</label>
- <input id="id_signoff-form_no"type="radio" name="signoff" value="no" {% if cu_signoff and cu_signoff.opinion == 'no' %}checked{% endif %}/><label class="radio" for="id_signoff-form_no">No</label>
- <input id="id_signoff-form_neutral"type="radio" name="signoff" value="neutral" {% if cu_signoff and cu_signoff.opinion == '' %}checked{% endif %}/><label class="radio" for="id_signoff-form_neutral">Neutral</label>
- </div>
-
- <div class="field">
- <label class="infield" for="id_signoff-form_body">Signoff message</label>
- <textarea autocomplete="off" id="id_signoff-form_body" cols="60" rows="6" name="new-signoff-body">{% if cu_signoff %}{{ cu_signoff.message }}{% endif %}</textarea>
- </div>
-
- <div class="field cuddly">
- <input type="checkbox" class="checkbox" name="signoff-markdown" id="id_signoff-form_markdown" checked="checked" />
- <label for="id_signoff-form_markdown">Use Markdown to format this message.</label>
-
- </div>
- {% if cu_signoff %}
- <a class="submit button" href="#"><span>Change Signoff</span></a>
- {% else %}
- <a class="submit button" href="#"><span>Add Signoff</span></a>
- {% endif %}
- <a class="cancel button" href="#"><span>Cancel</span></a>
- </form>
- </div>
+ {% include "pieces/forms/signoff.html" %}
{% endif %}
<h2>Files</h2>
@@ -172,26 +100,8 @@
{% endif %}
{% 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>
-
- <form id="id_comment-file-form_{{ loop.index }}" class="disabled" method="POST" action="">
- <div class="field">
- <label class="infield" for="id_comment-file-form_{{ loop.index }}_body">Comment</label>
- <textarea autocomplete="off" id="id_comment-file-form_{{ loop.index }}_body" cols="60" rows="6" name="new-comment-body"></textarea>
- </div>
-
- <div class="field cuddly">
- <input type="checkbox" class="checkbox" name="comment-markdown" id="id_comment-file-form_{{ loop.index }}_markdown" checked="checked" />
- <label for="id_comment-file-form_{{ loop.index }}_markdown">Use Markdown to format this comment.</label>
- </div>
-
- <a class="submit button" href="#"><span>Post Comment</span></a>
- <a class="cancel button" href="#"><span>Cancel</span></a>
-
- <input type="hidden" name="filename" value="{{ filename }}" />
- </form>
- </div>
+ {% set index = loop.index %}
+ {% include "pieces/forms/file-comment.html" %}
{% endif %}
{% include "pieces/diff.html" %}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/review/templates/pieces/forms/file-comment.html Fri Jun 18 22:36:26 2010 -0400
@@ -0,0 +1,20 @@
+<div class="add-file-comment togglebox group">
+ <span class="activate"><a class="button" href=""><span>Add a comment on this file</span></a></span>
+
+ <form id="id_comment-file-form_{{ index }}" class="disabled" method="POST" action="">
+ <div class="field">
+ <label class="infield" for="id_comment-file-form_{{ index }}_body">Comment</label>
+ <textarea autocomplete="off" id="id_comment-file-form_{{ index }}_body" cols="60" rows="6" name="new-comment-body"></textarea>
+ </div>
+
+ <div class="field cuddly">
+ <input type="checkbox" class="checkbox" name="comment-markdown" id="id_comment-file-form_{{ index }}_markdown" checked="checked" />
+ <label for="id_comment-file-form_{{ index }}_markdown">Use Markdown to format this comment.</label>
+ </div>
+
+ <a class="submit button" href="#"><span>Post Comment</span></a>
+ <a class="cancel button" href="#"><span>Cancel</span></a>
+
+ <input type="hidden" name="filename" value="{{ filename }}" />
+ </form>
+</div>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/review/templates/pieces/forms/review-comment.html Fri Jun 18 22:36:26 2010 -0400
@@ -0,0 +1,16 @@
+<div class="add-review-comment togglebox group">
+ <span class="activate"><a class="button" href="#"><span>Add a comment on this changeset</span></a></span>
+ <form class="disabled" id="comment-review-form" method="POST" action="">
+ <div class="field">
+ <label class="infield" for="id_comment-review-form_body">Comment</label>
+ <textarea autocomplete="off" id="id_comment-review-form_body" cols="60" rows="6" name="new-comment-body"></textarea>
+ </div>
+ <div class="field cuddly">
+ <input type="checkbox" class="checkbox" name="comment-markdown" id="id_comment-review-form_markdown" checked="checked" />
+ <label for="id_comment-review-form_markdown">Use Markdown to format this comment.</label>
+
+ </div>
+ <a class="submit button" href="#"><span>Post Comment</span></a>
+ <a class="cancel button" href="#"><span>Cancel</span></a>
+ </form>
+</div>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/review/templates/pieces/forms/signoff.html Fri Jun 18 22:36:26 2010 -0400
@@ -0,0 +1,35 @@
+<div class="add-signoff togglebox group">
+ <span class="activate">
+ {% if cu_signoff %}
+ <a class="button" href="#"><span>Change your signoff</span></a>
+ {% else %}
+ <a class="button" href="#"><span>Sign off on this changeset</span></a>
+ {% endif %}
+ </span>
+ <form id="signoff-form" class="disabled" method="POST" action="">
+ <p class="sign-off-as">Sign off as:</p>
+
+ <div class="field">
+ <input id="id_signoff-form_yes" type="radio" name="signoff" value="yes" {% if cu_signoff and cu_signoff.opinion == 'yes' %}checked{% endif %}/><label class="radio" for="id_signoff-form_yes">Yes</label>
+ <input id="id_signoff-form_no"type="radio" name="signoff" value="no" {% if cu_signoff and cu_signoff.opinion == 'no' %}checked{% endif %}/><label class="radio" for="id_signoff-form_no">No</label>
+ <input id="id_signoff-form_neutral"type="radio" name="signoff" value="neutral" {% if cu_signoff and cu_signoff.opinion == '' %}checked{% endif %}/><label class="radio" for="id_signoff-form_neutral">Neutral</label>
+ </div>
+
+ <div class="field">
+ <label class="infield" for="id_signoff-form_body">Signoff message</label>
+ <textarea autocomplete="off" id="id_signoff-form_body" cols="60" rows="6" name="new-signoff-body">{% if cu_signoff %}{{ cu_signoff.message }}{% endif %}</textarea>
+ </div>
+
+ <div class="field cuddly">
+ <input type="checkbox" class="checkbox" name="signoff-markdown" id="id_signoff-form_markdown" checked="checked" />
+ <label for="id_signoff-form_markdown">Use Markdown to format this message.</label>
+
+ </div>
+ {% if cu_signoff %}
+ <a class="submit button" href="#"><span>Change Signoff</span></a>
+ {% else %}
+ <a class="submit button" href="#"><span>Add Signoff</span></a>
+ {% endif %}
+ <a class="cancel button" href="#"><span>Cancel</span></a>
+ </form>
+</div>
--- a/review/templates/pieces/linecomment.html Fri Jun 18 22:28:46 2010 -0400
+++ b/review/templates/pieces/linecomment.html Fri Jun 18 22:36:26 2010 -0400
@@ -1,3 +1,7 @@
+{% if comment.style == 'markdown' %}
+ {% set rendered = utils['markdown'](comment.message) %}
+{% endif %}
+
<tr class="comment">
<td class="comment group" colspan="3" id="comment-{{ comment.identifier }}">
<div class="comment-content">
@@ -19,7 +23,12 @@
</a>
said:
</div>
- <div class="message">{{ comment.message }}</div>
+
+ {% if comment.style == 'markdown' %}
+ <div class="message markdown">{{ rendered|safe }}</div>
+ {% else %}
+ <div class="message plain">{{ comment.message }}</div>
+ {% endif %}
</div>
</div>
<div id="comment-{{ comment.identifier }}-colorboxed" class="colorboxed">
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/review/templates/pieces/signoff.html Fri Jun 18 22:36:26 2010 -0400
@@ -0,0 +1,24 @@
+{% if signoff.style == 'markdown' %}
+ {% set rendered = utils['markdown'](signoff.message) %}
+{% endif %}
+
+<div class="signoff group {{ signoff.opinion or 'neutral' }}">
+ <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>
+ <div class="author">
+ <a href="mailto:{{ utils['email'](signoff.author) }}">{{ utils['templatefilters'].person(signoff.author) }}</a>
+ signed off as <span class="opinion">{{ signoff.opinion or "neutral" }}</span> on this changeset, saying:
+ </div>
+
+ {% if signoff.style == 'markdown' %}
+ <div class="message markdown">{{ rendered|safe }}</div>
+ {% else %}
+ <div class="message plain">{{ signoff.message }}</div>
+ {% endif %}
+ </div>
+</div>