]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/CGI.pm
web commit by Justin: explain workaround using server rewriting.
[git.ikiwiki.info.git] / IkiWiki / CGI.pm
index 1ec23df68c4075788a4d301bd83c14277cba7876..cfb2c0b1d8e39447581d0fb16606c8ff3fac7243 100644 (file)
@@ -357,6 +357,8 @@ sub cgi_editpage ($$) { #{{{
                        linkify($page, "",
                        preprocess($page, $page,
                        filter($page, $page, $content), 0, 1))));
+               # previewing may have created files on disk
+               saveindex();
        }
        elsif ($form->submitted eq "Save Page") {
                $form->tmpl_param("page_preview", "");
@@ -392,9 +394,10 @@ sub cgi_editpage ($$) { #{{{
                                        $dir=~s![^/]+/+$!!;
                                        push @page_locs, $dir.$page;
                                }
+                       
+                               push @page_locs, "$config{userdir}/$page"
+                                       if length $config{userdir};
                        }
-                       push @page_locs, "$config{userdir}/$page"
-                               if length $config{userdir};
 
                        @page_locs = grep {
                                ! exists $pagecase{lc $_}
@@ -402,8 +405,16 @@ sub cgi_editpage ($$) { #{{{
                        if (! @page_locs) {
                                # hmm, someone else made the page in the
                                # meantime?
-                               redirect($q, "$config{url}/".htmlpage($page));
-                               return;
+                               if ($form->submitted eq "Preview") {
+                                       # let them go ahead with the edit
+                                       # and resolve the conflict at save
+                                       # time
+                                       @page_locs=$page;
+                               }
+                               else {
+                                       redirect($q, "$config{url}/".htmlpage($page));
+                                       return;
+                               }
                        }
 
                        my @editable_locs = grep {
@@ -448,7 +459,6 @@ sub cgi_editpage ($$) { #{{{
                }
                
                showform($form, \@buttons, $session, $q);
-               saveindex();
        }
        else {
                # save page