From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 0AF401F9F3; Thu, 26 Aug 2021 12:33:39 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Cc: Konstantin Ryabitsev Subject: [PATCH 3/8] www_stream: sh-friendly .onion URLs wrapping Date: Thu, 26 Aug 2021 12:33:33 +0000 Message-Id: <20210826123338.694-4-e@80x24.org> In-Reply-To: <20210826123338.694-1-e@80x24.org> References: <20210826123338.694-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: The long v3 .onion URL was causing havoc on small mobile displays, so extract "hostname" into a variable which can still used as a Bourne shell snippet. While we're at it, include "torsocks" in the git command used for .onion URLs since that's the (near)-universal wrapper for Tor-ifying things (like git) which are dynamically linked to libc. Cc: Konstantin Ryabitsev Link: https://public-inbox.org/meta/20210816163654.c6gfzuezhji4l6s7@nitro.local/ --- lib/PublicInbox/WwwStream.pm | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/PublicInbox/WwwStream.pm b/lib/PublicInbox/WwwStream.pm index adcb5fe2..57c23690 100644 --- a/lib/PublicInbox/WwwStream.pm +++ b/lib/PublicInbox/WwwStream.pm @@ -12,8 +12,10 @@ use parent qw(Exporter PublicInbox::GzipFilter); our @EXPORT_OK = qw(html_oneshot); use PublicInbox::Hval qw(ascii_html prurl ts2str); our $TOR_URL = 'https://www.torproject.org/'; -our $CODE_URL = [ qw(http://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/public-inbox.git - https://public-inbox.org/public-inbox.git) ]; + +our $CODE_URL = [ qw( +http://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/public-inbox.git +https://public-inbox.org/public-inbox.git) ]; sub base_url ($) { my $ctx = shift; @@ -107,7 +109,13 @@ EOF sub code_footer ($) { my ($env) = @_; my $u = prurl($env, $CODE_URL); - qq(AGPL code for this site: git clone $u) + my $arg = $u; + if ($arg =~ s!\A(https?://)([^/\.]+)\.onion/!$1\$hostname\.onion/!i) { + "AGPL code for this site:\n\thostname=$2\n\t" . + qq(torsocks git clone $arg) + } else { + qq(AGPL code for this site: git clone $u) + } } sub _html_end { @@ -125,6 +133,9 @@ EOF my $max = $ibx->max_git_epoch; my $dir = (split(m!/!, $http))[-1]; my %seen = ($http => 1); + # TODO: some of these URLs may be too long and we may need to + # do something like code_footer() above, but these are local + # admin-defined if (defined($max)) { # v2 for my $i (0..$max) { # old epochs my be deleted: