diff options
author | Dmitriy Zaporozhets <dzaporozhets@sphereconsultinginc.com> | 2011-12-01 03:51:04 +0400 |
---|---|---|
committer | Dmitriy Zaporozhets <dzaporozhets@sphereconsultinginc.com> | 2011-12-01 03:51:04 +0400 |
commit | 570f63daaff7ef2b7b05c83714c78755b5d07101 (patch) | |
tree | 81ef24a4b508a76c442590aed44bf746c686c59d /app/views/commits/_text_file.html.haml | |
parent | b60b7b2e2b6880306d701e6607fe7bf89f4de137 (diff) |
line links for commit diff, css fixed for line diff
Diffstat (limited to 'app/views/commits/_text_file.html.haml')
-rw-r--r-- | app/views/commits/_text_file.html.haml | 47 |
1 files changed, 27 insertions, 20 deletions
diff --git a/app/views/commits/_text_file.html.haml b/app/views/commits/_text_file.html.haml index 635391239e9..e39cf11700e 100644 --- a/app/views/commits/_text_file.html.haml +++ b/app/views/commits/_text_file.html.haml @@ -1,21 +1,28 @@ -- line_old = 0 -- line_new = 0 -- lines_arr = diff.diff.lines.to_a -- lines_arr.each do |line| - - line = encode(line) - - next if line.match(/^--- \/dev\/null/) - - next if line.match(/^--- a/) - - next if line.match(/^\+\+\+ b/) - - if line.match(/^@@ -/) - - line_old = line.match(/\-[0-9]*/)[0].to_i.abs rescue 0 - - line_new = line.match(/\+[0-9]*/)[0].to_i.abs rescue 0 - - next +%table + - line_old = 0 + - line_new = 0 + - lines_arr = diff.diff.lines.to_a + - lines_arr.each do |line| + - line = encode(line) + - next if line.match(/^--- \/dev\/null/) + - next if line.match(/^--- a/) + - next if line.match(/^\+\+\+ b/) + - if line.match(/^@@ -/) + - line_old = line.match(/\-[0-9]*/)[0].to_i.abs rescue 0 + - line_new = line.match(/\+[0-9]*/)[0].to_i.abs rescue 0 + - next - = diff_line(line, line_new, line_old) - - if line[0] == "+" - - line_new += 1 - - elsif line[0] == "-" - - line_old += 1 - - else - - line_new += 1 - - line_old += 1 + - full_line = html_escape(line.gsub(/\n/, '')) + %tr.line_holder + %td.old_line + = link_to raw(diff_line_class(line) == "new" ? " " : line_old), "#OLD#{index}-#{line_old}", :id => "OLD#{index}-#{line_old}" + %td.new_line + = link_to raw(diff_line_class(line) == "old" ? " " : line_new) , "#NEW#{index}-#{line_new}", :id => "NEW#{index}-#{line_new}" + %td.line_content{:class => diff_line_class(full_line)}= raw "#{full_line} " + - if line[0] == "+" + - line_new += 1 + - elsif line[0] == "-" + - line_old += 1 + - else + - line_new += 1 + - line_old += 1 |