Commit | Line | Data |
ecb0ebe7 |
1 | package Gitalist::Controller::Fragment; |
2 | |
3 | use Moose; |
4 | use namespace::autoclean; |
5 | |
b6ec181b |
6 | BEGIN { extends 'Gitalist::Controller' } |
ecb0ebe7 |
7 | |
493327c8 |
8 | sub base : Chained('/base') PathPart('fragment') CaptureArgs(0) { |
066e9aa4 |
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 }; |
b35a7123 |
16 | die 'No repositories found in '. ref($c->model) . ' ' . $c->model->debug_string |
066e9aa4 |
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; |