openannotation/annotator — pull request #444 by nickstenning (2014-09-25 17:28:16+00:00)
Title: [WIP] Plugin refactoring

This another big upset to the organisation of Annotator's internals, but one with significant benefits, I hope. The important things that change in this PR are:

- The `Annotator` object constructs the same old Annotator it has always done, complete with default UI -- but it is a simple wrapper over:
+ `AnnotatorCore` -- the class responsible for plugin and storage registration, which has a `runHook` method to run hooks on all plugins (if the associated callbacks exist)
+ the `DefaultUI` plugin -- where all of the default UI components are instantiated and wired together
- plugins become simple functions of one argument
+ the one argument plugins accept is a registry object
+ at the moment, the only thing that lives on the registry object is an `annotations` property, that provides the ability to perform annotation CRUD operations to plugins
+ plugin functions return a "plugin object", which can define function properties which are called by the core for specific events, such as `onAnnotationCreated`.
- all UI components have been decoupled from their respective plugins, and some don't even have plugins, because it's not actually useful to instantiate the component as a plugin without explicit configuration. These now live in the `Annotator.UI` namespace (`src/ui/`).
- all Storage components have been moved into the `Annotator.Storage` namespace. These are not plugins, they are "storages"
+ side note: what was called "AnnotationRegistry" is now "StorageAdapter", since @tilgovi pointed out that it wasn't a registry in any meaningful sense

If you're looking for a place to start when reviewing this code, I suggest a quick glance at `src/annotator.coffee`, followed by a look at how the default UI is wired together in `src/plugins/defaultui.coffee`.

This is WIP until I've finished messing with the other plugins (Auth, Markdown, Tags, Filter, etc. etc.)