From ec285dae3978138c372cef2baa04505238623418 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Fri, 16 Jan 2015 00:56:30 +0500 Subject: [PATCH] [#369] pull requests: show images --- app/assets/stylesheets/views/diff.css.sass | 18 ++++++++++++++++++ .../pull_requests/_pull_diff.html.slim | 14 ++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/views/diff.css.sass b/app/assets/stylesheets/views/diff.css.sass index af346caf2..ca13f297d 100644 --- a/app/assets/stylesheets/views/diff.css.sass +++ b/app/assets/stylesheets/views/diff.css.sass @@ -65,3 +65,21 @@ table.table.diff.inline .line-comment, #new_inline_comment max-width: 700px + + td.diff-image + text-align: center + + span.diff-image + text-align: center + margin: 0 + padding: 0 + + img + margin-top: 5px + +div.file div.top + height: 28px + background: #ededed + + .pull-left, .pull-right + margin: 6px 10px 0px 10px diff --git a/app/views/projects/pull_requests/_pull_diff.html.slim b/app/views/projects/pull_requests/_pull_diff.html.slim index b348c8052..75649c7d3 100644 --- a/app/views/projects/pull_requests/_pull_diff.html.slim +++ b/app/views/projects/pull_requests/_pull_diff.html.slim @@ -6,5 +6,15 @@ - if @pull.from_project.present? .pull-right= link_to "view file @ #{short_hash_id(commit_id)}", blob_path(@pull.from_project, commit_id, pull_diff.b_path) .clearfix - -if pull_diff.diff.present? && !(@pull.repo.tree(commit_id) / pull_diff.b_path).binary? - .diff_data== render_diff(pull_diff, diff_counter: pull_diff_counter, comments: @comments) + + -if pull_diff.diff.present? + .diff_data + - blob = @pull.repo.tree(commit_id) / pull_diff.b_path + - if blob.render_as == :image + table.table.diff.inline.table-bordered[ cellspacing = 0 cellpadding = 0 ] + tr + td.diff-image + span.diff-image + img[ src = "data:#{blob.mime_type};base64,#{Base64.encode64(blob.data)}" + style = 'max-width: 600px;' ] + == render_diff(pull_diff, diff_counter: pull_diff_counter, comments: @comments) unless blob.binary?