X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/b85485aaa2dd5d7514bfb8c8a0a77363b2b28bd2..d4a0732752e79b57509cee33001ab757132366c5:/IkiWiki/Plugin/attachment.pm
diff --git a/IkiWiki/Plugin/attachment.pm b/IkiWiki/Plugin/attachment.pm
index 9a4af4f2b..4af9ac92b 100644
--- a/IkiWiki/Plugin/attachment.pm
+++ b/IkiWiki/Plugin/attachment.pm
@@ -94,7 +94,7 @@ sub formbuilder_setup (@) {
# Add all the javascript used by the attachments interface.
require IkiWiki::Plugin::toggle;
my $js=IkiWiki::Plugin::toggle::include_javascript($params{page});
- $js.=''."\n";
+ $js.=''."\n";
my @jsfiles=qw{jquery.min jquery-ui.min
jquery.tmpl.min jquery.iframe-transport
jquery.fileupload jquery.fileupload-ui
@@ -252,22 +252,25 @@ sub attachment_store {
IkiWiki::fast_file_copy($tempfile, $filename, $fh, @_);
});
}
-
+
# Return JSON response for the jquery file upload widget.
- eval q{use JSON};
- error $@ if $@;
- print "Content-type: application/json\n\n";
- my $size=-s $dest."/".$filename;
- print to_json([
- {
- name => $filename,
- size => $size,
- humansize => IkiWiki::Plugin::filecheck::humansize($size),
- stored_msg => stored_msg(),
-
- }
- ]);
- exit 0;
+ if ($q->Accept("application/json") >= 1.0 &&
+ grep { /application\/json/i } $q->Accept) {
+ eval q{use JSON};
+ error $@ if $@;
+ print "Content-type: application/json\n\n";
+ my $size=-s $dest."/".$filename;
+ print to_json([
+ {
+ name => $filename,
+ size => $size,
+ humansize => IkiWiki::Plugin::filecheck::humansize($size),
+ stored_msg => stored_msg(),
+
+ }
+ ]);
+ exit 0;
+ }
}
# Save all stored attachments for a page.
@@ -354,7 +357,7 @@ sub attachment_list ($) {
my $base=IkiWiki::basename($file);
my $f=$loc.$base;
$attachments{$f}={
- $std->($f, (stat($file))[9], stored_msg(), (stat(_))[7]),
+ $std->($f, (stat($file))[9]*2, stored_msg(), (stat(_))[7]),
link => $base,
}
}