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 $render_atom_feed = $rev_file =~ s/\.atom$// ? 1 : 0;
my ($rev, $file) = $git->parse_rev_path($user, $project, $rev_file);
my $page = param('page') || 0;
# Commit
my $commit = $git->get_commit($user, $project, $rev);
# Not found
unless ($commit) {
$self->render_not_found;
return;
}
# Commits
my $page_count = 30;
my $commits = $git->get_commits(
$user,
$project,
$commit->{id},
$page_count,
$page_count * $page,
$file
);
my $commits_count = @$commits;
my $commits_date = {};
for my $commit (@$commits) {
my $date = $commit->{age_string_date_local};
$commits_date->{$date} ||= [];
push @{$commits_date->{$date}}, $commit;
}
# Global variable
stash(user => $user, project => $project, rev => $rev);
# Render atom xml feed
if ($render_atom_feed) {
# Add updated date time
for my $commit (@$commits) {
my $committer_epoch = $commit->{committer_epoch};
my $committer_tz = $commit->{committer_tz};
my $time_zone_second;
my $time_zone;
if ($committer_tz =~ /^(\+|\-)([0-9]{2})([0-9]{2})$/) {
my $time_zone_sign = $1;
my $time_zone_hour = $2;
my $time_zone_min = $3;
$time_zone_second = $time_zone_sign . ($time_zone_hour * (60 * 60) + $time_zone_min * 60);
$time_zone = sprintf("$time_zone_sign%02d:%02d", $time_zone_hour, $time_zone_min);
}
# updated datetime
my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($committer_epoch + $time_zone_second);
my $updated = sprintf('%4d-%02d-%02dT%02d:%02d:%02d', 1900 + $year, $mon + 1, $mday, $hour, $min, $sec);
$updated .= $time_zone;
$commit->{updated} = $updated;
}
}
# Set stash
stash(
user => $user,
project => $project,
rev => $rev
);
#%>
% if ($render_atom_feed) {
<%
$self->res->headers->content_type('application/atom+xml;charset=UTF-8');
# Create atom feed
my $alternate_url = url_with;
my $alternate_url_path_parts = $alternate_url->path->parts;
$alternate_url_path_parts->[-1] =~ s/\.atom$//;
#%>
<?xml version="1.0" encoding="UTF-8" ?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" xml:lang="en-US">
<id>tag:gitprep,2008:/<%= $user %>/<%= $project %>/commits/<%= $rev_file %></id>
<link type="text/html" rel="alternate" href="<%= $alternate_url->to_abs %>"/>
<link type="application/atom+xml" rel="self" href="<%= url_with->to_abs %>"/>
<title>Recent Commits to <%= "$project:$rev" %></title>
<updated><%= $commits->[0]->{updated} %></updated>
% for my $commit (@$commits) {
<entry>
<id>tag:gitprep,2008:Grit::Commit/<%= $commit->{id} %></id>
<link type="text/html" rel="alternate" href="<%= url_for("/$user/$project/commit/$commit->{id}")->to_abs %>" />
<title>
<%= $commit->{title} %>
</title>
<updated><%= $commit->{updated} %></updated>
<author>
<name><%= $user %></name>
<uri><%= url_for("/$user")->to_abs %></uri>
</author>
<content type="html">
<%= "<pre style='white-space:pre-wrap;width:81ex'>$commit->{title}</pre>" %>
</content>
</entry>
% }
</feed>
% } else {
% layout 'common', title => "Commit History \x{30fb} $user/$project";
%= include '/include/header';
<div class="container">
%= include '/include/project_header';
%= include '/include/code_menu', display => 'commits';
<div style="margin-top:20px;margin-bottom:15px">
% if (defined $file && length $file) {
%= include '/include/page_path', type => 'blob', Path => $file, operation => 'commits', prefix => 'History for';
% } else {
<div style="font-size:18px">
<a class="ubar" href="<%= url_for("/$user/$project") %>">
<%= $project %>
</a>
/
<span class="muted">Commit History</span>
</div>
% }
</div>
% for my $date (reverse sort keys %$commits_date) {
<div style="margin-bottom:20px">
% my $commits = $commits_date->{$date};
<div class="bk-blue-light border-blue radius-top" style="padding:5px 8px;color:#3a505b">
<b><%= $date %></b>
</div>
% my $num = 0;
% for my $commit (sort {$b->{author_epoch} <=> $a->{author_epoch}} @$commits) {
<div class="border-gray" style="font-size:14px;padding-bottom:0;border-top:none;border-bottom:none;padding:5px 5px 1px 5px">
<div class="row">
<div class="span8">
<a class="font-black" href="<%= url_for("/$user/$project/commit/$commit->{id}") %>">
<b><%= $commit->{title_short} %></b>
</a>
% if (app->config->{basic}{show_ignore_space_change_link}) {
(<a class="font-black" style="font-size:90%;color:#9999FF" href="<%= url_for("/$user/$project/commit/$commit->{id}?w=") %>">
ignore space
</a>)
% }
</div>
<div class="text-right">
<a class="btn" style="width:90px;padding:0px 10px;color:#3a505b;font-size:12px" href="<%= url_for("/$user/$project/commit/$commit->{id}") %>">
<%= substr($commit->{id}, 0, 10) %>
<i class="icon-circle-arrow-right"></i>
</a>
</div>
</div>
</div>
<div class="border-blue <%= $num eq @$commits - 1 ? 'radius-bottom' : '' %>" style="font-size:12px;border-top:none; padding:1px 5px 5px 5px">
<div class="row">
<div class="span8">
<span title="<%= $commit->{author_email} %>"><%= $commit->{author_name} %></span> <span class="muted" title="<%= $commit->{age_string_datetime_local} %>"><%= $commit->{age_string} %></span>
</div>
<div class="text-right">
<a class="muted" style="padding-right:18px;font-weight:bold" href="<%= url_for("/$user/$project/commit/$commit->{id}") %>"> Browse code
</a>
</div>
</div>
</div>
% $num++;
% }
</div>
% }
<ul class="pager" style="text-align:left">
% if ($page == 0) {
<li class="disabled">« Newer</li>
% } else {
% my $newer_page = $page - 1;
<li class="disable">
<a href="<%= url_for("/$user/$project/commits/$rev?page=$newer_page") %>">« Newer</a>
</li>
% }
% if ($commits_count < $page_count) {
<li class="disabled">Older »</li>
% } else {
% my $older_page = $page + 1;
<li>
<a href="<%= url_for("/$user/$project/commits/$rev?page=$older_page") %>">Older »</a>
</li>
% }
</ul>
</div>
%= include '/include/footer';
% }