Respect paging.log config settings.
[catagits/Gitalist.git] / lib / Gitalist / URIStructure / Fragment / WithLog.pm
CommitLineData
b9423b8e 1package Gitalist::URIStructure::Fragment::WithLog;
2use MooseX::MethodAttributes::Role;
3use namespace::autoclean;
4
5requires 'log';
6
7after log => sub {
8 my ($self, $c) = @_;
9 my $repository = $c->stash->{Repository};
b9423b8e 10
11 my %logargs = (
12 sha1 => $c->stash->{Commit}->sha1, # $commit->sha1
2ee4b079 13 count => Gitalist->config->{paging}{log} || 25,
b9423b8e 14 );
15
16 my $page = $c->req->param('pg') || 0;
906a2dd2 17 $logargs{skip} = abs $page * $logargs{count}
18 if $page;
19
b9423b8e 20 $c->stash(
906a2dd2 21 page => $page,
b9423b8e 22 log_lines => [$repository->list_revs(%logargs)],
18fdf3d0 23 refs => $repository->references,
b9423b8e 24 );
25};
26
271;