summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorintrigeri <intrigeri@boum.org>2008-11-06 13:26:45 +0100
committerintrigeri <intrigeri@boum.org>2008-11-06 13:26:45 +0100
commit34afa2c07d2defcaf683cf8d7eb486517b4fc389 (patch)
tree59b88213f45e91d80f89b77079686a633b8cee28
parentc96dd00480b8c0d18f74d42d3b6820f1cdd67240 (diff)
po: po_master_language and po_slave_languages are safe config settings
... and check their validity in checkconfig Signed-off-by: intrigeri <intrigeri@boum.org>
-rw-r--r--IkiWiki/Plugin/po.pm13
-rw-r--r--doc/plugins/po.mdwn7
2 files changed, 14 insertions, 6 deletions
diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm
index bdf4b2c29..5acbcd4f8 100644
--- a/IkiWiki/Plugin/po.pm
+++ b/IkiWiki/Plugin/po.pm
@@ -61,7 +61,7 @@ sub getsetup () { #{{{
'name' => 'English'
},
description => "master language (non-PO files)",
- safe => 0,
+ safe => 1,
rebuild => 1,
},
po_slave_languages => {
@@ -72,7 +72,7 @@ sub getsetup () { #{{{
'de' => 'Deutsch'
},
description => "slave languages (PO files)",
- safe => 0,
+ safe => 1,
rebuild => 1,
},
po_translatable_pages => {
@@ -92,12 +92,21 @@ sub getsetup () { #{{{
},
} #}}}
+sub islanguagecode ($) { #{{{
+ my $code=shift;
+ return ($code =~ /^[a-z]{2}$/);
+} #}}}
+
sub checkconfig () { #{{{
foreach my $field (qw{po_master_language po_slave_languages}) {
if (! exists $config{$field} || ! defined $config{$field}) {
error(sprintf(gettext("Must specify %s"), $field));
}
}
+ 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_link_to} ||
! defined $config{po_link_to}) {
$config{po_link_to}="default";
diff --git a/doc/plugins/po.mdwn b/doc/plugins/po.mdwn
index 1526798d1..f10ee1d2c 100644
--- a/doc/plugins/po.mdwn
+++ b/doc/plugins/po.mdwn
@@ -257,11 +257,10 @@ be fixed by something like [[todo/using_meta_titles_for_parentlinks]].
### websetup
-Which configuration settings are safe enough for websetup?
+Which configuration settings are safe enough for websetup, apart of
+`po_master_language` and `po_slave_languages` that already have
+been checked?
-> I see no problems with `po_master_language` and `po_slave_languages`
-> (assuming websetup handles the hashes correctly). Would not hurt to check
-> that the values of these are legal language codes, in `checkconfig`.
> `po_translatable_pages` seems entirely safe. `po_link_to` w/o usedirs
> causes ikiwiki to error out. If it were changed to fall back to a safe
> setting in this case rather than error, it would be safe.