From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 1EDB21F609 for ; Sun, 9 Jun 2019 04:31:06 +0000 (UTC) From: "Eric Wong (Contractor, The Linux Foundation)" To: meta@public-inbox.org Subject: [PATCH 1/4] wwwlisting: allow hiding entries from manifest Date: Sun, 9 Jun 2019 04:31:02 +0000 Message-Id: <20190609043105.22338-2-e@80x24.org> In-Reply-To: <20190609043105.22338-1-e@80x24.org> References: <20190609043105.22338-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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. --- lib/PublicInbox/WwwListing.pm | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/lib/PublicInbox/WwwListing.pm b/lib/PublicInbox/WwwListing.pm index e1473b3..6d6d301 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 = ''; -- EW