aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/po.pm
diff options
context:
space:
mode:
authorintrigeri <intrigeri@boum.org>2009-08-28 13:12:58 +0200
committerJoey Hess <joey@gnu.kitenet.net>2009-08-28 07:33:53 -0400
commit5136c22eed0527bce976c76205c6ccb2ddb0b062 (patch)
treebf928127c233f3b7e5494efdca007893a4f463ca /IkiWiki/Plugin/po.pm
parent18ddf727d1fb30e3a3022fa8a73077c4c75dd262 (diff)
downloadikiwiki-5136c22eed0527bce976c76205c6ccb2ddb0b062.tar
ikiwiki-5136c22eed0527bce976c76205c6ccb2ddb0b062.tar.gz
po: favor the type of linking page's masterpage on page creation
Signed-off-by: intrigeri <intrigeri@boum.org>
Diffstat (limited to 'IkiWiki/Plugin/po.pm')
-rw-r--r--IkiWiki/Plugin/po.pm21
1 files changed, 17 insertions, 4 deletions
diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm
index b9f59f3e8..55c1c32c6 100644
--- a/IkiWiki/Plugin/po.pm
+++ b/IkiWiki/Plugin/po.pm
@@ -531,10 +531,23 @@ sub formbuilder (@) {
if ($form->field("do") eq "create") {
foreach my $field ($form->field) {
next unless "$field" eq "type";
- if ($field->type eq 'select') {
- # remove po from the list of types
- my @types = grep { $_->[0] ne 'po' } $field->options;
- $field->options(\@types) if @types;
+ next unless $field->type eq 'select';
+ my $orig_value = $field->value;
+ # remove po from the list of types
+ my @types = grep { $_->[0] ne 'po' } $field->options;
+ $field->options(\@types) if @types;
+ # favor the type of linking page's masterpage
+ if ($orig_value eq 'po') {
+ my ($from, $type);
+ if (defined $form->field('from')) {
+ ($from)=$form->field('from')=~/$config{wiki_file_regexp}/;
+ $from = masterpage($from);
+ }
+ if (defined $from && exists $pagesources{$from}) {
+ $type=pagetype($pagesources{$from});
+ }
+ $type=$config{default_pageext} unless defined $type;
+ $field->value($type) ;
}
}
}