Move search and reflog and patch actions to the right places
Tomas Doran [Mon, 18 Jan 2010 20:00:04 +0000 (20:00 +0000)]
lib/Gitalist/Controller/Commit.pm
lib/Gitalist/Controller/Repository.pm
lib/Gitalist/Controller/Root.pm
root/repository/reflog.tt2 [moved from root/reflog.tt2 with 100% similarity]
root/repository/search.tt2 [moved from root/search.tt2 with 100% similarity]

index 2d3151c..a2a3b49 100644 (file)
@@ -34,4 +34,32 @@ sub snapshot : Chained('base') Args() {
     $c->response->body($snap[1]);
 }
 
+=head2 patch
+
+A raw patch for a given commit.
+
+=cut
+
+sub patch : Chained('find') Args(0) {
+    my ($self, $c) = @_;
+    $c->detach('patches', [1]);
+}
+
+=head2 patches
+
+The patcheset for a given commit ???
+
+=cut
+
+sub patches : Chained('find') Args(1) {
+    my ($self, $c, $count) = @_;
+    $count ||= Gitalist->config->{patches}{max};
+    my $commit = $c->stash->{Commit};
+    my $parent = $c->req->param('hp') || undef; # FIXME
+    my $patch = $commit->get_patch( $parent, $count );
+    $c->response->body($patch);
+    $c->response->content_type('text/plain');
+    $c->response->status(200);
+}
+
 __PACKAGE__->meta->make_immutable;
index c890d95..33e6f53 100644 (file)
@@ -11,6 +11,51 @@ with 'Gitalist::URIStructure::Repository';
 
 sub base : Chained('/base') PathPart('') CaptureArgs(0) {}
 
+=head2 search
+
+The action for the search form.
+
+=cut
+
+sub search : Chained('base') Args(0) {
+  my($self, $c) = @_;
+  my $repository = $c->stash->{Repository};
+  # Lifted from /shortlog.
+  my %logargs = (
+#    sha1   => $commit->sha1,
+#    count  => Gitalist->config->{paging}{log},
+#    ($c->req->param('f') ? (file => $c->req->param('f')) : ()),
+    search => {
+      type   => $c->req->param('type'),
+      text   => $c->req->param('text'),
+      regexp => $c->req->param('regexp') || 0,
+    },
+  );
+
+  $c->stash(
+#      commit  => $commit,
+      results => [$repository->list_revs(%logargs)],
+         # This could be added - page      => $page,
+  );
+}
+
+=head2 reflog
+
+Expose the local reflog. This may go away.
+
+=cut
+
+sub reflog : Chained('base') Args(0) {
+  my ( $self, $c ) = @_;
+  my @log = $c->stash->{Repository}->reflog(
+      '--since=yesterday'
+  );
+
+  $c->stash(
+      log    => \@log,
+  );
+}
+
 =head2 atom
 
 Provides an atom feed for a given repository.
index b713839..d39c867 100644 (file)
@@ -131,52 +131,6 @@ sub history : Chained('base') Args(0) {
            );
 }
 
-=head2 reflog
-
-Expose the local reflog. This may go away.
-
-=cut
-
-sub reflog : Chained('base') Args(0) {
-  my ( $self, $c ) = @_;
-  my @log = $c->stash->{Repository}->reflog(
-      '--since=yesterday'
-  );
-
-  $c->stash(
-      log    => \@log,
-  );
-}
-
-=head2 search
-
-The action for the search form.
-
-=cut
-
-sub search : Chained('base') Args(0) {
-  my($self, $c) = @_;
-  my $repository = $c->stash->{Repository};
-  my $commit  = $self->_get_object($c);
-  # Lifted from /shortlog.
-  my %logargs = (
-    sha1   => $commit->sha1,
-    count  => Gitalist->config->{paging}{log},
-    ($c->req->param('f') ? (file => $c->req->param('f')) : ()),
-    search => {
-      type   => $c->req->param('type'),
-      text   => $c->req->param('text'),
-      regexp => $c->req->param('regexp') || 0,
-    },
-  );
-
-  $c->stash(
-      commit  => $commit,
-      results => [$repository->list_revs(%logargs)],
-         # This could be added - page      => $page,
-  );
-}
-
 =head2 search_help
 
 Provides some help for the search form.
@@ -208,34 +162,6 @@ sub opml : Chained('base') Args(0) {
   $c->response->status(200);
 }
 
-=head2 patch
-
-A raw patch for a given commit.
-
-=cut
-
-sub patch : Chained('base') Args(0) {
-    my ($self, $c) = @_;
-    $c->detach('patches', [1]);
-}
-
-=head2 patches
-
-The patcheset for a given commit ???
-
-=cut
-
-sub patches : Chained('base') Args(0) {
-    my ($self, $c, $count) = @_;
-    $count ||= Gitalist->config->{patches}{max};
-    my $commit = $self->_get_object($c);
-    my $parent = $c->req->param('hp') || undef;
-    my $patch = $commit->get_patch( $parent, $count );
-    $c->response->body($patch);
-    $c->response->content_type('text/plain');
-    $c->response->status(200);
-}
-
 sub base : Chained('/root') PathPart('') CaptureArgs(0) {
   my($self, $c) = @_;
 
similarity index 100%
rename from root/reflog.tt2
rename to root/repository/reflog.tt2
similarity index 100%
rename from root/search.tt2
rename to root/repository/search.tt2