From: intrigeri Date: Sun, 5 Oct 2008 02:05:24 +0000 (+0200) Subject: added the targetpage hook X-Git-Tag: 3.15~479 X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/commitdiff_plain/fc299df955879bf958aa78338ba64d56a7df17a9?hp=219cb94841518ba938d5761c5d613a7aadb9c47c added the targetpage hook Signed-off-by: intrigeri --- diff --git a/IkiWiki.pm b/IkiWiki.pm index edee8aacb..28ee882cf 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -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 { diff --git a/IkiWiki/Plugin/skeleton.pm.example b/IkiWiki/Plugin/skeleton.pm.example index f844ddb91..af22b3406 100644 --- a/IkiWiki/Plugin/skeleton.pm.example +++ b/IkiWiki/Plugin/skeleton.pm.example @@ -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 diff --git a/doc/plugins/write.mdwn b/doc/plugins/write.mdwn index daf70c8e2..6d2622272 100644 --- a/doc/plugins/write.mdwn +++ b/doc/plugins/write.mdwn @@ -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: