]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/WWW.pm
WWW: eliminate "top" parameter for feeds
[public-inbox.git] / lib / PublicInbox / WWW.pm
index 7fe9b85be77dd02f22552e2f8199fd13ca7317d0..7cbfa355d238947d7726b6bff7154f614236e764 100644 (file)
@@ -35,9 +35,9 @@ sub run {
        } elsif ($path_info =~ m!$LISTNAME_RE\z!o) {
                invalid_list(\%ctx, $1) || redirect_list_index(\%ctx, $cgi);
        } elsif ($path_info =~ m!$LISTNAME_RE(?:/|/index\.html)?\z!o) {
-               invalid_list(\%ctx, $1) || get_index(\%ctx, $cgi, 0);
+               invalid_list(\%ctx, $1) || get_index(\%ctx, $cgi);
        } elsif ($path_info =~ m!$LISTNAME_RE/atom\.xml\z!o) {
-               invalid_list(\%ctx, $1) || get_atom(\%ctx, $cgi, 0);
+               invalid_list(\%ctx, $1) || get_atom(\%ctx, $cgi);
 
        # single-message pages
        } elsif ($path_info =~ m!$LISTNAME_RE/m/(\S+)\.txt\z!o) {
@@ -109,7 +109,7 @@ sub invalid_list_mid {
 
 # /$LISTNAME/atom.xml                       -> Atom feed, includes replies
 sub get_atom {
-       my ($ctx, $cgi, $top) = @_;
+       my ($ctx, $cgi) = @_;
        require PublicInbox::Feed;
        [ 200, [ 'Content-Type' => 'application/xml' ],
          [ PublicInbox::Feed->generate({
@@ -117,23 +117,23 @@ sub get_atom {
                        listname => $ctx->{listname},
                        pi_config => $pi_config,
                        cgi => $cgi,
-                       top => $top,
                }) ]
        ];
 }
 
 # /$LISTNAME/?r=$GIT_COMMIT                 -> HTML only
 sub get_index {
-       my ($ctx, $cgi, $top) = @_;
+       my ($ctx, $cgi) = @_;
        require PublicInbox::Feed;
+       my $srch = searcher($ctx);
        [ 200, [ 'Content-Type' => 'text/html; charset=UTF-8' ],
          [ PublicInbox::Feed->generate_html_index({
+                       srch => $srch,
                        git_dir => $ctx->{git_dir},
                        listname => $ctx->{listname},
                        pi_config => $pi_config,
                        cgi => $cgi,
                        footer => footer($ctx),
-                       top => $top,
                }) ]
        ];
 }
@@ -141,19 +141,10 @@ sub get_index {
 # just returns a string ref for the blob in the current ctx
 sub mid2blob {
        my ($ctx) = @_;
-       my $hex = $ctx->{mid};
-       my ($x2, $x38) = ($hex =~ /\A([a-f0-9]{2})([a-f0-9]{38})\z/);
-
-       unless (defined $x38) {
-               # compatibility with old links
-               require Digest::SHA;
-               $hex = Digest::SHA::sha1_hex($hex);
-               ($x2, $x38) = ($hex =~ /\A([a-f0-9]{2})([a-f0-9]{38})\z/);
-               defined $x38 or die "BUG: not a SHA-1 hex: $hex";
-       }
-
+       require PublicInbox::MID;
+       my $path = PublicInbox::MID::mid2path($ctx->{mid});
        my @cmd = ('git', "--git-dir=$ctx->{git_dir}",
-                       qw(cat-file blob), "HEAD:$x2/$x38");
+                       qw(cat-file blob), "HEAD:$path");
        my $cmd = join(' ', @cmd);
        my $pid = open my $fh, '-|';
        defined $pid or die "fork failed: $!\n";