]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/Plugin/attachment.pm
let thru HTTP_ACCEPT
[git.ikiwiki.info.git] / IkiWiki / Plugin / attachment.pm
index 9a4af4f2befb70472d8a23ccfb0f8ac2c3e4016c..4af9ac92bc2caf5b0c52002d83602dc46d1657ad 100644 (file)
@@ -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.='<link rel="stylesheet" href="'.urlto("ikiwiki/jquery-ui.min.css", $params{page}).' id="theme">'."\n";
+               $js.='<link rel="stylesheet" href="'.urlto("ikiwiki/jquery-ui.min.css", $params{page}).'" id="theme">'."\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,
                }
        }