URIStructure is now a really bad name properly, and the templates need sorting out to have default templates for log bits so that the templates consisting
of just [% PROCESS other/log.tt2 %] can die
use namespace::autoclean;
BEGIN { extends 'Gitalist::Controller' }
-with 'Gitalist::URIStructure::Ref';
+with qw/
+ Gitalist::URIStructure::Ref
+ Gitalist::URIStructure::Fragment::WithLog
+/;
sub base : Chained('/fragment/repository/find') PathPart('') CaptureArgs(0) {}
use namespace::autoclean;
BEGIN { extends 'Gitalist::Controller' }
-with 'Gitalist::URIStructure::Repository';
+with qw/
+ Gitalist::URIStructure::Repository
+ Gitalist::URIStructure::Fragment::WithLog
+/;
sub base : Chained('/fragment/base') PathPart('') CaptureArgs(0) {}
-after log => sub {
- my ($self, $c) = @_;
- my $repository = $c->stash->{Repository};
-# my $commit = $self->_get_object($c, $c->req->param('hb'));
-# my $filename = $c->req->param('f') || '';
-
- my %logargs = (
- sha1 => $repository->head_hash, # $commit->sha1
- count => 25, #Gitalist->config->{paging}{log} || 25,
-# ($filename ? (file => $filename) : ())
- );
-
- 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 => [$repository->list_revs(%logargs)],
-# refs => $repository->references,
-# page => $page,
-# filename => $filename,
- );
-};
-
after heads => sub {
my ($self, $c) = @_;
$c->stash(
--- /dev/null
+package Gitalist::URIStructure::Fragment::WithLog;
+use MooseX::MethodAttributes::Role;
+use namespace::autoclean;
+
+requires 'log';
+
+after log => sub {
+ my ($self, $c) = @_;
+ my $repository = $c->stash->{Repository};
+# my $commit = $self->_get_object($c, $c->req->param('hb'));
+# my $filename = $c->req->param('f') || '';
+
+ my %logargs = (
+ sha1 => $c->stash->{Commit}->sha1, # $commit->sha1
+ count => 25, #Gitalist->config->{paging}{log} || 25,
+# ($filename ? (file => $filename) : ())
+ );
+
+ 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 => [$repository->list_revs(%logargs)],
+# refs => $repository->references,
+# page => $page,
+# filename => $filename,
+ );
+};
+
+1;
requires 'base';
+with qw/
+ Gitalist::URIStructure::WithLog
+/;
+
after 'base' => sub {
my ($self, $c) = @_;
confess("No repository in the stash")
sub history : Chained('find') Does('FilenameArgs') Args() {}
-sub shortlog : Chained('find') Does('FilenameArgs') Args() {}
-
-sub longlog : Chained('find') Does('FilenameArgs') PathPart('log') Args() {}
-
1;
requires 'base';
+with qw/
+ Gitalist::URIStructure::WithLog
+/;
+
sub find : Chained('base') PathPart('') CaptureArgs(1) {
my ($self, $c, $repos_name) = @_;
# XXX FIXME - This should be in the repository fragment controller, and the repository
};
}
+before 'log' => sub {
+ my ($self, $c) = @_;
+ $c->stash->{Commit} = $c->stash->{Repository}->get_object($c->stash->{Repository}->head_hash);
+};
+
sub summary : Chained('find') PathPart('') Args(0) {}
sub heads : Chained('find') Args(0) {}
sub tags : Chained('find') Args(0) {}
-sub log : Chained('find') PathPart('') CaptureArgs(0) {}
-
-sub shortlog : Chained('log') Args(0) {}
-
-sub longlog : Chained('log') PathPart('log') Args(0) {}
-
1;
--- /dev/null
+package Gitalist::URIStructure::WithLog;
+use MooseX::MethodAttributes::Role;
+use namespace::autoclean;
+
+sub log : Chained('find') PathPart('') CaptureArgs(0) {}
+
+sub shortlog : Chained('log') Args(0) {}
+
+sub longlog : Chained('log') PathPart('log') Args(0) {}
+
+1;
\ No newline at end of file
--- /dev/null
+[% PROCESS 'fragment/repository/longlog.tt2' %]
--- /dev/null
+[% PROCESS 'fragment/repository/shortlog.tt2' %]
<div class='actions'>
<!-- This should probably be a real LIst -->
<a href="[% c.uri_for_action('/repository/summary', [c.req.captures.0]) %]">summary</a> •
- <a href="[% c.uri_for_action('/repository/shortlog', [c.req.captures.0]) %]">shortlog</a> •
- <a href="[% c.uri_for_action('/repository/log', [c.req.captures.0]) %]">log</a>
+ [% IF c.req.captures.size == 1; SET path = 'repository'; ELSE; SET path = 'ref'; END %]
+ <a href="[% c.uri_for_action('/' _ path _ '/shortlog', [c.req.captures]) %]">shortlog</a> •
+ <a href="[% c.uri_for_action('/' _ path _ '/longlog', [c.req.captures]) %]">log</a>
[% IF Commit %]
§
<a href="[% c.uri_for_action('/ref/commit', [c.req.captures.0, Commit.sha1]) %]">commit</a> •
--- /dev/null
+[% PROCESS 'repository/longlog.tt2' %]
-FIXME
+[% PROCESS 'repository/shortlog.tt2' %]
[% INCLUDE 'nav/actions.tt2' object = commit %]
-[% subinclude('/fragment/repository/shortlog', c.req.captures) %]
+[% subinclude('/fragment/' _ c.action, c.req.captures) %]