More/Archival template vars

This is a fairly large change set, I can break it down if you want but then the separate pull requests will have to be done in order because they will depend on the previous one.  These changes are mostly to support my use in shelve as a web history archiving plugin.

Many new variables were added, some just variations of existing ones.  This lead to the rewrite of shelve.getDocumentFilename, which should be now be simpler and more efficient.  Some of the new variables are queryhash (for getting the md5 hash of the query string), dirnameshorten (for getting the directory path with all path components exceeding the filesystem filename limit shorted and appended with a hash of the unshortened name to preserve uniqueness), archivefilename (filename unique across GET requests which tries to preserve as much of the original filename as possible), and several others.