[annotator-dev] annotator2/master storage configuration

Benjamin Young bigbluehat at hypothes.is
Mon Jan 26 14:32:24 UTC 2015


Hey Andrew,

I'm guessing your wanting to use the HTTP Storage implementation (since you
mention endpoint configuration). If that guess is correct, you would do it
something like this:

```
anno.setStorage(function() {
  return new HTTPStorage({
    prefix: '/url/to/your/endpoint'
  });
});
```

Essentially, setStorage expects a function that will return a storage
implementation (which amounts to an object with functions for create,
update, delete, and query; see the DebugStorage code [1] for a simple
example). HTTPStorage ships with annotator and assumes that you're using
something compatible with the annotator-store project [2].

So, in effect, you create a new HTTPStorage object inside a closure that
setStorage will use when it sets things up for create, update, etc.

The indirection can be a little confusing, but it does provide a way for
you to test your storage code without any additional setup (as they're
generally just plain JS functions and objects.

Hope that helps!
Benjamin

[1]
https://github.com/openannotation/annotator/blob/master/src/storage.js#L19
[2] https://github.com/openannotation/annotator-store

On Sun, Jan 25, 2015 at 10:06 PM, andrew simpson <andrew10961 at gmail.com>
wrote:

> I've been trying to look through example HTML files and storage.js
> implementation for details of how to specify a remote storage service
> for annotator2 (master), but haven't found a clear one yet.
>
> I can see this in dev.html, but so far seen nothing that corresponds to
> endpoint configuration - is this available?
>
>       var Annotator = require('annotator'),
>       elem = document.getElementById('airlock'),
>       anno = new Annotator(elem);
>       anno.addPlugin(Annotator.Plugin.Filter());
>       anno.setStorage(Annotator.Storage.DebugStorage);
>
> Thanks...
>
> _______________________________________________
> annotator-dev mailing list
> annotator-dev at lists.okfn.org
> https://lists.okfn.org/mailman/listinfo/annotator-dev
> Unsubscribe: https://lists.okfn.org/mailman/options/annotator-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/annotator-dev/attachments/20150126/273adf67/attachment-0002.html>


More information about the annotator-dev mailing list