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

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 = OpenStruct.new(diff)
@diff_file = Trustie::Gitlab::Diff::File.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]) @commit_details = @g.commit(@project.gpid, params[:changeset])
render :layout => 'base_projects' render :layout => 'base_projects'
end end

View File

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