Limit the number of branches/tags listed by default.
[catagits/Gitalist.git] / lib / Gitalist / URIStructure / Repository.pm
index 8673560..2e142bd 100644 (file)
@@ -5,31 +5,48 @@ use namespace::autoclean;
 
 requires 'base';
 
-after 'base' => sub {
-    my ($self, $c) = @_;
-    $c->stash(_do_not_mangle_uri_for => 1);
-};
+with qw/
+    Gitalist::URIStructure::WithLog
+/;
 
 sub find : Chained('base') PathPart('') CaptureArgs(1) {
-    my ($self, $c, $repository) = @_;
+    my ($self, $c, $repos_name) = @_;
     # XXX FIXME - This should be in the repository fragment controller, and the repository
     #             controller should just check has_repository
     try {
-        $c->stash(Repository => $c->model()->get_repository($repository));
+        my $repos = $c->model()->get_repository($repos_name);
+        $c->stash(
+            Repository => $repos,
+            HEAD => $repos->head_hash,
+            data => $repos,
+        );
     }
     catch {
         $c->detach('/error_404');
     };
 }
 
-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 object : Chained('find') PathPart('') Args(1) {
+    my ($self, $c, $sha1) = @_;
+
+    my $repo = $c->stash->{Repository};
+    my $obj  = $c->stash->{Commit} = $repo->get_object($sha1);
+    my($act) = (ref($obj) || '') =~ /::(\w+)$/;
 
-sub shortlog : Chained('find') Args(0) {}
+    $c->res->redirect($c->uri_for_action("/ref/\L$act", [$repo->name, $obj->sha1]));
+    $c->res->status(301);
+
+}
 
-sub heads : Chained('find') Args(0) {}
+sub summary : Chained('find') PathPart('') Args() {}
 
-sub log : Chained('find') Args(0) {}
+sub heads : Chained('find') Args() {}
 
-sub tags : Chained('find') Args(0) {}
+sub tags : Chained('find') Args() {}
 
 1;