X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FWwwStream.pm;h=12f5fa571ec27d57eb8a11859ce944df8deb067f;hb=58d16a4870defada082e0d5c4b9d24347d37c7be;hp=285416d5df75b8f5c42a4cb9d79257fd71149578;hpb=bfd60ef4c2eff566481f1e40b18b7c3d1b3e43fa;p=public-inbox.git diff --git a/lib/PublicInbox/WwwStream.pm b/lib/PublicInbox/WwwStream.pm index 285416d5..12f5fa57 100644 --- a/lib/PublicInbox/WwwStream.pm +++ b/lib/PublicInbox/WwwStream.pm @@ -7,11 +7,16 @@ use strict; 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'; + +sub close {} sub new { my ($class, $ctx, $cb) = @_; - bless { nr => 0, cb => $cb, ctx => $ctx }, $class; + bless { nr => 0, cb => $cb || *close, ctx => $ctx }, $class; } sub response { @@ -27,13 +32,16 @@ sub _html_top ($) { 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 = "$desc (Atom feed)"; + my $top = "$desc"; + my $links = "help / ". + "Atom feed"; 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 = ''; } @@ -41,12 +49,13 @@ sub _html_top ($) { my $extra = $ctx->{-extra_form_html} || ''; my $action = $upfx eq '' ? './' : $upfx; $top = qq{
} } else { - $top = '' . $top . ''; + $top = '
' . $top . "\n" . $links . ''; } "
'.join("\n", - '- ' . $desc, + + my @nntp = map { qq($_) } @{$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[$TOR_URL]; + if ($TOR2WEB_URL) { + $urls .= "\n or Tor2web: "; + $urls .= qq[$TOR2WEB_URL]; + } + } + my $url = PublicInbox::Hval::prurl($ctx->{env}, $CODE_URL); + ''.join("\n\n", + $desc, $urls, - 'Served with public-inbox: '. - qq(git clone $url public-inbox), + 'AGPL code for this site: '. + qq(git clone $url $PROJECT) ).''; } @@ -99,6 +124,4 @@ sub getline { delete $self->{cb} ? _html_end($self) : undef; } -sub close {} - 1;