[humanities-dev] Colouring and rendering annotations in Textus

Tom Oinn tom.oinn at okfn.org
Tue Jun 19 10:07:11 UTC 2012


Just in case anyone is playing with the Textus code and wants to
create their own colouring scheme...

Annotations in the Textus data store contain the minimum information
required for their definition. This does not include things like
colour, mostly because we want to enable different colouring - at the
moment there is a single colouring mode which picks a colour based on
the author of the annotation. To enable this annotations returned by
the API have a field 'dynamic' which contains any information the
server has dynamically added to the annotation - these fields are not
stored in the data store, they're augmented on the fly by the REST
server.

To change the colouring, you need to modify or add to the painter
algorithms defined at
https://github.com/okfn/textus/blob/master/src/js/annotationPainter.js
- any functions in the 'painters' property in that file will be called
whenever an annotation is about to be sent to the client, simply
return an object containing any properties you want merged into the
annotation.dynamic field. In the single case that already exists you
should be able to see how we're extracting the colour preferences from
the user object and using them to create a colour string which will
then be used by the client when rendering the annotation regions,
callouts and backgrounds.

Annotations are rendered through a simple templating engine, so any
(textual) dynamic properties your painters add are accessible as
fields to that engine, for example
https://github.com/okfn/textus/blob/master/src/public/templates/annotations/comment.html
is the template for the free text comments - you could create a
painter which added a field to the annotation's dynamic properties and
then access this in your template to show more information. What kind
of information? That's rather up to you...

-- 
Tom Oinn
+44 (0) 20 8123 5142 or Skype ID 'tomoinn'
http://www.crypticsquid.com




More information about the humanities-dev mailing list