]> sipb.mit.edu Git - ikiwiki.git/commitdiff
inline: moved rootpage logic to a function
authorintrigeri <intrigeri@boum.org>
Fri, 28 Aug 2009 11:56:03 +0000 (13:56 +0200)
committerintrigeri <intrigeri@boum.org>
Fri, 28 Aug 2009 12:22:23 +0000 (14:22 +0200)
The po plugin's injected bestlink must do something special when called by this
exact part of inline's code.

Signed-off-by: intrigeri <intrigeri@boum.org>
IkiWiki/Plugin/inline.pm

index a501566b554d11cd1894878637aaf5d2204089d4..c9cbb9cb7112f2384a1f5e30016ae592009f571c 100644 (file)
@@ -307,17 +307,7 @@ sub preprocess_inline (@) {
                # Add a blog post form, with feed buttons.
                my $formtemplate=template("blogpost.tmpl", blind_cache => 1);
                $formtemplate->param(cgiurl => $config{cgiurl});
-               my $rootpage;
-               if (exists $params{rootpage}) {
-                       $rootpage=bestlink($params{page}, $params{rootpage});
-                       if (!length $rootpage) {
-                               $rootpage=$params{rootpage};
-                       }
-               }
-               else {
-                       $rootpage=$params{page};
-               }
-               $formtemplate->param(rootpage => $rootpage);
+               $formtemplate->param(rootpage => rootpage(%params));
                $formtemplate->param(rssurl => $rssurl) if $feeds && $rss;
                $formtemplate->param(atomurl => $atomurl) if $feeds && $atom;
                if (exists $params{postformtext}) {
@@ -654,4 +644,21 @@ sub pingurl (@) {
        exit 0; # daemon done
 }
 
+
+sub rootpage (@) {
+       my %params=@_;
+
+       my $rootpage;
+       if (exists $params{rootpage}) {
+               $rootpage=bestlink($params{page}, $params{rootpage});
+               if (!length $rootpage) {
+                       $rootpage=$params{rootpage};
+               }
+       }
+       else {
+               $rootpage=$params{page};
+       }
+       return $rootpage;
+}
+
 1