]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/commitdiff
Merge remote branch 'intrigeri/po'
authorJoey Hess <joey@kitenet.net>
Sun, 18 Jul 2010 23:35:16 +0000 (19:35 -0400)
committerJoey Hess <joey@kitenet.net>
Sun, 18 Jul 2010 23:35:16 +0000 (19:35 -0400)
1  2 
IkiWiki.pm
doc/plugins/po.mdwn

diff --combined IkiWiki.pm
index 2cf0ad819876d43e8c03c757f90e5bbc585317ad,1dc989b39985acd8b829ff9fd5d56be7ae4d195f..0c0b7bd4c0d418fffda7b2d86623c7c967e82e37
@@@ -823,17 -823,6 +823,17 @@@ sub prep_writefile ($$) 
                if (-l "$destdir/$test") {
                        error("cannot write to a symlink ($test)");
                }
 +              if (-f _ && $test ne $file) {
 +                      # Remove conflicting file.
 +                      foreach my $p (keys %renderedfiles, keys %oldrenderedfiles) {
 +                              foreach my $f (@{$renderedfiles{$p}}, @{$oldrenderedfiles{$p}}) {
 +                                      if ($f eq $test) {
 +                                              unlink("$destdir/$test");
 +                                              last;
 +                                      }
 +                              }
 +                      }
 +              }
                $test=dirname($test);
        }
  
@@@ -887,36 -876,10 +887,36 @@@ sub will_render ($$;$) 
        my $dest=shift;
        my $clear=shift;
  
 -      # Important security check.
 +      # Important security check for independently created files.
        if (-e "$config{destdir}/$dest" && ! $config{rebuild} &&
            ! grep { $_ eq $dest } (@{$renderedfiles{$page}}, @{$oldrenderedfiles{$page}}, @{$wikistate{editpage}{previews}})) {
 -              error("$config{destdir}/$dest independently created, not overwriting with version from $page");
 +              my $from_other_page=0;
 +              # Expensive, but rarely runs.
 +              foreach my $p (keys %renderedfiles, keys %oldrenderedfiles) {
 +                      if (grep {
 +                              $_ eq $dest ||
 +                              dirname($_) eq $dest
 +                          } @{$renderedfiles{$p}}, @{$oldrenderedfiles{$p}}) {
 +                              $from_other_page=1;
 +                              last;
 +                      }
 +              }
 +
 +              error("$config{destdir}/$dest independently created, not overwriting with version from $page")
 +                      unless $from_other_page;
 +      }
 +
 +      # If $dest exists as a directory, remove conflicting files in it
 +      # rendered from other pages.
 +      if (-d _) {
 +              foreach my $p (keys %renderedfiles, keys %oldrenderedfiles) {
 +                      foreach my $f (@{$renderedfiles{$p}}, @{$oldrenderedfiles{$p}}) {
 +                              if (dirname($f) eq $dest) {
 +                                      unlink("$config{destdir}/$f");
 +                                      rmdir(dirname("$config{destdir}/$f"));
 +                              }
 +                      }
 +              }
        }
  
        if (! $clear || $cleared{$page}) {
@@@ -1118,6 -1081,15 +1118,15 @@@ sub urlto ($$;$) 
        return beautify_urlpath($link);
  }
  
+ sub isselflink ($$) {
+       # Plugins can override this function to support special types
+       # of selflinks.
+       my $page=shift;
+       my $link=shift;
+         return $page eq $link;
+ }
  sub htmllink ($$$;@) {
        my $lpage=shift; # the page doing the linking
        my $page=shift; # the page that will contain the link (different for inline)
        }
        
        return "<span class=\"selflink\">$linktext</span>"
-               if length $bestlink && $page eq $bestlink &&
+               if length $bestlink && isselflink($page, $bestlink) &&
                   ! defined $opts{anchor};
        
        if (! $destsources{$bestlink}) {
diff --combined doc/plugins/po.mdwn
index 4158d7547725c275338dc025c18b799eecd5d623,57f04a476094739efe23d9d04d6ef791699dfc1b..babdc188677a0946fcb5791e5fb457ec4a27d82a
@@@ -54,10 -54,10 +54,10 @@@ Supported language
  `po_slave_languages` is used to set the list of supported "slave"
  languages, such as:
  
-         po_slave_languages => { 'fr' => 'Français',
+         po_slave_languages => [ 'fr' => 'Français',
                                  'es' => 'Español',
                                  'de' => 'Deutsch',
-         }
+         ]
  
  Decide which pages are translatable
  -----------------------------------
@@@ -274,29 -274,6 +274,29 @@@ to an array to support this. (If twere 
  >> up if it is not.. and the value is marked safe so websetup can be
  >> used to modify it and break that way too. --[[Joey]] 
  
 +>>> I have added a sanity check for the even array problem. This was
 +>>> the easy part.
 +>>>
 +>>> About the hash-like vs. dump and websetup issue,
 +>>> I can think of a few solutions:
 +>>>
 +>>> - keep the current hash-like pairs and unmark this setting as safe
 +>>>   for websetup: this does not solve the dump setup issue, though;
 +>>> - replace the array of pairs with an array of
 +>>>   "LANGUAGECODE|LANGUAGENAME" elements, using a pipe or whatever
 +>>>   separator seems adequate;
 +>>> - add support for ordered hashes to `$config`, websetup and
 +>>>   dumpsetup, using Tie-IxHash or any similar module;
 +>>> - replace the array of hash-like pairs with an array of real
 +>>>   pairs, such as `[ ['de', 'Deutsch'], ['fr', 'Français'] ]`; this
 +>>>   brings once again the need for `$config` to support arrays of
 +>>>   arrays, which I have already implemented in my mirrorlist branch
 +>>>   (see [[todo/mirrorlist_with_per-mirror_usedirs_settings]] for
 +>>>   details).
 +>>>
 +>>> Joey, which of these solutions do you prefer? Or another one?
 +>>> I tend to prefer the last one. --[[intrigeri]]
 +
  Pagespecs
  ---------
  
@@@ -351,16 -328,6 +351,16 @@@ update. --[[Joey]
  > * The ENCODING\n part is due to an inconsistency in po4a, which
  >   I've just send a patch for. --[[intrigeri]]
  
 +New pages not translatable
 +--------------------------
 +
 +Today I added a new English page to l10n.ikiwiki.info. When I saved,
 +the page did not have the translation links at the top. I waited until
 +the po plugin had, in the background, created the po files, and refreshed;
 +still did not see the translation links. Only when I touched the page
 +source and refreshed did it finally add the translation links. 
 +I can reproduce this bug in a test site. --[[Joey]]
 +
  Ugly messages with empty files
  ------------------------------