]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/WwwListing.pm
wwwlisting: show configured "infourl" properly
[public-inbox.git] / lib / PublicInbox / WwwListing.pm
index e19ae8a173080160fb026e947b9cd4b2d777e85d..1faade6cd39959c581481755ccec4863092b147c 100644 (file)
@@ -16,29 +16,36 @@ require Digest::SHA;
 require File::Spec;
 *try_cat = \&PublicInbox::Inbox::try_cat;
 
+sub list_all_i {
+       my ($ibx, $arg) = @_;
+       my ($list, $hide_key) = @$arg;
+       push @$list, $ibx unless $ibx->{-hide}->{$hide_key};
+}
+
 sub list_all ($$$) {
        my ($self, $env, $hide_key) = @_;
-       my @list;
-       $self->{pi_config}->each_inbox(sub {
-               my ($ibx) = @_;
-               push @list, $ibx unless $ibx->{-hide}->{$hide_key};
-       });
-       \@list;
+       my $list = [];
+       $self->{pi_config}->each_inbox(\&list_all_i, [ $list, $hide_key ]);
+       $list;
+}
+
+sub list_match_domain_i {
+       my ($ibx, $arg) = @_;
+       my ($list, $hide_key, $re) = @$arg;
+       if (!$ibx->{-hide}->{$hide_key} && $ibx->{url} =~ $re) {
+               push @$list, $ibx;
+       }
 }
 
 sub list_match_domain ($$$) {
        my ($self, $env, $hide_key) = @_;
-       my @list;
+       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) = @_;
-               if (!$ibx->{-hide}->{$hide_key} && $ibx->{url} =~ $re) {
-                       push @list, $ibx;
-               }
-       });
-       \@list;
+       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 ($$) { [] }
@@ -82,8 +89,8 @@ sub ibx_entry {
 * $ts - $url
   ${\$ibx->description}
 
-       if (defined(my $info_url = $ibx->{info_url})) {
-               $tmp .= "\n$info_url";
+       if (defined(my $info_url = $ibx->{infourl})) {
+               $tmp .= '  ' . $info_url . "\n";
        }
        $tmp;
 }