<%= call_hook(:view_repositories_show_contextual, { :repository => @repository, :project => @project }) %>

<div class="contextual">
  <%= render :partial => 'navigation' %>
</div>

<h2 class="breadcrumbs"><%= render :partial => 'breadcrumbs', :locals => { :path => @path, :kind => 'file', :revision => @rev } %></h2>

<%= render :partial => 'link_to_functions' %>

<% if @annotate %>
<% colors = Hash.new {|k,v| k[v] = (k.size % 12) } %>
<div class="autoscroll">
<table class="filecontent annotate syntaxhl">
  <tbody>
    <% line_num = 1; previous_revision = nil %>
    <% syntax_highlight_lines(@path, Redmine::CodesetUtil.to_utf8_by_setting(@annotate.content)).each do |line| %>
      <% revision = @annotate.revisions[line_num - 1] %>
      <tr id="L<%= line_num %>" class="bloc-<%= revision.nil? ? 0 : colors[revision.identifier || revision.revision] %> <%= previous_revision && revision && revision != previous_revision ? 'bloc-change' : nil%>">
        <th class="line-num"><a href="#L<%= line_num %>" data-txt="<%= line_num %>"></a></th>
        <td class="revision">
          <% if revision && revision != previous_revision %>
            <%= revision.identifier ?
                  link_to_revision(revision, @repository) : format_revision(revision) %>
          <% end %>
        </td>
        <td class="author">
          <% if revision && revision != previous_revision %>
            <% author = Redmine::CodesetUtil.to_utf8(revision.author.to_s,
                                                     @repository.repo_log_encoding) %>
            <%= author.split('<').first %>
          <% end %>
        </td>
        <% if line == "\n" or line == "\r\n" %>
        <td class="line-code"><br></td>
        <% else %>
        <td class="line-code"><div><%= line.html_safe %></div></td>
        <% end %>
      </tr>
      <% line_num += 1; previous_revision = revision %>
    <% end %>
  </tbody>
</table>
</div>
<% else %>
<p id="errorExplanation"><%= @error_message %></p>
<% end %>

<% html_title(l(:button_annotate)) -%>

<% content_for :header_tags do %>
<%= stylesheet_link_tag 'scm' %>
<% end %>
