Needed for attachment to return json when requested.
I think some browsers send Accept: * , so I made sure to check that json
was explicitly listed as to be accepted, as well as having a high
priority.
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.
push @envsave, qw{REMOTE_ADDR QUERY_STRING REQUEST_METHOD REQUEST_URI
CONTENT_TYPE CONTENT_LENGTH GATEWAY_INTERFACE
HTTP_COOKIE REMOTE_USER HTTPS REDIRECT_STATUS
- HTTP_HOST SERVER_PORT HTTPS
+ HTTP_HOST SERVER_PORT HTTPS HTTP_ACCEPT
REDIRECT_URL} if $config{cgi};
my $envsave="";
foreach my $var (@envsave) {
* userlist: New plugin, lets admins see a list of users and their info.
* aggregate: Improve checking for too long aggregated filenames.
* Updated to jQuery 1.6.1.
+ * attachment: Speed up multiple file uploads by storing uploaded files
+ in a staging area until the page is saved/previewed, rather than
+ refreshing the site after each upload.
+ * attachment: Files can be dragged into the edit page to upload them.
+ Multiple file upload support. Upload progress bars.
+ Impemented using the jQuery-File-Upload widget.
-- Joey Hess <joeyh@debian.org> Thu, 09 Jun 2011 10:06:44 -0400