Skip to content

Refactor rich blob viewers and add Code|Rendered switch

Douwe Maan requested to merge dm-blob-viewers into master

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 BlobViewers,
  • 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 should hide() their own blob viewer (.blob-viewer[data-type=rich]) and the switch buttons (.js-blob-viewer-switcher), and show() 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:

Screen_Shot_2017-04-11_at_15.33.11

Screen_Shot_2017-04-11_at_15.33.15

/cc @rspeicher @jschatz1 @rymai @grzesiek

Merge request reports