<div id="c-uploads">
  <div id="a-show">
    <h1>Upload #<%= @upload.id %></h1>

    <ul>
      <li>Date: <%= @upload.created_at %></li>
      <li>Source: <%= @upload.source %></li>
      <% if policy(@upload).can_view_tags? %>
        <li>Tags: <%= @upload.tag_string %></li>
      <% end %>
      <% if @upload.md5.present? %>
        <li>MD5: <%= @upload.md5 %>
      <% end %>
      <% if @upload.file_size.present? %>
        <li>
          Size: <%= number_to_human_size(@upload.file_size) %></li>
          <% if @upload.image_width.present? %>
            (<%= @upload.image_width %>x<%= @upload.image_height %>)
          <% end %>
        </li>
      <% end %>
    </ul>

    <% if @upload.is_completed? %>
      <p>This upload has finished processing. <%= link_to "View the post", post_path(@upload.post_id) %>.</p>
    <% elsif @upload.is_pending? %>
      <p>This upload is waiting to be processed. Please wait a few seconds.</p>
    <% elsif @upload.is_processing? || @upload.is_preprocessing? || @upload.is_preprocessed? %>
      <p>This upload is being processed. Please wait a few seconds.</p>
    <% elsif @upload.is_duplicate? %>
      <p>This upload is a duplicate: <%= link_to "post ##{@upload.duplicate_post_id}", post_path(@upload.duplicate_post_id) %></p>
    <% else %>
      <p>An error occurred: <%= render_status(@upload) %></p>
      <% if CurrentUser.user.is_builder? %>
        <%= render "static/backtrace", backtrace: @upload.backtrace.to_s.split(/\n/) %>
      <% end %>
    <% end %>

    <p>
      You can <%= link_to "upload another file", new_upload_path %> or <%= link_to "view your current uploads", uploads_path(:search => {:uploader_id => CurrentUser.id}) %>.
    </p>
  </div>
</div>

<%= render "uploads/secondary_links" %>

<% if @upload.is_pending? || @upload.is_processing? || @upload.is_preprocessing? || @upload.is_preprocessed? %>
  <% content_for(:html_header) do %>
    <meta http-equiv="refresh" content="2">
  <% end %>
<% end %>
