X-Git-Url: https://sipb.mit.edu/gitweb.cgi/ikiwiki.git/blobdiff_plain/34e8c78c1c9bf65564c1a3086584158e5c3cc415..e93cee33786da51d80f375cbeb8fb24db24bf0c9:/IkiWiki/Plugin/editpage.pm diff --git a/IkiWiki/Plugin/editpage.pm b/IkiWiki/Plugin/editpage.pm index 26e38abc1..af2c5ff4e 100644 --- a/IkiWiki/Plugin/editpage.pm +++ b/IkiWiki/Plugin/editpage.pm @@ -78,7 +78,7 @@ sub cgi_editpage ($$) { action => $config{cgiurl}, header => 0, table => 0, - template => scalar template_params("editpage.tmpl"), + template => { template("editpage.tmpl") }, ); decode_form_utf8($form); @@ -148,12 +148,12 @@ sub cgi_editpage ($$) { $form->field(name => "editcontent", type => "textarea", rows => 20, cols => 80); $form->tmpl_param("can_commit", $config{rcs}); - $form->tmpl_param("indexlink", indexlink()); $form->tmpl_param("helponformattinglink", htmllink($page, $page, "ikiwiki/formatting", noimageinline => 1, linktext => "FormattingHelp")); + my $previewing=0; if ($form->submitted eq "Cancel") { if ($form->field("do") eq "create" && defined $from) { redirect($q, urlto($from, undef, 1)); @@ -167,6 +167,8 @@ sub cgi_editpage ($$) { exit; } elsif ($form->submitted eq "Preview") { + $previewing=1; + my $new=not exists $pagesources{$page}; if ($new) { # temporarily record its type @@ -256,7 +258,7 @@ sub cgi_editpage ($$) { if (! @page_locs) { # hmm, someone else made the page in the # meantime? - if ($form->submitted eq "Preview") { + if ($previewing) { # let them go ahead with the edit # and resolve the conflict at save # time @@ -313,7 +315,10 @@ sub cgi_editpage ($$) { $form->title(sprintf(gettext("editing %s"), pagetitle($page))); } - showform($form, \@buttons, $session, $q, forcebaseurl => $baseurl); + showform($form, \@buttons, $session, $q, + forcebaseurl => $baseurl, + ($previewing ? (page => $page) : ()), + ); } else { # save page @@ -330,7 +335,8 @@ sub cgi_editpage ($$) { $form->field(name => "page", type => 'hidden'); $form->field(name => "type", type => 'hidden'); $form->title(sprintf(gettext("editing %s"), $page)); - showform($form, \@buttons, $session, $q, forcebaseurl => $baseurl); + showform($form, \@buttons, $session, $q, + forcebaseurl => $baseurl); exit; } elsif ($form->field("do") eq "create" && $exists) { @@ -344,7 +350,8 @@ sub cgi_editpage ($$) { value => readfile("$config{srcdir}/$file"). "\n\n\n".$form->field("editcontent"), force => 1); - showform($form, \@buttons, $session, $q, forcebaseurl => $baseurl); + showform($form, \@buttons, $session, $q, + forcebaseurl => $baseurl); exit; }