Make filename handling a generic actionrole. Fix more nav uris
[catagits/Gitalist.git] / lib / Gitalist / Controller / Fragment.pm
CommitLineData
ecb0ebe7 1package Gitalist::Controller::Fragment;
2
3use Moose;
4use namespace::autoclean;
5
b6ec181b 6BEGIN { extends 'Gitalist::Controller' }
ecb0ebe7 7
493327c8 8sub base : Chained('/base') PathPart('fragment') CaptureArgs(0) {
066e9aa4 9 my ($self, $c) = @_;
10 $c->stash(no_wrapper => 1);
11}
12
13sub collectionofrepositories : Chained('base') Args(0) {
14 my ($self, $c) = @_;
15 my @list = @{ $c->model()->repositories };
16 die 'No repositories found in '. $c->model->repo_dir
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}
ecb0ebe7 31
32__PACKAGE__->meta->make_immutable;