From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 13/15] www_listing: support publicInbox.nameIsUrl
Date: Thu, 30 Nov 2023 11:41:06 +0000 [thread overview]
Message-ID: <20231130114109.2577708-14-e@80x24.org> (raw)
In-Reply-To: <20231130114109.2577708-1-e@80x24.org>
This is a convenient (and slightly memory-saving) alternative to
specifying a `publicinbox.*.url' entry for every single inbox
when using publicinbox.wwwListing.
---
Documentation/public-inbox-config.pod | 19 ++++++++++++++++++-
lib/PublicInbox/WwwListing.pm | 21 +++++++++++++--------
2 files changed, 31 insertions(+), 9 deletions(-)
diff --git a/Documentation/public-inbox-config.pod b/Documentation/public-inbox-config.pod
index d394d31f..d2017704 100644
--- a/Documentation/public-inbox-config.pod
+++ b/Documentation/public-inbox-config.pod
@@ -273,7 +273,9 @@ Default: 25
A comma-delimited list of listings to hide the inbox from.
-Valid values are currently C<www> and C<manifest>.
+Valid values are currently C<www> and C<manifest> for non-C<404>
+values of L</publicinbox.wwwListing> and L</publicinbox.grokManifest>,
+respectively
Default: none
@@ -379,6 +381,21 @@ TODO support showing cgit listing
Default: C<404>
+=item publicinbox.nameIsUrl
+
+Treat the name of the public inbox as it's unqualified URL when
+using C<publicInbox.wwwListing=all>. This is, every
+C<[publicinbox "foo"]> section implicitly sets C<publicinbox.foo.url=foo>.
+
+This is a convenient alternative to specifying
+C<publicinbox.E<lt>nameE<gt>.url> for every single inbox if
+your inbox URLs are domain-agnostic when using
+C<publicInbox.wwwListing=all>
+
+Default: false
+
+New in public-inbox 2.0.0 (PENDING).
+
=item publicinbox.grokmanifest
Controls the generation of a grokmirror-compatible gzipped JSON file
diff --git a/lib/PublicInbox/WwwListing.pm b/lib/PublicInbox/WwwListing.pm
index 21e5b8bc..e3d2e84c 100644
--- a/lib/PublicInbox/WwwListing.pm
+++ b/lib/PublicInbox/WwwListing.pm
@@ -41,10 +41,7 @@ sub list_match_i { # ConfigIter callback
if (defined($section)) {
return if $section !~ m!\Apublicinbox\.([^/]+)\z!;
my $ibx = $cfg->lookup_name($1) or return;
- if (!$ibx->{-hide}->{$ctx->hide_key} &&
- grep(/$re/, @{$ibx->{url} // []})) {
- $ctx->ibx_entry($ibx);
- }
+ $ctx->ibx_entry($ibx) unless $ctx->hide_inbox($ibx, $re);
} else { # undef == "EOF"
$ctx->{-wcb}->($ctx->psgi_triple);
}
@@ -54,13 +51,17 @@ sub url_filter {
my ($ctx, $key, $default) = @_;
$key //= 'publicInbox.wwwListing';
$default //= '404';
- my $v = $ctx->{www}->{pi_cfg}->{lc $key} // $default;
+ my $cfg = $ctx->{www}->{pi_cfg};
+ my $v = $cfg->{lc $key} // $default;
again:
if ($v eq 'match=domain') {
my $h = $ctx->{env}->{HTTP_HOST} // $ctx->{env}->{SERVER_NAME};
$h =~ s/:[0-9]+\z//;
(qr!\A(?:https?:)?//\Q$h\E(?::[0-9]+)?/!i, "url:$h");
} elsif ($v eq 'all') {
+ my $niu = $cfg->{lc 'publicinbox.nameIsUrl'};
+ defined($niu) && $cfg->git_bool($niu) and
+ $ctx->{-name_is_url} = [ '.' ];
(qr/./, undef);
} elsif ($v eq '404') {
(undef, undef);
@@ -76,6 +77,12 @@ EOF
sub hide_key { 'www' }
+sub hide_inbox {
+ my ($ctx, $ibx, $re) = @_;
+ $ibx->{-hide}->{$ctx->hide_key} ||
+ !grep(/$re/, @{$ibx->{url} // $ctx->{-name_is_url} // []})
+}
+
sub add_misc_ibx { # MiscSearch->retry_reopen callback
my ($misc, $ctx, $re, $qs) = @_;
require PublicInbox::SearchQuery;
@@ -104,15 +111,13 @@ sub add_misc_ibx { # MiscSearch->retry_reopen callback
$ctx->ibx_entry($pi_cfg->ALL // die('BUG: ->ALL expected'), {});
}
my $mset = $misc->mset($qs, $opt); # sorts by $MODIFIED (mtime)
- my $hide_key = $ctx->hide_key;
for my $mi ($mset->items) {
my $doc = $mi->get_document;
my ($eidx_key) = PublicInbox::Search::xap_terms('Q', $doc);
$eidx_key // next;
my $ibx = $pi_cfg->lookup_eidx_key($eidx_key) // next;
- next if $ibx->{-hide}->{$hide_key};
- grep(/$re/, @{$ibx->{url} // []}) or next;
+ next if $ctx->hide_inbox($ibx, $re);
$ctx->ibx_entry($ibx, $misc->doc2ibx_cache_ent($doc));
if ($r) { # for descriptions in search_nav_bot
my $pct = PublicInbox::Search::get_pct($mi);
next prev parent reply other threads:[~2023-11-30 11:41 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-30 11:40 [PATCH 00/15] various cindex fixes + speedups Eric Wong
2023-11-30 11:40 ` [PATCH 01/15] cindex: fix store_repo+repo_stored on no-op Eric Wong
2023-11-30 11:40 ` [PATCH 02/15] codesearch: allow inbox count to exceed matches Eric Wong
2023-11-30 11:40 ` [PATCH 03/15] config: reject newlines consistently in dir names Eric Wong
2023-11-30 11:40 ` [PATCH 04/15] cindex: only create {-cidx_err} field on failures Eric Wong
2023-11-30 11:40 ` [PATCH 05/15] cindex: keep batch pipe for pruning SHA-256 repos Eric Wong
2023-11-30 11:40 ` [PATCH 06/15] cindex: store extensions.objectFormat with repo data Eric Wong
2023-11-30 21:36 ` Eric Wong
2023-11-30 11:41 ` [PATCH 07/15] git: share unlinked pack checking code with gcf2 Eric Wong
2023-11-30 11:41 ` [PATCH 08/15] cindex: skip getpid guard for most OnDestroy use Eric Wong
2023-11-30 11:41 ` [PATCH 09/15] spawn: drop IO layer support from redirects Eric Wong
2023-11-30 11:41 ` [PATCH 10/15] cindex: speed up initial scan setup phase Eric Wong
2023-11-30 11:41 ` [PATCH 11/15] inbox: expire resources more aggressively Eric Wong
2023-11-30 11:41 ` [PATCH 12/15] git_async_cat: use git from "all" extindex if possible Eric Wong
2023-11-30 11:41 ` Eric Wong [this message]
2023-12-01 1:29 ` [PATCH 13/15] www_listing: support publicInbox.nameIsUrl Kyle Meyer
2023-12-01 2:01 ` [PATCH] doc: config: fix grammar for nameIsUrl Eric Wong
2023-11-30 11:41 ` [PATCH 14/15] inbox: shrink data structures for publicinbox.*.hide Eric Wong
2023-11-30 11:41 ` [PATCH 15/15] codesearch: use retry_reopen for WWW Eric Wong
2023-11-30 21:40 ` [PATCH v2] " Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://public-inbox.org/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231130114109.2577708-14-e@80x24.org \
--to=e@80x24.org \
--cc=meta@public-inbox.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).