parent
219cb94841
commit
fc299df955
15
IkiWiki.pm
15
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 {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue