| 1 | package Gitalist::Controller::Fragment; | ||
| 2 | |||
| 3 | use Moose; | ||
| 4 | use namespace::autoclean; | ||
| 5 | |||
| 6 | BEGIN { extends 'Gitalist::Controller' } | ||
| 7 | |||
| 8 | sub base : Chained('/base') PathPart('fragment') CaptureArgs(0) { | ||
| 9 | my ($self, $c) = @_; | ||
| 10 | $c->stash(no_wrapper => 1); | ||
| 11 | } | ||
| 12 | |||
| 13 | sub collectionofrepositories : Chained('base') Args(0) { | ||
| 14 | my ($self, $c) = @_; | ||
| 15 | my @list = @{ $c->model()->repositories }; | ||
| 16 | die 'No repositories found in '. ref($c->model) . ' ' . $c->model->debug_string | ||
| 17 | unless @list; | ||
| 18 | |||
| 19 | my $search = $c->req->param('s') || ''; | ||
| 20 | if($search) { | ||
| 21 | @list = grep { | ||
| 22 | index($_->name, $search) > -1 | ||
| 23 | or ( $_->description !~ /^Unnamed repository/ and index($_->description, $search) > -1 ) | ||
| 24 | } @list | ||
| 25 | } | ||
| 26 | |||
| 27 | $c->stash( | ||
| 28 | repositories => \@list, | ||
| 29 | ); | ||
| 30 | } | ||
| 31 | |||
| 32 | __PACKAGE__->meta->make_immutable; |