Diff: adds some space between 2 changes in the same file and reduces html size.

git-svn-id: http://redmine.rubyforge.org/svn/trunk@1486 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2008-06-02 19:18:17 +00:00
parent 870e8654b4
commit 36162c6cf2
2 changed files with 70 additions and 74 deletions

View File

@ -11,82 +11,78 @@
<%= 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> <%= 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 %> <% end %>
<% cache(@cache_key) do %> <% cache(@cache_key) do -%>
<% @diff.each do |table_file| %> <% @diff.each do |table_file| -%>
<div class="autoscroll"> <div class="autoscroll">
<% if @diff_type == 'sbs' %> <% if @diff_type == 'sbs' -%>
<table class="filecontent CodeRay"> <table class="filecontent CodeRay">
<thead> <thead>
<tr> <tr><th colspan="4" class="filename"><%= table_file.file_name %></th></tr>
<th colspan="4" class="filename"> <tr>
<%= table_file.file_name %>
</th>
</tr>
<tr>
<th colspan="2">@<%= format_revision @rev %></th> <th colspan="2">@<%= format_revision @rev %></th>
<th colspan="2">@<%= format_revision @rev_to %></th> <th colspan="2">@<%= format_revision @rev_to %></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<% table_file.keys.sort.each do |key| %> <% prev_line_left, prev_line_right = nil, nil -%>
<tr> <% table_file.keys.sort.each do |key| -%>
<th class="line-num"> <% 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) -%>
<%= table_file[key].nb_line_left %> <tr class="spacing"><td colspan="4"></td></tr>
</th> <% end -%>
<tr>
<th class="line-num"><%= table_file[key].nb_line_left %></th>
<td class="line-code <%= table_file[key].type_diff_left %>"> <td class="line-code <%= table_file[key].type_diff_left %>">
<pre><%=to_utf8 table_file[key].line_left %></pre> <pre><%=to_utf8 table_file[key].line_left %></pre>
</td> </td>
<th class="line-num"> <th class="line-num"><%= table_file[key].nb_line_right %></th>
<%= table_file[key].nb_line_right %>
</th>
<td class="line-code <%= table_file[key].type_diff_right %>"> <td class="line-code <%= table_file[key].type_diff_right %>">
<pre><%=to_utf8 table_file[key].line_right %></pre> <pre><%=to_utf8 table_file[key].line_right %></pre>
</td> </td>
</tr> </tr>
<% end %> <% prev_line_left, prev_line_right = table_file[key].nb_line_left.to_i, table_file[key].nb_line_right.to_i -%>
</tbody> <% end -%>
</table> </tbody>
</table>
<% else %> <% else -%>
<table class="filecontent CodeRay"> <table class="filecontent CodeRay">
<thead> <thead>
<tr> <tr><th colspan="3" class="filename"><%= table_file.file_name %></th></tr>
<th colspan="3" class="filename"> <tr>
<%= table_file.file_name %>
</th>
</tr>
<tr>
<th>@<%= format_revision @rev %></th> <th>@<%= format_revision @rev %></th>
<th>@<%= format_revision @rev_to %></th> <th>@<%= format_revision @rev_to %></th>
<th></th> <th></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<% table_file.keys.sort.each do |key, line| %> <% prev_line_left, prev_line_right = nil, nil -%>
<tr> <% table_file.keys.sort.each do |key, line| %>
<th class="line-num"> <% 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) -%>
<%= table_file[key].nb_line_left %> <tr class="spacing"><td colspan="3"></td></tr>
</th> <% end -%>
<th class="line-num"> <tr>
<%= table_file[key].nb_line_right %> <th class="line-num"><%= table_file[key].nb_line_left %></th>
</th> <th class="line-num"><%= table_file[key].nb_line_right %></th>
<% if table_file[key].line_left.empty? %> <% if table_file[key].line_left.empty? -%>
<td class="line-code <%= table_file[key].type_diff_right %>"> <td class="line-code <%= table_file[key].type_diff_right %>">
<pre><%=to_utf8 table_file[key].line_right %></pre> <pre><%=to_utf8 table_file[key].line_right %></pre>
</td> </td>
<% else %> <% else -%>
<td class="line-code <%= table_file[key].type_diff_left %>"> <td class="line-code <%= table_file[key].type_diff_left %>">
<pre><%=to_utf8 table_file[key].line_left %></pre> <pre><%=to_utf8 table_file[key].line_left %></pre>
</td> </td>
<% end %> <% end -%>
</tr> </tr>
<% end %> <% prev_line_left = table_file[key].nb_line_left.to_i if table_file[key].nb_line_left.to_i > 0 -%>
</tbody> <% prev_line_right = table_file[key].nb_line_right.to_i if table_file[key].nb_line_right.to_i > 0 -%>
</table> <% end -%>
<% end %> </tbody>
</table>
<% end -%>
</div> </div>
<% end %> <% end -%>
<% end %> <% end -%>
<% html_title(with_leading_slash(@path), 'Diff') -%> <% html_title(with_leading_slash(@path), 'Diff') -%>

View File

@ -2,7 +2,7 @@
table.filecontent { border: 1px solid #ccc; border-collapse: collapse; width:98%; } table.filecontent { border: 1px solid #ccc; border-collapse: collapse; width:98%; }
table.filecontent th { border: 1px solid #ccc; background-color: #eee; } table.filecontent th { border: 1px solid #ccc; background-color: #eee; }
table.filecontent th.filename { background-color: #ddc; text-align: left; } 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 { table.filecontent th.line-num {
border: 1px solid #d7d7d7; border: 1px solid #d7d7d7;
font-size: 0.8em; font-size: 0.8em;