Text file preview

This PR adds support for previewing text files.

Depends on #661.