X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FGitalist%2FController%2FRoot.pm;h=ddcc83a80cd8c3d5c981a17051733ae8526e09db;hb=f41fc74106e51d8055871cacdc1459be4f61f980;hp=d4190c03215d72784de6d3913bfd718e0376e932;hpb=12a0f9d30e501278244732292572ccb0967b194c;p=catagits%2FGitalist.git diff --git a/lib/Gitalist/Controller/Root.pm b/lib/Gitalist/Controller/Root.pm index d4190c0..ddcc83a 100644 --- a/lib/Gitalist/Controller/Root.pm +++ b/lib/Gitalist/Controller/Root.pm @@ -2,7 +2,7 @@ package Gitalist::Controller::Root; use Moose; use Moose::Autobox; - +use Digest::MD5 qw(md5_hex); use Gitalist::Utils qw/ age_string /; use namespace::autoclean; @@ -18,6 +18,14 @@ sub index : Chained('base') PathPart('') Args(0) { $c->stash( search_text => $c->req->param('s') || '' ) # FIXME - XSS? } +# XXX Fragile much? +sub css : Chained('/root') PathPart('core.css') Args(0) { + my ( $self, $c ) = @_; + + $c->response->content_type('text/css'); + $c->stash(template => 'static/css/core.css'); +} + sub base : Chained('/root') PathPart('') CaptureArgs(0) { my($self, $c) = @_; @@ -34,15 +42,24 @@ sub base : Chained('/root') PathPart('') CaptureArgs(0) { short_cmt => sub { my $cmt = shift; my($line) = split /\n/, $cmt; - $line =~ s/^(.{70,80}\b).*/$1 \x{2026}/; + $line =~ s/^(.{70,80}\b).*/$1 \x{2026}/ if defined $line; return $line; }, abridged_description => sub { join(' ', grep { defined } (split / /, shift)[0..10]); }, + uri_for_gravatar => sub { + my $email = shift; + my $size = shift; + my $uri = 'http://www.gravatar.com/avatar/' . md5_hex($email); + $uri .= "?s=$size" if $size; + return $uri; + }, ); } +sub search : Chained('base') Args(0) {} + =head2 search_help Provides some help for the search form. @@ -51,7 +68,16 @@ Provides some help for the search form. sub search_help : Chained('base') Args(0) {} -sub end : ActionClass('RenderView') {} +sub end : ActionClass('Serialize') { + my ($self, $c) = @_; + # Give repository views the current HEAD. + if ($c->stash->{Repository}) { + $c->stash->{HEAD} = $c->stash->{Repository}->head_hash; + } + if ($c->stash->{data} && blessed $c->stash->{data}) { + $c->stash->{rest} = $c->stash->{data}->pack; + } +} sub error_404 : Action { my ($self, $c) = @_; @@ -59,6 +85,16 @@ sub error_404 : Action { $c->response->body('Page not found'); } +__PACKAGE__->config( + default => 'text/html', + map => { + 'application/json' => [qw/ JSON /], + map { $_ => [qw/ View Default /] } + qw( text/css text/html text/plain + application/atom+xml application/rss+xml application/rss ) + } +); + __PACKAGE__->meta->make_immutable; __END__