2017-04-21 14:33:48 -04:00
|
|
|
- hidden = local_assigns.fetch(:hidden, false)
|
2017-04-21 14:59:34 -04:00
|
|
|
- render_error = viewer.render_error
|
2018-03-01 02:33:06 -05:00
|
|
|
- rich_type = viewer.type == :rich ? viewer.partial_name : nil
|
2017-06-07 17:07:57 -04:00
|
|
|
- load_async = local_assigns.fetch(:load_async, viewer.load_async? && render_error.nil?)
|
2018-02-06 08:33:18 -05:00
|
|
|
- external_embed = local_assigns.fetch(:external_embed, false)
|
2017-04-21 14:33:48 -04:00
|
|
|
|
2018-04-08 00:35:30 -04:00
|
|
|
- viewer_url = local_assigns.fetch(:viewer_url) { url_for(safe_params.merge(viewer: viewer.type, format: :json)) } if load_async
|
2018-03-01 02:33:06 -05:00
|
|
|
.blob-viewer{ data: { type: viewer.type, rich_type: rich_type, url: viewer_url }, class: ('hidden' if hidden) }
|
2017-06-07 17:07:57 -04:00
|
|
|
- if render_error
|
2017-04-26 16:48:49 -04:00
|
|
|
= render 'projects/blob/render_error', viewer: viewer
|
2017-06-07 17:07:57 -04:00
|
|
|
- elsif load_async
|
|
|
|
= render viewer.loading_partial_path, viewer: viewer
|
2018-02-06 08:33:18 -05:00
|
|
|
- elsif external_embed
|
|
|
|
= render 'projects/blob/viewers/highlight_embed', blob: viewer.blob
|
2017-04-21 14:33:48 -04:00
|
|
|
- else
|
|
|
|
- viewer.prepare!
|
2017-06-07 17:07:57 -04:00
|
|
|
|
2017-07-10 08:10:43 -04:00
|
|
|
-# 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?
|
|
|
|
|
|
|
|
= render viewer.partial_path, viewer: viewer
|
|
|
|
|