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;
53 sub search : Chained('base') Args(0) {}
57 Provides some help for the search form.
61 sub search_help : Chained('base') Args(0) {}
63 sub end : ActionClass('RenderView') {}
65 sub error_404 : Action {
67 $c->response->status(404);
68 $c->response->body('Page not found');
71 __PACKAGE__->meta->make_immutable;
77 Gitalist::Controller::Root - Root controller for the application
81 This controller handles all of the root level paths for the application
87 Root of chained actions
91 Populate the header and footer. Perhaps not the best location.
95 Provides the repository listing.
99 Attempt to render a view, if needed.
105 See L<Gitalist> for authors.
109 See L<Gitalist> for the license.