Move diff display logic out of views
A diff file is collapsed by default if it's:
- Over 10 KB in size.
- Past the first 100 files.
- Past the first 5000 lines.
- Undiffable (suppressed by .gitattributes).
- An image.
- Any other unpreviewable type.
The first three of those are defined in gitlab_git, and the latter three are defined in the view. This makes deciding whether any files are collapsed on page load or not problematic: if a file would be collapsed by any of the first three, but not by the latter three, then it shouldn't be collapsed but won't display sensibly.
Because the latter three are in the view, they mean that if we want to put the diff's collapsed status in the file header (like https://gitlab.com/gitlab-org/gitlab-ce/issues/14103#note_13134921), we have to duplicate the logic in the view further up. It would be nice if we could move as much logic out of the view as possible, to make it easier to do things like this.