<% meta_description "Search thousands of tags on #{Danbooru.config.app_name}." %>

<div id="c-tags">
  <div id="a-index" class="fixed-width-container">
    <%= render "search" %>

    <%= table_for @tags, class: "striped autofit" do |t| %>
      <% t.column "Name", td: {class: "col-expand"} do |t| %>
        <%= link_to_wiki "?", t.name, class: tag_class(t) %>
        <%= link_to t.name, posts_path(tags: t.name), class: tag_class(t) %>

        <% tag_alias = t.tag_alias_for_pattern(params[:search][:name_or_alias_matches]) %>
        <% if tag_alias.present? %>
          ← <%= link_to tag_alias.antecedent_name, tag_alias, class: "fineprint" %>
        <% end %>

        <%= tag.span humanized_number(t.post_count), class: "post-count", title: t.post_count %>
      <% end %>
      <% t.column column: "control" do |tag| %>
        <% if policy(tag).update? %>
          <%= link_to "Edit", edit_tag_path(tag) %> |
        <% end %>
        <%= link_to "History", post_versions_path(search: { changed_tags: tag.name }) %> |
        <%= link_to "Related", related_tag_path(search: { query: tag.name }) %> |
        <%= link_to "Similar", tags_path(search: { fuzzy_name_matches: tag.name, order: :similarity }) %>
      <% end %>
    <% end %>

    <%= numbered_paginator(@tags) %>
  </div>
</div>

<%= render "secondary_links" %>
