<div id="c-post-replacements">
  <div id="a-index">
    <h1>Post Replacements</h1>

    <%= render "posts/partials/common/inline_blacklist" %>

    <%= simple_form_for(:search, url: post_replacements_path, method: :get, defaults: { required: false }, html: { class: "inline-form" }) do |f| %>
      <%= f.input :creator_name, label: "Replacer", input_html: { value: params[:search][:creator_name] } %>
      <%= f.input :post_tags_match, label: "Tags", input_html: { value: params[:search][:post_tags_match] } %>
      <%= f.submit "Search" %>
    <% end %>

    <table width="100%" class="striped autofit">
      <thead>
        <tr>
          <th width="1%">Post</th>
          <th>Source</th>
          <th>Replacer</th>
        </tr>
      </thead>
      <tbody>
        <% @post_replacements.each do |post_replacement| %>
          <tr>
            <td><%= PostPresenter.preview(post_replacement.post, show_deleted: true) %></td>
            <td>
              <dl>
                <dt>Original Source</dt>
                <dd><%= external_link_to post_replacement.original_url %></dd>
                <dt>Replacement Source</dt>
                <dd>
                  <% if post_replacement.replacement_url.present? %>
                    <%= external_link_to post_replacement.replacement_url %>
                  <% else %>
                    <em>file</em>
                  <% end %>
                </dd>
              </dl>
            </td>
            <td>
              <%= compact_time post_replacement.created_at %>
              <br> by <%= link_to_user post_replacement.creator %>
              <%= link_to "»", post_replacements_path(search: params[:search].merge(creator_name: post_replacement.creator.name)) %>
            </td>
          </tr>
        <% end %>
      </tbody>
    </table>

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

<% content_for(:page_title) do %>
  Post Replacements - <%= Danbooru.config.app_name %>
<% end %>
