use Moose;
use namespace::autoclean;
-BEGIN { extends 'Catalyst::Controller' }
+BEGIN { extends 'Gitalist::Controller' }
with 'Gitalist::URIStructure::Commit';
sub base : Chained('/fragment/repository/find') PathPart('') CaptureArgs(0) {}
};
after tree => sub {
- my ( $self, $c, @fn ) = @_;
+ my ( $self, $c ) = @_;
my $repository = $c->stash->{Repository};
my $commit = $c->stash->{Commit};
- my $filename = join('/', @fn);
- my $tree = $filename
- ? $repository->get_object($repository->hash_by_path($commit->sha1, $filename))
+ my $tree = $c->stash->{filename}
+ ? $repository->get_object($repository->hash_by_path($commit->sha1, $c->stash->{filename}))
: $repository->get_object($commit->tree_sha1)
;
$c->stash(
tree => $tree,
tree_list => [$repository->list_tree($tree->sha1)],
- path => $filename,
+ path => $c->stash->{filename}, # FIXME?
);
};
after blame => sub {
- my($self, $c, @fn) = @_;
+ my($self, $c) = @_;
my $repository = $c->stash->{Repository};
- my $filename = join('/', @fn);
# WTF?
- my $blame = $c->stash->{Commit}->blame($filename, $c->stash->{Commit}->sha1);
+ my $blame = $c->stash->{Commit}->blame($c->stash->{filename}, $c->stash->{Commit}->sha1);
$c->stash(
blame => $blame,
- filename => $filename,
-
# XXX Hack hack hack, see View::SyntaxHighlight
- language => ($filename =~ /\.p[lm]$/i ? 'Perl' : ''),
+ language => ($c->stash->{filename} =~ /\.p[lm]$/i ? 'Perl' : ''),
blob => join("\n", map $_->{line}, @$blame),
);
=cut
after blob => sub {
- my ( $self, $c, @fn ) = @_;
+ my ( $self, $c ) = @_;
- my $filename = join('/', @fn);
my $repository = $c->stash->{Repository};
my $h =
- $repository->hash_by_path($c->stash->{Commit}->sha1, $filename)
+ $repository->hash_by_path($c->stash->{Commit}->sha1, $c->stash->{filename})
|| die "No file or sha1 provided.";
my $blob = $repository->get_object($h);
$c->stash(
blob => $blob->content,
- filename => $filename,
# XXX Hack hack hack, see View::SyntaxHighlight
- language => ($filename =~ /\.p[lm]$/i ? 'Perl' : ''),
+ language => ($c->stash->{filename} =~ /\.p[lm]$/i ? 'Perl' : ''),
);
$c->forward('View::SyntaxHighlight')