Add CONFIGURATION section to Gitalist POD.
[catagits/Gitalist.git] / lib / Gitalist / Controller / Root.pm
CommitLineData
89de6a33 1package Gitalist::Controller::Root;
89de6a33 2
c113db92 3use Moose;
cce8c9b6 4use Moose::Autobox;
b0265bca 5use Digest::MD5 qw(md5_hex);
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
2b686219 21# XXX Fragile much?
22sub css : Chained('/root') PathPart('core.css') Args(0) {
23 my ( $self, $c ) = @_;
24
25 $c->response->content_type('text/css');
26 $c->stash(template => 'static/css/core.css');
27}
28
5bb401c6 29sub base : Chained('/root') PathPart('') CaptureArgs(0) {
4621ecf0 30 my($self, $c) = @_;
04d1d917 31
066e9aa4 32 my $git_version = `git --version`;
33 chomp($git_version);
4621ecf0 34 $c->stash(
066e9aa4 35 git_version => $git_version,
da8f4f82 36 version => $Gitalist::VERSION,
37
4621ecf0 38 time_since => sub {
ef11b09e 39 return 'never' unless $_[0];
4621ecf0 40 return age_string(time - $_[0]->epoch);
41 },
42 short_cmt => sub {
43 my $cmt = shift;
44 my($line) = split /\n/, $cmt;
6dac2638 45 $line =~ s/^(.{70,80}\b).*/$1 \x{2026}/ if defined $line;
4621ecf0 46 return $line;
47 },
5cd9b9f9 48 abridged_description => sub {
49 join(' ', grep { defined } (split / /, shift)[0..10]);
50 },
5111a8ab 51 uri_for_gravatar => sub {
b0265bca 52 my $email = shift;
53 my $size = shift;
54 my $uri = 'http://www.gravatar.com/avatar/' . md5_hex($email);
55 $uri .= "?s=$size" if $size;
56 return $uri;
57 },
4621ecf0 58 );
04d1d917 59}
d9a9b56b 60
872e6812 61sub search : Chained('base') Args(0) {}
62
12a0f9d3 63=head2 search_help
64
65Provides some help for the search form.
66
67=cut
68
69sub search_help : Chained('base') Args(0) {}
70
71sub end : ActionClass('RenderView') {}
d9a9b56b 72
c113db92 73sub error_404 : Action {
4111e151 74 my ($self, $c) = @_;
75 $c->response->status(404);
5232dbdd 76 $c->response->body('Page not found');
4111e151 77}
78
775e96e0 79__PACKAGE__->meta->make_immutable;
80
81__END__
82
d137f7d5 83=head1 NAME
84
85Gitalist::Controller::Root - Root controller for the application
86
87=head1 DESCRIPTION
88
89This controller handles all of the root level paths for the application
90
91=head1 METHODS
92
5bb401c6 93=head2 root
94
95Root of chained actions
96
97=head2 base
98
99Populate the header and footer. Perhaps not the best location.
100
101=head2 index
102
82bc0f05 103Provides the repository listing.
5bb401c6 104
105=head2 end
106
107Attempt to render a view, if needed.
d137f7d5 108
d137f7d5 109=head2 error_404
110
775e96e0 111=head1 AUTHORS
89de6a33 112
775e96e0 113See L<Gitalist> for authors.
89de6a33 114
115=head1 LICENSE
116
775e96e0 117See L<Gitalist> for the license.
89de6a33 118
119=cut