{% extends base_template %}

{% load seahub_tags avatar_tags i18n %}
{% load url from future %}

{% block main_panel %}
    <div class="w100 ovhd">
        <h2 class="fleft"><span class="op-target">{{repo.props.name}}</span> {% trans "snapshot"%}<span class="commit-time">({{ current_commit.props.ctime|tsstr_sec }})</span></h2>
        <button data="{% url 'repo_view_snapshot' repo.id %}" class="fright" id="back">{% trans "Back to snapshots"%}</button>
    </div>

    {% if path == '/' %}
    <div id="repo-latest-commit">
        <p class="commit-msg">{{ current_commit.props.desc|translate_commit_desc }}</p>
        <p class="meta-info">
        <span class="author">
            {% if current_commit.props.creator_name %}
            {% avatar current_commit.props.creator_name 20 %}
            <a class="name" href="{% url 'user_profile' current_commit.props.creator_name|id_or_email %}">{{ current_commit.props.creator_name|short_email }}</a>
            {% else %}
            {% trans "Unknown"%}
            {% endif %}
        </span>
        <span class="time">{{ current_commit.props.ctime|translate_seahub_time }}</span>
        </p>
    </div>
    {% endif %}

    <div class="repo-file-list-outer-container">
        <div class="repo-file-list-inner-container">
            {% if not user_perm %}
            <div class="repo-file-list-not-show">
                <p class="access-notice">{% trans "Can't view this library"%}</p>
            </div>
            {% else %}
            <div class="repo-file-list-topbar">
                <p class="path">
                {% trans "Current path: "%}
                {% for name, link in zipped %}
                {% if not forloop.last %}
                <a href="{% url 'repo_history_view' repo.id %}?commit_id={{ current_commit.id }}&p={{ link|urlencode }}">{{ name }}</a> /                 
                {% else %}
                {{ name }}
                {% endif %}
                {% endfor %}
                </p>
            </div>
            <!-- /.repo-file-list-topbar -->
            <table class="repo-file-list">
                <tr>
                    <th width="5%"></th>
                    <th width="65%">{% trans "Name"%}</th>
                    <th width="30%">{% trans "Size"%}</th>
                </tr>

                {% for dirent in dir_list %}
                <tr>
                    <td class="alc"><img src="{{ MEDIA_URL }}img/folder-icon-24.png" alt="{% trans "Directory"%}" /></td>
                    <td><a href="{% url 'repo_history_view' repo.id %}?commit_id={{ current_commit.id }}&p={{ path|urlencode }}{{ dirent.obj_name|urlencode }}">{{ dirent.obj_name }}</a></td>              
                    <td></td>
                </tr>
                {% endfor %}

                {% for dirent in file_list %}
                <tr>
                    <td class="alc"><img src="{{ MEDIA_URL }}img/file/{{ dirent.obj_name|file_icon_filter }}" alt="{% trans "File"%}" /></td>
                    <td><a class="normal" href="{% url 'view_snapshot_file' repo.props.id %}?obj_id={{ dirent.props.obj_id }}&commit_id={{ current_commit.id }}&p={{ path|urlencode }}{{ dirent.obj_name|urlencode }}">{{ dirent.props.obj_name }}</a></td>              
                    <td>{{ dirent.file_size|filesizeformat }}</td>
                    <td>
                    </td>
                </tr>
                {% endfor %}
            </table>
            <!-- /.repo-file-list -->
            {% endif %}
        </div>
    </div>
    {% endblock %}

{% block extra_script %}
<script type="text/javascript">
$('#back').click(function() {
    location.href = $(this).attr('data');
});
</script>
{% endblock %}
