]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/Plugin/po.pm
po: better rootpage logic for inline's post form
[git.ikiwiki.info.git] / IkiWiki / Plugin / po.pm
index 55c1c32c64f24c563b40d17e8249163b2d8b36c5..14c7318feff935209e85e317039f0cee70fe620d 100644 (file)
@@ -59,6 +59,8 @@ 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);
 }
 
 
@@ -649,6 +651,22 @@ sub mycgiurl (@) {
        return $origsubs{'cgiurl'}->(%params);
 }
 
+sub myrootpage (@) {
+       my %params=@_;
+
+       my $rootpage;
+       if (exists $params{rootpage}) {
+               $rootpage=$origsubs{'bestlink'}->($params{page}, $params{rootpage});
+               if (!length $rootpage) {
+                       $rootpage=$params{rootpage};
+               }
+       }
+       else {
+               $rootpage=masterpage($params{page});
+       }
+       return $rootpage;
+}
+
 # ,----
 # | Blackboxes for private data
 # `----