Python backend for Annotator (http://github.com/nickstenning/annotator)
Reference implementation backend for Annotator
web annotation system.
Defines the reference RESTFul API and connects to a database backend to persist annotations created by the frontend, Annotator_.
.. _Annotator: http://github.com/nickstenning/annotator
There is also an experimental CouchDB implementation. See the couchdb
branch
of the repository.
The following instructions assume you have a working installation of python
(2.6 or higher) and sqlite
(any recent version). You will also need pip
and
virtualenv
, which can be installed quickly with one command::
easy_install virtualenv
Now, you should be ok to set up annotator-store-py::
git clone git://github.com/nickstenning/annotator-store-py.git
cd annotator-store-py
pip install -E pyenv -r requirements.txt -e .
If that worked ok, you should see something like::
[...]
Successfully installed annotator HTTPEncode httplib2 Paste PasteDeploy PasteScript routes SQLAlchemy webob wsgifilter
Cleaning up...
You should now be able to run the demo server::
source pyenv/bin/activate
paster serve store.ini
You might a deprecation warning from SQLAlchemy. We're working on removing this but in the mean time you can safely ignore it. You can take a peek at the (little) that the backend is now doing::
curl -i http://localhost:5000/annotations
You'll see that the store responds with "[]": there aren't any annotations in the store at the moment. That's not surprising: you haven't created any. For that, you'll need to go get Annotator_ and hook it up to the backend.
The RESTful interface is provided by the WSGI application in annotator/store.py.
It can be mounted anywhere you like and provides a RESTful resource 'annotations'.
For example if you have mounted it at '/store' you would have::
GET /store/annotations # list
POST /store/annotations # create
GET /store/annotations/{id} # show
PUT /store/annotations/{id} # update
DELETE /store/annotations/{id} # delete
Attributes for these methods (in particular annotation values) may be provided either as individual query parameters or as as json payload (encoded in standard way as argument to a parameter named json). Returned data will be JSON encoded. If a "callback" query parameter is supplied, any response will be JSONP encoded using the value of "callback" as the name of the callback function.
Notes:
Search API is located at: {mount_point}/annotations/search
Results are returned in JSON format::
{
'total': number of results,
'results': results list
}
You can search by any annotation attribute (but not "extras"). For example to search for annotation with a particular 'uri' field you'd visit::
/annotations/search?uri=http://example.com
In addition to search parameters there are three additional control parameters:
Annotations can have the following attributes:
You can also add arbitrary additional key/value pairs to annotations, these are serialized as "extras" in the database in this version of the annotation store.
Beta release: this annotator store has now been successfully used in production deployments.
Major release:
Copyright (c) 2006-2010 the Open Knowledge Foundation.
Licensed under the MIT license:
http://www.opensource.org/licenses/mit-license.php
Versions earlier than 0.3 used js code derived from Geof Glass' code which are therefore (c) Geoff Glass and collaborators and are licensed under the GPL v2.