From: broquaint Date: Tue, 27 Oct 2009 22:08:21 +0000 (+0000) Subject: Added paging to the /shortlog action. X-Git-Tag: 0.000000_01~108^2~3 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=fde5091ff5070c6b7bceb1cb2ed551ddf792d119;p=catagits%2FGitalist.git Added paging to the /shortlog action. --- diff --git a/gitalist.conf b/gitalist.conf index 81b1fb4..60c71e4 100644 --- a/gitalist.conf +++ b/gitalist.conf @@ -41,3 +41,8 @@ favicon /git-favicon.png # fs traversing limit for getting project list # the number is relative to the projectroot project_maxdepth 2007 + + + log = 50 + summary = 16 + diff --git a/lib/Gitalist/Controller/Root.pm b/lib/Gitalist/Controller/Root.pm index 8f90b64..ef231b3 100644 --- a/lib/Gitalist/Controller/Root.pm +++ b/lib/Gitalist/Controller/Root.pm @@ -117,10 +117,11 @@ sub summary : Local { $c->stash( commit => $commit, info => $c->model('Git')->project_info($c->model('Git')->project), - log_lines => [$c->model('Git')->list_revs(sha1 => $commit->sha1, count => 16)], + log_lines => [$c->model('Git')->list_revs( + sha1 => $commit->sha1, count => Gitalist->config->{paging}{summary} + )], refs => $c->model('Git')->references, heads => [$c->model('Git')->heads], - HEAD => $c->model('Git')->head_hash, action => 'summary', ); } @@ -137,7 +138,6 @@ sub heads : Local { $c->stash( commit => $self->_get_commit($c), heads => [$c->model('Git')->heads], - HEAD => $c->model('Git')->head_hash, action => 'heads', ); } @@ -251,16 +251,22 @@ sub shortlog : Local { my ( $self, $c ) = @_; my $commit = $self->_get_commit($c); - my @logargs = ( - sha1 => $commit->sha1, + my %logargs = ( + sha1 => $commit->sha1, + count => Gitalist->config->{paging}{log}, ($c->req->param('f') ? (file => $c->req->param('f')) : ()) ); - # XXX Needs paging. + + my $page = $c->req->param('pg') || 0; + $logargs{skip} = $c->req->param('pg') * $logargs{count} + if $c->req->param('pg'); + $c->stash( commit => $commit, - log_lines => [$c->model('Git')->list_revs(@logargs)], + log_lines => [$c->model('Git')->list_revs(%logargs)], refs => $c->model('Git')->references, action => 'shortlog', + page => $page + 1, ); } @@ -321,10 +327,6 @@ Populate the header and footer. Perhaps not the best location. sub auto : Private { my($self, $c) = @_; - # XXX Temp hack until a decent solution is invented. - $c->model('Git')->project($c->req->param('p')) - if $c->req->param('p'); - # Yes, this is hideous. $self->header($c); $self->footer($c); @@ -512,7 +514,10 @@ Attempt to render a view, if needed. =cut -sub end : ActionClass('RenderView') {} +sub end : ActionClass('RenderView') { + # Give every view the current HEAD. + $_[1]->stash->{HEAD} = $_[1]->model('Git')->head_hash; +} =head1 AUTHOR diff --git a/templates/_shortlog.tt2 b/templates/_shortlog.tt2 index 7892534..26b6ad7 100644 --- a/templates/_shortlog.tt2 +++ b/templates/_shortlog.tt2 @@ -1,3 +1,15 @@ +[% BLOCK pager %] +
+ [% IF log_lines.size == 50 %] + next + [% END %] + [% IF log_lines.first.sha1 != HEAD %] + prev + [% END %] +
+[% END %] + +[% INCLUDE pager %] @@ -44,4 +56,4 @@
- +[% INCLUDE pager %]