[annotator-dev] beforeAnnotationsLoaded event

Randall Leeds tilgovi at hypothes.is
Wed Dec 18 23:30:30 UTC 2013


On Wed, Dec 18, 2013 at 12:58 PM, Riccardo Tasso
<riccardo.tasso at gmail.com>wrote:

> Ok Randall, I've already seen that page, and it's very usefull to me.
>
>
I thought perhaps you had.


> My problem is that my backend doesn't know anything about the html
> structure of the page, so he shouldn't store the xpath for start and end of
> each annotation.
>
> I'd like to receive annotations from the backend, and let the client
> translate from my own format to annotateit format, since it's the only
> which really knows the html structure. Hence, after the store plugin
> receive the annotations, I'd like to apply a function to them and let
> annotateit make his job.
>
> If you help me understanding where the store plugin receives the
> annotations from the backend, and what does with them I could try to work
> on it, but I think It's a pity rewrite a storage plugin just for this task.
>

I agree. Thanks for the feedback on that.


> Probably another option would be that of passing a function as a storage
> plugin option, called for example annotationsProcessor.
>
> What do you think about it?
>

+1 to the sentiment.

What do you think the right hooks are?

Should we provide a way to override serialize/deserialize methods?


The master branch of Annotator now has a slightly easier way to use your
own store that doesn't require you to build a full plugin or utilize any
event subscription. Example:


    MyStore = function (elem, options) {
      this.query = //...
      this.create = //...
      this.update = //...
      this.delete = //...
    }

    var annotator = new Annotator(document.body, {
      store: {
        type: MyStore,
        /* Any other settings will get passed to your constructor as the
options parameter */
      }
    });


If you want most of the default Store functionality, with just overrides,
you could monkey-patch:


    var oldQuery = annotator['store'].query;
    annotator['store'].query = function (...) {
      // do something with oldQuery, then munge results
    };


Again, these examples are off annotator master branch, not the last tagged
release, but your input would be really helpful to shape how these
interfaces look for annotator 2.0.

Soooo... you tell me what would be most simple, elegant, helpful!

Steph's input, as well as anyone else paying attention, would be quite
helpful, too.


>
> Cheers,
>    Riccardo
>
> P.S. are you on IRC channel?
>

Yes. I missed you asking, though. I'm "tilgovi".
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/annotator-dev/attachments/20131218/edcb7e6b/attachment-0004.html>


More information about the annotator-dev mailing list