=cut
use IO::Capture::Stdout;
-use File::Slurp qw(slurp);
+
+=head2 run_gitweb
+
+The main shim around C<gitweb.pm>.
+
+=cut
sub run_gitweb {
my ( $self, $c ) = @_;
}
}
+=head2 index
+
+Provides the project listing.
+
+=cut
+
sub index :Path :Args(0) {
my ( $self, $c ) = @_;
);
}
+=head2 blob
+
+The blob action i.e the contents of a file.
+
+=cut
+
sub blob : Local {
my ( $self, $c ) = @_;
- my $git = $c->model('Git');
- my $req = $c->req;
- my $proj = $req->param('p');
- my $filename = $req->param('f') || $req->param('filename');
- my $hash = $req->param('hb') || $git->get_head_hash($proj);
- my $filehash = $req->param('h') || $git->get_hash_by_path($proj, $hash, $filename, 'blob');
-
- my $blob = $git->run_cmd('cat-file' => blob => $filehash);
+ my $h = $c->req->param('h')
+ || $c->model('Git')->hash_by_path($c->req->param('f'))
+ || die "No file or sha1 provided.";
+ my $hb = $c->req->param('hb')
+ || $c->model('Git')->head_hash
+ || die "Couldn't discern the corresponding head.";
$c->stash(
- blob => $blob,
- action => 'blob',
+ blob => $c->model('Git')->get_object($h)->content,
+ head => $c->model('Git')->get_object($hb),
+ filename => $c->req->param('f') || '',
+ action => 'blob',
);
+
+ $c->forward('View::SyntaxHighlight');
}
+=head2 reflog
+
+Expose the local reflog. This may go away.
+
+=cut
+
sub reflog : Local {
my ( $self, $c ) = @_;
my @log = $c->model('Git')->reflog(
- # XXX The project parameter should probably be passed into the Model.
- $c->req->param('p'),
'--since=yesterday'
);
);
}
+=head2 commit
+
+Exposes a given commit. Probably too simple currently.
+
+=cut
+
+sub commit : Local {
+ my ( $self, $c ) = @_;
+
+ $c->stash(
+ commit => $c->model('Git')->get_object($c->req->param('h')),
+ action => 'commit',
+ );
+}
+
+=head2 auto
+
+Populate the header and footer. Perhaps not the best location.
+
+=cut
+
sub auto : Private {
my($self, $c) = @_;
+ # XXX Temp hack until a decent solution is invented.
+ $c->model('Git')->project($c->req->param('p'))
+ if $c->req->param('p');
+
# Yes, this is hideous.
$self->header($c);
$self->footer($c);