]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/commitdiff
avoid stomping on inline's rootpage sub if it's not already present
authorJoey Hess <joey@kitenet.net>
Thu, 24 Mar 2011 21:55:03 +0000 (17:55 -0400)
committerJoey Hess <joey@kitenet.net>
Thu, 24 Mar 2011 21:55:03 +0000 (17:55 -0400)
If the inline plugin is not being loaded, or is perhaps loaded after po
(when IkiWiki::Setup::getsetup loads all the plugins, for example),
po should not inject its custom rootpage sub, as that will lead to a
redefinition error message when inline loads.

IkiWiki/Plugin/po.pm

index 4f8d5036e198b4c0eac2f290156c411907190b87..0ea35b21c79a38fa26e563e10c4cdb98e5ff5107 100644 (file)
@@ -66,8 +66,11 @@ sub import {
                inject(name => "IkiWiki::urlto", call => \&myurlto);
                $origsubs{'cgiurl'}=\&IkiWiki::cgiurl;
                inject(name => "IkiWiki::cgiurl", call => \&mycgiurl);
-               $origsubs{'rootpage'}=\&IkiWiki::rootpage;
-               inject(name => "IkiWiki::rootpage", call => \&myrootpage);
+               if (IkiWiki->can('rootpage')) {
+                       $origsubs{'rootpage'}=\&IkiWiki::rootpage;
+                       inject(name => "IkiWiki::rootpage", call => \&myrootpage)
+                               if defined $origsubs{'rootpage'};
+               }
                $origsubs{'isselflink'}=\&IkiWiki::isselflink;
                inject(name => "IkiWiki::isselflink", call => \&myisselflink);
        }