Skip to content

Instantly share code, notes, and snippets.

@yongbin
Created October 10, 2010 23:30
Show Gist options
  • Save yongbin/619693 to your computer and use it in GitHub Desktop.
Save yongbin/619693 to your computer and use it in GitHub Desktop.
diff --git a/lib/Gitalist/Controller/Fragment/Ref.pm b/lib/Gitalist/Controller/Fragment/Ref.pm
index 718d195..1e3503e 100644
--- a/lib/Gitalist/Controller/Fragment/Ref.pm
+++ b/lib/Gitalist/Controller/Fragment/Ref.pm
@@ -10,6 +10,7 @@ with qw/
use File::Type::WebImages ();
use JSON::XS qw(encode_json);
+use Encode qw(decode_utf8);
sub base : Chained('/fragment/repository/find') PathPart('') CaptureArgs(0) {}
@@ -28,7 +29,7 @@ sub _diff {
diff_tree => $tree,
diff => $patch,
# XXX Hack hack hack, see View::SyntaxHighlight
- blobs => [map $_->{diff}, @$patch],
+ blobs => [map decode_utf8($_->{diff}), @$patch],
%diff_args,
);
}
@@ -66,7 +67,7 @@ after blame => sub {
my $blame = $c->stash->{Commit}->blame($c->stash->{filename}, $c->stash->{Commit}->sha1);
$c->stash(
blame => $blame,
- blob => join("\n", map $_->{line}, @$blame),
+ blob => join("\n", map decode_utf8($_->{line}), @$blame),
);
$c->forward('Model::ContentMangler');
diff --git a/lib/Gitalist/URIStructure/Ref.pm b/lib/Gitalist/URIStructure/Ref.pm
index 2536dc5..741ddcd 100644
--- a/lib/Gitalist/URIStructure/Ref.pm
+++ b/lib/Gitalist/URIStructure/Ref.pm
@@ -2,6 +2,7 @@ package Gitalist::URIStructure::Ref;
use MooseX::MethodAttributes::Role;
use Moose::Autobox;
use namespace::autoclean;
+use Encode qw/decode_utf8/;
use Gitalist::Git::Types qw/SHA1/;
@@ -71,7 +72,7 @@ sub find_blob : Action {
: die "Unknown object type for '${\$object->sha1}'";
die "No file or sha1 provided."
unless $h;
- $c->stash(blob => $repo->get_object($h)->content);
+ $c->stash(blob => decode_utf8($repo->get_object($h)->content));
}
sub blob : Chained('find') Does('FilenameArgs') Args() {
diff --git a/lib/Gitalist/View/Default.pm b/lib/Gitalist/View/Default.pm
index b1d4840..02de507 100644
--- a/lib/Gitalist/View/Default.pm
+++ b/lib/Gitalist/View/Default.pm
@@ -11,6 +11,7 @@ use Template::Plugin::Cycle;
__PACKAGE__->config(
TEMPLATE_EXTENSION => '.tt2',
WRAPPER => 'wrapper.tt2',
+ ENCODING => 'utf-8',
subinclude_plugin => 'SubRequest',
render_die => 1,
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment