Correct example link and FCGI script.
[catagits/Gitalist.git] / lib / Gitalist / URIStructure / Repository.pm
CommitLineData
ecb0ebe7 1package Gitalist::URIStructure::Repository;
2use MooseX::MethodAttributes::Role;
3use Try::Tiny qw/try catch/;
4use namespace::autoclean;
5
6requires 'base';
7
b9423b8e 8with qw/
9 Gitalist::URIStructure::WithLog
10/;
11
ecb0ebe7 12sub find : Chained('base') PathPart('') CaptureArgs(1) {
12a0f9d3 13 my ($self, $c, $repos_name) = @_;
16dcb884 14 # XXX FIXME - This should be in the repository fragment controller, and the repository
15 # controller should just check has_repository
ecb0ebe7 16 try {
12a0f9d3 17 my $repos = $c->model()->get_repository($repos_name);
18 $c->stash(
19 Repository => $repos,
20 HEAD => $repos->head_hash,
21 );
ecb0ebe7 22 }
23 catch {
24 $c->detach('/error_404');
25 };
26}
27
b9423b8e 28before 'log' => sub {
29 my ($self, $c) = @_;
30 $c->stash->{Commit} = $c->stash->{Repository}->get_object($c->stash->{Repository}->head_hash);
31};
32
2d376b54 33sub object : Chained('find') PathPart('') Args(1) {
34 my ($self, $c, $sha1) = @_;
35
36 my $repo = $c->stash->{Repository};
37 my $obj = $c->stash->{Commit} = $repo->get_object($sha1);
38 my($act) = (ref($obj) || '') =~ /::(\w+)$/;
39
40 $c->res->redirect($c->uri_for_action("/ref/\L$act", [$repo->name, $obj->sha1]));
41 $c->res->status(301);
42
43}
44
ecb0ebe7 45sub summary : Chained('find') PathPart('') Args(0) {}
46
ecb0ebe7 47sub heads : Chained('find') Args(0) {}
48
5cb2f569 49sub tags : Chained('find') Args(0) {}
50
ecb0ebe7 511;