From: Joey Hess <joey@kitenet.net>
Date: Sun, 13 Jun 2010 02:43:34 +0000 (-0400)
Subject: edittemplate: Look for template pages under templates/ like everything else (still... 
X-Git-Tag: 3.20100623~79
X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/commitdiff_plain/dccd76487151acc6adc93ec79f1808096bc41324

edittemplate: Look for template pages under templates/ like everything else (still looks in old location for backwards compatability).
---

diff --git a/IkiWiki/Plugin/edittemplate.pm b/IkiWiki/Plugin/edittemplate.pm
index 742413c94..226f83bb4 100644
--- a/IkiWiki/Plugin/edittemplate.pm
+++ b/IkiWiki/Plugin/edittemplate.pm
@@ -56,10 +56,15 @@ sub preprocess (@) {
 	}
 
 	my $link=linkpage($params{template});
+	add_depends($params{page}, $link, deptype("presence"));
 	my $bestlink=bestlink($params{page}, $link);
+	if (! length $bestlink) {
+		add_depends($params{page}, "templates/$link", deptype("presence"));
+		$link="/templates/".$link;
+		$bestlink=bestlink($params{page}, $link);
+	}
 	$pagestate{$params{page}}{edittemplate}{$params{match}}=$bestlink;
 
-	add_depends($params{page}, $link, deptype("presence"));
 	return "" if ($params{silent} && IkiWiki::yesno($params{silent})) &&
 		length $bestlink;
 	return sprintf(gettext("edittemplate %s registered for %s"),
diff --git a/debian/changelog b/debian/changelog
index d607640c4..07b349c57 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -8,6 +8,8 @@ ikiwiki (3.20100611) UNRELEASED; urgency=low
     comments div.
   * edittemplate: Make silent mode not disable display when the template
     page does not exist, so it can be easily created.
+  * edittemplate: Look for template pages under templates/ like everything
+    else (still looks in old location for backwards compatability).
 
  -- Joey Hess <joeyh@debian.org>  Fri, 11 Jun 2010 13:39:15 -0400
 
diff --git a/doc/plugins/edittemplate.mdwn b/doc/plugins/edittemplate.mdwn
index 85dfdfc2d..c19ecd858 100644
--- a/doc/plugins/edittemplate.mdwn
+++ b/doc/plugins/edittemplate.mdwn
@@ -2,5 +2,5 @@
 [[!tag type/web]]
 
 This plugin provides the [[ikiwiki/directive/edittemplate]] [[ikiwiki/directive]].
-This directive allows registering template pages, that provide default
-content for new pages created using the web frontend.
+This directive allows registering [[template|templates]] pages, that
+provide default content for new pages created using the web frontend.
diff --git a/doc/templates.mdwn b/doc/templates.mdwn
index 22b9345ef..d7480ee8f 100644
--- a/doc/templates.mdwn
+++ b/doc/templates.mdwn
@@ -22,20 +22,22 @@ easy to learn. All you really need to know to modify templates is this:
 The template directive allows wiki pages to be used as templates,
 filled out and inserted into other pages in the wiki.
 """]]
-[[!if test="enabled(template) and enabled(inline)" then="""
-[[!inline pages="templates/* and !*.tmpl and !*/discussion"
-feeds=no archive=yes sort=title template=titlepage
-rootpage=templates postformtext="Add a new template named:"]]
-"""]]
 
 [[!if test="enabled(edittemplate)" then="""
-## edit templates
+## default content for new pages
 
 The edittemplate directive can be used to make new pages default to
-containing text from a template, which can be filled as out the page is
+containing text from a template page, which can be filled as out the page is
 edited.
 """]]
 
+[[!if test="(enabled(template) or enabled(edittemplate)
+and enabled(inline)" then="""
+[[!inline pages="templates/* and !*.tmpl and !templates/*/* and !*/discussion"
+feeds=no archive=yes sort=title template=titlepage
+rootpage=templates postformtext="Add a new template named:"]]
+"""]]
+
 ## wiki templates
 
 These templates are used to build the wiki. The aim is to keep almost all