aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Hess <joey@kitenet.net>2011-06-14 15:07:34 -0400
committerJoey Hess <joey@kitenet.net>2011-06-14 15:07:34 -0400
commita61849e95496027d07c38219d5cc47fe37b5aa25 (patch)
tree9001182512161ac7a8640766ecbb1c7c91261205
parent04b2a4d6762b33a199b18de4df3991ecba87db7d (diff)
downloadikiwiki-a61849e95496027d07c38219d5cc47fe37b5aa25.tar
ikiwiki-a61849e95496027d07c38219d5cc47fe37b5aa25.tar.gz
bugfix for attachments of non-index pages
-rw-r--r--IkiWiki/Plugin/attachment.pm24
1 files changed, 15 insertions, 9 deletions
diff --git a/IkiWiki/Plugin/attachment.pm b/IkiWiki/Plugin/attachment.pm
index c6f8891c2..ea40379ff 100644
--- a/IkiWiki/Plugin/attachment.pm
+++ b/IkiWiki/Plugin/attachment.pm
@@ -295,17 +295,25 @@ sub attachment_list ($) {
my $page=shift;
my $loc=attachment_location($page);
+ my $std=sub {
+ my $file=shift;
+ my $mtime=shift;
+ my $size=shift;
+
+ "field-select" => '<input type="checkbox" name="attachment_select" value="'.$file.'" />',
+ size => IkiWiki::Plugin::filecheck::humansize($size),
+ mtime => displaytime($mtime),
+ mtime_raw => $mtime,
+ };
+
# attachments already in the wiki
my %attachments;
foreach my $f (values %pagesources) {
if (! defined pagetype($f) &&
$f=~m/^\Q$loc\E[^\/]+$/) {
$attachments{$f}={
- "field-select" => '<input type="checkbox" name="attachment_select" value="'.$f.'" />',
+ $std->($f, $IkiWiki::pagemtime{$f}, (stat($f))[7]),
link => htmllink($page, $page, $f, noimageinline => 1),
- size => IkiWiki::Plugin::filecheck::humansize((stat($f))[7]),
- mtime => displaytime($IkiWiki::pagemtime{$f}),
- mtime_raw => $IkiWiki::pagemtime{$f},
};
}
}
@@ -315,13 +323,11 @@ sub attachment_list ($) {
my $heldmsg=gettext("this attachment is not yet saved");
foreach my $file (glob("$dir/*")) {
my $mtime=(stat($file))[9];
- my $f=IkiWiki::basename($file);
+ my $f=$file;
+ $f=~s/^\Q$dir\E\///;
$attachments{$f}={
- "field-select" => '<input type="checkbox" name="attachment_select" value="'.$f.'" />',
+ $std->($page."/".$f, (stat($file))[9], (stat($file))[7]),
link => "<span title=\"$heldmsg\">$f</span>",
- size => IkiWiki::Plugin::filecheck::humansize((stat($file))[7]),
- mtime => displaytime($mtime),
- mtime_raw => $mtime,
}
}