{% extends "base.html" %}

{% block content %}
    <div class="table-responsive">
    <table class="repositories">
        <thead>
        <tr>
            <th>Name</th>
            <th>Description</th>
            <th>Owner</th>
            <th>Idle</th>
        </tr>
        </thead>

        <tbody>
        {%- for (path, repositories) in repositories %}
            {%- if let Some(path) = path %}
            <tr><td class="repo-section" colspan="4">{{ path }}</td></tr>
            {%- endif -%}

            {%- for repository in repositories %}
            {% set repository = repository.get() %}
            <tr class="{% if path.is_some() %}has-parent{% endif %}">
                <td>
                    <a href="/{% if let Some(path) = path %}{{ path }}/{% endif %}{{ repository.name }}">
                        {{- repository.name -}}
                    </a>
                </td>
                <td>
                    <a href="/{% if let Some(path) = path %}{{ path }}/{% endif %}{{ repository.name }}">
                        {%- if let Some(description) = repository.description.as_ref() -%}
                            {{- description -}}
                        {%- else -%}
                            Unnamed repository; edit this file 'description' to name the repository.
                        {%- endif -%}
                    </a>
                </td>
                <td>
                    <a href="/{% if let Some(path) = path %}{{ path }}/{% endif %}{{ repository.name }}">
                        {%- if let Some(owner) = repository.owner.as_ref() -%}
                            {{- owner -}}
                        {%- endif -%}
                    </a>
                </td>
                <td>
                    <a href="/{% if let Some(path) = path %}{{ path }}/{% endif %}{{ repository.name }}">
                        <time datetime="{{ repository.last_modified|format_time }}" title="{{ repository.last_modified|format_time }}">
                            {{- repository.last_modified|timeago -}}
                        </time>
                    </a>
                </td>
            </tr>
            {%- endfor -%}
        {%- endfor %}
        </tbody>
    </table>
    </div>
{% endblock %}
