1 contributor
<%
# API
my $api = gitprep_api;
# Git
my $git = $self->app->git;
# Parameters
my $user = param('user');
my $project = param('project');
my $rev_file = param('rev_file');
my ($rev, $file) = $git->parse_rev_path($user, $project, $rev_file);
# Commit
my $commit = $git->last_change_commit($user, $project, $rev, $file);
# Authors
my $authors = $git->authors($user, $project, $rev, $file);
# File size
my $file_size = $git->blob_size($user, $project, $rev, $file);
# File mode
my $mode = $git->blob_mode($user, $project, $rev, $file);
my $file_type = $git->file_type_long($mode);
# MIME type
my $mime_type = $git->blob_mime_type($user, $project, $rev, $file);
# Blame
my $blame = $git->blame($user, $project, $rev, $file);
my $blame_lines = $blame->{lines};
my $blame_min_author_time = $blame->{min_author_time};
my $blame_max_author_time = $blame->{max_author_time};
# Color
my $colors = [
'#ffeca7',
'#ffdd8c',
'#ffdd7c',
'#fba447',
'#f68736',
'#f37636',
'#ca6632',
'#c0513f',
'#a2503a',
'#793738'
];
# Variables for included template
stash(id => $rev, project => $project, rev => $rev);
%>
% layout 'common' , title => "$user/$project at $rev";
%= include '/include/header';
<!-- Blame page -->
<div class="container">
%= include '/include/project_header';
%= include '/include/code_menu', display => 'files';
%= include '/include/page_path', type => 'blob', Path => $file;
<div class="text-right" style="margin-bottom:10px">
Newer
% for my $color (@$colors) {
<span style="font-size:20px;color:<%= $color %>">■</span>
% }
Older
</div>
<div class="border-gray bk-gray-light" style="padding:5px; border-bottom:none">
<div class="row">
<div class="span7" style="padding-top:5px">
<i class="icon-file icon-white"></i>
<%= $file_type %>
<span class="muted">|</span>
<%= @$blame_lines %> lines
<span class="muted">|</span>
<%= $file_size %>kb
</div>
<div class="text-right">
<a class="btn" href="<%= url_for("/$user/$project/raw/$rev/$file") %>">Raw</a><a class="btn" href="<%= url_for("/$user/$project/blob/$rev/$file") %>">Normal View</a><a class="btn" href="<%= url_for("/$user/$project/commits/$rev/$file") %>">History</a>
</div>
</div>
</div>
<div class="border-gray" style="width:938px;overflow-x:scroll;border-top:none">
<table style="min-width:938px">
% for my $line (@$blame_lines) {
% my $blame_commit = $line->{commit};
% my $summary = $line->{summary};
% my $summary_short= length $summary > 28 ? substr($summary, 0, 28) . '...' : $summary;
% my $time_rate = $blame_max_author_time == $blame_min_author_time
% ? 1
% : ($blame_max_author_time - $line->{author_time}) / ($blame_max_author_time - $blame_min_author_time);
% my $color_number = int($time_rate * 10);
% $color_number = 9 if $color_number == 10;
% my $hot_color = $colors->[$color_number];
<tr id="L<%= $line->{number} %>">
% if ($line->{before_same_commit}) {
<td nowrap class="border-gray" style="padding:5px 10px; background:#f7f7f7;vertical-align:middle;border-left:none;border-top:none;border-bottom:none;border-right:2px solid <%= $hot_color %>" >
</td>
% } else {
<td nowrap class="border-gray" style="padding:5px 10px; background:#f7f7f7;vertical-align:middle;border-left:none;border-bottom:none;border-right:2px solid <%= $hot_color %>" >
<div style="margin-bottom:0;padding-botttom:0">
<a href="<%= url_for("/$user/$project/commit/$blame_commit") %>" ><%= substr($blame_commit, 0, 8) %></a>
<a href="<%= url_for("/$user/$project/blame/$blame_commit/$file") %>" >»</a>
<span title="<%= $line->{author_mail} %>"><%= $line->{author} %></span>
</div>
<div style="margin-top:0;padding-top:0">
<%= $line->{author_age_string_date_local} %>
<%= $summary_short %>
</div>
</td>
% }
<td nowrap class="border-gray" style="padding:5px 10px;color:gray;font-size:12px;vertical-align:middle;">
<%= $line->{number} %>
</td>
<td nowrap class="border-gray" style="padding:5px 10px;vertical-align:middle;white-space: nowrap;border-right:none">
<pre style="border:none;background:white;margin:0;padding:0;white-space: nowrap;"><%= $line->{content} %></pre>
</td>
</tr>
% }
</table>
</div>
</div>
%= include '/include/footer';