From: intrigeri Date: Tue, 7 Oct 2008 22:50:10 +0000 (+0200) Subject: added hook urlpath X-Git-Tag: 3.15~469 X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/commitdiff_plain/d9b9022c13af3aa6c469df05beaa293fcf33cafc?ds=sidebyside added hook urlpath This hook can be used to modify the internal urls generated by ikiwiki. Signed-off-by: intrigeri --- diff --git a/IkiWiki.pm b/IkiWiki.pm index 28ee882cf..e75175a8d 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -927,6 +927,10 @@ sub beautify_urlpath ($) { #{{{ $url =~ s!/index.$config{htmlext}$!/!; } + run_hooks(urlpath => sub { + $url=shift->(url => $url); + }); + # Ensure url is not an empty link, and # if it's relative, make that explicit to avoid colon confusion. if ($url !~ /^\//) { diff --git a/IkiWiki/Plugin/skeleton.pm.example b/IkiWiki/Plugin/skeleton.pm.example index af22b3406..ecf2a2407 100644 --- a/IkiWiki/Plugin/skeleton.pm.example +++ b/IkiWiki/Plugin/skeleton.pm.example @@ -35,6 +35,7 @@ sub import { #{{{ hook(type => "formbuilder", id => "skeleton", call => \&formbuilder); hook(type => "savestate", id => "skeleton", call => \&savestate); hook(type => "targetpage", id => "skeleton", call => \&targetpage); + hook(type => "urlpath", id => "skeleton", call => \&urlpath); } # }}} sub getopt () { #{{{ @@ -209,4 +210,8 @@ sub targetpage () { #{{{ debug("skeleton plugin running in targetpage"); } #}}} +sub urlpath () { #{{{ + debug("skeleton plugin running in urlpath"); +} #}}} + 1 diff --git a/doc/plugins/write.mdwn b/doc/plugins/write.mdwn index 6d2622272..15f6c8a20 100644 --- a/doc/plugins/write.mdwn +++ b/doc/plugins/write.mdwn @@ -437,6 +437,16 @@ be compiled into. It should return the target filename. +### urlpath + + hook(type => "urlpath", id => "foo", call => \&urlpath); + +This hook can be used to modify the internal urls generated by +ikiwiki; it is run just after ikiwiki has removed the trailing +`index.html`, in case `usedirs` is enabled. + +It should return the modified url. + ## Plugin interface To import the ikiwiki plugin interface: