X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FGitalist%2FController%2FFragment.pm;h=3082b0c6d18309dbb125d05a1526d48c4a248be9;hb=b35a7123319dab548fd05ff0460b6bcc7318e70e;hp=869c5b72a35e33f80536bf7e638efaf279a3b8ca;hpb=ecb0ebe7c64899b8fd307ae2dcef609fb2811a7d;p=catagits%2FGitalist.git diff --git a/lib/Gitalist/Controller/Fragment.pm b/lib/Gitalist/Controller/Fragment.pm index 869c5b7..3082b0c 100644 --- a/lib/Gitalist/Controller/Fragment.pm +++ b/lib/Gitalist/Controller/Fragment.pm @@ -3,8 +3,30 @@ package Gitalist::Controller::Fragment; use Moose; use namespace::autoclean; -BEGIN { extends 'Catalyst::Controller' } +BEGIN { extends 'Gitalist::Controller' } -sub base : Chained('/root') PathPart('fragment') CaptureArgs(0) {} +sub base : Chained('/base') 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 '. ref($c->model) . ' ' . $c->model->debug_string + 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;