
<%def name="row(tile, tag)">
    <li class="tile">
        <div class="base" style="background-image: url(/img/icons/tag_24.png);">
            <h3><a class="link" href="${h.entity_url(tag)}">${tag.name}</a></h3>
            <div class="meta noclear">
                ${_("created %s") % h.datetime_tag(tag.create_time)|n}
                %if c.instance:
                     ·   ${_("used %s times") % len(tag)}
                %endif
            </div>
        </div>
    </li>
</%def>


<%def name="cloud(tags, plain, show_count, link_more)">
    <p>
    %for (tag, count, size) in tags:
        ${h.tag.link(tag, count=0 if not show_count else count, size=size, plain=plain)|n}
    %endfor
    </p>
    %if link_more:
    <p><a href="${h.base_url('/tag')}">${_("more tags...")}</a></p>
    %endif
</%def>

<%def name="sidebar(delegateable)">
    <% h.need.autocomplete %>
    <h6>${_("Tagged with")}</h6>
    <p>
        %if len(delegateable.tags):
        ${", ".join([h.tag.link_with_untag(tag, delegateable, simple=True) for
                     (tag, count) in delegateable.tags])|n}
        %else:
        ${_('Not tagged yet')}
        %endif
    </p>
    %if can.tag.create():
    <div class="only-js" id="add_tags">
        <a href="#" class="showhide_button button_small action"
           data-target="#tags_form"
           aria-controls="tags_form">
            ${_("add tags")}
        </a>
    </div>
    <div id="tags_form" data-cancel=".cancel" style="display: none">
        <form action="${h.base_url('/tag', delegateable.instance)}" method="POST">
            ${h.field_token()|n}
            <input name="delegateable" type="hidden" value="${delegateable.id}" />
            <input name="tags" type="tags" id="tags" autocomplete="off" data-instance-baseurl="${h.base_url(instance=delegateable.instance, append_slash=True)}" />
            <div>
                ${_("Multiple tags can be separated by commas or spaces.")}
            </div>
            <div class="submit">
                <input type="submit" value="${_('Add tags')}" />&nbsp;
                <a href="#" class="cancel">${_('Cancel')}</a>
                </div>
        </form>
    </div>
    %endif
</%def>

<%def name="widget(delegateable)">

## FIXME: Reimplement Tagging
%if can.tag.create():

<form action="/tag" method="POST">
    ${h.field_token()|n}
    <input name="delegateable" type="hidden" value="${delegateable.id}" />
    <select data-placeholder="${_('Add tags')}"
            class="chzn-select">
    </select>
    <input name="tags" type="tags" id="tags" autocomplete="off" data-instance-baseurl="${h.base_url(instance=delegateable.instance)}" />
    <span class="hint">
        ${_("Multiple tags can be separated by commas or spaces.")}
    </span>
    <input type="submit" value="${_("Add tags")}" />
</form>


%endif
</%def>
