Start using the subinclude plugin and splitting things up.
Tomas Doran [Sun, 17 Jan 2010 18:58:21 +0000 (18:58 +0000)]
Makefile.PL
lib/Gitalist.pm
lib/Gitalist/Controller/Repository.pm
lib/Gitalist/View/Default.pm
root/repository/shortlog.tt2 [new file with mode: 0644]
root/repository/summary.tt2 [new file with mode: 0644]

index 517d200..baf71bb 100644 (file)
@@ -56,6 +56,7 @@ requires 'Catalyst::Plugin::Static::Simple';
 requires 'Catalyst::Plugin::Unicode::Encoding';
 requires 'Catalyst::Action::RenderView';
 requires 'Catalyst::Component::InstancePerContext';
+requires 'Catalyst::View::Component::SubInclude' => '0.07';
 requires 'Catalyst::View::TT';
 
 requires 'Template';
index 41bfd04..be94265 100644 (file)
@@ -11,6 +11,7 @@ use Catalyst qw/
                 Unicode::Encoding
                 Static::Simple
                 StackTrace
+                SubRequest
 /;
 
 our $VERSION = '0.000005';
@@ -26,15 +27,21 @@ __PACKAGE__->setup();
 
 around uri_for => sub {
   my ($orig, $c) = (shift, shift);
-  my $repository_name = $c->stash->{'Repository'} && $c->stash->{'Repository'}->name;
   my $hash = ref($_[-1]) eq 'HASH' ? pop @_ : {};
-  my $params = Catalyst::Utils::merge_hashes(
-    { p => $hash->{p} || $repository_name },
-    $hash,
-  );
-  delete $params->{p} unless defined $params->{p} && length $params->{p};
-  (my $uri = $c->$orig(@_, $params))
-    =~ tr[&][;];
+  my $params;
+  if ($c->stash->{_do_not_mangle_uri_for}) {
+      $params = $hash;
+  }
+  else {
+      my $repository_name = $c->stash->{'Repository'} && $c->stash->{'Repository'}->name;
+      $params = Catalyst::Utils::merge_hashes(
+          { p => $hash->{p} || $repository_name },
+          $hash,
+       );
+       delete $params->{p} unless defined $params->{p} && length $params->{p};
+  }
+  my $uri = $c->$orig(@_, $params);
+  $$uri =~ tr[&][;];
   return $uri;
 };
 
index 6f9333e..5015ae2 100644 (file)
@@ -7,7 +7,10 @@ use namespace::autoclean;
 
 BEGIN { extends 'Catalyst::Controller' }
 
-sub base : Chained('/root') PathPart('') CaptureArgs(0) {}
+sub base : Chained('/root') PathPart('') CaptureArgs(0) {
+    my ($self, $c) = @_;
+    $c->stash(_do_not_mangle_uri_for => 1);
+}
 
 sub find : Chained('base') PathPart('') CaptureArgs(1) {
     my ($self, $c, $repository) = @_;
@@ -19,15 +22,11 @@ sub find : Chained('base') PathPart('') CaptureArgs(1) {
     };
 }
 
-sub summary : Chained('find') PathPart('') Args(0) {
-    my ($self, $c) = @_;
-    $c->stash(template => 'summary.tt2');
-    $c->forward('/summary');
-} 
+sub summary : Chained('find') PathPart('') Args(0) {}
 
 sub shortlog : Chained('find') Args(0) {
     my ($self, $c) = @_;
-    $c->stash(template => 'shortlog.tt2');
+    $c->stash(no_wrapper => 1);
     $c->forward('/shortlog');
 }
 
index 757f982..d89b1bb 100644 (file)
@@ -3,12 +3,14 @@ use Moose;
 use namespace::autoclean;
 
 extends 'Catalyst::View::TT';
+with 'Catalyst::View::Component::SubInclude';
 
 use Template::Plugin::Cycle;
 
 __PACKAGE__->config(
   TEMPLATE_EXTENSION => '.tt2',
   WRAPPER            => 'default.tt2',
+  subinclude_plugin => 'SubRequest',
 );
 
 __PACKAGE__->meta->make_immutable(inline_constructor => 0);
diff --git a/root/repository/shortlog.tt2 b/root/repository/shortlog.tt2
new file mode 100644 (file)
index 0000000..c1c7383
--- /dev/null
@@ -0,0 +1,7 @@
+<div class='content'>
+[%
+  INCLUDE '_log_pager.tt2';
+  INCLUDE '_shortlog.tt2';
+  INCLUDE '_log_pager.tt2';
+%]
+</div>
diff --git a/root/repository/summary.tt2 b/root/repository/summary.tt2
new file mode 100644 (file)
index 0000000..26fe59d
--- /dev/null
@@ -0,0 +1,15 @@
+[% PROCESS 'nav/actions.tt2' object = commit %]
+
+<div class='summary content'>
+ <dl>
+  <dt>description</dt><dd>[% Repository.description %]</dd>
+  <dt>owner</dt><dd>[% Repository.owner %]</dd>
+  <dt>last change</dt><dd>[% Repository.last_change %]</dd>
+ </dl>
+
+  <h2><a href='[% c.uri_for(c.controller.action_for('shortlog'), c.req.captures) %]'>shortlog</a></h2>
+  [% subinclude('/repository/shortlog', c.req.captures) %]
+
+  <h2><a href='[% c.uri_for(c.controller.action_for('heads'), c.req.captures) %]'>branches</a></h2>
+  [% subinclude('/repository/heads', c.req.captures) %]
+</div>