Assume UTF8 encoded blobs.
Dan Brook [Sun, 6 Mar 2011 12:36:56 +0000 (12:36 +0000)]
This makes text files that have UTF8 bits in them render
normally. Certainly this is not ideal but it shall suffice.

Makefile.PL
lib/Gitalist/Controller/Ref.pm
root/fragment/ref/blob.tt2

index f9efb7e..6c9ac68 100644 (file)
@@ -72,6 +72,7 @@ requires 'Try::Tiny';
 requires 'Template' => '2.22';
 requires 'Template::Provider::Encoding';
 requires 'Template::Plugin::Cycle';
+requires 'Template::Plugin::UTF8Decode';
 
 requires 'Config::General';
 
index ddaabe6..247b775 100644 (file)
@@ -31,6 +31,7 @@ sub raw : Chained('find') Does('FilenameArgs') Args() {
         );
     }
 
+    utf8::decode($c->stash->{blob});
     $c->response->body(delete $c->stash->{blob});
 }
 
index 3fe51e8..cb6097a 100644 (file)
@@ -4,5 +4,6 @@
 <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 -%]
 [%- INCLUDE inc/syntax_highlight_css.tt2 -%]
-<pre class='blob'>[% IF mangled; blob; ELSE; blob | html; END; %]</pre>
+[%- USE UTF8Decode -%]
+<pre class='blob'>[% IF mangled; blob; ELSE; blob | utf8_decode | html; END; %]</pre>
 [%- END -%]