fix two bugs in page location in new page creation
parent
7f8efe4524
commit
b26de7676b
9
ikiwiki
9
ikiwiki
|
@ -1020,26 +1020,31 @@ sub cgi_editpage ($$) { #{{{
|
||||||
}
|
}
|
||||||
|
|
||||||
my @page_locs;
|
my @page_locs;
|
||||||
|
my $best_loc;
|
||||||
my ($from)=$form->param('from')=~/$config{wiki_file_regexp}/;
|
my ($from)=$form->param('from')=~/$config{wiki_file_regexp}/;
|
||||||
if (! defined $from || ! length $from ||
|
if (! defined $from || ! length $from ||
|
||||||
$from ne $form->param('from') ||
|
$from ne $form->param('from') ||
|
||||||
$from=~/$config{wiki_file_prune_regexp}/ || $from=~/^\//) {
|
$from=~/$config{wiki_file_prune_regexp}/ || $from=~/^\//) {
|
||||||
@page_locs=$page;
|
@page_locs=$best_loc=$page;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
my $dir=$from."/";
|
my $dir=$from."/";
|
||||||
$dir=~s![^/]+/$!!;
|
$dir=~s![^/]+/$!!;
|
||||||
push @page_locs, $dir.$page;
|
push @page_locs, $dir.$page;
|
||||||
push @page_locs, "$from/$page";
|
push @page_locs, "$from/$page";
|
||||||
|
$best_loc="$from/$page";
|
||||||
while (length $dir) {
|
while (length $dir) {
|
||||||
$dir=~s![^/]+/$!!;
|
$dir=~s![^/]+/$!!;
|
||||||
push @page_locs, $dir.$page;
|
push @page_locs, $dir.$page;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@page_locs = grep { ! exists
|
||||||
|
$pagesources{lc($_)} } @page_locs;
|
||||||
}
|
}
|
||||||
|
|
||||||
$form->tmpl_param("page_select", 1);
|
$form->tmpl_param("page_select", 1);
|
||||||
$form->field(name => "page", type => 'select',
|
$form->field(name => "page", type => 'select',
|
||||||
options => \@page_locs);
|
options => \@page_locs, value => $best_loc);
|
||||||
$form->title("creating $page");
|
$form->title("creating $page");
|
||||||
}
|
}
|
||||||
elsif ($form->field("do") eq "edit") {
|
elsif ($form->field("do") eq "edit") {
|
||||||
|
|
Loading…
Reference in New Issue