From f119d4315be998de65d5a1b56fa643fb9084410b Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Fri, 17 Jan 2020 15:21:42 +0000 Subject: [PATCH 5/5] wwwstream: make source info configurable --- Documentation/public-inbox-config.pod | 6 ++++++ lib/PublicInbox/WwwListing.pm | 9 +++++---- lib/PublicInbox/WwwStream.pm | 28 +++++++++++++++++++++++---- 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/Documentation/public-inbox-config.pod b/Documentation/public-inbox-config.pod index 1c5ba015..5ae23924 100644 --- a/Documentation/public-inbox-config.pod +++ b/Documentation/public-inbox-config.pod @@ -186,6 +186,12 @@ and the path may be "/dev/null" or any empty file. Multiple files may be specified and will be included in the order specified. +=item publicinbox.sourceinfo + +Path to a file containing HTML instructions for downloading the +public-inbox source code. Useful for AGPL compliance. If not +specified, default git clone instructions are used. + =item publicinboxmda.spamcheck This may be set to C to disable the use of SpamAssassin diff --git a/lib/PublicInbox/WwwListing.pm b/lib/PublicInbox/WwwListing.pm index 03534f03..f1a1fd81 100644 --- a/lib/PublicInbox/WwwListing.pm +++ b/lib/PublicInbox/WwwListing.pm @@ -87,8 +87,8 @@ sub ibx_entry { $tmp; } -sub html ($$) { - my ($env, $list) = @_; +sub html ($$$) { + my ($pi_config, $env, $list) = @_; my $title = 'public-inbox'; my $out = ''; my $code = 404; @@ -107,7 +107,8 @@ sub html ($$) { $out = '
'.$l->linkify_2(ascii_html($tmp)).'

'; } $out = "$title" . $out; - $out .= '
'. PublicInbox::WwwStream::code_footer($env) .
+	$out .= '
' .
+	        PublicInbox::WwwStream::code_footer($pi_config, $env) .
 		'
'; my $h = [ 'Content-Type', 'text/html; charset=UTF-8' ]; @@ -231,7 +232,7 @@ sub call { js($env, $list); } else { # / my $list = $self->{www_cb}->($self, $env, 'www'); - html($env, $list); + html($self->{pi_config}, $env, $list); } } diff --git a/lib/PublicInbox/WwwStream.pm b/lib/PublicInbox/WwwStream.pm index 0f4f55d0..09473c9f 100644 --- a/lib/PublicInbox/WwwStream.pm +++ b/lib/PublicInbox/WwwStream.pm @@ -76,10 +76,30 @@ sub _html_top ($) { "". $top . $tip; } -sub code_footer ($) { - my ($env) = @_; +sub get_user_source_info ($) { + my ($pi_config) = @_; + + local $/; + my $path = $pi_config->{'publicinbox.sourceinfo'}; + if (!defined($path)) { + return; + } + open my $fh, '<', $path or do { + warn "Failed to open publicinbox.sourceinfo=$path: $!\n"; + return; + }; + <$fh>; +} + +sub code_footer { + my ($pi_config, $env) = @_; + my $u = PublicInbox::Hval::prurl($env, $CODE_URL); - qq(AGPL code for this site: git clone $u) + my $default_info = qq(git clone $u); + + my $info = get_user_source_info($pi_config) || $default_info; + + "AGPL code for this site: $info" } sub _html_end { @@ -153,7 +173,7 @@ EOF '
'.join("\n\n",
 		$desc,
 		$urls,
-		code_footer($ctx->{env})
+		code_footer($ctx->{www}->{pi_config}, $ctx->{env})
 	).'
'; } -- 2.26.1