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?
22 sub css : Chained('/root') PathPart('core.css') Args(0) {
23 my ( $self, $c ) = @_;
25 $c->response->content_type('text/css');
26 $c->stash(template => 'static/css/core.css');
29 sub base : Chained('/root') PathPart('') CaptureArgs(0) {
32 my $git_version = `git --version`;
35 git_version => $git_version,
36 version => $Gitalist::VERSION,
39 return 'never' unless $_[0];
40 return age_string(time - $_[0]->epoch);
44 my($line) = split /\n/, $cmt;
45 $line =~ s/^(.{70,80}\b).*/$1 \x{2026}/ if defined $line;
48 abridged_description => sub {
49 join(' ', grep { defined } (split / /, shift)[0..10]);
51 uri_for_gravatar => sub { # FIXME - Cache these?
54 my $uri = 'http://www.gravatar.com/avatar/' . md5_hex($email);
55 $uri .= "?s=$size" if $size;
61 sub search : Chained('base') Args(0) {}
65 Provides some help for the search form.
69 sub search_help : Chained('base') Args(0) {}
71 sub end : ActionClass('RenderView') {}
73 sub error_404 : Action {
75 $c->response->status(404);
76 $c->response->body('Page not found');
80 default => 'text/html',
82 'text/html' => [qw/ View Default /],
83 'application/json' => [qw/ JSON /],
87 __PACKAGE__->meta->make_immutable;
93 Gitalist::Controller::Root - Root controller for the application
97 This controller handles all of the root level paths for the application
103 Root of chained actions
107 Populate the header and footer. Perhaps not the best location.
111 Provides the repository listing.
115 Attempt to render a view, if needed.
121 See L<Gitalist> for authors.
125 See L<Gitalist> for the license.