diff options
author | Douwe Maan <douwe@selenight.nl> | 2017-06-07 00:28:06 +0300 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2017-06-14 18:12:21 +0300 |
commit | 794425456322864f37dbd862aca9bc6b6447591a (patch) | |
tree | e04869a293f434756527fcdf80505bcde12bc3f6 /app/models/diff_viewer/server_side.rb | |
parent | 64e85fdaffcd03ef52ff74953b1a4e0caf5a23e8 (diff) |
Implement diff viewers
Diffstat (limited to 'app/models/diff_viewer/server_side.rb')
-rw-r--r-- | app/models/diff_viewer/server_side.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/app/models/diff_viewer/server_side.rb b/app/models/diff_viewer/server_side.rb new file mode 100644 index 00000000000..aed1a0791b1 --- /dev/null +++ b/app/models/diff_viewer/server_side.rb @@ -0,0 +1,26 @@ +module DiffViewer + module ServerSide + extend ActiveSupport::Concern + + included do + self.collapse_limit = 1.megabyte + self.size_limit = 5.megabytes + end + + def prepare! + diff_file.old_blob&.load_all_data! + diff_file.new_blob&.load_all_data! + end + + def render_error + # Files that are not stored in the repository, like LFS files and + # build artifacts, can only be rendered using a client-side viewer, + # since we do not want to read large amounts of data into memory on the + # server side. Client-side viewers use JS and can fetch the file from + # `diff_file_blob_raw_path` and `diff_file_old_blob_raw_path` using AJAX. + return :server_side_but_stored_externally if diff_file.stored_externally? + + super + end + end +end |