Module: RendersBlob
- Extended by:
- ActiveSupport::Concern
- Included in:
- Projects::ArtifactsController, Projects::BlobController, SnippetsActions
- Defined in:
- app/controllers/concerns/renders_blob.rb
Instance Method Summary collapse
- #blob_viewer_json(blob) ⇒ Object
- #conditionally_expand_blob(blob) ⇒ Object
- #conditionally_expand_blobs(blobs) ⇒ Object
- #render_blob_json(blob) ⇒ Object
Instance Method Details
#blob_viewer_json(blob) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'app/controllers/concerns/renders_blob.rb', line 6 def blob_viewer_json(blob) viewer = case params[:viewer] when 'rich' then blob.rich_viewer when 'auxiliary' then blob.auxiliary_viewer when 'none' then nil else blob.simple_viewer end return {} unless viewer { html: view_to_html_string("projects/blob/_viewer", viewer: viewer, load_async: false) } end |
#conditionally_expand_blob(blob) ⇒ Object
28 29 30 |
# File 'app/controllers/concerns/renders_blob.rb', line 28 def (blob) ([blob]) end |
#conditionally_expand_blobs(blobs) ⇒ Object
32 33 34 35 36 |
# File 'app/controllers/concerns/renders_blob.rb', line 32 def (blobs) return unless params[:expanded] == 'true' blobs.each(&:expand!) end |
#render_blob_json(blob) ⇒ Object
21 22 23 24 25 26 |
# File 'app/controllers/concerns/renders_blob.rb', line 21 def render_blob_json(blob) json = blob_viewer_json(blob) return render_404 unless json.present? render json: json end |