about summary refs log tree commit homepage
path: root/lib/PublicInbox/WwwStream.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2016-07-21 01:50:01 +0000
committerEric Wong <e@80x24.org>2016-07-21 01:56:36 +0000
commitaed2002eec05e5c51d6cac8775866667d6518361 (patch)
treec0749878edaab069b114d71ed936cf3e0464b34b /lib/PublicInbox/WwwStream.pm
parentd42aa8d31212060e107951a64045ab0796d6a56c (diff)
downloadpublic-inbox-aed2002eec05e5c51d6cac8775866667d6518361.tar.gz
Not everybody knows what .onion URLs are, so refer them to Tor.
Diffstat (limited to 'lib/PublicInbox/WwwStream.pm')
-rw-r--r--lib/PublicInbox/WwwStream.pm14
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/PublicInbox/WwwStream.pm b/lib/PublicInbox/WwwStream.pm
index bdc8048d..de457b48 100644
--- a/lib/PublicInbox/WwwStream.pm
+++ b/lib/PublicInbox/WwwStream.pm
@@ -8,6 +8,7 @@ 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/';
 
 sub close {}
 
@@ -68,8 +69,10 @@ 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;
         }
@@ -79,12 +82,17 @@ sub _html_end {
                 $urls .= "\n" .
                         join("\n", map { "\tgit clone --mirror $_" } @urls);
         }
+
+        if ($need_tor) {
+                $urls .= "\n note: .onion URLs require Tor: ";
+                $urls .= qq[<a\nhref="$TOR_URL">$TOR_URL</a>];
+        }
         my $url = PublicInbox::Hval::prurl($ctx->{env}, PI_URL);
-        '<hr><pre>'.join("\n",
-                '- ' . $desc,
+        '<hr><pre>'.join("\n\n",
+                $desc,
                 $urls,
                 'Served with public-inbox: '.
-                qq(git clone <a\nhref="$url">$url</a> public-inbox),
+                qq(git clone <a\nhref="$url">$url</a> public-inbox)
         ).'</pre></body></html>';
 }