Fixed summary and changed a few links.
[catagits/Gitalist.git] / lib / Gitalist / URIStructure / Repository.pm
index df26f4f..13c6ed8 100644 (file)
@@ -5,6 +5,10 @@ use namespace::autoclean;
 
 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
@@ -14,6 +18,7 @@ sub find : Chained('base') PathPart('') CaptureArgs(1) {
         $c->stash(
             Repository => $repos,
             HEAD => $repos->head_hash,
+            data => $repos,
         );
     }
     catch {
@@ -21,16 +26,27 @@ sub find : Chained('base') PathPart('') CaptureArgs(1) {
     };
 }
 
-sub summary : Chained('find') PathPart('') Args(0) {}
+before 'log' => sub {
+    my ($self, $c) = @_;
+    $c->stash->{Commit} = $c->stash->{Repository}->get_object($c->stash->{Repository}->head_hash);
+};
 
-sub heads : Chained('find') Args(0) {}
+sub object : Chained('find') PathPart('') Args(1) {
+    my ($self, $c, $sha1) = @_;
 
-sub tags : Chained('find') Args(0) {}
+    my $repo = $c->stash->{Repository};
+    my $obj  = $c->stash->{Commit} = $repo->get_object($sha1);
+    my($act) = (ref($obj) || '') =~ /::(\w+)$/;
+
+    $c->res->redirect($c->uri_for_action("/ref/\L$act", [$repo->name, $obj->sha1]));
+    $c->res->status(301);
 
-sub log : Chained('find') PathPart('') CaptureArgs(0) {}
+}
+
+sub summary : Chained('find') Args() {}
 
-sub shortlog : Chained('log') Args(0) {}
+sub heads : Chained('find') Args(0) {}
 
-sub longlog : Chained('log') PathPart('log') Args(0) {}
+sub tags : Chained('find') Args(0) {}
 
 1;