+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 {
- manifest_add($manifest, $ibx);
+ my $d = $q->qs_html(r => 1);
+ $rv .= qq{updated |relevance };
}
+ $rv .= ']';
}
- my $abs2urlpath = delete $manifest->{-abs2urlpath};
- my $mtime = delete $manifest->{-mtime};
- while (my ($url_path, $repo) = each %$manifest) {
- defined(my $abs = $repo->{reference}) or next;
- $repo->{reference} = $abs2urlpath->{$abs};
- }
- my $out;
- IO::Compress::Gzip::gzip(\(($json ||= _json())->encode($manifest)) =>
- \$out);
- $manifest = undef;
- [ 200, [ qw(Content-Type application/gzip),
- 'Last-Modified', time2str($mtime),
- 'Content-Length', bytes::length($out) ], [ $out ] ];
+ $rv .= qq{ };
}
-# not really a stand-alone PSGI app, but maybe it could be...
-sub call {
- my ($self, $env) = @_;
-
- if ($env->{PATH_INFO} eq '/manifest.js.gz') {
- # grokmirror uses relative paths, so it's domain-dependent
- my $list = $self->{manifest_cb}->($self, $env, 'manifest');
- js($env, $list);
- } else { # /
- my $list = $self->{www_cb}->($self, $env, 'www');
- html($env, $list);
+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;