latin-language-toolkit/arethusa — pull request #453 by LFDM (2014-10-23 09:18:00+00:00)
Title: Add preview and download functionality of documents

This came up while debugging the problems eventually fixed in #451 and #452.

Code needed for this could be reworked a bit to bring as a new feature: We can now preview and download annotation documents on the fly, right from within the browser.

This is done through state persisters, which have to expose a couple of things, so that the `saver` service can work it them through the `outputter` directive.

When persisters define an `output` function, they are added to the list of valid outputters.
The `docIdentifier` of persisters also needs to be publically exposed. It's a component of the downloadable file's name and also displayed in the modal that drives this process.

They also have to define a `mimeType` variable, so that the datastream is really correct as well as a `fileType` variable - this is used to build the proper file extension.

Let's assume we have a persister `x` that serves xml:

``` javascript
x.output = function() {
// Has to return the output string
}

x.mimeType = 'text/xml'
x.fileType = 'xml'
x.identifier = 'treebank'
```

This would allow us to download a file called `treebank.xml`.

As of now this `outputter` is accessible through the top bar, right next to the `Save` button.