Use a middleware function for middleware config

Rather than exporting an object which then has to be added to app.locals
manually we simply export the middleware config as another piece of
middlware, which can then augments app.locals itself.

This has the added benefit of being able to do further configuration
beyond template locals if necessary.

I've also taken this opportunity to remove the dependency on the
'version' module, which was only being used here.
Move duplicated locals into config middleware
Move template config into a separate module

This configuration is duplicated between the hosting and instance apps,
so it makes sense to move it all into one place.
Make route middleware an actual piece of middleware
Prevent mixed content warnings from font loading
Add secure middleware to redirect to https

Piece of middleware that will redirect all non-api urls to https.

We're skipping the API urls for now so that backwards compatibility is
preserved for those that are currently using the API. The API is still
available over https, though.
Add force_https config variable

This defaults to false but when set to true the secure middleware is
used which redirects users to the secure version of the site.
Enable express' "trust proxy" setting

This means that express will set 'req.protocol' as 'https' based on the
value of the 'X-Forwarded-Proto' header.

See http://expressjs.com/3x/api.html#app-settings
Enable secure cookies
Fix API url so it uses base_url_format config value