diff options
author | Douwe Maan <douwe@gitlab.com> | 2018-06-15 12:42:56 +0300 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2018-06-15 12:42:56 +0300 |
commit | fbc749a96e07dd1b1b5760cfe376b5b7838181f0 (patch) | |
tree | ab7f1576bcb409f614db6a40ca77de032553a7a7 /app/controllers | |
parent | 4ac381a565eb1b3e7ebaec443889c6a7138fdfd0 (diff) |
Reuse viewer param and move logic to blob controller
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/concerns/renders_blob.rb | 2 | ||||
-rw-r--r-- | app/controllers/projects/blob_controller.rb | 11 |
2 files changed, 6 insertions, 7 deletions
diff --git a/app/controllers/concerns/renders_blob.rb b/app/controllers/concerns/renders_blob.rb index 10fb004a60c..ba7adcfea86 100644 --- a/app/controllers/concerns/renders_blob.rb +++ b/app/controllers/concerns/renders_blob.rb @@ -14,8 +14,6 @@ module RendersBlob return unless viewer - return {} if params[:html_render] == 'false' - { html: view_to_html_string("projects/blob/_viewer", viewer: viewer, load_async: false) } diff --git a/app/controllers/projects/blob_controller.rb b/app/controllers/projects/blob_controller.rb index 0c1c286a0a4..64bc6bd5536 100644 --- a/app/controllers/projects/blob_controller.rb +++ b/app/controllers/projects/blob_controller.rb @@ -197,14 +197,11 @@ class Projects::BlobController < Projects::ApplicationController end def show_json - json = blob_json(@blob) - return render_404 unless json - path_segments = @path.split('/') path_segments.pop tree_path = path_segments.join('/') - render json: json.merge( + json = { id: @blob.id, path: blob.path, name: blob.name, @@ -221,6 +218,10 @@ class Projects::BlobController < Projects::ApplicationController commits_path: project_commits_path(project, @id), tree_path: project_tree_path(project, File.join(@ref, tree_path)), permalink: project_blob_path(project, File.join(@commit.id, @path)) - ) + } + + json.merge!(blob_json(@blob) || {}) unless params[:viewer] == 'none' + + render json: json end end |