<div id="c-posts">
  <div id="a-show">
    <aside id="sidebar">
      <%= render "posts/partials/common/search", :path => posts_path, :tags => params[:tags], :tags_dom_id => "tags" %>

      <%= render "posts/partials/index/blacklist" %>

      <section id="tag-list">
        <%= @post.presenter.split_tag_list_html(self) %>
      </section>

      <section id="post-information">
        <h1>Information</h1>
        <%= render "posts/partials/show/information", :post => @post %>
      </section>

      <% if CurrentUser.is_member? %>
        <section id="post-options">
          <h1>Options</h1>
          <%= render "posts/partials/show/options", :post => @post %>
        </section>

        <section id="post-history">
          <h1>History</h1>
          <ul>
            <li><%= fast_link_to "Tags", post_versions_path(:search => {:post_id => @post.id}) %></li>
            <li><%= fast_link_to "Notes", note_versions_path(:search => {:post_id => @post.id}) %></li>
            <li><%= fast_link_to "Flags & Appeals", post_events_path(@post.id) %></li>
            <li><%= fast_link_to "Commentary", artist_commentary_versions_path(:search => {:post_id => @post.id}) %></li>
            <li><%= fast_link_to "Replacements", post_replacements_path(:search => {:post_id => @post.id}) %></li>
          </ul>
        </section>

      <% end %>
      
    </aside>

    <section id="content">
      <% if @post.presenter.has_nav_links?(self) %>
        <%= render "posts/partials/show/nav_links", :post => @post, :position => "top" %>
      <% end %>

      <%= render "posts/partials/show/notices", :post => @post %>

      <section itemscope itemtype="http://schema.org/ImageObject" id="image-container" <%= PostPresenter.data_attributes(@post) %>>
        <div id="note-container"></div>
        <div id="note-preview"></div>
        <%= @post.presenter.image_html(self) %>
      </section>

      <div class="fav-buttons">
        <%= button_to "Favorite", favorites_path(post_id: @post.id), remote: true, method: :post, form: {id: "add-fav-button"}, class: "ui-button ui-widget ui-corner-all gradient" %>
        <%= button_to "Unfavorite", favorite_path(@post), remote: true, method: :delete, form: {id: "remove-fav-button"}, class: "ui-button ui-widget ui-corner-all gradient" %>
      </div>

      <section id="mark-as-translated-section" style="display: none;">
        <%= form_tag(mark_as_translated_post_path(@post), :class => "simple_form", :method => :put) do |f| %>
          <%= hidden_field_tag :tags_query, params[:tags] %>
          <%= hidden_field_tag :pool_id, params[:pool_id] %>

          <fieldset>
            <label for="post_check_translation">
              <%= check_box "post", "check_translation", :checked => @post.has_tag?("check_translation") %>
              Check translation
            </label>

            <label for="post_partially_translated">
              <%= check_box "post", "partially_translated", :checked => @post.has_tag?("partially_translated") %>
              Partially translated
            </label>
          </fieldset>

          <div class="input">
            <%= submit_tag "Mark as translated" %>
          </div>
        <% end %>
      </section>

      <% if @post.artist_commentary && @post.artist_commentary.any_field_present? %>
        <div id="artist-commentary">
          <%= render "artist_commentaries/show", :artist_commentary => @post.artist_commentary %>
        </div>
      <% end %>

      <% if @post.presenter.has_nav_links?(self) %>
        <%= render "posts/partials/show/nav_links", :post => @post, :position => "bottom" %>
      <% end %>

      <menu id="post-sections">
        <li><a href="#comments">Comments</a></li>
        <% if CurrentUser.is_member? && @post.visible? %>
          <li><a href="#edit" id="post-edit-link">Edit</a></li>
        <% end %>
        <li><a href="#share">Share</a></li>
      </menu>

      <section id="comments">
        <% if !CurrentUser.user.is_builder? %>
          <h2>Before commenting, read the <%= link_to "how to comment guide", wiki_pages_path(:search => {:title => "howto:comment"}) %>.</h2>
        <% end %>
        <%= render "comments/partials/index/list", :comments => @post.comments.visible(CurrentUser.user), :post => @post, :show_header => false %>
      </section>

      <section id="notes" style="display: none;">
        <% cache("p/#{@post.id}/n/#{@post.last_noted_at.to_i}") do %>
          <%= render :partial => "notes/note", :collection => @post.notes.active %>
        <% end %>
      </section>

      <% if CurrentUser.is_member? && @post.visible? %>
        <section id="edit" style="display: none;">
          <%= render "posts/partials/show/edit", :post => @post %>
        </section>
      <% end %>

      <section id="share" style="display: none;">
        <%= render "posts/partials/show/share", :post => @post %>
      </section>
    </section>
  </div>

  <div id="flag-dialog" class="prose" title="Flag post" style="display: none;">
    <%= render "post_flags/new", post_flag: @post.flags.new %>
  </div>

  <div id="appeal-dialog" class="prose" title="Appeal post" style="display: none;">
    <%= render "post_appeals/new", post_appeal: @post.appeals.new %>
  </div>

  <div id="replace-image-dialog" class="prose" title="Replace image" style="display: none;">
    <%= render "post_replacements/new", post_replacement: @post.replacements.new %>
  </div>

  <div id="add-to-pool-dialog" title="Add to pool" style="display: none;">
    <%= render "pool_elements/new" %>
  </div>

  <div id="add-commentary-dialog" title="Add artist commentary" style="display: none;">
    <%= render "artist_commentaries/form", :post => @post %>
  </div>

  <div id="add-to-favgroup-dialog" title="Add to favorite group" style="display: none;">
    <%= render "favorite_groups/add_to_favgroup_dialog", :post => @post %>
  </div>

  <div id="saved-searches-nav">
    <%= render "saved_searches/interface" %>
  </div>
</div>

<% content_for(:page_title) do %>
  <%= @post.presenter.humanized_essential_tag_string %> - <%= Danbooru.config.app_name %>
<% end %>

<% content_for(:html_header) do %>
  <meta name="description" content="<%= @post.presenter.humanized_tag_string %>">
  <meta name="tags" content="<%= @post.tag_string %>">
  <meta name="favorites" content="<%= @post.fav_string %>">
  <meta name="pools" content="<%= @post.pool_string %>">
  <meta name="post-id" content="<%= @post.id %>">
  <% if CurrentUser.can_approve_posts? %>
    <meta name="post-is-approvable" content="<%= @post.is_approvable? %>">
  <% end %>
  <meta name="post-is-deleted" content="<%= @post.is_deleted? %>">
  <meta name="post-is-flagged" content="<%= @post.is_flagged? %>">
  <meta name="config-large-width" content="<%= Danbooru.config.large_image_width %>">
  <meta name="post-has-embedded-notes" content="<%= @post.has_embedded_notes? %>">
  <meta name="always-resize-images" content="<%= CurrentUser.user.always_resize_images? %>">
  <meta property="og:title" content="<%= @post.presenter.humanized_essential_tag_string %> - <%= Danbooru.config.app_name %>">

  <% if @post.visible? %>
    <meta property="og:image" content="http://<%= Danbooru.config.hostname %><%= @post.large_file_url %>">
  <% end %>

  <% if Danbooru.config.enable_post_search_counts %>
    <meta name="report-server" content="<%= Danbooru.config.reportbooru_server %>">
  <% end %>

  <!-- Twitter properties -->
  <% if @post.twitter_card_supported? %>
    <meta name="twitter:card" content="summary_large_image">
    <meta name="twitter:site" content="<%= Danbooru.config.twitter_site %>">
    <meta name="twitter:title" content="<%= @post.presenter.humanized_essential_tag_string %> - <%= Danbooru.config.app_name %>">
    <meta name="twitter:description" content="<%= @post.presenter.humanized_tag_string %> - <%= Danbooru.config.app_name %>">

    <% if @post.visible? %>
      <meta name="twitter:image" content="http://<%= Danbooru.config.hostname %><%= @post.large_file_url %>">
    <% end %>
  <% end %>

  <%= auto_discovery_link_tag(:atom, comments_url(:atom, search: { post_id: @post.id }), title: "Comments for post ##{@post.id}") %>
<% end %>

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