Fix paging links for /shortlog.
Dan Brook [Fri, 5 Mar 2010 15:35:25 +0000 (15:35 +0000)]
lib/Gitalist.pm
lib/Gitalist/ActionRole/FilenameArgs.pm
lib/Gitalist/Git/Object/Commit.pm
lib/Gitalist/URIStructure/Fragment/WithLog.pm
root/repository/shortlog.tt2
root/wrapper.tt2

index 91992e4..53dabb1 100644 (file)
@@ -39,6 +39,21 @@ around uri_for => sub {
   return $uri;
 };
 
+around uri_for_action => sub {
+  my ($orig, $c) = (shift, shift);
+  my $uri = $c->$orig(@_);
+  $$uri =~ s[/fragment\b][] if defined $uri;
+  return $uri;
+};
+
+sub uri_with {
+  my ($self, @args) = @_;
+  my $uri = $self->request->uri_with(@args);
+  # Wow this awful.
+  $uri =~ s[/fragment\b][];
+  return $uri;  
+}
+
 1;
 
 __END__
index 3283aa2..1401cfd 100644 (file)
@@ -6,7 +6,8 @@ requires 'execute';
 
 before 'execute' => sub {
     my ($self, $controller, $c, @args) = @_;
-    $c->stash->{filename} = join('/', @args) || '';
+    $c->stash->{filename} = join('/', @args) || ''
+        unless $c->stash->{filename};
 };
 
 1;
index 921fb6b..7ac568b 100644 (file)
@@ -105,7 +105,7 @@ class Gitalist::Git::Object::Commit
                 $line{sha1}   = $line{sha1dst};
                 $line{is_new} = $line{sha1src} =~ /^0+$/
                     if $line{sha1src};
-                @line{qw/status sim/} = $line{status} =~ /(R)(\d+)/
+                @line{qw/status sim/} = $line{status} =~ /(R)0*(\d+)/
                     if $line{status} =~ /^R/;
                 push @ret, \%line;
             }
index 470f59d..ea3ae2a 100644 (file)
@@ -14,9 +14,11 @@ after log => sub {
     );
 
     my $page = $c->req->param('pg') || 0;
-    $logargs{skip} = $c->req->param('pg') * $logargs{count}
-        if $c->req->param('pg');
+    $logargs{skip} = abs $page * $logargs{count}
+        if $page;
+
     $c->stash(
+       page      => $page,
        log_lines => [$repository->list_revs(%logargs)],
        refs      => $repository->references,
     );
index 74bdbba..1a39f61 100644 (file)
@@ -1,2 +1,2 @@
 [% INCLUDE 'nav/actions.tt2' object = commit %]
-[% subinclude('/fragment/' _ c.action, c.req.captures) %]
+[% subinclude('/fragment/' _ c.action, c.req.captures, c.req.parameters) %]
index f0dc83b..b6c6c86 100644 (file)
@@ -4,14 +4,14 @@
 <head>
   <!-- git core binaries version [% git_version %] -->
   <meta charset="utf-8">
-  <meta name="generator" content="gitweb/[% version %] git/[% git_version %][% mod_perl_version %]">
+  <meta name="generator" content="gitweb/[% version %] git/[% git_version %]">
   <meta name="robots" content="index, nofollow">
   <title>[%# FIXME - MING %][%-
     title = BLOCK;
       c.config.sitename;
       IF Repository; ' - ' _ Repository.name | html; END;
-      IF c.action;  ' / ' _ c.action; END;
-      IF filename; ' - ' _ filename | html; END;
+      IF c.action;   ' / ' _ c.action; END;
+      IF filename;   ' - ' _ filename | html; END;
       IF c.action && c.action == 'tree'; '/'; END;
     END;
     title;
 
 <div id='the-container'>
 
-[% site_header %]
-
 <div id="page-header">
   <a title="git homepage" href="http://git-scm.org">
    <img src="[% c.uri_for('/logo.png') %]" alt="git" class="logo">
   </a>
-  <a href="[% c.uri_for('/') %]">A Gitalist</a>
-  [%- IF Repository %]
-  / <a href="[% c.uri_for_action('/repository/summary', [Repository.name]) %]">[% Repository.name %]</a>
-  [% 
-    INCLUDE 'nav/search.tt2';
-  END; %]
+  <div id='header-title'>
+   <a href="[% c.uri_for('/') %]">A Gitalist</a>
+   [%- IF Repository %]
+    / <a href="[% c.uri_for_action('/repository/summary', [Repository.name]) %]">[% Repository.name %]</a>
+    [%# INCLUDE 'nav/branches.tt2' %]
+   </div>
+   [% INCLUDE 'nav/search.tt2' %]
+  [% END %]
 </div>
 
 <div id='body'>
-[%
-    content;
-%]
+[% content %]
 </div>
 
 <div id="page-footer">