]> sipb.mit.edu Git - ikiwiki.git/commitdiff
template: Search for templates in the templatedir, if they are not found as pages...
authorJoey Hess <joey@gnu.kitenet.net>
Fri, 2 Apr 2010 20:54:06 +0000 (16:54 -0400)
committerJoey Hess <joey@gnu.kitenet.net>
Fri, 2 Apr 2010 20:54:06 +0000 (16:54 -0400)
IkiWiki/Plugin/template.pm
debian/changelog
doc/templates.mdwn
doc/todo/user-defined_templates_outside_the_wiki.mdwn
doc/wikitemplates.mdwn

index 3e024c5f81b11db1c7791fe8ef214d06f186cb09..36282055a5274987747026b284609e45f793208c 100644 (file)
@@ -37,7 +37,13 @@ sub preprocess (@) {
        my $template_page="templates/$params{id}";
        add_depends($params{page}, $template_page);
 
        my $template_page="templates/$params{id}";
        add_depends($params{page}, $template_page);
 
-       my $template_file=$pagesources{$template_page};
+       my $template_file;
+       if (exists $pagesources{$template_page}) {
+               $template_file=srcfile($pagesources{$template_page});
+       }
+       else {
+               $template_file=template_file("$params{id}.tmpl")
+       }
        return sprintf(gettext("template %s not found"),
                htmllink($params{page}, $params{destpage}, "/".$template_page))
                        unless defined $template_file;
        return sprintf(gettext("template %s not found"),
                htmllink($params{page}, $params{destpage}, "/".$template_page))
                        unless defined $template_file;
@@ -50,7 +56,7 @@ sub preprocess (@) {
                                $$text_ref=&Encode::decode_utf8($$text_ref);
                                chomp $$text_ref;
                        },
                                $$text_ref=&Encode::decode_utf8($$text_ref);
                                chomp $$text_ref;
                        },
-                       filename => srcfile($template_file),
+                       filename => $template_file,
                                die_on_bad_params => 0,
                        no_includes => 1,
                        blind_cache => 1,
                                die_on_bad_params => 0,
                        no_includes => 1,
                        blind_cache => 1,
index adf0dfed6133f028937a55103f3cfadac6108654..362ba54ab6adeb57e103a10f7589ee4a288542d3 100644 (file)
@@ -26,6 +26,8 @@ ikiwiki (3.20100324) UNRELEASED; urgency=low
   * page.tmpl: Add Cache-Control must-revalidate to ensure that users
     (especially of Firefox) see fresh page content.
   * htmlscrubber: Allow colons in urls after '?'
   * page.tmpl: Add Cache-Control must-revalidate to ensure that users
     (especially of Firefox) see fresh page content.
   * htmlscrubber: Allow colons in urls after '?'
+  * template: Search for templates in the templatedir, if they are not
+    found as pages in the wiki.
 
  -- Joey Hess <joeyh@debian.org>  Sat, 13 Mar 2010 14:48:10 -0500
 
 
  -- Joey Hess <joeyh@debian.org>  Sat, 13 Mar 2010 14:48:10 -0500
 
index eff0e15e93d5930821677833ce4de8619658fb44..07531ae98811442280467ee61e47822b6c3354c0 100644 (file)
@@ -43,6 +43,12 @@ page will provide a link that can be used to create the template. The template
 is a regular wiki page, located in the `templates/` subdirectory inside
 the source directory of the wiki.
 
 is a regular wiki page, located in the `templates/` subdirectory inside
 the source directory of the wiki.
 
+(Alternatively, templates can be stored in a directory outside the wiki,
+as files with the extension ".tmpl".
+By default, these are searched for in `/usr/share/ikiwiki/templates`;
+the `templatedir` setting can be used to make another directory be searched
+first.)
+
 The template uses the syntax used by the [[!cpan HTML::Template]] perl
 module, which allows for some fairly complex things to be done. Consult its
 documentation for the full syntax, but all you really need to know are a
 The template uses the syntax used by the [[!cpan HTML::Template]] perl
 module, which allows for some fairly complex things to be done. Consult its
 documentation for the full syntax, but all you really need to know are a
index 880ad64938c6861be4d6d04734ee44def7e9780e..1d72aa6a7e270fe4577c10a6d0494eae5c4b014d 100644 (file)
@@ -6,3 +6,5 @@ source, but also looks in the system templates directory (the one with
 invoked via `\[[!template]]`, but don't have to "work" as wiki pages in their
 own right. I think the normal [[plugins/template]] plugin could benefit from
 this functionality.
 invoked via `\[[!template]]`, but don't have to "work" as wiki pages in their
 own right. I think the normal [[plugins/template]] plugin could benefit from
 this functionality.
+
+[[done]] --[[Joey]] 
index 6c0480cea0630d2183efea5435d81204f8bd0cc1..6e5a7261daaf2d6ef7cd1be919e1e315232d9674 100644 (file)
@@ -5,7 +5,8 @@ to learn.
 The aim is to keep almost all html out of ikiwiki and in the templates.
 
 It ships with some basic templates which can be customised. These are
 The aim is to keep almost all html out of ikiwiki and in the templates.
 
 It ships with some basic templates which can be customised. These are
-located in /usr/share/ikiwiki/templates by default.
+located in `/usr/share/ikiwiki/templates` by default; the `templatedir`
+setting can be used to make another directory be searched first.
 
 * `page.tmpl` - Used for displaying all regular wiki pages.
 * `misc.tmpl` - Generic template used for any page that doesn't
 
 * `page.tmpl` - Used for displaying all regular wiki pages.
 * `misc.tmpl` - Generic template used for any page that doesn't
@@ -43,7 +44,8 @@ The [[plugins/pagetemplate]] plugin can allow individual pages to use a
 different template than `page.tmpl`.
 
 The [[plugins/template]] plugin also uses templates, though those
 different template than `page.tmpl`.
 
 The [[plugins/template]] plugin also uses templates, though those
-[[templates]] are stored in the wiki and inserted into pages.
+[[templates]] are typically stored as pages in the wiki, and are inserted
+into pages.
 
 The [[plugins/edittemplate]] plugin is used to make new pages default to
 containing text from a template, which can be filled as out the page is
 
 The [[plugins/edittemplate]] plugin is used to make new pages default to
 containing text from a template, which can be filled as out the page is