Commit | Line | Data |
ecb0ebe7 |
1 | package Gitalist::URIStructure::Repository; |
2 | use MooseX::MethodAttributes::Role; |
3 | use Try::Tiny qw/try catch/; |
4 | use namespace::autoclean; |
5 | |
6 | requires 'base'; |
7 | |
b9423b8e |
8 | with qw/ |
9 | Gitalist::URIStructure::WithLog |
10 | /; |
11 | |
ecb0ebe7 |
12 | sub 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, |
5ed74c87 |
21 | data => $repos, |
12a0f9d3 |
22 | ); |
ecb0ebe7 |
23 | } |
24 | catch { |
25 | $c->detach('/error_404'); |
26 | }; |
27 | } |
28 | |
b9423b8e |
29 | before 'log' => sub { |
30 | my ($self, $c) = @_; |
31 | $c->stash->{Commit} = $c->stash->{Repository}->get_object($c->stash->{Repository}->head_hash); |
32 | }; |
33 | |
2d376b54 |
34 | sub object : Chained('find') PathPart('') Args(1) { |
35 | my ($self, $c, $sha1) = @_; |
36 | |
37 | my $repo = $c->stash->{Repository}; |
38 | my $obj = $c->stash->{Commit} = $repo->get_object($sha1); |
39 | my($act) = (ref($obj) || '') =~ /::(\w+)$/; |
40 | |
41 | $c->res->redirect($c->uri_for_action("/ref/\L$act", [$repo->name, $obj->sha1])); |
42 | $c->res->status(301); |
43 | |
44 | } |
45 | |
b31e8020 |
46 | sub summary : Chained('find') PathPart('') Args() {} |
ecb0ebe7 |
47 | |
535bc6e2 |
48 | sub heads : Chained('find') Args() {} |
ecb0ebe7 |
49 | |
535bc6e2 |
50 | sub tags : Chained('find') Args() {} |
5cb2f569 |
51 | |
ecb0ebe7 |
52 | 1; |