# -*- encoding : utf-8 -*- module DiffHelper def render_diff(diff, diff_counter) diff_display ||= Diff::Display::Unified.new(diff.diff) path = if @pull "#{polymorphic_path [@project, @pull]}/diff" elsif @commit "#{commit_path @project, @commit}" end #res = "" res = "" res += "" res += diff_display.render(Git::Diff::InlineCallback.new(diff_counter, path)) res += "" res += "
" res.html_safe end def render_diff_stats(stats) path = "#{polymorphic_path [@project, @pull]}/diff" res = [""] stats.each_with_index do |stat, ind| res << "" res << "" res << "" end res << "
#{link_to stat.filename.rtruncate(120), "#{path}#diff-#{ind}"}" res << I18n.t("layout.projects.inline_changes_count", :count => stat.additions + stat.deletions).strip + " (" + I18n.t("layout.projects.inline_additions_count", :count => stat.additions).strip + ", " + I18n.t("layout.projects.inline_deletions_count", :count => stat.deletions).strip + ")" res << "
" res.join("\n").html_safe.default_encoding! end end