<%= wiki_page_breadcrumb(@page) %>

<% unless @content.current_version? %>
  <%= title [@page.pretty_title, project_wiki_page_path(@page.project, @page.title, :version => nil)],
            [l(:label_history), history_project_wiki_page_path(@page.project, @page.title)],
            "#{l(:label_version)} #{@content.version}" %>
  <p>
    <%= link_to(("\xc2\xab " + l(:label_previous)),
                :action => 'show', :id => @page.title, :project_id => @page.project,
                :version => (@content.version - 1)) + " - " if @content.version > 1 %>
    <%= "#{l(:label_version)} #{@content.version}/#{@page.content.version}" %>
    <%= '('.html_safe + link_to(l(:label_diff), :controller => 'wiki', :action => 'diff',
                                :id => @page.title, :project_id => @page.project,
                                :version => @content.version) + ')'.html_safe if @content.version > 1 %> -
    <%= link_to((l(:label_next) + " \xc2\xbb"), :action => 'show',
                :id => @page.title, :project_id => @page.project,
                :version => (@content.version + 1)) + " - " if @content.version < @page.content.version %>
    <%= link_to(l(:label_current_version), :action => 'show', :id => @page.title, :project_id => @page.project) %>
    <br/>
    <em><%= @content.author ? link_to_user(@content.author) : l(:label_user_anonymous)
    %>, <%= format_time(@content.updated_on) %> </em><br/>
    <%= @content.comments %>
  </p>
  <hr/>
<% end %>
<%= render(:partial => "wiki/content", :locals => {:content => @content}) %>

<%= link_to_attachments @page %>

<% if @editable && authorize_for('wiki', 'add_attachment') %>
  <div id="wiki_add_attachment">
    <p class="toolbar"><%= link_to l(:label_attachment_new), {}, :onclick => "$('#add_attachment_form').show(); $(document).trigger('erui_interface_change_vertical'); return false;",
                                   :id => 'attach_files_link', :class => 'button' %></p>
    <%= form_tag({:controller => 'wiki', :action => 'add_attachment',
                  :project_id => @project, :id => @page.title},
                 :multipart => true, :id => "add_attachment_form",
                 :style => "display:none;", :class => 'form-box') do %>
      <div class="box">
        <p><%= render :partial => 'attachments/form' %></p>
      </div>
      <div class="form-actions">
        <%= submit_tag l(:button_save), :class => 'button-positive' %>
        <%= link_to l(:button_cancel), {}, :onclick => "$('#add_attachment_form').hide(); return false;", :class => 'button' %>
      </div>
    <% end %>
  </div>
<% end %>

<% content_for :sidebar_exports do -%>
  <div class="other-formats links">
    <% easy_other_formats_links do |f| %>
      <%= f.link_to 'PDF', :url => {:id => @page.title, :version => params[:version]} %>
      <%= f.link_to 'HTML', :url => {:id => @page.title, :version => params[:version]} %>
      <%= f.link_to 'TXT', :url => {:id => @page.title, :version => params[:version]} %>
    <% end if User.current.allowed_to?(:export_wiki_pages, @project) %>
  </div>
<% end %>
<% content_for :header_tags do %>
  <%= stylesheet_link_tag 'scm' %>
<% end %>

<% content_for :easy_page_layout_service_box do -%>
  <ul class="menu-manager">
    <% links = []
       links << link_to(l(:label_wiki_page_new), new_project_wiki_page_path(@project), :remote => true, :class => 'icon icon-add') if User.current.allowed_to?(:edit_wiki_pages, @project)
       if @editable
         links << link_to_if_authorized(l(:button_edit), {:action => 'edit', :id => @page.title}, :class => 'icon icon-edit', :accesskey => accesskey(:edit)) if @content.current_version?
         links << watcher_link(@page, User.current)
         links << link_to_if_authorized(l(:button_lock), {:action => 'protect', :id => @page.title, :protected => 1}, :method => :post, :class => 'icon icon-lock') if !@page.protected?
         links << link_to_if_authorized(l(:button_unlock), {:action => 'protect', :id => @page.title, :protected => 0}, :method => :post, :class => 'icon icon-unlock') if @page.protected?
         links << link_to_if_authorized(l(:button_rename), {:action => 'rename', :id => @page.title}, :class => 'icon icon-move') if @content.current_version?
         links << link_to_if_authorized(l(:button_delete), {:action => 'destroy', :id => @page.title}, :method => :delete, :data => {:confirm => l(:text_are_you_sure)}, :class => 'icon icon-del')
         links << link_to_if_authorized(l(:button_rollback), {:action => 'edit', :id => @page.title, :version => @content.version}, :class => 'icon icon-cancel') unless @content.current_version?
       end
       links << link_to_if_authorized(l(:label_history), {:action => 'history', :id => @page.title}, :class => 'icon icon-history')
    %>
    <%= links.map! { |l| content_tag(:li, l) unless l.blank? }.join.html_safe %>
  </ul>
<% end %>

<% content_for :sidebar do %>
  <%= render :partial => 'sidebar' %>
<% end %>

<% html_title @page.pretty_title %>
