let thru HTTP_ACCEPT
authorJoey Hess <joey@kitenet.net>
Thu, 16 Jun 2011 00:02:14 +0000 (20:02 -0400)
committerJoey Hess <joey@kitenet.net>
Thu, 16 Jun 2011 00:02:14 +0000 (20:02 -0400)
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/Plugin/attachment.pm
IkiWiki/Wrapper.pm
debian/changelog

index 6004a09828721af15032f7e3396e40d99141aee0..4af9ac92bc2caf5b0c52002d83602dc46d1657ad 100644 (file)
@@ -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.
index 4fe2d8111d0a76714f37387f41da4d2666f3f5e2..d39a3ea402d153db93c34dd1e1aef751954a7e79 100644 (file)
@@ -49,7 +49,7 @@ sub gen_wrapper () {
        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) {
index cb0ee6856eca5fd173558cae252089ccd3e5a50b..5900b4e5fdfdd75693a824a53e0539f6c7e6fb11 100644 (file)
@@ -3,6 +3,12 @@ ikiwiki (3.20110609) UNRELEASED; urgency=low
   * 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