{% extends "layout.html" %}

{% import "macros.html" as macros %}


{% block page_title %}Tags{% endblock %}
{% block main_title %}Tags{% endblock %}


{% block body %}

<div id="update-tags">
<ul class="controls">

{{ macros.toggle_link('counts', [
    ('yes', 'counts'),
    ('no', 'no counts'),
], 'no', '.tags') }}

{% if error %}
<li class="error"><b>error</b>: {{ error }}
{% endif %}

</ul>
</div>


<dl class="tag-list">

{% for tag, feed_counts, entry_counts in tags %}
<dt id="tag-{{ loop.index }}">
    {% if tag == none %} <span class="tag-text">all</span>
    {% elif tag == true %} <span class="tag-text">any tags</span>
    {% elif tag == false %} <span class="tag-text">no tags</span>
    {% else %} <span class="tag">{{ tag }}</span>
    {% endif %}
</dt>

<dd>
    {% set url_kwargs = {'tags': [tag] | tojson } if tag is not none else {} %}

    {% if feed_counts %}
        <abbr title='({{ feed_counts.broken }} broken, {{ feed_counts.total - feed_counts.updates_enabled }} disabled)'>{{ feed_counts.total }}
    {% endif %}
    <a href="{{ url_for('.feeds', **url_kwargs) }}">feeds</a>
    {%- if feed_counts %}</abbr>{% endif -%}
    ,
    {% if entry_counts %}
        {{ macros.entry_counts(entry_counts, url_for('.entries', **url_kwargs)) }}
    {% else %}
        <a href="{{ url_for('.entries', **url_kwargs) }}">entries</a>
    {% endif %}
    {% if entry_counts %}</abbr>{% endif %}
</dd>

{% else %}

{% if not error %}
<p>no tags</p>
{% endif %}

{% endfor %}
</dl>



{% endblock %}
