{url});
- my $tmp = <<"";
-* $ts - $url
- ${\$ibx->description}
+sub hide_key { 'www' }
- if (defined(my $info_url = $ibx->{info_url})) {
- $tmp .= "\n$info_url";
+sub response {
+ my ($class, $ctx) = @_;
+ bless $ctx, $class;
+ my $re = $ctx->url_regexp or return $ctx->psgi_triple;
+ my $iter = PublicInbox::ConfigIter->new($ctx->{www}->{pi_cfg},
+ \&list_match_i, $re, $ctx);
+ sub {
+ $ctx->{-wcb} = $_[0]; # HTTP server callback
+ $ctx->{env}->{'pi-httpd.async'} ?
+ $iter->event_step : $iter->each_section;
}
- $tmp;
}
-# not really a stand-alone PSGI app, but maybe it could be...
-sub call {
- my ($self, $env) = @_;
- my $h = [ 'Content-Type', 'text/html; charset=UTF-8' ];
- my $list = $self->{list_cb}->($self, $env);
+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' .
+ '');
my $code = 404;
- my $title = 'public-inbox';
- my $out = '';
- if (@$list) {
- # Swartzian transform since ->modified is expensive
- @$list = sort {
- $b->[0] <=> $a->[0]
- } map { [ $_->modified, $_ ] } @$list;
-
+ if (my $list = $ctx->{-list}) {
$code = 200;
- $title .= ' - listing';
- my $tmp = join("\n", map { ibx_entry(@$_, $env) } @$list);
+ # sort by ->modified
+ @$list = map { $_->[1] } sort { $b->[0] <=> $a->[0] } @$list;
+ $list = join("\n", @$list);
my $l = PublicInbox::Linkify->new;
- $l->linkify_1($tmp);
- $out = ''.$l->linkify_2(ascii_html($tmp)).'
';
+ $gzf->zmore($l->to_html($list));
+ } else {
+ $gzf->zmore('no inboxes, yet');
}
- $out = "$title" . $out;
- $out .= ''. PublicInbox::WwwStream::code_footer($env) .
- '
';
- [ $code, $h, [ $out ] ]
+ my $out = $gzf->zflush('
'.
+ PublicInbox::WwwStream::code_footer($ctx->{env}) .
+ '
');
+ $h->[3] = bytes::length($out);
+ [ $code, $h, [ $out ] ];
}
1;