<div class="box wide">
  <p>
  To hide stories with certain <a href="/tags">tags</a> from across the site, check them below.
  If you don't have an account, this will save to a cookie in your browser.
  </p>

  <% if !@user %>
    <p>
    Since you are not logged in, your filters will be stored in a long-lasting
    browser cookie.  To permanently store your tag filters and have them work
    across browsers, <a href="/login">login</a> to your account.
    </p>
  <% end %>

  <%= form_with url: '/filters', method: :post do |f| %>
    <table class="data zebra" cellspacing=0>
    <tr>
      <th>Hide</th>
      <th>Tag</th>
      <th>Description</th>
      <th style="text-align: right;">Stories</th>
      <th style="text-align: right; padding-right: 1em;">Filtering</th>
    </tr>
    <% @categories.each do |category| %>
      <tr>
        <th></th>
        <th colspan=4><%= category.category %></th>
      </tr>
      <% category.tags.each do |tag| %>
        <tr id="<%= tag.tag %>">
          <td>
            <% if tag.user_can_filter?(@user) %>
              <%= check_box_tag "tags[#{tag.tag}]", tag.tag, @filtered_tags.include?(tag.id) %>
            <% end %>
          </td>
          <td><%= tag_link(tag) %></td>
          <td>
            <%= label_tag "tags[#{tag.tag}]" do %>
              <span class="<%= tag.active? ? '' : 'inactive_tag' %>"><%= tag.description %></span>
              <% if !tag.active %>
                | <em>inactive</em>
              <% end %>
              <% if tag.hotness_mod != 0 %>
                |
                <em>hotness mod <%= tag.hotness_mod > 0 ? "+" : ""%><%= tag.hotness_mod %></em>
              <% end %>
            <% end %>
          </td>
          <td style="text-align: right;"><%= number_with_delimiter(@story_counts[tag.id]) %></td>
          <td style="text-align: right; padding-right: 1em;"><%= number_with_delimiter(@filter_counts[tag.id]) %></td>
        </tr>
      <% end %>
    <% end %>
    </table>
    <p>
    <%= f.submit "Save Filters" %>
    </p>
  <% end %>
</div>
