<% if forum_post.visible?(CurrentUser.user) %>
  <article class="forum-post" id="forum_post_<%= forum_post.id %>" data-forum-post-id="<%= forum_post.id %>" data-creator="<%= forum_post.creator.name %>">
    <div class="author">
      <h4>
        <%= link_to_user forum_post.creator %>
        <% if forum_post.is_deleted? %>
          (deleted)
        <% end %>
      </h4>
      <p>
        <%= time_ago_in_words_tagged(forum_post.created_at) %>
      </p>
    </div>
    <div class="content">
      <div class="prose">
        <%= format_text(forum_post.body) %>
      </div>
      <% if forum_post.updated_at - forum_post.created_at > 5.minutes %>
        <p class="info">Updated by <%= link_to_user forum_post.updater %> <%= time_ago_in_words_tagged(forum_post.updated_at) %></p>
      <% end %>
      <menu>
        <li>ID: <%= forum_post.id %></li>
        <% if CurrentUser.is_member? && @forum_topic %>
          <li><%= link_to "Quote", new_forum_post_path(:post_id => forum_post.id), :method => :get, :remote => true %></li>
        <% end %>
        <% if CurrentUser.is_moderator? && !forum_post.is_original_post? %>
          <% if forum_post.is_deleted %>
            <li><%= link_to "Undelete", undelete_forum_post_path(forum_post.id), :method => :post, :remote => true %></li>
          <% else %>
            <li><%= link_to "Delete", forum_post_path(forum_post.id), :data => {:confirm => "Are you sure you want to delete this forum post?"}, :method => :delete, :remote => true %></li>
          <% end %>
        <% end %>
        <% if forum_post.editable_by?(CurrentUser.user) %>
          <% if forum_post.is_original_post? %>
            <li><%= link_to "Edit", edit_forum_topic_path(forum_post.topic), :id => "edit_forum_topic_link_#{forum_post.topic.id}", :class => "edit_forum_topic_link" %></li>
          <% else %>
            <li><%= link_to "Edit", edit_forum_post_path(forum_post.id), :id => "edit_forum_post_link_#{forum_post.id}", :class => "edit_forum_post_link" %></li>
          <% end %>
        <% end %>
        <% if params[:controller] == "forum_posts" %>
          <li><%= link_to "Parent", forum_topic_path(forum_post.topic, :page => forum_post.forum_topic_page, :anchor => "forum_post_#{forum_post.id}") %></li>
        <% else %>
          <li><%= link_to "Permalink", forum_post_path(forum_post) %></li>
        <% end %>
      </menu>
      <% if forum_post.editable_by?(CurrentUser.user) %>
        <% if forum_post.is_original_post? %>
          <%= render "forum_topics/form", :forum_topic => forum_post.topic %>
        <% else %>
          <%= render "forum_posts/partials/edit/form", :forum_post => forum_post %>
        <% end %>
      <% end %>
    </div>
    <div class="clearfix"></div>
  </article>
<% end %>
