From d4d232740078d0cab15b4f78e797c0802b692e5c Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 14 Jun 2011 13:59:11 -0400 Subject: [PATCH] fixed saving attachments on page save Also saved on preview, but previewing is a bit broken, does not see the newly saved attachment yet. --- IkiWiki/Plugin/attachment.pm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/IkiWiki/Plugin/attachment.pm b/IkiWiki/Plugin/attachment.pm index 7f88010b5..06b0c6c51 100644 --- a/IkiWiki/Plugin/attachment.pm +++ b/IkiWiki/Plugin/attachment.pm @@ -118,7 +118,7 @@ sub formbuilder (@) { ($form->submitted eq "Upload Attachment" || $form->submitted eq "Save Page")) { attachment_store($filename, $form, $q, $params{session}); } - if ($form->submitted eq "Save Page") { + if ($form->submitted eq "Save Page" || $form->submitted eq "Preview") { attachments_save($form, $params{session}); } @@ -236,7 +236,7 @@ sub attachments_save { my $dest=$config{srcdir}."/". linkpage(IkiWiki::possibly_foolish_untaint( attachment_location($form->field('page')))). - $filename; + IkiWiki::basename($filename); unlink($dest); rename($filename, $dest); push @attachments, $dest; @@ -291,12 +291,13 @@ sub attachment_list ($) { # attachments in holding directory my $dir=attachment_holding_dir($page); + my $heldmsg=gettext("this attachment is not yet saved"); foreach my $file (glob("$dir/*")) { my $mtime=(stat($file))[9]; my $f=IkiWiki::basename($file); $attachments{$f}={ "field-select" => '', - link => $f, # no link possible + link => "$f", size => IkiWiki::Plugin::filecheck::humansize((stat($file))[7]), mtime => displaytime($mtime), mtime_raw => $mtime, -- 2.26.2