EOM
chomp $rv;
if (defined($q->{'q'})) {
my $initial_q = $ctx->{-uxs_retried};
if (defined $initial_q) {
my $rewritten = $q->{'q'};
utf8::decode($initial_q);
utf8::decode($rewritten);
$initial_q = ascii_html($initial_q);
$rewritten = ascii_html($rewritten);
$rv .= " Warning: Initial query:\n $initial_q \n";
$rv .= " returned no results, used:\n";
$rv .= " $rewritten \n instead\n\n";
}
$rv .= 'Search results ordered by [';
if ($q->{r}) {
my $d = $q->qs_html(r => 0);
$rv .= qq{updated |relevance };
} else {
my $d = $q->qs_html(r => 1);
$rv .= qq{updated |relevance };
}
$rv .= ']';
}
$rv .= qq{ };
}
sub psgi_triple {
my ($ctx) = @_;
my $h = [ 'Content-Type', 'text/html; charset=UTF-8',
'Content-Length', undef ];
my $gzf = gzf_maybe($h, $ctx->{env});
$gzf->zmore('public-inbox listing ' .
$ctx->{www}->style('+/') .
'');
my $code = 404;
if (my $list = delete $ctx->{-list}) {
my $mset = delete $ctx->{-mset};
$code = 200;
if ($mset) { # already sorted, so search bar:
$gzf->zmore(mset_nav_top($ctx, $mset));
} else { # sort config dump by ->modified
@$list = map { $_->[1] }
sort { $b->[0] <=> $a->[0] } @$list;
}
$gzf->zmore('');
$gzf->zmore(join("\n", @$list));
$gzf->zmore(mset_footer($ctx, $mset)) if $mset;
} elsif (my $mset = delete $ctx->{-mset}) {
$gzf->zmore(mset_nav_top($ctx, $mset));
$gzf->zmore('no matching inboxes');
$gzf->zmore(mset_footer($ctx, $mset));
} else {
$gzf->zmore('no inboxes, yet');
}
my $out = $gzf->zflush(' '.
qq(This is a listing of public inboxes, see the `mirror' link of each inbox
for instructions on how to mirror all the data and code on this site.) .
' ');
$h->[3] = length($out);
[ $code, $h, [ $out ] ];
}
1;