{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,
- 'served with software from public-inbox: '
- ."$url",
+ 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;
+ if (my $middle = $self->{cb}) {
+ $middle = $middle->($nr, $self->{ctx}) and return $middle;
}
delete $self->{cb} ? _html_end($self) : undef;
}
-sub close {}
+sub oneshot {
+ my ($ctx, $code, $sref) = @_;
+ my $self = bless {
+ ctx => $ctx,
+ base_url => base_url($ctx),
+ }, __PACKAGE__;
+ my @x = (_html_top($self), $sref ? $$sref : (), _html_end($self));
+ my $len = 0;
+ $len += bytes::length($_) for @x;
+ [ $code, [
+ 'Content-Type' => 'text/html; charset=UTF-8',
+ 'Content-Length' => $len
+ ], \@x ];
+}
1;