{% extends "projector/project/repository/browse.html" %}

{% load i18n %}
{% load gravatar_tags %}
{% load richtemplates_tags %}
{% load pagination_tags %}
{% load projector_tags %}

{% if root.is_file %}
    {% block head-css %}{{ block.super }}
    {% endblock %}
{% endif %}

{% block info-block %}
<div class="richtemplates-panel">
    <h5>{% trans "Node's information" %}</h5>
    <div class="richtemplates-panel-content">
        <div class="richblock">
            <table class="richblock-properties">
                <tbody>
                    <tr>
                        <th>{% trans "Changesets count" %}</th>
                        <td>{{ repository.revisions|length }}</td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
</div>
{% endblock %}

{% block col-single-extra %}

<div class="richtemplates-panel">
    <h5>{% trans "Project's repository browser" %}</h5>
    <div class="richtemplates-panel-content">
    {% block repository-menu %}{{ block.super }}{% endblock %}
    
    {% autopaginate repository CHANGESETS_PAGINATE_BY %}

    {% paginate %}

    <table class="datatable">
        <thead class="datatable-thead">
            <tr class="datatable-thead-subheader lefted">
                <th class="width-5">{% trans "Revision" %}</th>
                <th class="width-10">{% trans "Differences" %}</th>
                <th class="width-15">{% trans "Commited at" %}</th>
                <th class="width-10">{% trans "Author" %}</th>
                <th class="width-65">{% trans "Message" %}</th>
            </tr>
        </thead>
        <tbody class="datatable-tbody">
            {% for changeset in repository %}
            <tr class="{% cycle "odd" "even" %} hoverable">
                <td><a href="{% url projector_project_sources_browse project.author.username project.slug changeset.id '' %}"
                       class="browser-changeset block-link show-tipsy-right"
                       title="{% trans "Browse revision's content" %}">{{ changeset.revision }}:{{ changeset.raw_id }}</a>
                </td>
                <td>
                    <ul class="changeset-changes centered">
                        <li class="added show-tipsy"
                            title="{% trans "Added" %}: {{ changeset.added|length }}">{{ changeset.added|length }}</li>
                        <li class="changed show-tipsy"
                            title="{% trans "Changed" %}: {{ changeset.changed|length }}">{{ changeset.changed|length }}</li>
                        <li class="removed show-tipsy"
                            title="{% trans "Removed" %}: {{ changeset.removed|length }}">{{ changeset.removed|length }}</li>
                    </ul>
                    <a href="{% url projector_project_changeset_detail project.author.username project.slug changeset.raw_id %}"
                       class="show-tipsy"
                       title="{% trans "Shows diff for whole changeset" %}">{% trans "Show diff" %}</a>
                </td>
                <td class="show-tipsy" title="{{ changeset.date }}">
                    {{ changeset.date|timesince }} {% trans "ago" %}
                </td>
                <td>
                    {% fetch_user changeset.author as "author" %}
                    {% if author %}
                    <img src="{% gravatar_for_user author 16 %}" alt="{% trans "Avatar" %}"/>
                    <a href="{% url projector_users_profile_detail author.username %}"
                            >{{ author.username|tooltip:"15" }}</a>
                    {% else %}
                    {{ changeset.author|hide_email|tooltip:"15" }}
                    {% endif %}
                </td>
                <td>{{ changeset.message|tooltip:"90" }}</td>
            </tr>
            {% endfor %}
        </tbody>
    </table>
        
    {% paginate %}
</div>
</div>

{% endblock %}
