]> Sergey Matveev's repositories - public-inbox.git/commitdiff
feed: disable navigation to previous page
authorEric Wong <e@80x24.org>
Mon, 28 Apr 2014 07:39:41 +0000 (07:39 +0000)
committerEric Wong <e@80x24.org>
Mon, 28 Apr 2014 07:53:09 +0000 (07:53 +0000)
This is unfortunately needed for scalability to long histories.
The design of git requires it to traverse full history to walk
forward in time, since commits can only record past history.

Instead, replace "prev" with a "head" link to zip us back to
the most recent page.  Users who wish to go backwards can use
browser history, which should always work on our old-fashioned
HTML pages.

lib/PublicInbox/Feed.pm

index c2f7f448f5567c25f5b1a8fc9d5b840905c4b416..8d5648edd3acd376812b4eaf34b2dd69342538b2 100644 (file)
@@ -62,7 +62,7 @@ sub generate_html_index {
 
        my @messages;
        my $git = try_git_pm($args->{git_dir});
-       my ($first, $last) = each_recent_blob($args, sub {
+       my $last = each_recent_blob($args, sub {
                my $mime = do_cat_mail($git, $_[0])
                        or return 0;
                if ($top && ($mime->header('In-Reply-To') ||
@@ -96,7 +96,7 @@ sub generate_html_index {
        });
        dump_html_line($_, 0, \@out) for $th->rootset;
 
-       my $footer = nav_footer($args->{cgi}, $first, $last);
+       my $footer = nav_footer($args->{cgi}, $last);
        $footer = "<hr /><pre>$footer</pre>" if $footer;
        $out[0] . "</pre>$footer</html>";
 }
@@ -104,21 +104,21 @@ sub generate_html_index {
 # private subs
 
 sub nav_footer {
-       my ($cgi, $first, $last) = @_;
+       my ($cgi, $last) = @_;
        $cgi or return '';
        my $old_r = $cgi->param('r');
-       my $prev = '    ';
+       my $head = '    ';
        my $next = '    ';
 
        if ($last) {
                $next = $cgi->path_info . "?r=$last";
                $next = qq!<a href="$next">next</a>!;
        }
-       if ($first && $old_r) {
-               $prev = $cgi->path_info . "?r=$first..";
-               $prev = qq!<a href="$prev">prev</a>!;
+       if ($old_r) {
+               $head = $cgi->path_info;
+               $head = qq!<a href="$head">head</a>!;
        }
-       "$prev $next";
+       "$head $next";
 }
 
 sub each_recent_blob {
@@ -131,25 +131,17 @@ sub each_recent_blob {
        my $cgi = $args->{cgi};
 
        # revision ranges may be specified
-       my $reverse;
        my $range = 'HEAD';
        my $r = $cgi->param('r') if $cgi;
-       if ($r) {
-               if ($r =~ /\A(?:$refhex\.\.)?$refhex\z/o) {
-                       $range = $r;
-               } elsif ($r =~ /\A(?:$refhex\.\.)\z/o) {
-                       $reverse = 1;
-                       $range = $r;
-               }
+       if ($r && ($r =~ /\A(?:$refhex\.\.)?$refhex\z/o)) {
+               $range = $r;
        }
 
        # get recent messages
        # we could use git log -z, but, we already know ssoma will not
        # leave us with filenames with spaces in them..
        my @cmd = qw/git log --no-notes --no-color --raw -r/;
-       push @cmd, '--reverse' if $reverse;
        push @cmd, $range;
-       my $first;
 
        my $pid = open(my $log, '-|', @cmd) or
                die('open `'.join(' ', @cmd) . " pipe failed: $!\n");
@@ -180,15 +172,13 @@ sub each_recent_blob {
                                last;
                        }
                }
-       } elsif ($reverse) {
-               unshift @commits, undef
        } else {
                push @commits, undef;
        }
 
        close $log; # we may EPIPE here
        # for pagination
-       $reverse ? ($commits[-1],$commits[0]) : ($commits[0],$commits[-1]);
+       $commits[-1];
 }
 
 # private functions below