]> sipb.mit.edu Git - ikiwiki.git/commitdiff
added the targetpage hook
authorintrigeri <intrigeri@boum.org>
Sun, 5 Oct 2008 02:05:24 +0000 (04:05 +0200)
committerintrigeri <intrigeri@boum.org>
Sat, 18 Oct 2008 13:49:07 +0000 (15:49 +0200)
Signed-off-by: intrigeri <intrigeri@boum.org>
IkiWiki.pm
IkiWiki/Plugin/skeleton.pm.example
doc/plugins/write.mdwn

index edee8aacb707e93081b1dfdec7a21a1f04e361bb..28ee882cf20d99b30059cf195ca8f70881de932d 100644 (file)
@@ -647,8 +647,19 @@ sub newpagefile ($$) { #{{{
 sub targetpage ($$) { #{{{
        my $page=shift;
        my $ext=shift;
-       
-       if (! $config{usedirs} || $page eq 'index') {
+
+       my $targetpage='';
+       run_hooks(targetpage => sub {
+               $targetpage=shift->(
+                       page => $page,
+                       ext => $ext,
+               );
+       });
+
+       if (defined $targetpage && (length($targetpage) > 0)) {
+               return $targetpage;
+       }
+       elsif (! $config{usedirs} || $page eq 'index') {
                return $page.".".$ext;
        }
        else {
index f844ddb91ddaa96680094d792df96af2ddd4a229..af22b340659bd72067c1cd552e69c221dd7ab364 100644 (file)
@@ -34,6 +34,7 @@ sub import { #{{{
        hook(type => "formbuilder_setup", id => "skeleton", call => \&formbuilder_setup);
        hook(type => "formbuilder", id => "skeleton", call => \&formbuilder);
        hook(type => "savestate", id => "skeleton", call => \&savestate);
+       hook(type => "targetpage", id => "skeleton", call => \&targetpage);
 } # }}}
 
 sub getopt () { #{{{
@@ -204,4 +205,8 @@ sub savestate () { #{{{
        debug("skeleton plugin running in savestate");
 } #}}}
 
+sub targetpage () { #{{{
+       debug("skeleton plugin running in targetpage");
+} #}}}
+
 1
index daf70c8e23393d5b860b30e324523da6f46c45ab..6d2622272f01eaa5ed65d0fc496e886633fdf8c7 100644 (file)
@@ -428,6 +428,15 @@ describes the plugin as a whole. For example:
   and undef if a rebuild could be needed in some circumstances, but is not
   strictly required.
 
+### targetpage
+
+       hook(type => "targetpage", id => "foo", call => \&targetpage);
+
+This hook can be used to override the name of the file a page should
+be compiled into. 
+
+It should return the target filename.
+
 ## Plugin interface
 
 To import the ikiwiki plugin interface: