]> source.dussan.org Git - redmine.git/commitdiff
Diff: adds some space between 2 changes in the same file and reduces html size.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 2 Jun 2008 19:18:17 +0000 (19:18 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 2 Jun 2008 19:18:17 +0000 (19:18 +0000)
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1486 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/views/repositories/diff.rhtml
public/stylesheets/scm.css

index eaef1abf54dd0ce9a0c8e2c93c7c5c80bca6783b..73c1e8c9edcf9ea6f118f445e7c4ddd45d3e5e52 100644 (file)
   <%= select_tag 'type', options_for_select([[l(:label_diff_inline), "inline"], [l(:label_diff_side_by_side), "sbs"]], @diff_type), :onchange => "if (this.value != '') {this.form.submit()}" %></p>
 <% end %>
 
-<% cache(@cache_key) do %>
-<% @diff.each do |table_file| %>
+<% cache(@cache_key) do -%>
+<% @diff.each do |table_file| -%>
 <div class="autoscroll">
-<% if @diff_type == 'sbs' %>
-    <table class="filecontent CodeRay">
-      <thead>
-        <tr>
-          <th colspan="4" class="filename">
-            <%= table_file.file_name %>
-          </th>
-        </tr>
-        <tr>
-          <th colspan="2">@<%= format_revision @rev %></th>
-          <th colspan="2">@<%= format_revision @rev_to %></th>
-        </tr>
-      </thead>
-      <tbody>
-        <% table_file.keys.sort.each do |key| %>
-          <tr>
-            <th class="line-num">
-              <%= table_file[key].nb_line_left %>
-            </th>
-            <td class="line-code <%= table_file[key].type_diff_left %>">
-              <pre><%=to_utf8 table_file[key].line_left %></pre>
-            </td>
-            <th class="line-num">
-              <%= table_file[key].nb_line_right %>
-            </th>
-            <td class="line-code <%= table_file[key].type_diff_right %>">
-              <pre><%=to_utf8 table_file[key].line_right %></pre>
-            </td>
-          </tr>
-        <% end %>
-      </tbody>
-    </table>
+<% if @diff_type == 'sbs' -%>
+<table class="filecontent CodeRay">
+<thead>
+<tr><th colspan="4" class="filename"><%= table_file.file_name %></th></tr>
+<tr>
+  <th colspan="2">@<%= format_revision @rev %></th>
+  <th colspan="2">@<%= format_revision @rev_to %></th>
+</tr>
+</thead>
+<tbody>
+<% prev_line_left, prev_line_right = nil, nil -%>
+<% table_file.keys.sort.each do |key| -%>
+<% if prev_line_left && prev_line_right && (table_file[key].nb_line_left != prev_line_left+1) && (table_file[key].nb_line_right != prev_line_right+1) -%>
+<tr class="spacing"><td colspan="4"></td></tr>
+<% end -%>
+<tr>
+  <th class="line-num"><%= table_file[key].nb_line_left %></th>
+  <td class="line-code <%= table_file[key].type_diff_left %>">
+    <pre><%=to_utf8 table_file[key].line_left %></pre>
+  </td>
+  <th class="line-num"><%= table_file[key].nb_line_right %></th>
+  <td class="line-code <%= table_file[key].type_diff_right %>">
+    <pre><%=to_utf8 table_file[key].line_right %></pre>
+  </td>
+</tr>
+<% prev_line_left, prev_line_right = table_file[key].nb_line_left.to_i, table_file[key].nb_line_right.to_i -%>
+<% end -%>
+</tbody>
+</table>
+
+<% else -%>
+<table class="filecontent CodeRay">
+<thead>
+<tr><th colspan="3" class="filename"><%= table_file.file_name %></th></tr>
+<tr>
+  <th>@<%= format_revision @rev %></th>
+  <th>@<%= format_revision @rev_to %></th>
+  <th></th>
+</tr>
+</thead>
+<tbody>
+<% prev_line_left, prev_line_right = nil, nil -%>
+<% table_file.keys.sort.each do |key, line| %>
+<% if prev_line_left && prev_line_right && (table_file[key].nb_line_left != prev_line_left+1) && (table_file[key].nb_line_right != prev_line_right+1) -%>
+<tr class="spacing"><td colspan="3"></td></tr>
+<% end -%>
+<tr>
+  <th class="line-num"><%= table_file[key].nb_line_left %></th>
+  <th class="line-num"><%= table_file[key].nb_line_right %></th>
+  <% if table_file[key].line_left.empty? -%>
+  <td class="line-code <%= table_file[key].type_diff_right %>">
+    <pre><%=to_utf8 table_file[key].line_right %></pre>
+  </td>
+  <% else -%>
+  <td class="line-code <%= table_file[key].type_diff_left %>">
+    <pre><%=to_utf8 table_file[key].line_left %></pre>
+  </td>
+  <% end -%>
+</tr>
+<% prev_line_left = table_file[key].nb_line_left.to_i if table_file[key].nb_line_left.to_i > 0 -%>
+<% prev_line_right = table_file[key].nb_line_right.to_i if table_file[key].nb_line_right.to_i > 0 -%>
+<% end -%>
+</tbody>
+</table>
+<% end -%>
 
-<% else %>
-    <table class="filecontent CodeRay">
-      <thead>
-        <tr>
-          <th colspan="3" class="filename">
-            <%= table_file.file_name %>
-          </th>
-        </tr>
-        <tr>
-          <th>@<%= format_revision @rev %></th>
-          <th>@<%= format_revision @rev_to %></th>
-          <th></th>
-        </tr>
-      </thead>
-      <tbody>
-        <% table_file.keys.sort.each do |key, line| %>
-          <tr>
-            <th class="line-num">
-              <%= table_file[key].nb_line_left %>
-            </th>
-            <th class="line-num">
-              <%= table_file[key].nb_line_right %>
-            </th>
-            <% if table_file[key].line_left.empty? %>
-              <td class="line-code <%= table_file[key].type_diff_right %>">
-                <pre><%=to_utf8 table_file[key].line_right %></pre>
-              </td>
-            <% else %>
-              <td class="line-code <%= table_file[key].type_diff_left %>">
-                <pre><%=to_utf8 table_file[key].line_left %></pre>
-              </td>
-            <% end %>
-          </tr>
-        <% end %>
-      </tbody>
-    </table>
-<% end %>
 </div>
-<% end %>
-<% end %>
+<% end -%>
+<% end -%>
 
 <% html_title(with_leading_slash(@path), 'Diff') -%>
 
index 66847af8cf356c28326ac741bc19a2707ac535ff..d1495a5efc2025b2d47cee6378ad5558a9699883 100644 (file)
@@ -2,7 +2,7 @@
 table.filecontent { border: 1px solid #ccc;  border-collapse: collapse; width:98%; }
 table.filecontent th { border: 1px solid #ccc; background-color: #eee; }
 table.filecontent th.filename {        background-color: #ddc; text-align: left; }
-table.filecontent tr.spacing { border: 1px solid #d7d7d7; }
+table.filecontent tr.spacing td { border: 1px solid #d7d7d7; height: 0.4em; }
 table.filecontent th.line-num {
     border: 1px solid #d7d7d7;
        font-size: 0.8em;