{% extends "page.html" %}
{% import 'macros/form.html' as form %}

{% block subtitle %}{{ _("Tags") }}{% endblock %}

{% block breadcrumb_content %}
  <li class="active">{{ h.nav_link(_('Tags Manager'), controller='package', action='search', highlight_actions = 'new index') }}</li>
{% endblock %}

{% block primary_content %}
  <section class="module">
    <div class="module-content">
      {% block page_primary_action %}
        {% if h.check_access('package_create') %}
          <div class="page_primary_action">
            {% link_for _('Add Tag'), controller='package', action='new', class_='btn btn-primary', icon='plus-sign-alt' %}
          </div>
        {% endif %}
      {% endblock %}
    </div>

  </section>

  {% block tag_search_results_api %}
  <section class="module">
    <div class="module-content">
    <ul>
    {% block tags_list %}
    {% set tl = h.tagmanager_list_tags() %}
      {% for tag in tl %}
	<li>{{ h.link_to(tag.display_name + ' (' + h.tagmanager_tag_show(tag.id).packages|count|string + ')', h.url_for(controller='package', action='search', tags= tag.name), class_='tag') }}</li>
      {% endfor %}
    {% endblock %}	
    </ul>
   </div>
  </section>
  {% endblock %}
  {% block tag_merge_suggestion %}
  <h2>Merge Suggestions</h2>
  <section class="module">
    <div class="module-content">
    <ul>
    {% block tags_merge_list %}
    {% set ml = h.tagmanager_tags_merge_list() %}
    {% set tl = h.tagmanager_list_tags() %}
	
      {% for s in range(tl|count) %}
        {% for r in range(s,tl|count) %}
	  {% if (s != r) and (ml[r][s] > 0.5 )%}
	<li> {{ tl[s].name }} and {{ tl[r].name }} | 
	{# h.link_to(_('Merge'), h.url_for(controller='tagmanager', action='merge_confirm', tag1= tl[s].id, tag2=tl[r].id), class_='button') #}
	<a href='/tagmanager/merge_confirm?tag1={{ tl[s].id }}&tag2={{tl[r].id}}'>Merge</a>

	</li>
	  {% endif %}
       {% endfor %}
       {% endfor %}
     {% endblock %}	
    </ul>
   </div>
  </section>
  {% endblock %}
{% endblock %} <!--primary content -->
