Refactor rich blob viewers and add Code|Rendered switch
Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/24287
EE port: https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/1720
After https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/10563, and while waiting for the build for https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/1556 to succeed, I couldn't help myself.
We now have:
- a totally refactored backend for
BlobViewer
s, - a Source|Rendered switch that shows "Rendered" by default, except when the URL anchor starts with
#L
, which means line number anchors now work to link to specific lines in Markdown source! - a file size limit of 10MB on client-side rendered files, so we don't force users to download huge files,
- and a
.blob-viewer[data-type=simple]
that rich JS viewers can fall back to when the rich rendering fails for whatever reason. They shouldhide()
their own blob viewer (.blob-viewer[data-type=rich]
) and the switch buttons (.js-blob-viewer-switcher
), andshow()
that simple fallback viewer, which will be the regular Download or Text view.
To do:
-
Split up in a sensible way -
Specs
The switch can be seen in action with SVG, but also supported for Markdown and IPython Notebooks, as well as other supported Markup formats: