2011-10-08 23:36:38 +02:00
|
|
|
module CommitsHelper
|
|
|
|
def diff_line(line, line_new = 0, line_old = 0)
|
|
|
|
full_line = html_escape(line.gsub(/\n/, ''))
|
|
|
|
color = if line[0] == "+"
|
|
|
|
full_line = "<span class=\"old_line\"> </span><span class=\"new_line\">#{line_new}</span> " + full_line
|
|
|
|
"#DFD"
|
|
|
|
elsif line[0] == "-"
|
|
|
|
full_line = "<span class=\"old_line\">#{line_old}</span><span class=\"new_line\"> </span> " + full_line
|
|
|
|
"#FDD"
|
|
|
|
else
|
|
|
|
full_line = "<span class=\"old_line\">#{line_old}</span><span class=\"new_line\">#{line_new}</span> " + full_line
|
|
|
|
"none"
|
|
|
|
end
|
|
|
|
|
|
|
|
raw "<div style=\"white-space:pre;background:#{color};\">#{full_line}</div>"
|
|
|
|
end
|
|
|
|
|
|
|
|
def more_commits_link
|
|
|
|
offset = params[:offset] || 0
|
|
|
|
limit = params[:limit] || 100
|
|
|
|
link_to "More", project_commits_path(@project, :offset => offset.to_i + limit.to_i, :limit => limit),
|
|
|
|
:remote => true, :class => "lite_button vm", :style => "text-align:center; width:930px; ", :id => "more-commits-link"
|
|
|
|
end
|
2011-10-16 23:30:48 +02:00
|
|
|
|
2011-10-17 00:14:48 +02:00
|
|
|
# Cause some errors with trucate & encoding use this method
|
2011-10-16 23:30:48 +02:00
|
|
|
def truncate_commit_message(commit, size = 60)
|
2011-10-17 00:14:48 +02:00
|
|
|
message = commit.message
|
|
|
|
message.length > size ? (message[0..(size - 1)] + "...") : message
|
2011-10-16 23:30:48 +02:00
|
|
|
# if special characters occurs
|
|
|
|
rescue
|
2011-10-17 00:14:48 +02:00
|
|
|
commit.message
|
2011-10-16 23:30:48 +02:00
|
|
|
end
|
2011-10-08 23:36:38 +02:00
|
|
|
end
|