{% extends theme('base.html') %}
{% block content %}
{% if contents %}
{% if contents.__parents__ %}
<ul class="breadcrumb">
</ul>
{% endif %}
<div>
    <h4>{{ request.path }}</h4>
    {% if request.path != '/' %}
    <p>&nbsp;</p>
    <form action="{{ url_for('admin.upload') }}" class="form-inline" enctype="multipart/form-data" method="post">
        <input class="btn" type="button" onclick="$('input[id=file]').click();" value="Browse" />
        <input name="path" type="hidden" value="{{ request.path }}" />
        <span id="upload-div" style="display:none;">
            <input class="btn" type="submit" value="Upload" />
            <input class="btn" onclick="$(this).parent().parent().prev().html('&nbsp;');$(this).parent().hide();" type="reset" value="Clear" />
        </span>
        <input id="file" name="file" onchange="$(this).parent().prev().html('Upload: '+$(this).val());$('#upload-div').show();" type="file" style="visibility:hidden;" />
    </form>
    {% endif %}
    <form action="{{ url_for('admin.create_folder') }}" class="form-inline" method="post">
        <input name="path" type="hidden" value="{{ request.path }}" />
        <input name="folder_name" placeholder="Name" type="text" />
        <input class="btn" type="submit" value="Create" />
    </form>
</div>

<table class="table table-striped" id="pkg-table">
    <thead>
        <tr>
            <th>Item</th>
            <th></th>
            <th>Action</th>
        </tr>
    </thead>
    <tbody>
{% for item in contents.__contents__ %}
    <form action="{{ url_for('admin.remove') }}" class="form-inline" method="post">
    <tr>
        <td><a href="{{ item }}">{{ item }}</a></td>
        <td><input name="item_path" type="hidden" value="{{ request.path }}{{ item }}" /></td>
        <td><input class="btn btn-small" type="submit" value="Remove" /></td>
    </tr>
    </form>
{% endfor %}
    </tbody>
</table>
{% endif %}
{% endblock %}
