about summary refs log tree commit homepage
path: root/lib/PublicInbox/WwwListing.pm
diff options
context:
space:
mode:
authorEric Wong (Contractor, The Linux Foundation) <e@80x24.org>2019-06-09 04:31:02 +0000
committerEric Wong <e@80x24.org>2019-06-09 04:32:31 +0000
commit3e0e596105198cfad0eaf3e15f69a21c6bc9ffe1 (patch)
tree0e30b04c5345744f0fe9a5925a4648258fa9bfbc /lib/PublicInbox/WwwListing.pm
parent5a4caaca8f52799844d0baf93b8c2595edb04f2b (diff)
downloadpublic-inbox-3e0e596105198cfad0eaf3e15f69a21c6bc9ffe1.tar.gz
Since we already have a mechanism for hiding repositories from
the WWW listing, we might as well support another one for hiding
repositories from the upcoming manifest.js.gz generation.
Diffstat (limited to 'lib/PublicInbox/WwwListing.pm')
-rw-r--r--lib/PublicInbox/WwwListing.pm20
1 files changed, 13 insertions, 7 deletions
diff --git a/lib/PublicInbox/WwwListing.pm b/lib/PublicInbox/WwwListing.pm
index e1473b3d..6d6d3015 100644
--- a/lib/PublicInbox/WwwListing.pm
+++ b/lib/PublicInbox/WwwListing.pm
@@ -10,25 +10,27 @@ use PublicInbox::Hval qw(ascii_html);
 use PublicInbox::Linkify;
 use PublicInbox::View;
 
-sub list_all ($$) {
-        my ($self, undef) = @_;
+sub list_all ($$$) {
+        my ($self, $env, $hide_key) = @_;
         my @list;
         $self->{pi_config}->each_inbox(sub {
                 my ($ibx) = @_;
-                push @list, $ibx unless $ibx->{-hide}->{www};
+                push @list, $ibx unless $ibx->{-hide}->{$hide_key};
         });
         \@list;
 }
 
-sub list_match_domain ($$) {
-        my ($self, $env) = @_;
+sub list_match_domain ($$$) {
+        my ($self, $env, $hide_key) = @_;
         my @list;
         my $host = $env->{HTTP_HOST} // $env->{SERVER_NAME};
         $host =~ s/:[0-9]+\z//;
         my $re = qr!\A(?:https?:)?//\Q$host\E(?::[0-9]+)?/!i;
         $self->{pi_config}->each_inbox(sub {
                 my ($ibx) = @_;
-                push @list, $ibx if !$ibx->{-hide}->{www} && $ibx->{url} =~ $re;
+                if (!$ibx->{-hide}->{$hide_key} && $ibx->{url} =~ $re) {
+                        push @list, $ibx;
+                }
         });
         \@list;
 }
@@ -78,7 +80,11 @@ sub ibx_entry {
 sub call {
         my ($self, $env) = @_;
         my $h = [ 'Content-Type', 'text/html; charset=UTF-8' ];
-        my $list = $self->{list_cb}->($self, $env);
+        my $hide_key = 'www';
+        if ($env->{PATH_INFO} =~ m!/manifest\.js(?:\.gz)\z/!) {
+                $hide_key = 'manifest';
+        }
+        my $list = $self->{list_cb}->($self, $env, $hide_key);
         my $code = 404;
         my $title = 'public-inbox';
         my $out = '';