From 829e0b1b65529975131f3095333963cce5b0eea4 Mon Sep 17 00:00:00 2001
From: joey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Date: Sat, 23 Dec 2006 06:18:55 +0000
Subject: [PATCH] * Avoid creating edit links when not in cgi mode. * Avoid
 displaying discussion links at all, if there's not a discussion   page, when
 not in cgi mode.

---
 IkiWiki.pm                                       | 1 +
 IkiWiki/Render.pm                                | 2 +-
 debian/changelog                                 | 5 ++++-
 doc/bugs/__63__Discussion_when_not_CGI_mode.mdwn | 4 +++-
 4 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/IkiWiki.pm b/IkiWiki.pm
index 9f6c3bb1f..b8f3e7a55 100644
--- a/IkiWiki.pm
+++ b/IkiWiki.pm
@@ -413,6 +413,7 @@ sub htmllink ($$$;$$$) { #{{{
 		$bestlink=htmlpage($bestlink);
 	}
 	if (! grep { $_ eq $bestlink } map { @{$_} } values %renderedfiles) {
+		return $linktext unless $config{cgi};
 		return "<span><a href=\"".
 			cgiurl(do => "create", page => lc($link), from => $page).
 			"\">?</a>$linktext</span>"
diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm
index 4033468b2..6d19a1dd3 100644
--- a/IkiWiki/Render.pm
+++ b/IkiWiki/Render.pm
@@ -93,7 +93,7 @@ sub genpage ($$$) { #{{{
 		$template->param(historyurl => $u);
 		$actions++;
 	}
-	if ($config{discussion}) {
+	if ($config{discussion} && ($config{cgi} || exists $links{"$page/discussion"})) {
 		$template->param(discussionlink => htmllink($page, $page, "Discussion", 1, 1));
 		$actions++;
 	}
diff --git a/debian/changelog b/debian/changelog
index 59bd097f1..d0fb28093 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -3,8 +3,11 @@ ikiwiki (1.37) UNRELEASED; urgency=low
   * Add mirrorlist plugin.
   * Fixed permissions of some files that were 600 in the tarball. (Did not
     affect the deb).
+  * Avoid creating edit links when not in cgi mode.
+  * Avoid displaying discussion links at all, if there's not a discussion
+    page, when not in cgi mode.
 
- -- Joey Hess <joeyh@debian.org>  Sat, 23 Dec 2006 00:49:16 -0500
+ -- Joey Hess <joeyh@debian.org>  Sat, 23 Dec 2006 01:17:54 -0500
 
 ikiwiki (1.36) unstable; urgency=low
 
diff --git a/doc/bugs/__63__Discussion_when_not_CGI_mode.mdwn b/doc/bugs/__63__Discussion_when_not_CGI_mode.mdwn
index f4437c3dc..e08abaff3 100644
--- a/doc/bugs/__63__Discussion_when_not_CGI_mode.mdwn
+++ b/doc/bugs/__63__Discussion_when_not_CGI_mode.mdwn
@@ -4,4 +4,6 @@ But I did have a "?Discussion" link still and that is CGI.
 
 So the bug (I think) is that it has a hyperlink to a CGI when CGI is not enabled.
 
-(Note that my title above has _63_ but was supposed to be a question mark.)
\ No newline at end of file
+> [[bugs/done]] -- [[Joey]]
+
+(Note that my title above has _63_ but was supposed to be a question mark.)
-- 
2.39.5