1 package Gitalist::Controller::Root;
5 use Digest::MD5 qw(md5_hex);
6 use Gitalist::Utils qw/ age_string /;
8 use namespace::autoclean;
10 BEGIN { extends 'Gitalist::Controller' }
12 __PACKAGE__->config(namespace => '');
14 sub root : Chained('/') PathPart('') CaptureArgs(0) {}
16 sub index : Chained('base') PathPart('') Args(0) {
17 my ( $self, $c ) = @_;
18 $c->stash( search_text => $c->req->param('s') || '' ) # FIXME - XSS?
21 sub base : Chained('/root') PathPart('') CaptureArgs(0) {
24 my $git_version = `git --version`;
27 git_version => $git_version,
28 version => $Gitalist::VERSION,
31 return 'never' unless $_[0];
32 return age_string(time - $_[0]->epoch);
36 my($line) = split /\n/, $cmt;
37 $line =~ s/^(.{70,80}\b).*/$1 \x{2026}/ if defined $line;
40 abridged_description => sub {
41 join(' ', grep { defined } (split / /, shift)[0..10]);
43 uri_for_gravatar => sub { # FIXME - Cache these?
46 my $uri = 'http://www.gravatar.com/avatar/' . md5_hex($email);
47 $uri .= "?s=$size" if $size;
55 Provides some help for the search form.
59 sub search_help : Chained('base') Args(0) {}
61 sub end : ActionClass('RenderView') {}
63 sub error_404 : Action {
65 $c->response->status(404);
66 $c->response->body('Page not found');
69 __PACKAGE__->meta->make_immutable;
75 Gitalist::Controller::Root - Root controller for the application
79 This controller handles all of the root level paths for the application
85 Root of chained actions
89 Populate the header and footer. Perhaps not the best location.
93 Provides the repository listing.
97 Attempt to render a view, if needed.
103 See L<Gitalist> for authors.
107 See L<Gitalist> for the license.