<% # 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(app->rep_info($user, $project), $rev_file); my $page = param('page') || 0; # Latest commit my $latest_commit = $git->get_commit(app->rep_info($user, $project), $rev); # Authors my %author_id_of = map { $_->{email} => $_->{id} } @{ app->dbi->model('user')->select( [ 'id', 'email' ] )->all }; # Commits my $page_count = 30; my $commits = $git->get_commits( app->rep_info($user, $project), $latest_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$//; #%> tag:gitprep,2008:/<%= $user %>/<%= $project %>/commits/<%= $rev_file %> Recent Commits to <%= "$project:$rev" %> <%= $commits->[0]->{updated} %> % for my $commit (@$commits) { tag:gitprep,2008:Grit::Commit/<%= $commit->{id} %> {id}")->to_abs %>" /> <%= $commit->{title} %> <%= $commit->{updated} %> <%= $user %> <%= url_for("/$user")->to_abs %> <%= "
$commit->{title}
" %>
% }
% } else { % layout 'common', title => "Commit History \x{30fb} $user/$project"; %= include '/include/header';
%= include '/include/branch_select', display => 'commits';
% for my $date (reverse sort keys %$commits_date) { % my $commits = $commits_date->{$date};
Commits on <%= $date %>
% }
%= include '/include/footer'; % }