review/templates/changeset.html @ 63bcbedb9341

web: add support for Markdown formatting
author Steve Losh <steve@stevelosh.com>
date Fri, 18 Jun 2010 22:28:46 -0400
parents a88dd00c4079
children 24f0d81f3aa5
{% extends "base.html" %}

{% 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>

        <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 %}
    </div>

    {% with %}
        {% set comments = rcset.review_level_comments() %}

        {% if comments %}
            <div class="review-level-comments item-listing">
                {% for comment in comments %}
                    {% include "pieces/comment.html" %}
                {% endfor %}
            </div>
        {% else %}
            <p class="placeholder">No changeset-level comments yet&hellip;</p>
        {% endif %}
    {% 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>
    {% endif %}

    <h2>Signoffs</h2>

    {% with %}
        {% set signoffs = rcset.signoffs %}

        {% 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>
                {% endfor %}
            </div>
        {% else %}
            <p class="placeholder">No signoffs yet&hellip;</p>
        {% endif %}
    {% 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>
    {% endif %}

    <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="#"><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">
                {% if comments %}
                    <div class="comments item-listing">
                        {% for comment in comments %}
                            {% include "pieces/comment.html" %}
                        {% endfor %}
                    </div>
                {% 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>
                {% endif %}

                {% include "pieces/diff.html" %}
            </div>
        </div>
    {% endfor %}
{% endblock %}