BEGIN { extends 'Gitalist::Controller' }
with 'Gitalist::URIStructure::Ref';
+use File::Type;
+use File::Type::WebImages ();
+
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');
- $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})
+ );
+ }
+
+ 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.
=cut
-sub snapshot : Chained('base') Args() {
+sub snapshot : Chained('find') PathPart('snapshot') Args() {
my ($self, $c, $format) = @_;
$format ||= 'tgz';
my @snap = $c->stash->{Repository}->snapshot(