Got blob highlighting working with the ContentMangler.
[catagits/Gitalist.git] / lib / Gitalist / Controller / Fragment / Ref.pm
index b4a2181..14f8561 100644 (file)
@@ -8,6 +8,8 @@ with qw/
     Gitalist::URIStructure::Fragment::WithLog
 /;
 
+use File::Type::WebImages ();
+
 sub base : Chained('/fragment/repository/find') PathPart('') CaptureArgs(0) {}
 
 sub _diff {
@@ -25,7 +27,6 @@ sub _diff {
       diff      => $patch,
       # XXX Hack hack hack, see View::SyntaxHighlight
       blobs     => [map $_->{diff}, @$patch],
-      language  => 'Diff',
       %filename,
     );
 }
@@ -33,7 +34,7 @@ sub _diff {
 after diff_fancy => sub {
     my ($self, $c) = @_;
     $self->_diff($c);
-    $c->forward('View::SyntaxHighlight');
+    $c->forward('Model::ContentMangler');
 };
 
 after diff_plain => sub {
@@ -52,7 +53,6 @@ after tree => sub {
     $c->stash(
         tree      => $tree,
         tree_list => [$repository->list_tree($tree->sha1)],
-        path      => $c->stash->{filename}, # FIXME?
     );
 };
 
@@ -64,13 +64,10 @@ after blame => sub {
     my $blame = $c->stash->{Commit}->blame($c->stash->{filename}, $c->stash->{Commit}->sha1);
     $c->stash(
         blame    => $blame,
-        # XXX Hack hack hack, see View::SyntaxHighlight
-        language => ($c->stash->{filename} =~ /\.p[lm]$/i ? 'Perl' : ''),
         blob     => join("\n", map $_->{line}, @$blame),
     );
 
-    $c->forward('View::SyntaxHighlight')
-        unless $c->stash->{no_wrapper};
+    $c->forward('Model::ContentMangler');
 };
 
 =head2 blob
@@ -82,12 +79,10 @@ The blob action i.e the contents of a file.
 after blob => sub {
     my ( $self, $c ) = @_;
     $c->stash(
-        # XXX Hack hack hack, see View::SyntaxHighlight
-        language => ($c->stash->{filename} =~ /\.p[lm]$/i ? 'Perl' : ''),
+        is_image  => File::Type::WebImages::mime_type($c->stash->{blob}),
+        is_binary => Gitalist::Utils::is_binary($c->stash->{blob}),
     );
-
-    $c->forward('View::SyntaxHighlight')
-        unless $c->stash->{no_wrapper};
+    $c->forward('Model::ContentMangler');
 };
 
 after history => sub {