about summary refs log tree commit homepage
path: root/lib/PublicInbox/WwwStream.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2016-08-12 19:52:35 +0000
committerEric Wong <e@80x24.org>2016-08-12 19:52:35 +0000
commit50c1b933afec4937ebc99e1d372cef2dc6b295c2 (patch)
tree87d96aff45da05c97ed56d8133322ef3f32d33f1 /lib/PublicInbox/WwwStream.pm
parent9a38d54754c724c5f81e8dc000bd42dbeddc39a6 (diff)
downloadpublic-inbox-50c1b933afec4937ebc99e1d372cef2dc6b295c2.tar.gz
Improve the discoverability of NNTP endpoints for users
who still know what NNTP is.

==> ~/.public-inbox/config <==
; aliases for the locally-run nntpd can be specified in
; the "publicinbox" section:
[publicinbox]
	nntpserver = nntp://ou63pmih66umazou.onion/
	nntpserver = news.public-inbox.org

	; NNTPS is not supported natively, yet,
	; but one can use haproxy or similar
	; nntpserver = nntps://news.public-inbox.invalid/

; mirrors for specific inboxes may be specified either as full
; NNTP (or NNTPS) URLs, or with the server name only if the
; newsgroup name is specfied for a local NNTP server
[publicinbox "git"]
	...
	newsgroup = inbox.a.b.c
	nntpmirror = nntp://czquwvybam4bgbro.onion/
	nntpmirror = hjrcffqmbrq6wope.onion

	; there may be a mirror on a different server with a
	; different name:
	nntpmirror = nntp://news.example.com/differently.named.group

; (And I really need to write manpages for all this...)
Diffstat (limited to 'lib/PublicInbox/WwwStream.pm')
-rw-r--r--lib/PublicInbox/WwwStream.pm11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/PublicInbox/WwwStream.pm b/lib/PublicInbox/WwwStream.pm
index 29395f40..9ed25e1d 100644
--- a/lib/PublicInbox/WwwStream.pm
+++ b/lib/PublicInbox/WwwStream.pm
@@ -72,10 +72,8 @@ sub _html_end {
         chop $http;
         my %seen = ( $http => 1 );
         my @urls = ($http);
-        my $need_tor;
         foreach my $u (@{$obj->cloneurl}) {
                 next if $seen{$u};
-                $need_tor = 1 if $u =~ m!\A[^:]+://\w+\.onion/!;
                 $seen{$u} = 1;
                 push @urls, $u =~ /\Ahttps?:/ ? qq(<a\nhref="$u">$u</a>) : $u;
         }
@@ -86,7 +84,14 @@ sub _html_end {
                         join("\n", map { "\tgit clone --mirror $_" } @urls);
         }
 
-        if ($need_tor) {
+        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>];
         }