{name} $dir/ $http \\
+ $addrs
+ public-inbox-index $dir
+EOF
+ } else { # v1
+ $urls .= "\n";
+ }
+
+ my $cfg_link = ($ctx->{-upfx} // '').'_/text/config/raw';
+ $urls .= qq(\nExample config snippet for mirrors\n);
+ my @nntp = map { qq($_) } @{$ibx->nntp_url};
+ if (@nntp) {
+ $urls .= "\n";
+ $urls .= @nntp == 1 ? 'Newsgroup' : 'Newsgroups are';
+ $urls .= ' available over NNTP:';
+ $urls .= "\n\t" . join("\n\t", @nntp) . "\n";
}
- my $url = PublicInbox::Hval::prurl($ctx->{env}, PI_URL);
- ''.join("\n",
- '- ' . $desc,
+ if ($urls =~ m!\b[^:]+://\w+\.onion/!) {
+ $urls .= "\n note: .onion URLs require Tor: ";
+ $urls .= qq[$TOR_URL];
+ }
+ '
'.join("\n\n",
+ $desc,
$urls,
- 'Archived served using code from public-inbox:',
- "\tgit clone $url public-inbox",
+ code_footer($ctx->{env})
).'
';
}
+# callback for HTTP.pm (and any other PSGI servers)
sub getline {
- my ($self) = @_;
- my $nr = $self->{nr}++;
-
- return _html_top($self) if $nr == 0;
-
- if (my $mid = $self->{cb}) { # middle
- $mid = $mid->($nr, $self->{ctx}) and return $mid;
+ my ($ctx) = @_;
+ my $cb = $ctx->{cb} or return;
+ if (defined(my $buf = $cb->($ctx))) {
+ return $ctx->translate($buf);
}
-
- delete $self->{cb} ? _html_end($self) : undef;
+ delete $ctx->{cb};
+ $ctx->zflush(_html_end($ctx));
}
-sub close {}
+sub html_oneshot ($$;$) {
+ my ($ctx, $code, $sref) = @_;
+ $ctx->{base_url} = base_url($ctx);
+ bless $ctx, __PACKAGE__;
+ my @bdy;
+ my $res_hdr = [ 'Content-Type' => 'text/html; charset=UTF-8',
+ 'Content-Length' => undef ];
+ $ctx->{gz} = PublicInbox::GzipFilter::gz_or_noop($res_hdr, $ctx->{env});
+ $ctx->zmore(html_top($ctx));
+ $ctx->zmore($$sref) if $sref;
+ $bdy[0] = $ctx->zflush(_html_end($ctx));
+ $res_hdr->[3] = bytes::length($bdy[0]);
+ [ $code, $res_hdr, \@bdy ]
+}
1;