Add a UrlBuilder to generate context-aware URLs

Also inject the `contextPath` into the templates for manual url specification.

This is step 3 towards #25.