From: Eric Wong <e@80x24.org>
Date: Mon, 29 Aug 2022 09:26:41 +0000 (+0000)
Subject: www: atom: fix "changed" href to nowhere
X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=6320f9f813443cdd14476f723deb022e2dfff9c4;p=public-inbox.git

www: atom: fix "changed" href to nowhere

The HTML generated for the Atom feed doesn't have the footer
of /T/ and /t/ HTML-only views, so just make "changed" in
the diffstat go directly to the permalink #related anchor.

Fixes: 66512e177390 ("view: generate query in single-message and commit views")
---

diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index 354cdd93..86f4a467 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -248,7 +248,7 @@ sub eml_entry {
 
 	# scan through all parts, looking for displayable text
 	$ctx->{mhref} = $mhref;
-	$ctx->{end_id} = "e$id";
+	$ctx->{changed_href} = "#e$id"; # for diffstat "files? changed,"
 	$ctx->{obuf} = \$rv;
 	$eml->each_part(\&add_text_body, $ctx, 1);
 	delete $ctx->{obuf};
diff --git a/lib/PublicInbox/ViewDiff.pm b/lib/PublicInbox/ViewDiff.pm
index ee2d688c..8c1853e6 100644
--- a/lib/PublicInbox/ViewDiff.pm
+++ b/lib/PublicInbox/ViewDiff.pm
@@ -180,8 +180,8 @@ sub diff_before_or_after ($$) {
 			$$dst .= $linkify->to_html($l);
 		}
 		$$dst .= $x[2]; # $3 /^ \d+ files? /
-		my $end = $ctx->{end_id} // 'related';
-		$$dst .= "<a href=#$end>changed</a>,";
+		my $ch = $ctx->{changed_href} // '#related';
+		$$dst .= qq(<a href="$ch">changed</a>,);
 		$$dst .= ascii_html($x[1]); # $4: insertions/deletions
 		$$dst .= $linkify->to_html($x[0]); # notes, commit message, etc
 	} else {
diff --git a/lib/PublicInbox/WwwAtomStream.pm b/lib/PublicInbox/WwwAtomStream.pm
index 7b7047ac..09b6facb 100644
--- a/lib/PublicInbox/WwwAtomStream.pm
+++ b/lib/PublicInbox/WwwAtomStream.pm
@@ -156,6 +156,7 @@ sub feed_entry {
 		qq(<pre\nstyle="white-space:pre-wrap">);
 	$ctx->{obuf} = \$s;
 	$ctx->{mhref} = $href;
+	$ctx->{changed_href} = "${href}#related";
 	PublicInbox::View::multipart_text_as_html($eml, $ctx);
 	delete $ctx->{obuf};
 	$s .= '</pre></div></content></entry>';