summaryrefslogtreecommitdiff
path: root/IkiWiki
diff options
context:
space:
mode:
authorJoey Hess <joey@gnu.kitenet.net>2009-07-20 07:20:43 +0200
committerJoey Hess <joey@gnu.kitenet.net>2009-07-20 07:20:43 +0200
commitbe30203459f6994f650ed56b9f7da88b8c98c137 (patch)
tree1f97d8f50e6f5a05c3b7edb184c06f56145acba1 /IkiWiki
parente6709f6677f037097744a07cc9c3b58db4fd4595 (diff)
parenta7b813182df7d18a0d1bf2fb28b3ee4c069c86e9 (diff)
Merge branch 'master' into integration
Diffstat (limited to 'IkiWiki')
-rw-r--r--IkiWiki/Plugin/po.pm25
-rw-r--r--IkiWiki/Plugin/rename.pm2
-rw-r--r--IkiWiki/Render.pm35
3 files changed, 39 insertions, 23 deletions
diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm
index 1aa60a14f..5d2d42d3b 100644
--- a/IkiWiki/Plugin/po.pm
+++ b/IkiWiki/Plugin/po.pm
@@ -119,20 +119,18 @@ sub getsetup () {
}
sub checkconfig () {
- foreach my $field (qw{po_master_language po_slave_languages}) {
+ foreach my $field (qw{po_master_language}) {
if (! exists $config{$field} || ! defined $config{$field}) {
error(sprintf(gettext("Must specify %s when using the %s plugin"),
$field, 'po'));
}
}
- if (! (keys %{$config{po_slave_languages}})) {
- error(gettext("At least one slave language must be defined ".
- "in po_slave_languages when using the po plugin"));
- }
+
map {
islanguagecode($_)
or error(sprintf(gettext("%s is not a valid language code"), $_));
} ($config{po_master_language}{code}, keys %{$config{po_slave_languages}});
+
if (! exists $config{po_translatable_pages} ||
! defined $config{po_translatable_pages}) {
$config{po_translatable_pages}="";
@@ -150,7 +148,16 @@ sub checkconfig () {
warn(gettext('po_link_to=negotiated requires usedirs to be enabled, falling back to po_link_to=default'));
$config{po_link_to}='default';
}
+
push @{$config{wiki_file_prune_regexps}}, qr/\.pot$/;
+
+ if ($config{po_master_language}{code} ne 'en') {
+ # use translated underlay directories in preference
+ # to the untranslated ones
+ foreach my $underlay ('basewiki', reverse @{$config{underlaydirs}}) {
+ add_underlay("locale/".$config{po_master_language}{code}."/".$underlay);
+ }
+ }
}
sub needsbuild () {
@@ -904,10 +911,10 @@ sub otherlanguagesloop ($) {
}
}
return sort {
- return -1 if $a->{code} eq $config{po_master_language}{code};
- return 1 if $b->{code} eq $config{po_master_language}{code};
- return $a->{language} cmp $b->{language};
- } @ret;
+ return -1 if $a->{code} eq $config{po_master_language}{code};
+ return 1 if $b->{code} eq $config{po_master_language}{code};
+ return $a->{language} cmp $b->{language};
+ } @ret;
}
sub homepageurl (;$) {
diff --git a/IkiWiki/Plugin/rename.pm b/IkiWiki/Plugin/rename.pm
index d0e5894dc..c3e03496f 100644
--- a/IkiWiki/Plugin/rename.pm
+++ b/IkiWiki/Plugin/rename.pm
@@ -480,7 +480,7 @@ sub renamepage_hook ($$$$) {
return $content;
}
-sub rename_hook (@) {
+sub rename_hook {
my %params = @_;
my @torename=@{$params{torename}};
diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm
index 2da18738d..59cec3646 100644
--- a/IkiWiki/Render.pm
+++ b/IkiWiki/Render.pm
@@ -246,7 +246,7 @@ sub prune ($) {
}
}
-sub refresh () {
+sub srcdir_check () {
# security check, avoid following symlinks in the srcdir path by default
my $test=$config{srcdir};
while (length $test) {
@@ -258,11 +258,10 @@ sub refresh () {
}
}
- run_hooks(refresh => sub { shift->() });
+}
- # find existing pages
- my %exists;
- my @files;
+sub find_src_files () {
+ my (@files, %pages);
eval q{use File::Find};
error($@) if $@;
find({
@@ -281,10 +280,10 @@ sub refresh () {
$f=~s/^\Q$config{srcdir}\E\/?//;
push @files, $f;
my $pagename = pagename($f);
- if ($exists{$pagename}) {
+ if ($pages{$pagename}) {
debug(sprintf(gettext("%s has multiple possible source pages"), $pagename));
}
- $exists{$pagename}=1;
+ $pages{$pagename}=1;
}
}
},
@@ -310,9 +309,9 @@ sub refresh () {
if (! -l "$config{srcdir}/$f" &&
! -e _) {
my $page=pagename($f);
- if (! $exists{$page}) {
+ if (! $pages{$page}) {
push @files, $f;
- $exists{$page}=1;
+ $pages{$page}=1;
}
}
}
@@ -321,9 +320,19 @@ sub refresh () {
}, $dir);
};
+ # Returns a list of all source files found, and a hash of
+ # the corresponding page names.
+ return \@files, \%pages;
+}
+
+sub refresh () {
+ srcdir_check();
+ run_hooks(refresh => sub { shift->() });
+ my ($files, $exists)=find_src_files();
+
my (%rendered, @add, @del, @internal);
# check for added or removed pages
- foreach my $file (@files) {
+ foreach my $file (@$files) {
my $page=pagename($file);
if (exists $pagesources{$page} && $pagesources{$page} ne $file) {
# the page has changed its type
@@ -353,7 +362,7 @@ sub refresh () {
}
}
foreach my $page (keys %pagemtime) {
- if (! $exists{$page}) {
+ if (! $exists->{$page}) {
if (isinternal($page)) {
push @internal, $pagesources{$page};
}
@@ -377,7 +386,7 @@ sub refresh () {
# find changed and new files
my @needsbuild;
- foreach my $file (@files) {
+ foreach my $file (@$files) {
my $page=pagename($file);
my ($srcfile, @stat)=srcfile_stat($file);
if (! exists $pagemtime{$page} ||
@@ -435,7 +444,7 @@ sub refresh () {
my @changed=(keys %rendered, @del);
# rebuild dependant pages
- foreach my $f (@files) {
+ foreach my $f (@$files) {
next if $rendered{$f};
my $p=pagename($f);
if (exists $depends{$p}) {