]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/WWW.pm
isearch: emulate per-inbox search with ->ALL
[public-inbox.git] / lib / PublicInbox / WWW.pm
index 93ab3c9d82c7ee12b8139420f07dee6d2cd13396..fc208816f56b880454952b4ee2cb9b460c9bccd9 100644 (file)
@@ -29,7 +29,7 @@ our $INBOX_RE = qr!\A/([\w\-][\w\.\-]*)!;
 our $MID_RE = qr!([^/]+)!;
 our $END_RE = qr!(T/|t/|t\.mbox(?:\.gz)?|t\.atom|raw|)!;
 our $ATTACH_RE = qr!([0-9][0-9\.]*)-($PublicInbox::Hval::FN)!;
-our $OID_RE = qr![a-f0-9]{7,40}!;
+our $OID_RE = qr![a-f0-9]{7,}!;
 
 sub new {
        my ($class, $pi_config) = @_;
@@ -77,8 +77,12 @@ sub call {
        }
 
        # top-level indices and feeds
-       if ($path_info eq '/' || $path_info eq '/manifest.js.gz') {
-               www_listing($self)->call($env);
+       if ($path_info eq '/') {
+               require PublicInbox::WwwListing;
+               PublicInbox::WwwListing->response($ctx);
+       } elsif ($path_info eq '/manifest.js.gz') {
+               require PublicInbox::ManifestJsGz;
+               PublicInbox::ManifestJsGz->response($ctx);
        } elsif ($path_info =~ m!$INBOX_RE\z!o) {
                invalid_inbox($ctx, $1) || r301($ctx, $1);
        } elsif ($path_info =~ m!$INBOX_RE(?:/|/index\.html)?\z!o) {
@@ -171,7 +175,6 @@ sub preload {
                }
                $self->cgit;
                $self->stylesheets_prepare($_) for ('', '../', '../../');
-               $self->www_listing;
                $self->news_www;
                $pi_config->each_inbox(\&preload_inbox);
        }
@@ -207,7 +210,8 @@ sub news_cgit_fallback ($) {
 # returns undef if valid, array ref response if invalid
 sub invalid_inbox ($$) {
        my ($ctx, $inbox) = @_;
-       my $ibx = $ctx->{www}->{pi_config}->lookup_name($inbox);
+       my $ibx = $ctx->{www}->{pi_config}->lookup_name($inbox) //
+                       $ctx->{www}->{pi_config}->lookup_ei($inbox);
        if (defined $ibx) {
                $ctx->{-inbox} = $ibx;
                return;
@@ -458,7 +462,7 @@ sub serve_git {
 sub mbox_results {
        my ($ctx) = @_;
        if ($ctx->{env}->{QUERY_STRING} =~ /(?:\A|[&;])q=/) {
-               $ctx->{-inbox}->search or return need($ctx, 'search');
+               $ctx->{-inbox}->isrch or return need($ctx, 'search');
                require PublicInbox::SearchView;
                return PublicInbox::SearchView::mbox_results($ctx);
        }
@@ -496,21 +500,13 @@ sub cgit {
        }
 }
 
-sub www_listing {
-       my ($self) = @_;
-       $self->{www_listing} ||= do {
-               require PublicInbox::WwwListing;
-               PublicInbox::WwwListing->new($self);
-       }
-}
-
 # GET $INBOX/manifest.js.gz
 sub get_inbox_manifest ($$$) {
        my ($ctx, $inbox, $key) = @_;
        my $r404 = invalid_inbox($ctx, $inbox);
        return $r404 if $r404;
        require PublicInbox::ManifestJsGz;
-       PublicInbox::ManifestJsGz::response($ctx->{env}, [$ctx->{-inbox}]);
+       PublicInbox::ManifestJsGz->response($ctx);
 }
 
 sub get_attach {