- else {
- # save page
- check_canedit($page, $q, $session);
-
- my $content=$form->field('editcontent');
-
- $content=~s/\r\n/\n/g;
- $content=~s/\r/\n/g;
-
- $config{cgi}=0; # avoid cgi error message
- eval { writefile($file, $config{srcdir}, $content) };
- $config{cgi}=1;
- if ($@) {
- $form->field(name => "rcsinfo", value => rcs_prepedit($file),
- force => 1);
- $form->tmpl_param("failed_save", 1);
- $form->tmpl_param("error_message", $@);
- $form->field("editcontent", value => $content, force => 1);
- $form->field(name => "comments", value => $form->field('comments'), force => 1);
- $form->field("do", "edit)");
- $form->tmpl_param("page_select", 0);
- $form->field(name => "page", type => 'hidden');
- $form->field(name => "type", type => 'hidden');
- $form->title(sprintf(gettext("editing %s"), $page));
- print $form->render(submit => \@buttons);
- return;
- }
-
- if ($config{rcs}) {
- my $message="";
- if (defined $form->field('comments') &&
- length $form->field('comments')) {
- $message=$form->field('comments');
- }
-
- if ($newfile) {
- rcs_add($file);
- }
- # prevent deadlock with post-commit hook
- unlockwiki();
- # presumably the commit will trigger an update
- # of the wiki
- my $conflict=rcs_commit($file, $message,
- $form->field("rcsinfo"),
- $session->param("name"), $ENV{REMOTE_ADDR});
-
- if (defined $conflict) {
- $form->field(name => "rcsinfo", value => rcs_prepedit($file),
- force => 1);
- $form->tmpl_param("page_conflict", 1);
- $form->field("editcontent", value => $conflict, force => 1);
- $form->field(name => "comments", value => $form->field('comments'), force => 1);
- $form->field("do", "edit)");
- $form->tmpl_param("page_select", 0);
- $form->field(name => "page", type => 'hidden');
- $form->field(name => "type", type => 'hidden');
- $form->title(sprintf(gettext("editing %s"), $page));
- print $form->render(submit => \@buttons);
- return;
- }
- else {
- # Make sure that the repo is up-to-date;
- # locking prevents the post-commit hook
- # from updating it.
- rcs_update();
- }
- }
- else {
- require IkiWiki::Render;
- refresh();
- saveindex();
- }
-
- # The trailing question mark tries to avoid broken
- # caches and get the most recent version of the page.
- redirect($q, "$config{url}/".htmlpage($page)."?updated");