1 contributor
<%
my $rev = stash('rev');
my $from_rev = stash('from_rev');
my $git = app->git;
my $diff_tree = stash('diff_tree');
my $blob_diff = stash('blob_diff');
my $from_mode_str = $diff_tree->{from_mode_str};
my $to_mode_str = $diff_tree->{to_mode_str};
my $lines = $blob_diff->{lines} || [];
my $file = $blob_diff->{file};
$file = '' unless defined $file;
my $from_file = $blob_diff->{from_file};
$from_file = $file unless defined $from_file;
my $status = $diff_tree->{status} || '';
my $binary_rev_shown;
my $binary_from_rev_shown;
my $binary_not_shown;
if ($blob_diff->{binary}) {
if ($status eq 'A') {
if ($git->blob_is_image($user, $project, $rev, $file)) {
$binary_rev_shown = 1;
}
else {
$binary_not_shown = 1;
}
} elsif ($status eq 'D') {
if ($git->blob_is_image($user, $project, $from_rev, $file)) {
$binary_from_rev_shown = 1;
}
else {
$binary_not_shown = 1;
}
} else {
if ($git->blob_is_image($user, $project, $from_rev, $file) && $git->blob_is_image($user, $project, $from_rev, $file)) {
$binary_from_rev_shown = 1;
$binary_rev_shown = 1;
}
else {
$binary_not_shown = 1;
}
}
}
%>
<div style="margin-bottom:20px;">
<div class="border-gray bk-gray-light" style="padding:5px">
<div class="row">
<div class="span8" style="padding-top:3px">
<div class="radius-top radius-bottom" style="padding:1px 3px;margin-right:5px;border:1px solid #ccc;display:inline-block;background:#f7f7f7">
%= include '/include/diff_status_bar', diff_tree => $diff_tree;
</div>
% if ($status eq 'R' || $status eq 'C') {
<%= $from_file %> → <%= $file %>
% } else {
<%= $file %>
% }
% if ($status ne 'A' && $status ne 'D' && $from_mode_str ne $to_mode_str) {
<%= "100$from_mode_str → 100$to_mode_str" %>
% }
</div>
<div class="text-right">
% if ($status eq 'D') {
<a class="btn" href="<%= url_for("/$user/$project/blob/$from_rev/$file") %>">
View file @ <%= substr($from_rev, 0, 7) %>
</a>
% } else {
<a class="btn" href="<%= url_for("/$user/$project/blob/$rev/$file") %>">
View file @ <%= substr($rev, 0, 7) %>
</a>
% }
</div>
</div>
</div>
<table class="border-gray" style="border-top:none">
% my $not_shown;
% my $from_rev_shown;
% my $rev_shown;
% if ($blob_diff->{binary}) {
% if ($binary_not_shown) {
<div class="border-gray" style="padding:10px;margin-bottom:30px;border-top:none">
Binary file not shown.
</div>
% } else {
<div class="border-gray" style="border-top:none;background:#ddd;text-align:center;padding-top:30px;padding-bottom:30px">
% if ($binary_from_rev_shown) {
<a href="<%= url_for("/$user/$project/blob/$from_rev/$file") %>">
<img src="<%= url_for("/$user/$project/raw/$from_rev/$file") %>" style="border:1px solid red;padding:1px;margin-right:20px">
</a>
% }
% if ($binary_rev_shown) {
<a href="<%= url_for("/$user/$project/blob/$rev/$file") %>">
<img src="<%= url_for("/$user/$project/raw/$rev/$file") %>" style="border:1px solid green;padding:1px;margin-left:20px">
</a>
% }
</div>
% }
% } elsif (@$lines) {
% for my $line (@$lines) {
% my $class = $line->{class};
% my $value = $line->{value};
<%
my $bk_color_line = '';
my $bk_color = '';
my $border_color;
if ($value =~ /^@/) {
$bk_color_line = '#f3f3ff';
$border_color = '#e4e4ff';
$bk_color = '#f8f8ff';
} elsif ($value =~ /^\+/) {
$bk_color_line = '#ceffce';
$border_color = '#b4e2b4';
$bk_color = '#dfd';
} elsif ($value =~ /^-/) {
$bk_color_line = '#f7c8c8';
$border_color = '#e9aeae';
$bk_color = '#fdd';
} else {
$border_color = '#e5e5e5';
}
%>
<tr >
<td style="font-size:12px;color:#aaa;padding:0 7px;border-right:1px <%= $border_color %> solid;background:<%= $bk_color_line %>;">
<%= $line->{before_line_num} %>
</td>
<td style="font-size:12px;color:#aaa;padding:0 7px;border-right:1px <%= $border_color %> solid;background:<%= $bk_color_line %>;">
<%= $line->{after_line_num} %>
</td>
<td style="width:100%;padding-left:7px;background:<%= $bk_color %>;">
<pre style="border:none;background:none;padding:0;margin:0"><%= $value %></pre>
</td>
</tr>
% }
% } else {
<div class="border-gray" style="padding:10px;margin-bottom:30px;border-top:none">
% if ($status eq 'R') {
File renamed without changes.
% } elsif ($status eq 'A' || $status eq 'D') {
No changes.
% } elsif ($from_mode_str ne $to_mode_str) {
File mode changed.
% }
</div>
% }
</table>
</div>