Fix a warning
[catagits/Gitalist.git] / lib / Gitalist / Controller / Root.pm
CommitLineData
89de6a33 1package Gitalist::Controller::Root;
89de6a33 2
c113db92 3use Moose;
cce8c9b6 4use Moose::Autobox;
d17ce39c 5
c113db92 6use Gitalist::Utils qw/ age_string /;
89de6a33 7
c113db92 8use namespace::autoclean;
89de6a33 9
b6ec181b 10BEGIN { extends 'Gitalist::Controller' }
89de6a33 11
12a0f9d3 12__PACKAGE__->config(namespace => '');
89de6a33 13
c113db92 14sub root : Chained('/') PathPart('') CaptureArgs(0) {}
89de6a33 15
5bb401c6 16sub index : Chained('base') PathPart('') Args(0) {
12a0f9d3 17 my ( $self, $c ) = @_;
18 $c->stash( search_text => $c->req->param('s') || '' ) # FIXME - XSS?
286cea09 19}
20
5bb401c6 21sub base : Chained('/root') PathPart('') CaptureArgs(0) {
4621ecf0 22 my($self, $c) = @_;
04d1d917 23
066e9aa4 24 my $git_version = `git --version`;
25 chomp($git_version);
4621ecf0 26 $c->stash(
066e9aa4 27 git_version => $git_version,
da8f4f82 28 version => $Gitalist::VERSION,
29
4621ecf0 30 time_since => sub {
ef11b09e 31 return 'never' unless $_[0];
4621ecf0 32 return age_string(time - $_[0]->epoch);
33 },
34 short_cmt => sub {
35 my $cmt = shift;
36 my($line) = split /\n/, $cmt;
741e110e 37 $line =~ s/^(.{70,80}\b).*/$1 \x{2026}/;
4621ecf0 38 return $line;
39 },
5cd9b9f9 40 abridged_description => sub {
41 join(' ', grep { defined } (split / /, shift)[0..10]);
42 },
4621ecf0 43 );
04d1d917 44}
d9a9b56b 45
12a0f9d3 46=head2 search_help
47
48Provides some help for the search form.
49
50=cut
51
52sub search_help : Chained('base') Args(0) {}
53
54sub end : ActionClass('RenderView') {}
d9a9b56b 55
c113db92 56sub error_404 : Action {
4111e151 57 my ($self, $c) = @_;
58 $c->response->status(404);
5232dbdd 59 $c->response->body('Page not found');
4111e151 60}
61
775e96e0 62__PACKAGE__->meta->make_immutable;
63
64__END__
65
d137f7d5 66=head1 NAME
67
68Gitalist::Controller::Root - Root controller for the application
69
70=head1 DESCRIPTION
71
72This controller handles all of the root level paths for the application
73
74=head1 METHODS
75
5bb401c6 76=head2 root
77
78Root of chained actions
79
80=head2 base
81
82Populate the header and footer. Perhaps not the best location.
83
84=head2 index
85
82bc0f05 86Provides the repository listing.
5bb401c6 87
88=head2 end
89
90Attempt to render a view, if needed.
d137f7d5 91
d137f7d5 92=head2 error_404
93
775e96e0 94=head1 AUTHORS
89de6a33 95
775e96e0 96See L<Gitalist> for authors.
89de6a33 97
98=head1 LICENSE
99
775e96e0 100See L<Gitalist> for the license.
89de6a33 101
102=cut