Make the log work for commits and symbolic refs also.
Tomas Doran [Sun, 24 Jan 2010 15:37:30 +0000 (15:37 +0000)]
URIStructure is now a really bad name properly, and the templates need sorting out to have default templates for log bits so that the templates consisting
of just [% PROCESS other/log.tt2 %] can die

12 files changed:
lib/Gitalist/Controller/Fragment/Ref.pm
lib/Gitalist/Controller/Fragment/Repository.pm
lib/Gitalist/URIStructure/Fragment/WithLog.pm [new file with mode: 0644]
lib/Gitalist/URIStructure/Ref.pm
lib/Gitalist/URIStructure/Repository.pm
lib/Gitalist/URIStructure/WithLog.pm [new file with mode: 0644]
root/fragment/ref/longlog.tt2 [new file with mode: 0644]
root/fragment/ref/shortlog.tt2 [new file with mode: 0644]
root/nav/actions.tt2
root/ref/longlog.tt2 [new file with mode: 0644]
root/ref/shortlog.tt2
root/repository/shortlog.tt2

index 310c12c..7a63a95 100644 (file)
@@ -3,7 +3,10 @@ use Moose;
 use namespace::autoclean;
 
 BEGIN { extends 'Gitalist::Controller' }
-with 'Gitalist::URIStructure::Ref';
+with qw/
+    Gitalist::URIStructure::Ref
+    Gitalist::URIStructure::Fragment::WithLog
+/;
 
 sub base : Chained('/fragment/repository/find') PathPart('') CaptureArgs(0) {}
 
index 135cb8f..b73c1a5 100644 (file)
@@ -3,34 +3,13 @@ use Moose;
 use namespace::autoclean;
 
 BEGIN { extends 'Gitalist::Controller' }
-with 'Gitalist::URIStructure::Repository';
+with qw/
+    Gitalist::URIStructure::Repository
+    Gitalist::URIStructure::Fragment::WithLog
+/;
 
 sub base : Chained('/fragment/base') PathPart('') CaptureArgs(0) {}
 
-after log => sub {
-    my ($self, $c) = @_;
-    my $repository  = $c->stash->{Repository};
-#    my $commit   =  $self->_get_object($c, $c->req->param('hb'));
-#    my $filename = $c->req->param('f') || '';
-
-    my %logargs = (
-       sha1   => $repository->head_hash, # $commit->sha1
-       count  => 25, #Gitalist->config->{paging}{log} || 25,
-#       ($filename ? (file => $filename) : ())
-    );
-
-    my $page = $c->req->param('pg') || 0;
-    $logargs{skip} = $c->req->param('pg') * $logargs{count}
-        if $c->req->param('pg');
-    $c->stash(
-#       commit    => $commit,
-       log_lines => [$repository->list_revs(%logargs)],
-#       refs      => $repository->references,
-#       page      => $page,
-#       filename  => $filename,
-    );
-};
-
 after heads => sub {
     my ($self, $c) = @_;
     $c->stash(
diff --git a/lib/Gitalist/URIStructure/Fragment/WithLog.pm b/lib/Gitalist/URIStructure/Fragment/WithLog.pm
new file mode 100644 (file)
index 0000000..b1a7d36
--- /dev/null
@@ -0,0 +1,31 @@
+package Gitalist::URIStructure::Fragment::WithLog;
+use MooseX::MethodAttributes::Role;
+use namespace::autoclean;
+
+requires 'log';
+
+after log => sub {
+    my ($self, $c) = @_;
+    my $repository  = $c->stash->{Repository};
+#    my $commit   =  $self->_get_object($c, $c->req->param('hb'));
+#    my $filename = $c->req->param('f') || '';
+
+    my %logargs = (
+       sha1   => $c->stash->{Commit}->sha1, # $commit->sha1
+       count  => 25, #Gitalist->config->{paging}{log} || 25,
+#       ($filename ? (file => $filename) : ())
+    );
+
+    my $page = $c->req->param('pg') || 0;
+    $logargs{skip} = $c->req->param('pg') * $logargs{count}
+        if $c->req->param('pg');
+    $c->stash(
+#       commit    => $commit,
+       log_lines => [$repository->list_revs(%logargs)],
+#       refs      => $repository->references,
+#       page      => $page,
+#       filename  => $filename,
+    );
+};
+
+1;
index dae28c4..afea1ee 100644 (file)
@@ -5,6 +5,10 @@ use namespace::autoclean;
 
 requires 'base';
 
+with qw/
+    Gitalist::URIStructure::WithLog
+/;
+
 after 'base' => sub {
     my ($self, $c) = @_;
     confess("No repository in the stash")
@@ -45,8 +49,4 @@ sub blame : Chained('find') Does('FilenameArgs') Args() {}
 
 sub history : Chained('find') Does('FilenameArgs') Args() {}
 
-sub shortlog : Chained('find') Does('FilenameArgs') Args() {}
-
-sub longlog : Chained('find') Does('FilenameArgs') PathPart('log') Args() {}
-
 1;
index df26f4f..47e7016 100644 (file)
@@ -5,6 +5,10 @@ use namespace::autoclean;
 
 requires 'base';
 
+with qw/
+    Gitalist::URIStructure::WithLog
+/;
+
 sub find : Chained('base') PathPart('') CaptureArgs(1) {
     my ($self, $c, $repos_name) = @_;
     # XXX FIXME - This should be in the repository fragment controller, and the repository
@@ -21,16 +25,15 @@ sub find : Chained('base') PathPart('') CaptureArgs(1) {
     };
 }
 
+before 'log' => sub {
+    my ($self, $c) = @_;
+    $c->stash->{Commit} = $c->stash->{Repository}->get_object($c->stash->{Repository}->head_hash);
+};
+
 sub summary : Chained('find') PathPart('') Args(0) {}
 
 sub heads : Chained('find') Args(0) {}
 
 sub tags : Chained('find') Args(0) {}
 
-sub log : Chained('find') PathPart('') CaptureArgs(0) {}
-
-sub shortlog : Chained('log') Args(0) {}
-
-sub longlog : Chained('log') PathPart('log') Args(0) {}
-
 1;
diff --git a/lib/Gitalist/URIStructure/WithLog.pm b/lib/Gitalist/URIStructure/WithLog.pm
new file mode 100644 (file)
index 0000000..318522d
--- /dev/null
@@ -0,0 +1,11 @@
+package Gitalist::URIStructure::WithLog;
+use MooseX::MethodAttributes::Role;
+use namespace::autoclean;
+
+sub log : Chained('find') PathPart('') CaptureArgs(0) {}
+
+sub shortlog : Chained('log') Args(0) {}
+
+sub longlog : Chained('log') PathPart('log') Args(0) {}
+
+1;
\ No newline at end of file
diff --git a/root/fragment/ref/longlog.tt2 b/root/fragment/ref/longlog.tt2
new file mode 100644 (file)
index 0000000..5470847
--- /dev/null
@@ -0,0 +1 @@
+[% PROCESS 'fragment/repository/longlog.tt2' %]
diff --git a/root/fragment/ref/shortlog.tt2 b/root/fragment/ref/shortlog.tt2
new file mode 100644 (file)
index 0000000..0ba3aa1
--- /dev/null
@@ -0,0 +1 @@
+[% PROCESS 'fragment/repository/shortlog.tt2' %]
index 2778685..57e7b71 100644 (file)
@@ -1,8 +1,9 @@
 <div class='actions'>
   <!-- This should probably be a real LIst -->
     <a href="[% c.uri_for_action('/repository/summary', [c.req.captures.0]) %]">summary</a> &bull;
-    <a href="[% c.uri_for_action('/repository/shortlog', [c.req.captures.0]) %]">shortlog</a> &bull;
-    <a href="[% c.uri_for_action('/repository/log', [c.req.captures.0]) %]">log</a>
+    [% IF c.req.captures.size == 1; SET path = 'repository'; ELSE; SET path = 'ref'; END %]
+    <a href="[% c.uri_for_action('/' _ path _ '/shortlog', [c.req.captures]) %]">shortlog</a> &bull;
+    <a href="[% c.uri_for_action('/' _ path _ '/longlog', [c.req.captures]) %]">log</a>
     [% IF Commit %]
         &sect;
         <a href="[% c.uri_for_action('/ref/commit', [c.req.captures.0, Commit.sha1]) %]">commit</a> &bull;
diff --git a/root/ref/longlog.tt2 b/root/ref/longlog.tt2
new file mode 100644 (file)
index 0000000..e927a16
--- /dev/null
@@ -0,0 +1 @@
+[% PROCESS 'repository/longlog.tt2' %]
index 9d6cf4b..4175b41 100644 (file)
@@ -1 +1 @@
-FIXME
+[% PROCESS 'repository/shortlog.tt2' %]
index 7bf52b4..74bdbba 100644 (file)
@@ -1,2 +1,2 @@
 [% INCLUDE 'nav/actions.tt2' object = commit %]
-[% subinclude('/fragment/repository/shortlog', c.req.captures) %]
+[% subinclude('/fragment/' _ c.action, c.req.captures) %]