完成项目比较功能(样式未完,待设计)

This commit is contained in:
daiao 2016-11-28 17:16:43 +08:00
parent 3f5e840e76
commit ece69b9e7a
2 changed files with 23 additions and 55 deletions

View File

@ -586,21 +586,6 @@ update
diff = OpenStruct.new(diff)
@diff_file = Trustie::Gitlab::Diff::File.new(diff)
# diff_file.diff_lines.each_with_index do |line, index|
# type = line.type
# last_line = line.new_pos
# line_old = line.old_pos.to_s
#
#
# if type == 'match'
# ## 表示没有修改,两个都要显示行号
# output += "|#{line_old.center(4)}|#{last_line.to_s.center(4)}|#{line.text}\n"
# else
# old_line = type == 'new' ? ' '*4: line_old
# new_line = type == 'old' ? ' '*4: last_line
# output += "|#{old_line.to_s.center(4)}|#{new_line.to_s.center(4)}|#{line.text}\n"
# end
# end
@commit_details = @g.commit(@project.gpid, params[:changeset])
render :layout => 'base_projects'
end

View File

@ -9,46 +9,29 @@
</li>
</div>
<div class="showing-changes-project f14"><%= @commit_details.message %></div>
<!--<div class="showing-changes-row fontGrey2">Showing <a href="javascript:void()" class="linkGrey3" id="changed-files">3 changed files</a> with <span class="c_green">3 additions</span> and <span class="c_red">3 deletions</span>-->
<!--<ol class="mt10" id="changed-files-detail">-->
<!--<li><a href="javascript:void()" class="linkGrey3" id="changed-files">app/views/organizations/_org_course_homework.html.erb</a> </li>-->
<!--<li><a href="javascript:void()" class="linkGrey3" id="changed-files">app/views/users/_course_homework.html.erb</a> </li>-->
<!--<li><a href="javascript:void()" class="linkGrey3" id="changed-files">app/views/users/_user_homework_detail.html.erb</a> </li>-->
<!--</ol>-->
<!--</div>-->
<%= @diff_file.diff_lines %>
<% @diff_file.diff_lines.each_with_index do |line, index| %>
<%= type = ldine.type %>
<%= last_line = line.new_pos %>
<%= line_old = line.old_pos.to_s %>
<div class="showing-changes-row fontGrey2">
<a href="javascript:void(0);" class="linkGrey3" id="changed-files">
<img src="/images/vlicon/file.png" width="18" height="20" style="vertical-align:middle;" class="mr5" /><%= cd.new_path %>
</a>
</div>
<div class="autoscroll">
<table class="filecontent syntaxhl" style="width:100%;" >
<tbody>
<% line_num = diff_line_num(cd.diff) %>
<% diff_content = diff_content(cd.diff) %>
<% syntax_highlight_lines(cd.new_path, Redmine::CodesetUtil.to_utf8_by_setting(diff_content)).each do |line| %>
<tr>
<th class="line-num" id="L<%= line_num %>" style="vertical-align: top;">
<a href="#L<%= line_num %>" style="padding-top: 0px;"><%= line_num %></a>
</th>
<% if line[0,1] == "-" %>
<td class="line-code diff_out"><pre style="width:auto;white-space: nowrap; "><%= line.html_safe %></pre></td>
<% elsif line[0,1] == "+" %>
<td class="line-code diff_in"><pre style="width:auto;white-space: nowrap; "><%= line.html_safe %></pre></td>
<% else%>
<td class="line-code"><pre style="width:auto;white-space: nowrap; "><%= line.html_safe %></pre></td>
<% end %>
</tr>
<% line_num += 1 %>
<% end %>
</tbody>
</table>
</div>
<%= line[0] %>
<% type = line.type %>
<% last_line = line.new_pos.to_s %>
<% line_old = line.old_pos.to_s %>
<table>
<tbody>
<% if type == "match" %>
<tr>
<td class="old_line"><%= line_old.center(4) %></td>
<td class="new_line"><%= last_line.center(4) %></td>
<td class="line_content"><%= line.text %></td>
</tr>
<% else %>
<% old_line = type == 'new' ? ' '*4: line_old %>
<% new_line = type == 'old' ? ' '*4: last_line %>
<tr>
<td class="old_line"><%= old_line.to_s.center(4) %></td>
<td class="new_line"><%= new_line.to_s.center(4) %></td>
<td class="line_content"><%= line.text %></td>
</tr>
<% end %>
</tbody>
</table>
<% end %>
</div>