summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin
diff options
context:
space:
mode:
authorJoey Hess <joey@kitenet.net>2010-06-09 17:44:40 -0400
committerJoey Hess <joey@kitenet.net>2010-06-09 17:44:40 -0400
commit24b59b3a9edb350ef0dc064b0a3f3cdee01f81be (patch)
tree7397521e97ea8fa8a65f46e9cb29ece923c8293e /IkiWiki/Plugin
parentb2327cfae4ac7da1df7bbf848f575b553f74eafb (diff)
editpage: Avoid storing accidental state changes when previewing pages.
This is a slow, safe, stupid approach. Could make deep copies of the data structures as backups instead of re-loading the index from disk.
Diffstat (limited to 'IkiWiki/Plugin')
-rw-r--r--IkiWiki/Plugin/editpage.pm15
1 files changed, 6 insertions, 9 deletions
diff --git a/IkiWiki/Plugin/editpage.pm b/IkiWiki/Plugin/editpage.pm
index af2c5ff4e..3d731d399 100644
--- a/IkiWiki/Plugin/editpage.pm
+++ b/IkiWiki/Plugin/editpage.pm
@@ -170,10 +170,8 @@ sub cgi_editpage ($$) {
$previewing=1;
my $new=not exists $pagesources{$page};
- if ($new) {
- # temporarily record its type
- $pagesources{$page}=$page.".".$type;
- }
+ # temporarily record its type
+ $pagesources{$page}=$page.".".$type if $new;
my %wasrendered=map { $_ => 1 } @{$renderedfiles{$page}};
my $content=$form->field('editcontent');
@@ -198,18 +196,17 @@ sub cgi_editpage ($$) {
});
$form->tmpl_param("page_preview", $preview);
- if ($new) {
- delete $pagesources{$page};
- }
-
# Previewing may have created files on disk.
# Keep a list of these to be deleted later.
my %previews = map { $_ => 1 } @{$wikistate{editpage}{previews}};
foreach my $f (@{$renderedfiles{$page}}) {
$previews{$f}=1 unless $wasrendered{$f};
}
+
+ # Throw out any other state changes made during previewing,
+ # and save the previews list.
+ loadindex();
@{$wikistate{editpage}{previews}} = keys %previews;
- $renderedfiles{$page}=[keys %wasrendered];
saveindex();
}
elsif ($form->submitted eq "Save Page") {