-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 $arg = [ $list, $hide_key,
- qr!\A(?:https?:)?//\Q$host\E(?::[0-9]+)?/!i ];
- $self->{pi_config}->each_inbox(\&list_match_domain_i, $arg);
- $list;
-}
-
-sub list_404 ($$) { [] }
-
-# TODO: +cgit
-my %VALID = (
- all => *list_all,
- 'match=domain' => *list_match_domain,
- 404 => *list_404,
-);
-
-sub set_cb ($$$) {
- my ($pi_config, $k, $default) = @_;
- my $v = $pi_config->{lc $k} // $default;
- $VALID{$v} || do {
- warn <<"";
-`$v' is not a valid value for `$k'
-$k be one of `all', `match=domain', or `404'
-
- $VALID{$default};
- };
-}
-
-sub new {
- my ($class, $www) = @_;
- my $pi_config = $www->{pi_config};
- bless {
- pi_config => $pi_config,
- style => $www->style("\0"),
- www_cb => set_cb($pi_config, 'publicInbox.wwwListing', 404),
- manifest_cb => set_cb($pi_config, 'publicInbox.grokManifest',
- 'match=domain'),
- }, $class;
-}
-
-sub ibx_entry {
- my ($mtime, $ibx, $env) = @_;
- my $ts = PublicInbox::View::fmt_ts($mtime);
- my $url = prurl($env, $ibx->{url});
- my $tmp = <<"";
-* $ts - $url
- ${\$ibx->description}
-
- if (defined(my $info_url = $ibx->{infourl})) {
- $tmp .= ' ' . prurl($env, $info_url) . "\n";
+sub list_match_i { # ConfigIter callback
+ my ($cfg, $section, $re, $ctx) = @_;
+ 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);
+ }
+ } else { # undef == "EOF"
+ $ctx->{-wcb}->($ctx->psgi_triple);