2017-08-17 22:00:37 +05:30
|
|
|
- hidden = local_assigns.fetch(:hidden, false)
|
|
|
|
- render_error = viewer.render_error
|
2017-09-10 17:25:29 +05:30
|
|
|
- load_async = local_assigns.fetch(:load_async, viewer.load_async? && render_error.nil?)
|
|
|
|
|
|
|
|
- viewer_url = local_assigns.fetch(:viewer_url) { url_for(params.merge(viewer: viewer.type, format: :json)) } if load_async
|
|
|
|
.blob-viewer{ data: { type: viewer.type, url: viewer_url }, class: ('hidden' if hidden) }
|
|
|
|
- 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
|
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
|
|
|
|