]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Plugin/po.pm
po: also filter sidebar translation pages
[ikiwiki.git] / IkiWiki / Plugin / po.pm
index 990847b488c33ff14c3f64c3064ae1e1d9a92268..6bf09b6d660cd97f76c28266ad159c2ceb930b11 100644 (file)
@@ -64,6 +64,8 @@ sub import {
                inject(name => "IkiWiki::cgiurl", call => \&mycgiurl);
                $origsubs{'rootpage'}=\&IkiWiki::rootpage;
                inject(name => "IkiWiki::rootpage", call => \&myrootpage);
+               $origsubs{'isselflink'}=\&IkiWiki::isselflink;
+               inject(name => "IkiWiki::isselflink", call => \&myisselflink);
        }
 }
 
@@ -241,6 +243,13 @@ sub filter (@) {
        my $page = $params{page};
        my $destpage = $params{destpage};
        my $content = $params{content};
+
+       my @caller = caller(4);
+        unless ($caller[3] eq "IkiWiki::render" ||
+                $caller[3] eq 'IkiWiki::Plugin::sidebar::sidebar_content') {
+               return $content;
+       }
+
        if (istranslation($page) && ! alreadyfiltered($page, $destpage)) {
                $content = po_to_markup($page, $content);
                setalreadyfiltered($page, $destpage);
@@ -429,8 +438,7 @@ sub change (@) {
 
        if ($updated_po_files) {
                commit_and_refresh(
-                       gettext("updated PO files"),
-                       "IkiWiki::Plugin::po::change");
+                       gettext("updated PO files"));
        }
 }
 
@@ -676,6 +684,17 @@ sub myrootpage (@) {
        return $rootpage;
 }
 
+sub myisselflink ($$) {
+       my $page=shift;
+       my $link=shift;
+
+       return 1 if $origsubs{'isselflink'}->($page, $link);
+       if (istranslation($page)) {
+               return $origsubs{'isselflink'}->(masterpage($page), $link);
+        }
+       return;
+}
+
 # ,----
 # | Blackboxes for private data
 # `----
@@ -1035,17 +1054,18 @@ sub deletetranslations ($) {
 
        if (@todelete) {
                commit_and_refresh(
-                       gettext("removed obsolete PO files"),
-                       "IkiWiki::Plugin::po::deletetranslations");
+                       gettext("removed obsolete PO files"));
        }
 }
 
-sub commit_and_refresh ($$) {
-       my ($msg, $author) = (shift, shift);
+sub commit_and_refresh ($) {
+       my $msg = shift;
 
        if ($config{rcs}) {
                IkiWiki::disable_commit_hook();
-               IkiWiki::rcs_commit_staged($msg, $author, "127.0.0.1");
+               IkiWiki::rcs_commit_staged(
+                       message => $msg,
+               );
                IkiWiki::enable_commit_hook();
                IkiWiki::rcs_update();
        }