From 05bb65fc687b357a5265f0c378a694b5b02d376d Mon Sep 17 00:00:00 2001
From: Simon McVittie <smcv@ http://smcv.pseudorandom.co.uk/>
Date: Mon, 22 Dec 2008 23:02:08 +0000
Subject: [PATCH] recentchanges_link CGI: If the linked page is internal, use
 its permalink

This fixes a bug, that comments appear in recentchanges as broken links.
---
 IkiWiki/Plugin/recentchanges.pm | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/IkiWiki/Plugin/recentchanges.pm b/IkiWiki/Plugin/recentchanges.pm
index 12577e9ef..7071596e6 100644
--- a/IkiWiki/Plugin/recentchanges.pm
+++ b/IkiWiki/Plugin/recentchanges.pm
@@ -95,6 +95,15 @@ sub cgi ($) {
 
 		IkiWiki::loadindex();
 
+		# If the page is internal (like a comment), see if it has a
+		# permalink. Comments do.
+		if (IkiWiki::isinternal($page) &&
+		    defined $pagestate{$page}{meta}{permalink}) {
+			IkiWiki::redirect($cgi,
+			                  $pagestate{$page}{meta}{permalink});
+			exit;
+		}
+
 		my $link=bestlink("", $page);
 		if (! length $link) {
 			print "Content-type: text/html\n\n";
-- 
2.26.2