debian-mirror-gitlab/app/controllers/concerns/renders_blob.rb

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

41 lines
754 B
Ruby
Raw Normal View History

2018-12-05 23:21:45 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
module RendersBlob
extend ActiveSupport::Concern
2017-09-10 17:25:29 +05:30
def blob_json(blob)
2017-08-17 22:00:37 +05:30
viewer =
2017-09-10 17:25:29 +05:30
case params[:viewer]
when 'rich'
2017-08-17 22:00:37 +05:30
blob.rich_viewer
2017-09-10 17:25:29 +05:30
when 'auxiliary'
blob.auxiliary_viewer
2017-08-17 22:00:37 +05:30
else
blob.simple_viewer
end
2017-09-10 17:25:29 +05:30
return unless viewer
{
html: view_to_html_string("projects/blob/_viewer", viewer: viewer, load_async: false)
2017-08-17 22:00:37 +05:30
}
end
2017-09-10 17:25:29 +05:30
def render_blob_json(blob)
json = blob_json(blob)
return render_404 unless json
render json: json
end
def conditionally_expand_blob(blob)
2020-10-24 23:57:45 +05:30
conditionally_expand_blobs([blob])
end
def conditionally_expand_blobs(blobs)
return unless params[:expanded] == 'true'
2023-03-17 16:20:25 +05:30
blobs.each(&:expand!)
2017-08-17 22:00:37 +05:30
end
end