2017-04-13 13:10:21 -04:00
|
|
|
module RendersBlob
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
2017-08-03 08:29:35 -04:00
|
|
|
def blob_json(blob)
|
2017-04-13 13:10:21 -04:00
|
|
|
viewer =
|
2017-05-08 19:50:23 -04:00
|
|
|
case params[:viewer]
|
|
|
|
when 'rich'
|
2017-04-13 13:10:21 -04:00
|
|
|
blob.rich_viewer
|
2017-05-08 19:50:23 -04:00
|
|
|
when 'auxiliary'
|
|
|
|
blob.auxiliary_viewer
|
2017-04-13 13:10:21 -04:00
|
|
|
else
|
|
|
|
blob.simple_viewer
|
|
|
|
end
|
2017-07-10 08:10:43 -04:00
|
|
|
|
2017-08-03 08:29:35 -04:00
|
|
|
return unless viewer
|
|
|
|
|
|
|
|
{
|
|
|
|
html: view_to_html_string("projects/blob/_viewer", viewer: viewer, load_async: false)
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def render_blob_json(blob)
|
|
|
|
json = blob_json(blob)
|
|
|
|
return render_404 unless json
|
|
|
|
|
|
|
|
render json: json
|
2017-04-13 13:10:21 -04:00
|
|
|
end
|
2017-04-13 12:47:28 -04:00
|
|
|
|
2017-05-26 19:27:30 -04:00
|
|
|
def conditionally_expand_blob(blob)
|
|
|
|
blob.expand! if params[:expanded] == 'true'
|
2017-04-13 12:47:28 -04:00
|
|
|
end
|
2017-04-13 13:10:21 -04:00
|
|
|
end
|