From 6660c930c8ef590831df22d9e1b7656b4833501f Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Wed, 8 Oct 2014 18:15:28 +0600 Subject: [PATCH] show blob images in the commit --- .../projects/git/commits/_commit_diff.html.haml | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/app/views/projects/git/commits/_commit_diff.html.haml b/app/views/projects/git/commits/_commit_diff.html.haml index d9943b7f9..92ff8aa8a 100644 --- a/app/views/projects/git/commits/_commit_diff.html.haml +++ b/app/views/projects/git/commits/_commit_diff.html.haml @@ -6,6 +6,17 @@ - if commit_diff.b_path.present? .r= link_to "view file @ #{short_hash_id(commit_id)}", blob_path(@project, commit_id, commit_diff.b_path) .clear - -if commit_diff.diff.present? && !(@project.repo.tree(commit_id) / commit_diff.a_path).binary? - ="a_path=#{commit_diff.a_path}; b_path=#{commit_diff.b_path}" if (@project.repo.tree(commit_id) / commit_diff.b_path).nil? - .diff_data=render_diff(commit_diff, diff_counter: commit_diff_counter, comments: @comments) + - if commit_diff.diff.present? + - blob = @project.repo.tree(commit_id) / commit_diff.a_path + - if blob.render_as == :image + %table.diff.inline{ cellspacing: 0, cellpadding: 0 } + %tr + %td.lines + %td.blob.diff-image + %span.diff-image + %img{ src: "data:#{blob.mime_type};base64,#{Base64.encode64(blob.data)}", + style: 'max-width: 600px;' } + - else !blob.binary? + - if (@project.repo.tree(commit_id) / commit_diff.b_path).nil? + ="a_path=#{commit_diff.a_path}; b_path=#{commit_diff.b_path}" + .diff_data=render_diff(commit_diff, diff_counter: commit_diff_counter, comments: @comments)