debian-mirror-gitlab/app/views/projects/blob/_viewer.html.haml

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

26 lines
1.2 KiB
Text
Raw Normal View History

2017-08-17 22:00:37 +05:30
- hidden = local_assigns.fetch(:hidden, false)
- render_error = viewer.render_error
2018-03-27 19:54:05 +05:30
- rich_type = viewer.type == :rich ? viewer.partial_name : nil
2017-09-10 17:25:29 +05:30
- load_async = local_assigns.fetch(:load_async, viewer.load_async? && render_error.nil?)
2018-10-15 14:42:47 +05:30
- external_embed = local_assigns.fetch(:external_embed, false)
2017-09-10 17:25:29 +05:30
2018-06-27 16:04:02 +05:30
- viewer_url = local_assigns.fetch(:viewer_url) { url_for(safe_params.merge(viewer: viewer.type, format: :json)) } if load_async
2021-09-04 01:27:46 +05:30
- add_page_startup_api_call viewer_url
2020-07-28 23:09:34 +05:30
.blob-viewer{ data: { type: viewer.type, rich_type: rich_type, url: viewer_url, path: viewer.blob.path }, class: ('hidden' if hidden) }
2017-09-10 17:25:29 +05:30
- if render_error
2017-08-17 22:00:37 +05:30
= render 'projects/blob/render_error', viewer: viewer
2017-09-10 17:25:29 +05:30
- elsif load_async
= render viewer.loading_partial_path, viewer: viewer
2018-10-15 14:42:47 +05:30
- elsif external_embed
= render 'projects/blob/viewers/highlight_embed', blob: viewer.blob
2017-08-17 22:00:37 +05:30
- else
- viewer.prepare!
2017-09-10 17:25:29 +05:30
-# In the rare case where the first kilobyte of the file looks like text,
-# but the file turns out to actually be binary after loading all data,
-# we fall back on the binary Download viewer.
- viewer = BlobViewer::Download.new(viewer.blob) if viewer.binary_detected_after_load?
2017-08-17 22:00:37 +05:30
= render viewer.partial_path, viewer: viewer
2017-09-10 17:25:29 +05:30