]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/WWW.pm
www: support listing of inboxes
[public-inbox.git] / lib / PublicInbox / WWW.pm
index 268c5b8c7de8e49872cb6333b869b5f3c3170fdb..1f3ca1574aa0c5c84c43dcc31d8797f08b6de5e6 100644 (file)
@@ -68,8 +68,9 @@ sub call {
        } split(/[&;]+/, $env->{QUERY_STRING});
        $ctx->{qp} = \%qp;
 
-       # not using $env->{PATH_INFO} here since that's already decoded
+       # avoiding $env->{PATH_INFO} here since that's already decoded
        my ($path_info) = ($env->{REQUEST_URI} =~ path_re($env));
+       $path_info //= $env->{PATH_INFO};
        my $method = $env->{REQUEST_METHOD};
 
        if ($method eq 'POST') {
@@ -87,7 +88,7 @@ sub call {
 
        # top-level indices and feeds
        if ($path_info eq '/') {
-               r404();
+               www_listing($self)->call($env);
        } 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) {
@@ -157,6 +158,7 @@ sub preload {
        if (ref($self)) {
                $self->cgit;
                $self->stylesheets_prepare($_) for ('', '../', '../../');
+               $self->www_listing;
        }
 }
 
@@ -489,6 +491,14 @@ sub cgit {
        }
 }
 
+sub www_listing {
+       my ($self) = @_;
+       $self->{www_listing} ||= do {
+               require PublicInbox::WwwListing;
+               PublicInbox::WwwListing->new($self);
+       }
+}
+
 sub get_attach {
        my ($ctx, $idx, $fn) = @_;
        require PublicInbox::WwwAttach;