Links to shared content fail when the base URL is of another tenant

Moved from oaeproject/Hilary#951

If I want to reference a shared document in an OAE discussion or document then I have to put in a link to the URL of the document. Users from my own tenancy will then be able to follow the link and see the document. However, if the user is in another tenancy, they will be shown the Access Denied screen - even if the document has already been shared with them.

For example, the URL https://oae.gatech.edu/content/gatech/eJNUAMMw1e references a document that has been shared with me. But clicking this link gives me the access denied page.
The URLPatterns should be abstracted so they can be shared between this function and the `encodeForHTMLWithMarkdownLinks` function. I would just make them top level properties as part of the `template` function.