Got blob highlighting working with the ContentMangler.
Dan Brook [Sat, 17 Apr 2010 20:42:07 +0000 (21:42 +0100)]
lib/Gitalist/Controller/Fragment/Ref.pm
lib/Gitalist/Model/ContentMangler.pm
root/fragment/ref/blob.tt2
root/ref/blob.tt2

index 549e4a3..14f8561 100644 (file)
@@ -67,8 +67,7 @@ after blame => sub {
         blob     => join("\n", map $_->{line}, @$blame),
     );
 
-    $c->forward('Model::ContentMangler')
-        unless $c->stash->{no_wrapper};
+    $c->forward('Model::ContentMangler');
 };
 
 =head2 blob
@@ -83,9 +82,7 @@ after blob => sub {
         is_image  => File::Type::WebImages::mime_type($c->stash->{blob}),
         is_binary => Gitalist::Utils::is_binary($c->stash->{blob}),
     );
-
-    $c->forward('Model::ContentMangler')
-        unless $c->stash->{no_wrapper};
+    $c->forward('Model::ContentMangler');
 };
 
 after history => sub {
index d7b7457..62a3356 100644 (file)
@@ -44,7 +44,10 @@ sub process {
 
     my @steps = $self->resolve({ filename => $c->stash->{filename} });
     my @css = map { $_->[1]->{css} } grep { exists $_->[1] && exists $_->[1]->{css} && defined $_->[1]->{css} && length $_->[1]->{css} } @steps;
-    $c->stash(syntax_css => [ map { $c->uri_for('/static/css/syntax/' . $_ . '.css') } @css ]);
+    $c->stash(
+      syntax_css => [ map { $c->uri_for('/static/css/syntax/' . $_ . '.css') } @css ],
+      mangled    => scalar @steps,
+    );
     
     if ($c->stash->{blobs} || $c->stash->{blob}) {
         foreach my $step (@steps) {
index aaaa65d..3fe51e8 100644 (file)
@@ -3,5 +3,6 @@
 [%- ELSIF is_binary -%]
 <div class='blob'>This is a binary file which won't render natively on the web, but you can get it here all the same: <a href="[% c.uri_for_action('/ref/raw', c.req.captures, filename) %]" title="[% filename %]">[% filename %]</a></div>
 [%- ELSE -%]
-<pre class='blob'>[% blob | html %]</pre>
+[%- INCLUDE inc/syntax_highlight_css.tt2 -%]
+<pre class='blob'>[% IF mangled; blob; ELSE; blob | html; END; %]</pre>
 [%- END -%]
index fb4497d..92fbf03 100755 (executable)
@@ -1,5 +1,3 @@
-[% INCLUDE inc/syntax_highlight_css.tt2 %]
-
 <h3>[% INCLUDE 'nav/path.tt2' %]</h3>
 
   [% IF object.type == 'commit' %]