2011-03-10 13:33:50 +00:00
|
|
|
module DiffHelper
|
|
|
|
def render_inline_diff(commit, diff)
|
|
|
|
[render_inline_diff_header(commit, diff), render_inline_diff_body(diff.diff), render_inline_diff_footer].join("\n")
|
|
|
|
end
|
|
|
|
|
|
|
|
def render_inline_diff_header(commit, diff)
|
|
|
|
res = "<a name='#{h(diff.a_path)}'></a>"
|
|
|
|
if diff.b_path.present?
|
2011-03-11 17:19:47 +00:00
|
|
|
res += link_to("view file @ #{commit.id}", blob_commit_path(@platform, @repository, @project, commit.id, diff.b_path))
|
2011-03-10 13:33:50 +00:00
|
|
|
res += "<br />"
|
|
|
|
end
|
|
|
|
|
|
|
|
res += "<table class='diff inline'>
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<td class='comments'> </td>
|
|
|
|
<td class='line_numbers'></td>
|
|
|
|
<td class='line_numbers'></td>
|
|
|
|
<td class=''> </td>
|
|
|
|
</tr>
|
|
|
|
</thead>"
|
|
|
|
|
|
|
|
res
|
|
|
|
end
|
|
|
|
|
|
|
|
def render_inline_diff_body(diff)
|
|
|
|
diff_display ||= Diff::Display::Unified.new(diff)
|
|
|
|
"<tbody>
|
|
|
|
#{diff_display.render(Git::Diff::InlineCallback.new)}
|
|
|
|
</tbody>"
|
|
|
|
end
|
|
|
|
|
|
|
|
def render_inline_diff_footer
|
|
|
|
"</table>"
|
|
|
|
end
|
|
|
|
end
|