{% extends "skeleton.html" %}
{% block page_title %}Blobstore Viewer{% endblock %}

{% block page_head %}
  <script>{% include "blobstore_viewer.js" %}</script>
  <style type="text/css">{% include "blobstore_viewer.css" %}</style>
{% endblock %}

{% macro paginator(previous, next) %}
  <p>
    {% if previous is not none %}
      <a href="?offset={{previous}}">&laquo; previous</a>
    {% endif %}
    {% if next is not none %}
      <a href="?offset={{next}}">next &raquo;</a>
    {% endif %}
  </p>
{% endmacro %}

{% block body %}
<div>
  <h3>Blobstore Viewer</h3>

  {{ paginator(previous, next) }}

  <form action="{{ request.path }}" method="post">
    <input type="hidden" name="xsrf_token" value="{{ xsrf_token }}"/>
    <table class="ae-table">
      <thead>
        <tr>
          <th><input id="allkeys" type="checkbox"></th>
          <th>Key</th>
          <th>MD5</th>
          <th>Size (bytes)</th>
          <th>Content Type</th>
          <th>Filename</th>
          <th>Created</th>
        </tr>
      </thead>
      <tbody>
        {% for blob_info in blob_infos %}
          <tr>
            <td>
              <input type="checkbox" name="blob_key"
                     value="{{ blob_info.key() }}"/>
            </td>
            <td>
              <a href="/blobstore/blob/{{ blob_info.key() }}?return_to={{ return_to|urlencode }}">
                {{blob_info.key()|string|truncate(10, True)}}
              </a>
            </td>
            <td>{{ blob_info.md5_hash}}</td>
            <td>{{ blob_info.size}}</td>
            <td>{{ blob_info.content_type}}</td>
            <td>{{ blob_info.filename}}</td>
            <td>{{ blob_info.creation}}</td>
          </tr>
        {% endfor %}
      </tbody>
    </table>

    <p>
      <button type="submit" id="delete_button" data-action="delete"
              class="ae-button">Delete selected</button>
    </p>
  </form>

  {{ paginator(previous, next) }}
</div>
{% endblock %}
