package Gitalist::Controller::Commit;
use Moose;
-use Moose::Autobox;
-use Try::Tiny qw/try catch/;
use namespace::autoclean;
BEGIN { extends 'Catalyst::Controller' }
+with 'Gitalist::URIStructure::Commit';
sub base : Chained('/repository/find') PathPart('') CaptureArgs(0) {}
-sub find : Chained('base') PathPart('') CaptureArgs(1) {
- my ($self, $c, $sha1part) = @_;
- $c->stash->{Commit} = $c->stash->{Repository}->get_object($sha1part)
- or $c->detach('/error404', "Couldn't find a object for '$sha1part' in XXXX!");
-}
-
-sub diff : Chained('find') Args(0) {}
-
-sub tree : Chained('find') Args(0) {}
-
-sub commit : Chained('find') Args(0) {}
-
__PACKAGE__->meta->make_immutable;
--- /dev/null
+package Gitalist::Controller::Fragment::Commit;
+use Moose;
+use namespace::autoclean;
+
+BEGIN { extends 'Catalyst::Controller' }
+with 'Gitalist::URIStructure::Commit';
+
+sub base : Chained('/fragment/repository/find') PathPart('') CaptureArgs(0) {}
+
+__PACKAGE__->meta->make_immutable;
--- /dev/null
+package Gitalist::URIStructure::Commit;
+use MooseX::MethodAttributes::Role;
+use namespace::autoclean;
+
+requires 'base';
+
+after 'base' => sub {
+ my ($self, $c) = @_;
+ confess("No repository in the stash")
+ unless $c->stash->{Repository};
+};
+
+sub find : Chained('base') PathPart('') CaptureArgs(1) {
+ my ($self, $c, $sha1part) = @_;
+ # FIXME - Should not be here!
+ $c->stash->{Commit} = $c->stash->{Repository}->get_object($sha1part)
+ or $c->detach('/error404', "Couldn't find a object for '$sha1part' in XXXX!");
+}
+
+sub diff : Chained('find') Args(0) {}
+
+sub tree : Chained('find') Args(0) {}
+
+sub commit : Chained('find') Args(0) {}
+
+1;
--- /dev/null
+[% INCLUDE 'nav/actions.tt2' object = commit %]
+
+<div class='content'>
+ <div class='commit-message'>
+ [% short_cmt(commit.comment) | html %] ...
+ </div>
+
+ [%
+ IF path;
+ INCLUDE 'nav/path.tt2' filename = path, head = commit;
+ END;
+
+ subinclude('/fragment/commit/tree', c.req.captures);
+ %]
+</div>
--- /dev/null
+<table class='tree listing'>
+ <thead>
+ <tr>
+ <th>mode</th>
+ <th>file</th>
+ <th>actions</th>
+ </tr>
+ </thead>
+ <tfoot>
+ <tr>
+ <td>mode</td>
+ <td>file</td>
+ <td>actions</td>
+ </tr>
+ </tfoot>
+
+ <tbody>
+ [% FOREACH item IN tree_list %]
+ <tr>
+ <td class='file-mode'>[% item.modestr %]</td>
+ [% theact = item.type == 'tree' ? 'tree' : 'blob' -%]
+ [% fullpath = path ? path _ '/' _ item.file : item.file %]
+ <td class='file-name'>
+ <a href="[% c.uri_for(theact, {h=item.sha1, hb=commit.sha1, f=fullpath}) %]">[% item.file %]</a>
+ </td>
+ <td class='action-list'>
+ <a href="[% c.uri_for(theact, {h=item.sha1, hb=commit.sha1, f=fullpath}) %]">[% theact %]</a>
+ [% IF item.type == 'blob' %]
+ <a href="[% c.uri_for('blame', {h=commit.sha1, hb=commit.sha1, f=fullpath}) %]">blame</a>
+ [% END %]
+ <a href="[% c.uri_for('history', {h=item.sha1, hb=commit.sha1, f=fullpath}) %]">history</a>
+ [% IF item.type == 'blob' %]
+ <a href="[% c.uri_for('raw', {hb=commit.sha1, f=fullpath}) %]">raw</a>
+ [% END %]
+ </td>
+ </tr>
+ [% END %]
+ </tbody>
+</table>