Add document_metadata helper to display document metadata at top and bottom

This was primarily to get an array of metadata into the template so they could be
displayed in the footer as a list instead of a sentence.

It also means the logic of generating metadata has been pulled out into a helper
which can be unit tested.

Some other helpers have been modified to return arrays instead of sentences. Maybe
these don't make sense to be in helpers any longer, I'm not sure.