Factor out permalink code so the permalink server and the /permalink handler have the same codepath