X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FGitalist.git;a=blobdiff_plain;f=lib%2FGitalist%2FController%2FRef.pm;h=c0e4ce35e0e99ff96ad5e4b5706488262b5c317f;hp=e43bd98aa68cc62fff43a484b3e25afa532a7f5e;hb=e172b6b86d415fbe6137dd8ca4ef7dc6919f61ba;hpb=3a58f004e86fccfa384065e6da7d268917afb1b8 diff --git a/lib/Gitalist/Controller/Ref.pm b/lib/Gitalist/Controller/Ref.pm index e43bd98..c0e4ce3 100644 --- a/lib/Gitalist/Controller/Ref.pm +++ b/lib/Gitalist/Controller/Ref.pm @@ -6,6 +6,9 @@ use namespace::autoclean; BEGIN { extends 'Gitalist::Controller' } with 'Gitalist::URIStructure::Ref'; +use File::Type; +use File::Type::WebImages (); + sub base : Chained('/repository/find') PathPart('') CaptureArgs(0) {} after commit => sub { @@ -20,7 +23,16 @@ sub raw : Chained('find') Does('FilenameArgs') Args() { my ($self, $c) = @_; $c->forward('find_blob'); - $c->response->content_type('text/plain; charset=utf-8'); + if(-T $c->stash->{blob}) { + $c->response->content_type('text/plain; charset=utf-8'); + } else { + my $ft = File::Type->new(); + $c->response->content_type( + File::Type::WebImages::mime_type($c->stash->{blob}) + || File::Type->new->mime_type($c->stash->{blob}) + ); + } + $c->response->body(delete $c->stash->{blob}); }