[annotator-dev] beforeAnnotationsLoaded event

Steph Skardal steph at endpoint.com
Wed Dec 18 21:14:11 UTC 2013


I had to complete a similar task to this. I created a custom 
loadAnnotations method, shown at 
https://github.com/berkmancenter/h2o/blob/annotator/public/javascripts/h2o-annotator.js#L678-L703. 
This method formats the annotations in the format that my application 
stores them to the format that the annotator plugin can use them.

I did have to override the annotator core to call this before loading 
the annotations ( 
https://github.com/berkmancenter/h2o/blob/annotator/public/javascripts/annotator-full.js#L2296-L2302). 
I utilize much of the existing Store plugin functionality, and I second 
that it's not ideal to rewrite the storage plugin to override small 
parts of it.

Also, notable: I tried to pull out various methods from 
annotator-full.js to override them in my plugin (e.g. 
https://github.com/berkmancenter/h2o/blob/annotator/public/javascripts/h2o-annotator.js#L22-L50) 
because I didn't want so many core overrides, however, I hit limitations 
because some functionality was not available in the scope of my plugin, 
specifically I tried to override setupAnnotation, and Range.sniff was 
not a known method when overridden in my plugin. I'm sure there was a 
fix for this and I'd gradually like to pull out all of my core overrides 
from annotator-full.js, but I have to pick my battles and for now 
annotator is working with some customizations. At the very least, I can 
take a diff between my annotator-full and the release version to see 
where there are customizations.

Steph





On 12/18/2013 03:58 PM, Riccardo Tasso wrote:
> Ok Randall, I've already seen that page, and it's very usefull to me.
>
> 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.
>
> 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?
>
> Cheers,
>    Riccardo
>
> P.S. are you on IRC channel?
>
>
> 2013/12/18 Randall Leeds <tilgovi at hypothes.is 
> <mailto:tilgovi at hypothes.is>>
>
>     You can customize the Store plugin to load from your backend, if
>     it's just a matter of configuration.
>     https://github.com/okfn/annotator/wiki/Store-Plugin
>
>     I would like to know how you would use a beforeAnnotationsLoaded
>     event, in case there's another way the use case should be supported.
>
>
>     On Tue, Dec 17, 2013 at 12:38 PM, Riccardo Tasso
>     <riccardo.tasso at gmail.com <mailto:riccardo.tasso at gmail.com>> wrote:
>
>         Since I'm not fluent in coffeescript, I understood that for
>         the creation/update/delete I should register for the
>         corresponding events in my plugin.
>
>
>         What should I do to make my plugin load the annotation list
>         from my own backend?
>
>
>         Thanks,
>
>            Riccardo
>
>
>         Il 17/dic/2013 20:31 "Randall Leeds" <tilgovi at hypothes.is
>         <mailto:tilgovi at hypothes.is>> ha scritto:
>
>             No. There is no such event. You should take care of this
>             transformation in your store plugin. You may need to
>             extend the existing Store plugin to suit your needs.
>
>
>             On Tue, Dec 17, 2013 at 11:07 AM, Riccardo Tasso
>             <riccardo.tasso at gmail.com
>             <mailto:riccardo.tasso at gmail.com>> wrote:
>
>                 Hi, does exist an event which holds just after the
>                 annotations are returned by the store?
>
>                 My store uses an internal format and I'd like to
>                 change its results a little bit before the annotations
>                 are drawn.
>
>                 Thanks,
>                    Riccardo
>
>
>                 _______________________________________________
>                 annotator-dev mailing list
>                 annotator-dev at lists.okfn.org
>                 <mailto:annotator-dev at lists.okfn.org>
>                 https://lists.okfn.org/mailman/listinfo/annotator-dev
>                 Unsubscribe:
>                 https://lists.okfn.org/mailman/options/annotator-dev
>
>
>
>
>
>
> _______________________________________________
> 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/20131218/4c8c9199/attachment-0004.html>


More information about the annotator-dev mailing list