[annotator-dev] Implementing REST APIs for store plugin vs handing storage on events
steph at endpoint.com
Thu Mar 26 13:45:18 UTC 2015
On 03/26/2015 08:30 AM, Apurva Jalit wrote:
> I am trying to provide annotation functionality through a chrome
> extension and I wish to preserve these annotations. The documentation
> suggests creating some REST APIs on a server to preserve these
> annotations in a self hosted server. I am very new to web development
> and don't understand in depth the REST API creation and have been
> facing problem implementing those. I am using MVC .NET with C# as the
> backend. Any help to create REST APIs is also welcome.
> But currently, I am just wondering if instead of these APIs through
> storage plugin can I make ajax calls to fetch and save annotations
> through events like "annotation created"? Are there enough events for
> all the operations that have to be performed through REST APIs? What
> are these events? Are there in cons using this approach?
Forgive me if any of this is redundant, but I'll start from the top. You
have to create a backend database server+ store to store the annotations
created by the extension. It's ultimately up to you to determine what
server + data store you use to save this data. Combinations might
include ElasticSearch + Python (see
https://github.com/openannotation/annotator-store), Mongoose + Node (see
https://github.com/hyperstudio/MIT-Annotation-Data-Store), or even
PostgreSQL + Rails (I've done this in one app). I don't think you are
going to get much help on this forum for implementing a backend via C#,
but maybe someone can pipe in about .NET.
You'll need the server to handle a few types of responses:
/search (to list annotations)
POST to /create (create annotation)
DELETE to /annotations/:id (delete annotation)
PATCH/POST to /annotations/:id (update)
GET to /annotations/:id (retrieve)
The actual path names are configurable via Annotator's Store API, but
the ones I've listed are fairly standard in CRUD interfaces. You'll also
want to pay attention to which version of Annotator you are using,
because the Store API may change slightly across versions.
I don't understand the second paragraph, but hopefully I've provided
some help. All of these requests are made via AJAX, and you configure
the specific paths via the Store API as noted.
The best advice I can offer here in terms of debugging is to use Chrome
Developer tools or Firebug to observe AJAX calls as you manipulate
annotations. That will reveal the path being called, the data being
passed, and the response.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the annotator-dev