From: Tomas Doran Date: Mon, 18 Jan 2010 01:23:40 +0000 (+0000) Subject: Get blob view working again X-Git-Tag: 0.000006_01~1^2~82 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=85aed493b5cbf1b8518e7156b48ea23719f3681a;p=catagits%2FGitalist.git Get blob view working again --- diff --git a/lib/Gitalist/Controller/Fragment/Commit.pm b/lib/Gitalist/Controller/Fragment/Commit.pm index 12e86ad..b39b9ef 100644 --- a/lib/Gitalist/Controller/Fragment/Commit.pm +++ b/lib/Gitalist/Controller/Fragment/Commit.pm @@ -55,7 +55,6 @@ after blame => sub { my $repository = $c->stash->{Repository}; my $filename = join('/', @fn); - # WTF? my $blame = $c->stash->{Commit}->blame($filename, $c->stash->{Commit}->sha1); $c->stash( @@ -71,4 +70,30 @@ after blame => sub { unless $c->stash->{no_wrapper}; }; +=head2 blob + +The blob action i.e the contents of a file. + +=cut + +after blob => sub { + my ( $self, $c, @fn ) = @_; + + my $filename = join('/', @fn); + my $repository = $c->stash->{Repository}; + my $h = + $repository->hash_by_path($c->stash->{Commit}->sha1, $filename) + || die "No file or sha1 provided."; + my $blob = $repository->get_object($h); + $c->stash( + blob => $blob->content, + filename => $filename, + # XXX Hack hack hack, see View::SyntaxHighlight + language => ($filename =~ /\.p[lm]$/i ? 'Perl' : ''), + ); + + $c->forward('View::SyntaxHighlight') + unless $c->stash->{no_wrapper}; +}; + __PACKAGE__->meta->make_immutable; diff --git a/lib/Gitalist/Controller/Root.pm b/lib/Gitalist/Controller/Root.pm index b2223ec..b20ebc1 100644 --- a/lib/Gitalist/Controller/Root.pm +++ b/lib/Gitalist/Controller/Root.pm @@ -73,27 +73,7 @@ sub _blob_objs { return $blob, $repository->get_object($hb), $filename; } -=head2 blob -The blob action i.e the contents of a file. - -=cut - -sub blob : Chained('base') Args(0) { - my ( $self, $c ) = @_; - - my($blob, $head, $filename) = $self->_blob_objs($c); - $c->stash( - blob => $blob->content, - head => $head, - filename => $filename, - # XXX Hack hack hack, see View::SyntaxHighlight - language => ($filename =~ /\.p[lm]$/i ? 'Perl' : ''), - ); - - $c->forward('View::SyntaxHighlight') - unless $c->stash->{no_wrapper}; -} =head2 blob_plain diff --git a/root/blob.tt2 b/root/commit/blob.tt2 similarity index 73% rename from root/blob.tt2 rename to root/commit/blob.tt2 index 06077b2..994b9d7 100644 --- a/root/blob.tt2 +++ b/root/commit/blob.tt2 @@ -9,6 +9,6 @@ [% END %] [% INCLUDE 'nav/path.tt2' %]
-
[% blob %]
+
[% subinclude('/fragment/commit/blob', c.req.captures, c.req.args.to_path) %]
diff --git a/root/fragment/commit/blob.tt2 b/root/fragment/commit/blob.tt2 new file mode 100644 index 0000000..592f8c5 --- /dev/null +++ b/root/fragment/commit/blob.tt2 @@ -0,0 +1 @@ +[% blob %]