Get the index page working with the content in a fragment and all the URIs moved
[catagits/Gitalist.git] / lib / Gitalist / Controller / Fragment.pm
index 869c5b7..15c4511 100644 (file)
@@ -5,6 +5,28 @@ use namespace::autoclean;
 
 BEGIN { extends 'Catalyst::Controller' }
 
-sub base : Chained('/root') PathPart('fragment') CaptureArgs(0) {}
+sub base : Chained('/root') PathPart('fragment') CaptureArgs(0) {
+    my ($self, $c) = @_;
+    $c->stash(no_wrapper => 1);
+}
+
+sub collectionofrepositories : Chained('base') Args(0) {
+    my ($self, $c) = @_;
+    my @list = @{ $c->model()->repositories };
+    die 'No repositories found in '. $c->model->repo_dir
+      unless @list;
+
+    my $search = $c->req->param('s') || '';
+    if($search) {
+      @list = grep {
+           index($_->name, $search) > -1
+        or ( $_->description !~ /^Unnamed repository/ and index($_->description, $search) > -1 )
+      } @list
+    }
+
+    $c->stash(
+      repositories    => \@list,
+    );
+}
 
 __PACKAGE__->meta->make_immutable;