Merge pull request #23 from hggh/mainifest_fix
[catagits/Gitalist.git] / lib / Gitalist / Controller / Ref.pm
index c0e4ce3..46def57 100644 (file)
@@ -14,28 +14,33 @@ sub base : Chained('/repository/find') PathPart('') CaptureArgs(0) {}
 after commit => sub {
   my($self, $c) = @_;
 
-  $c->stash->{diff_tree} = ($c->stash->{Repository}->diff(
-    commit => $c->stash->{Commit},
-  ))[0];
+  $c->stash->{diff_tree} = ( $c->stash->{Commit}->diff )[0];
 };
 
 sub raw : Chained('find') Does('FilenameArgs') Args() {
     my ($self, $c) = @_;
     $c->forward('find_blob');
 
-    if(-T $c->stash->{blob}) {
-       $c->response->content_type('text/plain; charset=utf-8');
+    if(!Gitalist::Utils::is_binary($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})
-       );
+        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})
+        );
     }
 
+    utf8::decode($c->stash->{blob});
     $c->response->body(delete $c->stash->{blob});
 }
 
+=encoding UTF-8
+
+=head1 NAME
+
+Gitalist::Controller::Ref - Controller::Ref module for Gitalist
+
 =head2 snapshot
 
 Provides a snapshot of a given commit.