From 9497b1a76ee84d12613604e37007e94a048b379e Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 5 Jul 2012 23:19:37 +0300 Subject: [PATCH] Compare images --- app/assets/stylesheets/sections/commits.scss | 15 +++++++++------ app/views/commits/_diffs.html.haml | 10 ++++++++-- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/app/assets/stylesheets/sections/commits.scss b/app/assets/stylesheets/sections/commits.scss index acab785ac..6052ec3fa 100644 --- a/app/assets/stylesheets/sections/commits.scss +++ b/app/assets/stylesheets/sections/commits.scss @@ -101,18 +101,21 @@ margin:50px; padding:1px; max-width:400px; - } - &.diff_image_removed { - img { + + &.diff_image_removed { border: 1px solid #C00; } - } - &.diff_image_added { - img { + &.diff_image_added { border: 1px solid #0C0;; } } + + &.img_compared { + img { + max-width:300px; + } + } } } diff --git a/app/views/commits/_diffs.html.haml b/app/views/commits/_diffs.html.haml index 02a156330..d51561d90 100644 --- a/app/views/commits/_diffs.html.haml +++ b/app/views/commits/_diffs.html.haml @@ -35,7 +35,13 @@ - if file.text? = render "commits/text_file", :diff => diff, :index => i - elsif file.image? - .diff_file_content_image{:class => image_diff_class(diff)} - %img{:src => "data:#{file.mime_type};base64,#{Base64.encode64(file.data)}"} + - if diff.renamed_file || diff.new_file || diff.deleted_file + .diff_file_content_image + %img{:class => image_diff_class(diff), :src => "data:#{file.mime_type};base64,#{Base64.encode64(file.data)}"} + - else + - old_file = (@commit.prev_commit.tree / diff.old_path) + .diff_file_content_image.img_compared + %img{:class => "diff_image_removed", :src => "data:#{file.mime_type};base64,#{Base64.encode64(old_file.data)}"} + %img{:class => "diff_image_added", :src => "data:#{file.mime_type};base64,#{Base64.encode64(file.data)}"} - else %p.nothing_here_message No preview for this file type -- 2.11.0