diff options
author | Mark Chao <mchao@gitlab.com> | 2019-01-23 11:50:19 +0300 |
---|---|---|
committer | Mark Chao <mchao@gitlab.com> | 2019-03-06 10:50:55 +0300 |
commit | 90527b9f842d53595fb14a97a8f8ad19d9dc505a (patch) | |
tree | fed26f765da312e42b19e720b94dc3eab7c423b2 /app/controllers/projects/blob_controller.rb | |
parent | 154720cadc05d79fd5a89bfec18b9385964447ec (diff) |
Add full option for blob diff action
Returns all diff lines for frontend if full is true.
Turn UnfoldForm into presenter, and move controller logic to presenter.
Diffstat (limited to 'app/controllers/projects/blob_controller.rb')
-rw-r--r-- | app/controllers/projects/blob_controller.rb | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/app/controllers/projects/blob_controller.rb b/app/controllers/projects/blob_controller.rb index 77672e7d9fc..63e04539b40 100644 --- a/app/controllers/projects/blob_controller.rb +++ b/app/controllers/projects/blob_controller.rb @@ -90,20 +90,9 @@ class Projects::BlobController < Projects::ApplicationController def diff apply_diff_view_cookie! - @blob.load_all_data! - @lines = @blob.present.highlight.lines - - @form = UnfoldForm.new(params.to_unsafe_h) - - @lines = @lines[@form.since - 1..@form.to - 1].map(&:html_safe) - - if @form.bottom? - @match_line = '' - else - lines_length = @lines.length - 1 - line = [@form.since, lines_length].join(',') - @match_line = "@@ -#{line}+#{line} @@" - end + @form = Blobs::UnfoldPresenter.new(blob, params.to_unsafe_h) + @lines = @form.lines + @match_line = @form.match_line_text # We can keep only 'render_diff_lines' from this conditional when # https://gitlab.com/gitlab-org/gitlab-ce/issues/44988 is done @@ -231,6 +220,8 @@ class Projects::BlobController < Projects::ApplicationController end def validate_diff_params + return if params[:full] + if [:since, :to, :offset].any? { |key| params[key].blank? } head :ok end |