gitprep / templates / include / diff_status_bar.html.ep /
d7a564c 7 years ago
1 contributor
61 lines | 2.186kb
<%
  my $diff_tree = stash('diff_tree');
  my $fragment = stash('fragment');
  my $add_line_count = $diff_tree->{add_line_count} || 0;
  my $delete_line_count = $diff_tree->{delete_line_count} || 0;
  my $diff_line_count = $add_line_count + $delete_line_count;
  my $diff_count_text;
  my $status = $diff_tree->{status};
  
  $diff_count_text = "$add_line_count additions";
  $diff_count_text .= " & $delete_line_count deletions" if $delete_line_count > 0;
  my $tag = $fragment ? 'a' : 'span';
  my $add_block_count = $diff_tree->{add_block_count} || 0;
  my $delete_block_count = $diff_tree->{delete_block_count} || 0;
  
  if ($diff_tree->{status} eq 'A') {
    $add_block_count = 5;
    $delete_block_count = 0;
  }
  elsif ($diff_tree->{status} eq 'R' && $add_line_count == 0 && $delete_line_count == 0) {
    $add_block_count = 5;
  }
  if ($diff_tree->{status} eq 'D') {
    $add_block_count = 0;
    $delete_block_count = 5;
  }
  
  if ($diff_line_count <= 5) {
    $add_block_count = $add_line_count;
    $delete_block_count = $delete_line_count;
  }
  if ($diff_tree->{binary}) {
    $add_block_count = 5;
  }
%>


<<%= $tag %> title="<%= $diff_count_text %>" style="text-decoration:none;color:#666" href="#<%= $fragment %>">
  % if ($diff_tree->{binary}) {
    BIN
  % } else {
    % if ($add_line_count) {
      <span style="color:green">+<%= $add_line_count %></span>
    % }
    % if ($delete_line_count) {
      <span style="color:red">-<%= $delete_line_count %></span>
    % }
  % }
</<%= $tag %>>

<<%= $tag %> title="<%= $diff_count_text %>" style="text-decoration:none;display:inline-block;overflow:none;" href="#<%= $fragment %>">
  % for (my $i = 0; $i < $add_block_count; $i++) {
    <div style="display:inline-block;background:#6cc644;width:8px;height:9px;float:left;margin:1px"></div>
  % }
  % for (my $i = 0; $i < $delete_block_count; $i++) {
    <div style="display:inline-block;background:#bd2c00;width:8px;height:9px;float:left;margin:1px"></div>
  % }
  % for (my $i = 0; $i < 5 - $add_block_count - $delete_block_count; $i++) {
    <div style="display:inline-block;background:#ddd;;width:8px;height:9px;float:left;margin:1px"></div>
  % }
</<%= $tag %>>