1 contributor
<%
# API
my $api = Gitprep::API->new($self);
# Parameters
my $user = param('user');
my $project = param('project');
my $object = param('object');
# Git
my $git = $self->app->git;
# Revision and blob
my ($rev, $blob) = @{$git->parse_object($user, $project, $object)};
# Commit log
my $commit_log = $git->latest_commit_log($user, $project, $rev, $blob);
# Commit
my $commit = $git->parse_commit($user, $project, $rev);
# Authors
my $authors = $git->authors($user, $project, $rev, $blob);
# Blob content
my $bid = $git->id_by_path($user, $project, $rev, $blob, 'blob')
or $api->croak('Cannot find file');
my @cmd = $git->cmd(
$user,
$project,
'cat-file',
'blob',
$bid
);
open my $fh, '-|', @cmd
or $api->croak(qq/Couldn't cat "$blob", "$bid"/);
# Blob info
my $blob_size = $git->blob_size_kb($user, $project, $rev, $blob);
my $mimetype = $git->blob_mimetype($fh, $blob);
# Parse line
my $lines =[];
while (my $line = $git->dec(scalar <$fh>)) {
chomp $line;
$line = $git->_tab_to_space($line);
push @$lines, $line;
}
# Variables for included template
stash(id => $rev, project => $project);
%>
% layout 'common';
%= include '/include/header';
<div class="container">
%= include '/include/project_header';
%= include '/include/code_menu', display => 'files';
%= include '/include/page_path', type => 'blob', Path => $blob;
<div class="border-gray" style="margin-bottom:20px">
<div class="bk-blue-light padding5">
<%= $commit_log->{author} %>
<span class="muted"><%= $commit_log->{author_date} %></span>
<a href="<%= url_for("/$user/$project/commit/$rev") %>">
<%= $commit->{title} %>
</a>
</div>
<div class="padding5">
<%= @$authors %> contributor
</div>
</div>
<div class="border-gray bk-gray-light padding5">
<div class="row">
<div class="span7" style="padding-top:5px">
<i class="icon-file icon-white"></i>
<span style="color:gray">|</span>
<%= @$lines %> lines
<span style="color:gray">|</span>
<%= $blob_size %>kb
</div>
<div class="span4 offset1-mini text-right">
<a class="btn" href="<%= url_for("/$user/$project/raw/$rev/$blob") %>">Raw</a><a class="btn" href="<%= url_for("/$user/$project/commits/$rev/$blob") %>">History</a>
</div>
</div>
</div>
% if ($mimetype =~ m#^image/#) {
<div>
<img type="<%= $mimetype %>
% if (defined $blob) {
alt="<%= $blob %>" title="<%= $blob %>"
% }
src="<%= url_for("/$user/$project/raw/$rev/$blob") %>"
/>
</div>
% } else {
<pre class="prettyprint linenums">
% for my $line (@$lines) {
%= $line;
% }
</pre>
% }
</div>
%= javascript '/js/google-code-prettify/prettify.js';
%= javascript begin
// Google prety print
prettyPrint();
% end
%= include '/include/footer';