{% extends "pylucid_admin/base_site.html" %}
{% load i18n %}

{% block extrastyle %}
{% compress css %}
<style type="text/css">/* filemanager default.html */
table#files, fieldset {
    width: 97%;
    padding: 0 1em 0 1em;
    margin: 1em;
}
table#files {
    border: 2px solid #555;
}
table#files th {
    background-color: #ddd;
}
table#files tr:nth-child(2n) td {
    background-color: #fafafa;
}
table#files tr td {
    border-bottom: 1px solid #eee;
}
table#files tr:hover td {
    border-bottom: 1px solid #aaa;
}
table#files .item_size, table#files .item_mtime {
    text-align:right;
}
table#files .item_uid, table#files .item_gid {
    text-align:center;
}
table#files span {
    cursor:help;
    color: #008;
}
table#files {
    white-space:nowrap;
}
</style>
{% endcompress %}
{% endblock %}

{% block content %}
<!-- view_content block -->

<script type="text/javascript">
try {
    jQuery(document);
} catch (e) {
    alert("Error, jQuery JS not loaded!\n Original error was:" + e);
}

jQuery(document).ready(function($) {
    log("filemanager initialized.");
});
</script>


<fieldset class="breadcrumbs"><legend>{% trans "Path" %}</legend>
<p>
{% for breadcrumb in breadcrumbs %}/<a href="{{ breadcrumb.url }}" title="{{ breadcrumb.title }}">{{ breadcrumb.name }}</a>{% if forloop.last %}/{% endif %}{% endfor %}
</p>
</fieldset>

<table id="files">
    <tr>
        <th class="item_name">{% trans "name" %}</th>
        <th class="item_size">{% trans "size" %}</th>
        <th class="item_mtime">{% trans "modification time" %}</th>
        <th class="item_mode">{% trans "mode" %}</th>
        <th class="item_uid">{% trans "user" %}</th>
        <th class="item_gid">{% trans "group" %}</th>
        <th class="item_type">{% trans "info" %}</th>
        <th class="item_type">{% trans "url" %}</th>
    </tr>
{% for dir_item in dir_items %}
    <tr>
        <td class="item_name">      
            {% if dir_item.is_dir %}
            <a href="{{ dir_item.name }}/">{{ dir_item.name }}</a>
            {% else %}{{ dir_item.name }}{% endif %}
        </td>
        <td class="item_size">
            {% if dir_item.is_dir %}&lt;dir&gt;{% else %}{{ dir_item.size|filesizeformat }}{% endif %}
        </td>
        <td class="item_mtime">
            {{ dir_item.mtime|date:_("DATETIME_FORMAT") }}
        </td>
        <td class="item_mode">
            <span title="ocatal: {{ dir_item.mode_octal }} - raw integer: {{ dir_item.mode }}">
            {{ dir_item.mode_symbol }}
            </span>
        </td>   
        <td class="item_uid">
            <span title="user UD: {{ dir_item.uid }}">{{ dir_item.username }}</span>
        </td>   
        <td class="item_gid">
            <span title="group UD: {{ dir_item.gid }}">{{ dir_item.groupname }}</span>
        </td>   
        <td class="item_type">
            <span title="{{ dir_item.item_type }}">{{ dir_item.item_type|truncatechars:50 }}</span>
        </td>
        <td class="item_url">
            {% if dir_item.url %}
                <a href="{{ dir_item.url }}">link</a>
            {% else %}
                -
            {% endif %}
        </td>
    </tr>
{% empty %}
    <tr><td colspan="7">(contains no directories/files.)</td></tr>
{% endfor %}
</table>

{% if upload_form %}
<fieldset><legend>{% trans "file upload" %}</legend>
<form enctype="multipart/form-data" method="post" action="">{% csrf_token %}
{{ upload_form.as_p }}
<input type="submit" value="upload" />
</form>
</fieldset>
{% endif %}

<fieldset><legend>{% trans "base path" %}</legend>
<form action="" method="post">{% csrf_token %}
{{ path_form.as_p }}
<input type="submit" value="Submit" />
</form>
</fieldset>

<fieldset><legend>{% trans "system info" %}</legend>
<p>
    user: <span title="user ID: '{{ uid }}'">{{ username }}</span>
    usergroup: <span title="group ID: '{{ gid }}'">{{ groupname }}</span>
</p>
</fieldset>
{% endblock %}