Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 24
- Log:
Initial import of Collaboa 0.5.6 from downloaded Tarball. Collaboa is
a Ruby On Rails based bug tracker and SVN repository browsing tool.
- Author:
- adh
- Date:
- Mon Jul 24 21:54:39 +0100 2006
- Size:
- 4364 Bytes
1 | module RepositoryHelper |
2 | |
3 | def change_map(change_name) |
4 | changed_type = { |
5 | 'M' => 'Updated', |
6 | 'A' => 'Added', |
7 | 'D' => 'Deleted', |
8 | 'CP'=> 'Copied', |
9 | 'MV'=> 'Moved' |
10 | } |
11 | changed_type[change_name] |
12 | end |
13 | |
14 | # returns and unordered list with clickable path parts |
15 | def path_breadcrumbs(paths, last_element_clickable=false) |
16 | out = "<ul>\n" |
17 | out << "<li>" + link_to('root', :action => 'browse', :path => nil) + "</li>\n" |
18 | path = [] |
19 | paths.each_with_index do |p,i| |
20 | path << p |
21 | if i == paths.length - 1 and not last_element_clickable |
22 | link = p |
23 | else |
24 | link = link_to(p, :action => 'browse', :path => path) |
25 | end |
26 | out << "<li>» " + link + "</li>\n" |
27 | end |
28 | out << "</ul>" |
29 | end |
30 | |
31 | # Takes a unified diff as input and renders it as html |
32 | def render_diff(udiff) |
33 | return if udiff.blank? |
34 | out = "<table class=\"codediff\">\n" |
35 | |
36 | lines = udiff.split("\n") |
37 | |
38 | lines_that_differs = /@@ -(\d+),?(\d*) \+(\d+),?(\d*) @@/ |
39 | |
40 | out << "<thead>\n" |
41 | out << "\t<tr><td class=\"line-numbers\">prev.</td><td class=\"line-numbers\">current</td><td> </td></tr>\n" |
42 | out << "</thead>\n" |
43 | |
44 | prev_counter = 0 |
45 | cur_counter = 0 |
46 | change_num = 0 |
47 | |
48 | lines[2..lines.length].each do |line| |
49 | if line_nums = line.match(lines_that_differs) |
50 | prev_line_numbers = line_nums[1].to_i...(line_nums[1].to_i + (line_nums[2]).to_i) |
51 | cur_line_numbers = line_nums[3].to_i...(line_nums[3].to_i + (line_nums[4]).to_i) |
52 | prev_counter = prev_line_numbers.first - 1 |
53 | cur_counter = cur_line_numbers.first - 1 |
54 | change_num += 1 |
55 | end |
56 | |
57 | line = h(line) |
58 | line.gsub!(/^(\+{1}(\s+|\t+)?(.*))/, '\2<ins>\3</ins>') |
59 | line.gsub!(/^(-{1}(\s+|\t+)?(.*))/, '\2<del>\3</del>') |
60 | line.gsub!('\ No newline at end of file', '') |
61 | |
62 | out << "<tr class=\"changes\">\n" |
63 | |
64 | if line.match(/^(\s+|\t+)?<del>/) |
65 | out << "\t<td class=\"line-numbers\">" + prev_counter.to_s + "</td>\n" |
66 | out << "\t<td class=\"line-numbers\"> </td>\n" |
67 | prev_counter += 1 |
68 | action_class = 'del' |
69 | elsif line.match(/^(\s+|\t+)?<ins>/) |
70 | out << "\t<td class=\"line-numbers\"> </td>\n" |
71 | out << "\t<td class=\"line-numbers\">" + cur_counter.to_s + "</td>\n" |
72 | cur_counter += 1 |
73 | action_class = 'ins' |
74 | else |
75 | if line.match(lines_that_differs) |
76 | line = '' |
77 | if change_num > 1 |
78 | out << "\t<td class=\"line-numbers line-num-cut\">...</td>\n" |
79 | out << "\t<td class=\"line-numbers line-num-cut\">...</td>\n" |
80 | action_class = 'cut-line' |
81 | else |
82 | out << "\t<td class=\"line-numbers\"></td>\n" |
83 | out << "\t<td class=\"line-numbers\"></td>\n" |
84 | action_class = 'unchanged' |
85 | end |
86 | else |
87 | out << "\t<td class=\"line-numbers\"></td>\n" |
88 | out << "\t<td class=\"line-numbers\"></td>\n" |
89 | action_class = 'unchanged' |
90 | end |
91 | prev_counter += 1 |
92 | cur_counter += 1 |
93 | end |
94 | |
95 | out << "\t<td class=\"code #{action_class}\">" + line + "</td></tr>\n" |
96 | end |
97 | out << "\n</table>\n" |
98 | end |
99 | |
100 | def highlight(content, mime_type) |
101 | # prepare the hash of mime_types to tokenizer types |
102 | # TODO: Create more Syntax defs, and/or fix the xml highlighter to be more forgiving |
103 | mime_tokenizers = { 'text/xml' => 'xml', |
104 | #'text/x-html+ruby' => 'xml', # .rhtml |
105 | #'text/html' => 'xml', |
106 | 'text/x-ruby' => 'ruby', |
107 | 'text/x-yaml' => 'yaml', |
108 | #'text/css' => 'yaml' |
109 | } |
110 | type = mime_tokenizers[mime_type] |
111 | return make_line_nums(h(content)) unless Syntax::SYNTAX.has_key? type |
112 | |
113 | converted = Syntax::Convertors::HTML.for_syntax(type).convert(content,false) |
114 | make_line_nums(converted, type) |
115 | end |
116 | |
117 | def make_line_nums(contents, css_class="") |
118 | line_num = 1 |
119 | html = "<table class=\"#{css_class}\">\n" |
120 | contents.each_line do |content| |
121 | html << "<tr>\n" |
122 | html << ' <td class="line-numbers">' + line_num.to_s + "</td>\n" |
123 | html << ' <td class="code">' + content + "</td>\n" |
124 | html << "</tr>\n" |
125 | line_num += 1 |
126 | end |
127 | html << '</table>' |
128 | end |
129 | |
130 | end |