[annotator-dev] New to CoffeeScript and building Annotator source

Brian Long brilong87 at gmail.com
Tue May 15 02:52:41 UTC 2012


Hi All,

I'm new to CoffeeScript (and haven't yet been convinced of it's
usefulness), but I've started building Annotator source.  We're using
the Annotator
library <https://github.com/okfn/annotator> at work and I've had a heck of
a time figuring out how to delete my annotator instance, created via
$(".content-body").annotator(); , or perhaps just update specific options
and send another request to the server to get existing annotations.

I'm hoping to reinitialize my annotator when my document changes.  We only
load one document at a time and essentially I remove all of it's DOM
elements and then append in the new DOM elements for the newly displayed
content.  After that, I'd like to do refresh the displayed (already
persisted) annotations from the server, which have already been stored for
the document.  Hopefully something like this:

    commentOptions.store.prefix = '/rest-services/comments/';
    commentOptions.store.prefix += myConfig.docID+'/';

    myComments = $('.content-body').annotator();
    myComments.annotator ('addPlugin', 'Store', commentOptions.store);
    myComments.annotator ('addPlugin', 'Permissions', {
        user: '',
        showViewPermissionsCheckbox: false,
        showEditPermissionsCheckbox: false
    });

The quote above is from a comment I
made<https://github.com/okfn/annotator/issues/87#issuecomment-5689248>on
the annotator project.

I really couldn't figure out how to do this from the Wiki documentation, so
I figured I'd start hacking around in the source.  After some issues
installing NodeJS (v 0.6.12), npm (v 1.1.4), CoffeeScript (v 1.2.0) and
PhantomJS (v. 1.5) -- all of which on Ubuntu 12.04 x64 -- I was able to
build and run Jasmine tests like this:

me at home:~/annotator$ ./tools/watch ./test/helpers/phantomjs_helper.coffee
22:26:01 - compiled src/annotator.coffee
22:26:01 - compiled src/widget.coffee
22:26:01 - compiled src/...

Then, I open : http://localhost:8000/test/runner.html and have the
resulting "411 specs, 0 failures in
5.718s<http://localhost:8000/test/runner.html?>
".

I have to say, I'm not entirely sure how I got to this point, so hopefully
I can reproduce my steps.  If so, I'd love to add a bit to your
documentation and perhaps create a wiki page of "Building Annotator for
Dummies" (*I really couldn't figure out the 'redo' build tool)*...

Anyhow, does anyone have any thoughts on how I might delete /
re-instantiation the annotator like I've mentioned above or where I might
begin digging in the source to enable the functionality I want ?

Thanks in advance,
Brian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/annotator-dev/attachments/20120514/bbf97eb6/attachment-0001.html>


More information about the annotator-dev mailing list