+ my $page=$form->field("page");
+ my $file=$pagesources{$page};
+
+ # Validate removal by checking that the page exists,
+ # and that the user is allowed to edit(/remove) it.
+ if (! exists $pagesources{$page}) {
+ error(sprintf(gettext("%s does not exist"),
+ htmllink("", "", $page, noimageinline => 1)));
+ }
+ IkiWiki::check_canedit($page, $q, $session);
+
+ # Do removal, and update the wiki.
+ require IkiWiki::Render;
+ if ($config{rcs}) {
+ IkiWiki::rcs_remove($file);
+ IkiWiki::disable_commit_hook();
+ IkiWiki::rcs_commit($file, gettext("removed"),
+ IkiWiki::rcs_prepedit($file),
+ $session->param("name"), $ENV{REMOTE_ADDR});
+ IkiWiki::enable_commit_hook();
+ IkiWiki::rcs_update();
+ }
+ IkiWiki::prune("$config{srcdir}/$file");
+ IkiWiki::refresh();
+ IkiWiki::saveindex();
+
+ # Redirect to parent of the page.
+ my $parent=IkiWiki::dirname($page);
+ if (! exists $pagesources{$parent}) {
+ $parent="index";
+ }
+ IkiWiki::redirect($q, $config{url}."/".htmlpage($parent));