about summary refs log tree commit diff
path: root/overlays/patches/public-inbox/0005-wwwstream-make-source-info-configurable.patch
diff options
context:
space:
mode:
Diffstat (limited to 'overlays/patches/public-inbox/0005-wwwstream-make-source-info-configurable.patch')
-rw-r--r--overlays/patches/public-inbox/0005-wwwstream-make-source-info-configurable.patch112
1 files changed, 112 insertions, 0 deletions
diff --git a/overlays/patches/public-inbox/0005-wwwstream-make-source-info-configurable.patch b/overlays/patches/public-inbox/0005-wwwstream-make-source-info-configurable.patch
new file mode 100644
index 000000000000..605100cd38ae
--- /dev/null
+++ b/overlays/patches/public-inbox/0005-wwwstream-make-source-info-configurable.patch
@@ -0,0 +1,112 @@
+From f119d4315be998de65d5a1b56fa643fb9084410b Mon Sep 17 00:00:00 2001
+From: Alyssa Ross <hi@alyssa.is>
+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<none> 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 = '<pre>'.$l->linkify_2(ascii_html($tmp)).'</pre><hr>';
+ 	}
+ 	$out = "<html><head><title>$title</title></head><body>" . $out;
+-	$out .= '<pre>'. PublicInbox::WwwStream::code_footer($env) .
++	$out .= '<pre>' .
++	        PublicInbox::WwwStream::code_footer($pi_config, $env) .
+ 		'</pre></body></html>';
+ 
+ 	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 ($) {
+ 		"</head><body>". $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 <a\nhref="$u">$u</a>)
++	my $default_info = qq(git clone <a\n href="$u">$u</a>);
++
++	my $info = get_user_source_info($pi_config) || $default_info;
++
++	"AGPL code for this site: $info"
+ }
+ 
+ sub _html_end {
+@@ -153,7 +173,7 @@ EOF
+ 	'<hr><pre>'.join("\n\n",
+ 		$desc,
+ 		$urls,
+-		code_footer($ctx->{env})
++		code_footer($ctx->{www}->{pi_config}, $ctx->{env})
+ 	).'</pre></body></html>';
+ }
+ 
+-- 
+2.26.1
+