Fix document display code

Fixes GH-1. Also a bit of refactor in the DocumentView class.

The error was in the placement of a condition; it was being checked for each document type instead of just once at the end.