diff options
author | Douwe Maan <douwe@selenight.nl> | 2017-04-13 12:10:21 -0500 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2017-04-27 12:23:26 -0500 |
commit | 121c5f66180acd78cedf18b19b0e86ee5bf1204d (patch) | |
tree | cec9700bc7b076381d8275fbcbb0013e82b01c49 /app/controllers/projects/blob_controller.rb | |
parent | ee17c659dc3899802ff3a21ddcab0c943d13dd53 (diff) | |
download | gitlab-ce-121c5f66180acd78cedf18b19b0e86ee5bf1204d.tar.gz |
Add JSON endpoint to get simple blob viewer
Diffstat (limited to 'app/controllers/projects/blob_controller.rb')
-rw-r--r-- | app/controllers/projects/blob_controller.rb | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/app/controllers/projects/blob_controller.rb b/app/controllers/projects/blob_controller.rb index 4c6db91d7c0..173c6bcee53 100644 --- a/app/controllers/projects/blob_controller.rb +++ b/app/controllers/projects/blob_controller.rb @@ -2,6 +2,7 @@ class Projects::BlobController < Projects::ApplicationController include ExtractsPath include CreatesCommit + include RendersBlob include ActionView::Helpers::SanitizeHelper # Raised when given an invalid file path @@ -34,8 +35,18 @@ class Projects::BlobController < Projects::ApplicationController end def show - environment_params = @repository.branch_exists?(@ref) ? { ref: @ref } : { commit: @commit } - @environment = EnvironmentsFinder.new(@project, current_user, environment_params).execute.last + respond_to do |format| + format.html do + environment_params = @repository.branch_exists?(@ref) ? { ref: @ref } : { commit: @commit } + @environment = EnvironmentsFinder.new(@project, current_user, environment_params).execute.last + + render 'show' + end + + format.json do + render_blob_json(@blob) + end + end end def edit |