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 <konstantin@linuxfoundation.org>
Link: https://public-inbox.org/meta/20210816163654.c6gfzuezhji4l6s7@nitro.local/
our @EXPORT_OK = qw(html_oneshot);
use PublicInbox::Hval qw(ascii_html prurl ts2str);
our $TOR_URL = 'https://www.torproject.org/';
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;
sub base_url ($) {
my $ctx = shift;
sub code_footer ($) {
my ($env) = @_;
my $u = prurl($env, $CODE_URL);
sub code_footer ($) {
my ($env) = @_;
my $u = prurl($env, $CODE_URL);
- qq(AGPL code for this site: git clone <a\nhref="$u">$u</a>)
+ 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 <a\nhref="$u">$arg</a>)
+ } else {
+ qq(AGPL code for this site: git clone <a\nhref="$u">$u</a>)
+ }
my $max = $ibx->max_git_epoch;
my $dir = (split(m!/!, $http))[-1];
my %seen = ($http => 1);
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:
if (defined($max)) { # v2
for my $i (0..$max) {
# old epochs my be deleted: