Template injection

This adds a mechanism for injecting templates from plugins into the themes.

Using it, plugins can define their own specific templates for pages they want to generate, which can still be override by themes, or the user's ``templates/`` folder.

Fixes #1139 

In the longer term, it means we could move some basic templates into tags/gallery/post/stories plugins (not sure that's a good idea)