mirroring instructions on how to clone and mirror
all data and code used by this external index.
EOF
}
chomp $x;
'
'.join("\n\n", coderepos($ctx), $x).'
'
}
# callback for HTTP.pm (and any other PSGI servers)
sub getline {
my ($ctx) = @_;
my $cb = $ctx->{cb} or return;
while (defined(my $x = $cb->($ctx))) { # x = smsg or scalar non-ref
if (ref($x)) { # smsg
my $eml = $ctx->{ibx}->smsg_eml($x) or next;
$ctx->{smsg} = $x;
return $ctx->translate($cb->($ctx, $eml));
} else { # scalar
return $ctx->translate($x);
}
}
delete $ctx->{cb};
$ctx->zflush(_html_end($ctx));
}
sub html_oneshot ($$;$) {
my ($ctx, $code, $sref) = @_;
my $res_hdr = [ 'Content-Type' => 'text/html; charset=UTF-8',
'Content-Length' => undef ];
bless $ctx, __PACKAGE__;
$ctx->{gz} = PublicInbox::GzipFilter::gz_or_noop($res_hdr, $ctx->{env});
$ctx->{base_url} // do {
$ctx->zmore(html_top($ctx));
$ctx->{base_url} = base_url($ctx);
};
$ctx->zmore($$sref) if $sref;
my $bdy = $ctx->zflush(_html_end($ctx));
$res_hdr->[3] = length($bdy);
[ $code, $res_hdr, [ $bdy ] ]
}
sub async_next ($) {
my ($http) = @_; # PublicInbox::HTTP
my $ctx = $http->{forward} or return;
eval {
if (my $smsg = $ctx->{smsg} = $ctx->{cb}->($ctx)) {
$ctx->smsg_blob($smsg);
} else {
$ctx->write(_html_end($ctx));
$ctx->close; # GzipFilter->close
}
};
warn "E: $@" if $@;
}
sub aresponse {
my ($ctx, $code, $cb) = @_;
my $res_hdr = [ 'Content-Type' => 'text/html; charset=UTF-8' ];
init($ctx, $cb);
$ctx->psgi_response($code, $res_hdr);
}
1;