]> sipb.mit.edu Git - ikiwiki.git/commitdiff
add newpagefile function
authorJoey Hess <joey@kodama.kitenet.net>
Mon, 29 Sep 2008 22:51:16 +0000 (18:51 -0400)
committerJoey Hess <joey@kodama.kitenet.net>
Mon, 29 Sep 2008 22:51:16 +0000 (18:51 -0400)
IkiWiki.pm
doc/plugins/write.mdwn

index c01c59ac61a73fc32a88cb305064b7e75609e0a9..34b315bbc36914919a83433fa58e94086f7fa15e 100644 (file)
@@ -20,7 +20,7 @@ use Exporter q{import};
 our @EXPORT = qw(hook debug error template htmlpage add_depends pagespec_match
                  bestlink htmllink readfile writefile pagetype srcfile pagename
                  displaytime will_render gettext urlto targetpage
 our @EXPORT = qw(hook debug error template htmlpage add_depends pagespec_match
                  bestlink htmllink readfile writefile pagetype srcfile pagename
                  displaytime will_render gettext urlto targetpage
-                add_underlay pagetitle titlepage linkpage
+                add_underlay pagetitle titlepage linkpage newpagefile
                  %config %links %pagestate %wikistate %renderedfiles
                  %pagesources %destsources);
 our $VERSION = 2.00; # plugin interface version, next is ikiwiki version
                  %config %links %pagestate %wikistate %renderedfiles
                  %pagesources %destsources);
 our $VERSION = 2.00; # plugin interface version, next is ikiwiki version
@@ -632,13 +632,26 @@ sub pagename ($) { #{{{
        return $page;
 } #}}}
 
        return $page;
 } #}}}
 
+sub newpagefile ($$) { #{{{
+       my $page=shift;
+       my $type=shift;
+
+       if (! $config{indexpages} || $page eq 'index') {
+               return $page.".".$type;
+       }
+       else {
+               return $page."/index.".$type;
+       }
+} #}}}
+
 sub targetpage ($$) { #{{{
        my $page=shift;
        my $ext=shift;
        
 sub targetpage ($$) { #{{{
        my $page=shift;
        my $ext=shift;
        
-       if (! $config{usedirs} || $page =~ /^index$/ ) {
+       if (! $config{usedirs} || $page eq 'index') {
                return $page.".".$ext;
                return $page.".".$ext;
-       } else {
+       }
+       else {
                return $page."/index.".$ext;
        }
 } #}}}
                return $page."/index.".$ext;
        }
 } #}}}
index 4e27d361d36d06353230318a5e31f98539f5dee4..1b78f5900b2de71ee10c4a4bd94f17c8c6d62bf1 100644 (file)
@@ -691,6 +691,12 @@ destination file, as registered by `will_render`.
 If the third parameter is passed and is true, an absolute url will be
 constructed instead of the default relative url.
 
 If the third parameter is passed and is true, an absolute url will be
 constructed instead of the default relative url.
 
+#### `newpagefile($$)`
+
+This can be called when creating a new page, to determine what filename
+to save the page to. It's passed a page name, and its type, and returns
+the name of the file to create, relative to the srcdir.
+
 #### `targetpage($$)`
 
 Passed a page and an extension, returns the filename that page will be
 #### `targetpage($$)`
 
 Passed a page and an extension, returns the filename that page will be