]> sipb.mit.edu Git - ikiwiki.git/commitdiff
fix two bugs in page location in new page creation
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Tue, 14 Mar 2006 06:19:16 +0000 (06:19 +0000)
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Tue, 14 Mar 2006 06:19:16 +0000 (06:19 +0000)
ikiwiki

diff --git a/ikiwiki b/ikiwiki
index 53a86c1edc3ef5f3d4498fa2a55d559e8887df3a..1c16b67258d1cc9fb776df620d12b6cd53095695 100755 (executable)
--- a/ikiwiki
+++ b/ikiwiki
@@ -1020,26 +1020,31 @@ sub cgi_editpage ($$) { #{{{
                        }
                        
                        my @page_locs;
+                       my $best_loc;
                        my ($from)=$form->param('from')=~/$config{wiki_file_regexp}/;
                        if (! defined $from || ! length $from ||
                            $from ne $form->param('from') ||
                            $from=~/$config{wiki_file_prune_regexp}/ || $from=~/^\//) {
-                               @page_locs=$page;
+                               @page_locs=$best_loc=$page;
                        }
                        else {
                                my $dir=$from."/";
                                $dir=~s![^/]+/$!!;
                                push @page_locs, $dir.$page;
                                push @page_locs, "$from/$page";
+                               $best_loc="$from/$page";
                                while (length $dir) {
                                        $dir=~s![^/]+/$!!;
                                        push @page_locs, $dir.$page;
                                }
+
+                               @page_locs = grep { ! exists
+                                       $pagesources{lc($_)} } @page_locs;
                        }
 
                        $form->tmpl_param("page_select", 1);
                        $form->field(name => "page", type => 'select',
-                               options => \@page_locs);
+                               options => \@page_locs, value => $best_loc);
                        $form->title("creating $page");
                }
                elsif ($form->field("do") eq "edit") {