Completed the last two features of the backup system: there's now a button which can back up all the files, one by one; and there's a link to download a zip archive of all the files.
Because of (very reasonable) browser restrictions to prevent cross-domain scripting, it proves to be impossible to retrieve the response from the server when doing either an individual file backup or all of them, when the site is proxied through Bruno's server. What happens is that the JavaScript on the client runs, but the XMLHttpRequest object quite sensibly says that it can't do anything with the response because the response originates from a server which is not the one serving the page. Fair enough; I have some error-trapping in place which gives reasonable feedback for that, and given that (we hope) this password-protection nonsense will go away soon, we can live with it.
The other feature is pretty cool, and worth documenting in some detail. This is how it works:
- A directory generator is called to create Cocoon's standard directory generator XML output.
- This is run through an XSLT transformation which formats it as expected by Cocoon's zip serializer.
- The zip serializer streams out a zip file, as if it were a normal download of a static file. Whether it's creating a temp file first, then serializing it out, or serializing a zip file on the file, file by file, is difficult to know, but it's very fast and it works perfectly.
So now, with one click, the editor can create backups of every output format of every file on the system; and then download a zip archive of the results.