1 package Gitalist::Controller::Fragment::Ref;
3 use namespace::autoclean;
5 BEGIN { extends 'Gitalist::Controller' }
7 Gitalist::URIStructure::Ref
8 Gitalist::URIStructure::Fragment::WithLog
11 sub base : Chained('/fragment/repository/find') PathPart('') CaptureArgs(0) {}
15 my $commit = $c->stash->{Commit};
16 my($tree, $patch) = $c->stash->{Repository}->diff(
18 parent => $c->req->param('hp') || undef,
24 # XXX Hack hack hack, see View::SyntaxHighlight
25 blobs => [map $_->{diff}, @$patch],
30 after diff_fancy => sub {
32 $c->forward('View::SyntaxHighlight');
35 after diff_plain => sub {
37 $c->response->content_type('text/plain; charset=utf-8');
41 my ( $self, $c ) = @_;
42 my $repository = $c->stash->{Repository};
43 my $commit = $c->stash->{Commit};
44 my $tree = $c->stash->{filename}
45 ? $repository->get_object($repository->hash_by_path($commit->sha1, $c->stash->{filename}))
46 : $repository->get_object($commit->tree_sha1)
50 tree_list => [$repository->list_tree($tree->sha1)],
51 path => $c->stash->{filename}, # FIXME?
58 my $repository = $c->stash->{Repository};
60 my $blame = $c->stash->{Commit}->blame($c->stash->{filename}, $c->stash->{Commit}->sha1);
63 # XXX Hack hack hack, see View::SyntaxHighlight
64 language => ($c->stash->{filename} =~ /\.p[lm]$/i ? 'Perl' : ''),
65 blob => join("\n", map $_->{line}, @$blame),
68 $c->forward('View::SyntaxHighlight')
69 unless $c->stash->{no_wrapper};
74 The blob action i.e the contents of a file.
79 my ( $self, $c ) = @_;
81 # XXX Hack hack hack, see View::SyntaxHighlight
82 language => ($c->stash->{filename} =~ /\.p[lm]$/i ? 'Perl' : ''),
85 $c->forward('View::SyntaxHighlight')
86 unless $c->stash->{no_wrapper};
89 __PACKAGE__->meta->make_immutable;