]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/commitdiff
fixed saving attachments on page save
authorJoey Hess <joey@kitenet.net>
Tue, 14 Jun 2011 17:59:11 +0000 (13:59 -0400)
committerJoey Hess <joey@kitenet.net>
Tue, 14 Jun 2011 17:59:56 +0000 (13:59 -0400)
Also saved on preview, but previewing is a bit broken, does not see the
newly saved attachment yet.

IkiWiki/Plugin/attachment.pm

index 7f88010b5d263559123d9ca0202aafff9d52a7a7..06b0c6c51685ebb3206b1411b5ba52f2df236e71 100644 (file)
@@ -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" => '<input type="checkbox" name="attachment_select" value="'.$f.'" />',
-                       link => $f, # no link possible
+                       link => "<span title=\"$heldmsg\">$f</span>",
                        size => IkiWiki::Plugin::filecheck::humansize((stat($file))[7]),
                        mtime => displaytime($mtime),
                        mtime_raw => $mtime,