{% extends "base.html" %}

{% block content %}

<div class="formats">
    <p>
        Get this data as:
        <strong>HTML</strong>,
        {% for fmt, link in formats %}
            <a href="{{ link }}">{{ fmt }}</a>{% if not loop.last %}, {% endif %}
        {% endfor %}
    </p>
</div>

<p>
    {% for name, link in location %}
        {% if link %}
            <a href="{{ link }}">{{ name }}</a>
        {% else %}
            <strong>{{ name }}</strong>
        {% endif %}
        {% if not loop.last %}/{% endif %}
    {% endfor %}
</p>

{% if empty %}
    <div>No data.</div>
{% elif params.pk %}
    {% for row in data %}
    <table class="table">
        <tbody>
        {% for title, cell in zip(header, row) %}
            <tr>
                <th>{{ title }}</th>
                <td{% if cell.color %} style="background-color: {{ cell.color.value }}"{% endif %}>
                    {% if column in ('id', 'type') %}
                        <strong>{{ cell.value }}</strong>
                    {% elif cell.link %}
                        <a href="{{ cell.link }}">{{ cell.value }}</a>
                    {% else %}
                        {{ cell.value }}
                    {% endif %}
                </td>
            </tr>
        {% endfor %}
        </tbody>
    </table>
    {% endfor %}
{% else %}
    <table class="table">
        <thead>
        <tr>
            {% for cell in header %}
                <th>{{ cell }}</th>
            {% endfor %}
        </tr>
        </thead>
        <tbody>
        {% for row in data %}
            <tr>
                {% for cell in row %}
                    <td{% if cell.color %} style="background-color: {{ cell.color.value }}"{% endif %}>
                        {% if cell.link %}
                            <a href="{{ cell.link }}">{{ cell.value }}</a>
                        {% else %}
                            {{ cell.value }}
                        {% endif %}
                    </td>
                {% endfor %}
            </tr>
        {% endfor %}
        </tbody>
    </table>

    {% if not data.exhausted %}
        <p>Number of rows is limited up to {{ data.limit }} rows.</p>
    {% endif %}
{% endif %}

{% endblock %}
