Commit 9497b1a76ee84d12613604e37007e94a048b379e
1 parent
31bc2b94
Exists in
master
and in
4 other branches
Compare images
Showing
2 changed files
with
17 additions
and
8 deletions
Show diff stats
app/assets/stylesheets/sections/commits.scss
| @@ -101,18 +101,21 @@ | @@ -101,18 +101,21 @@ | ||
| 101 | margin:50px; | 101 | margin:50px; |
| 102 | padding:1px; | 102 | padding:1px; |
| 103 | max-width:400px; | 103 | max-width:400px; |
| 104 | - } | ||
| 105 | - &.diff_image_removed { | ||
| 106 | - img { | 104 | + |
| 105 | + &.diff_image_removed { | ||
| 107 | border: 1px solid #C00; | 106 | border: 1px solid #C00; |
| 108 | } | 107 | } |
| 109 | - } | ||
| 110 | 108 | ||
| 111 | - &.diff_image_added { | ||
| 112 | - img { | 109 | + &.diff_image_added { |
| 113 | border: 1px solid #0C0;; | 110 | border: 1px solid #0C0;; |
| 114 | } | 111 | } |
| 115 | } | 112 | } |
| 113 | + | ||
| 114 | + &.img_compared { | ||
| 115 | + img { | ||
| 116 | + max-width:300px; | ||
| 117 | + } | ||
| 118 | + } | ||
| 116 | } | 119 | } |
| 117 | } | 120 | } |
| 118 | 121 |
app/views/commits/_diffs.html.haml
| @@ -35,7 +35,13 @@ | @@ -35,7 +35,13 @@ | ||
| 35 | - if file.text? | 35 | - if file.text? |
| 36 | = render "commits/text_file", :diff => diff, :index => i | 36 | = render "commits/text_file", :diff => diff, :index => i |
| 37 | - elsif file.image? | 37 | - elsif file.image? |
| 38 | - .diff_file_content_image{:class => image_diff_class(diff)} | ||
| 39 | - %img{:src => "data:#{file.mime_type};base64,#{Base64.encode64(file.data)}"} | 38 | + - if diff.renamed_file || diff.new_file || diff.deleted_file |
| 39 | + .diff_file_content_image | ||
| 40 | + %img{:class => image_diff_class(diff), :src => "data:#{file.mime_type};base64,#{Base64.encode64(file.data)}"} | ||
| 41 | + - else | ||
| 42 | + - old_file = (@commit.prev_commit.tree / diff.old_path) | ||
| 43 | + .diff_file_content_image.img_compared | ||
| 44 | + %img{:class => "diff_image_removed", :src => "data:#{file.mime_type};base64,#{Base64.encode64(old_file.data)}"} | ||
| 45 | + %img{:class => "diff_image_added", :src => "data:#{file.mime_type};base64,#{Base64.encode64(file.data)}"} | ||
| 40 | - else | 46 | - else |
| 41 | %p.nothing_here_message No preview for this file type | 47 | %p.nothing_here_message No preview for this file type |