summaryrefslogtreecommitdiffstats
path: root/app/views/repositories/diff.rhtml
blob: 0060e7867831be1c95634c6624b6672697b7f80f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<h2><%= render :partial => 'navigation', :locals => { :path => @path, :kind => 'file', :revision => @rev } %></h2>

<table class="list">
<thead><tr><th>@<%= @rev %></th><th>@<%= @rev_to  %></th><th></th></tr></thead>
<tbody>
<% parsing = false
line_num_l = 0
line_num_r = 0 %>
<% @diff.each do |line| %>
<% 
   if line =~ /^@@ (\+|\-)(\d+),\d+ (\+|\-)(\d+),\d+ @@/
     line_num_l = $2.to_i
     line_num_r = $4.to_i
     if parsing %>
     <tr class="spacing"><td colspan="3">&nbsp;</td></tr>
  <% end
     parsing = true
     next
   end
   next unless parsing
%>

<tr>

<% case line[0, 1] 
   when " " %>
<th class="line-num"><%= line_num_l %></th>
<th class="line-num"><%= line_num_r %></th>
<td class="line-code">
<% line_num_l = line_num_l + 1
   line_num_r = line_num_r + 1
   
   when "-" %>
<th class="line-num"></th>
<th class="line-num"><%= line_num_r %></th>
<td class="line-code" style="background: #fdd;">
<% line_num_r = line_num_r + 1

   when "+" %>
<th class="line-num"><%= line_num_l %></th>
<th class="line-num"></th>
<td class="line-code" style="background: #dfd;">
<% line_num_l = line_num_l + 1

   else
     next
   end %>
   
<%= h(line[1..-1]).gsub(/\s/, "&nbsp;") %></td></tr>

<% end %>
</tbody>
</table>

<% content_for :header_tags do %>
<%= stylesheet_link_tag "scm" %>
<% end %>