use warnings;
use PublicInbox::Hval qw(ascii_html);
use URI;
-use constant PI_URL => 'https://public-inbox.org/';
+our $TOR_URL = 'https://www.torproject.org/';
+our $TOR2WEB_URL = 'https://www.tor2web.org/';
+our $CODE_URL = 'https://public-inbox.org/';
+our $PROJECT = 'public-inbox';
+# noop for HTTP.pm (and any other PSGI servers)
sub close {}
sub new {
my $desc = ascii_html($obj->description);
my $title = $ctx->{-title_html} || $desc;
my $upfx = $ctx->{-upfx} || '';
+ my $help = $upfx.'_/text/help';
my $atom = $ctx->{-atom} || $upfx.'new.atom';
my $tip = $ctx->{-html_tip} || '';
- my $top = "<b>$desc</b> (<a\nhref=\"$atom\">Atom feed</a>)";
+ my $top = "<b>$desc</b>";
+ my $links = "<a\nhref=\"$help\">help</a> / ".
+ "<a\nhref=\"$atom\">Atom feed</a>";
if ($obj->search) {
my $q_val = $ctx->{-q_value_html};
if (defined $q_val && $q_val ne '') {
- $q_val = qq(\nvalue="$q_val" );
+ $q_val = qq(\nvalue="$q_val");
} else {
$q_val = '';
}
my $extra = $ctx->{-extra_form_html} || '';
my $action = $upfx eq '' ? './' : $upfx;
$top = qq{<form\naction="$action"><pre>$top} .
- qq{ <input\nname=q\ntype=text$q_val/>} .
+ qq{\n<input\nname=q\ntype=text$q_val />} .
$extra .
qq{<input\ntype=submit\nvalue=search />} .
+ ' ' . $links .
q{</pre></form>}
} else {
- $top = '<pre>' . $top . '</pre>';
+ $top = '<pre>' . $top . "\n" . $links . '</pre>';
}
"<html><head><title>$title</title>" .
"<link\nrel=alternate\ntitle=\"Atom feed\"\n".
$urls .= "\n" .
join("\n", map { "\tgit clone --mirror $_" } @urls);
}
- my $url = PublicInbox::Hval::prurl($ctx->{env}, PI_URL);
- '<pre>'.join("\n",
- '- ' . $desc,
+
+ my @nntp = map { qq(<a\nhref="$_">$_</a>) } @{$obj->nntp_url};
+ if (@nntp) {
+ $urls .= "\n\n";
+ $urls .= @nntp == 1 ? 'Newsgroup' : 'Newsgroups are';
+ $urls .= ' available over NNTP:';
+ $urls .= "\n\t" . join("\n\t", @nntp) . "\n";
+ }
+ if ($urls =~ m!\b[^:]+://\w+\.onion/!) {
+ $urls .= "\n note: .onion URLs require Tor: ";
+ $urls .= qq[<a\nhref="$TOR_URL">$TOR_URL</a>];
+ if ($TOR2WEB_URL) {
+ $urls .= "\n or Tor2web: ";
+ $urls .= qq[<a\nhref="$TOR2WEB_URL">$TOR2WEB_URL</a>];
+ }
+ }
+ my $url = PublicInbox::Hval::prurl($ctx->{env}, $CODE_URL);
+ '<hr><pre>'.join("\n\n",
+ $desc,
$urls,
- 'Served with public-inbox: '.
- qq(git clone <a\nhref="$url">$url</a> public-inbox),
+ 'AGPL code for this site: '.
+ qq(git clone <a\nhref="$url">$url</a> $PROJECT)
).'</pre></body></html>';
}
+# 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;