{% macro filelist(files) %}
    <table class="table table-hover">
        <thead>
        <tr>
            <th>
                Filename
                <br />
                Type
            </th>
            <th class="text-right">
                Size [B]
            </th>
            <th>
                Upload [UTC]
                <br />
                Download [UTC]
            </th>
            <th>
                Actions
            </th>
        </tr>
        </thead>
        <tbody>
            {% for file in files %}
            <tr>
                <td>
                    <a href="{{ url_for('bepasty.display', name=file['id']) }}">{{ file['filename'] }}</a>
                    <br />
                    {{ file['type'] }}
                </td>
                <td class="text-right">
                    {{ file['size'] }}
                </td>
                <td>
                    {{ file['timestamp-upload'] | datetime }}
                    <br />
                    {% if file['timestamp-download'] %}
                    {{ file['timestamp-download'] | datetime }}
                    {% else %}
                    never
                    {% endif %}
                </td>
                <td>
                    <div class="btn-group flex-wrap flex-md-nowrap" role="group">
                        <a href="{{ url_for('bepasty.display', name=file['id']) }}" class="btn btn-sm btn-info" role="button">
                            display
                        </a>
                        <a href="{{ url_for('bepasty.download', name=file['id']) }}" class="btn btn-sm btn-info" role="button">
                            download
                        </a>
                        <a href="{{ url_for('bepasty.inline', name=file['id']) }}" class="btn btn-sm btn-info" role="button">
                            inline
                        </a>
                        {% if may(DELETE) %}
                            <form action="{{ url_for('bepasty.delete', name=file['id']) }}" method="post" class="btn-group">
                                <button type="submit" class="btn btn-sm btn-danger">
                                    delete
                                </button>
                            </form>
                        {% endif %}
                        {% if may(ADMIN) %}
                        {% if not file['locked'] %}
                            <form action="{{ url_for('bepasty.lock', name=file['id']) }}" method="post" class="btn-group">
                                <button type="submit" class="btn btn-sm btn-danger">
                                    lock
                                </button>
                            </form>
                        {% else %}
                            <form action="{{ url_for('bepasty.unlock', name=file['id']) }}" method="post" class="btn-group">
                                <button type="submit" class="btn btn-sm btn-info">
                                    unlock
                                </button>
                            </form>
                        {% endif %}
                        {% endif %}
                    </div>
                </td>
            </tr>
            {% endfor %}
        </tbody>
    </table>
{% endmacro %}

{% macro input_filename(value) -%}
    <input class="form-control" type="text" id="filename" name="filename" size="40" placeholder="optional download-filename"{% if value is defined %} value="{{ value }}"{% endif %}>
{%- endmacro %}

{% macro input_contenttype(value) -%}
    <input class="form-control" type="text" id="contenttype" name="contenttype" size="30" placeholder="Content-Type"{% if value is defined %} value="{{ value }}"{% endif %}>
{%- endmacro %}

{% macro contenttype_autocomplete(selector, contenttypes) -%}
    var availableTypes = ["{{ contenttypes | join('","') | safe}}"];
    {{ selector|safe }}.autocomplete({source: availableTypes});
{%- endmacro %}
