about summary refs log tree commit homepage
path: root/lib/PublicInbox/WWW.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2019-05-05 23:28:02 +0000
committerEric Wong <e@80x24.org>2019-05-05 23:28:02 +0000
commite1ed79d1e99e2c58b3edb370e60904cf656dd823 (patch)
tree30607048c2f16a2610ad0774dcb959025357d8af /lib/PublicInbox/WWW.pm
parent632ed77815b8ad0f683abe78f32544c7ca7b9aed (diff)
parent7a3946ef122e8218c6ce3355d7f968562212d53b (diff)
downloadpublic-inbox-e1ed79d1e99e2c58b3edb370e60904cf656dd823.tar.gz
* origin/wwwlisting:
  www: support listing of inboxes
  start depending on Perl 5.10.1+
Diffstat (limited to 'lib/PublicInbox/WWW.pm')
-rw-r--r--lib/PublicInbox/WWW.pm16
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/PublicInbox/WWW.pm b/lib/PublicInbox/WWW.pm
index 6e69001c..1f3ca157 100644
--- a/lib/PublicInbox/WWW.pm
+++ b/lib/PublicInbox/WWW.pm
@@ -11,7 +11,7 @@
 # - Must not rely on static content
 # - UTF-8 is only for user-content, 7-bit US-ASCII for us
 package PublicInbox::WWW;
-use 5.008;
+use 5.010_001;
 use strict;
 use warnings;
 use bytes (); # only for bytes::length
@@ -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;