##// END OF EJS Templates
Rails3: prevent double rendering file view and annotate on Rails 3.0.11 and Rails 3.1.3...
Toshi MARUYAMA -
r8868:b4630c03f732
parent child
Show More
@@ -355,6 +355,12 module ApplicationHelper
355 end
355 end
356 end
356 end
357
357
358 def syntax_highlight_lines(name, content)
359 lines = []
360 syntax_highlight(name, content).each_line { |line| lines << line }
361 lines
362 end
363
358 def syntax_highlight(name, content)
364 def syntax_highlight(name, content)
359 Redmine::SyntaxHighlighting.highlight_by_filename(content, name)
365 Redmine::SyntaxHighlighting.highlight_by_filename(content, name)
360 end
366 end
@@ -2,13 +2,13
2 <table class="filecontent syntaxhl">
2 <table class="filecontent syntaxhl">
3 <tbody>
3 <tbody>
4 <% line_num = 1 %>
4 <% line_num = 1 %>
5 <% syntax_highlight(filename, Redmine::CodesetUtil.to_utf8_by_setting(content)).each_line do |line| %>
5 <% syntax_highlight_lines(filename, Redmine::CodesetUtil.to_utf8_by_setting(content)).each do |line| %>
6 <tr>
6 <tr>
7 <th class="line-num" id="L<%= line_num %>">
7 <th class="line-num" id="L<%= line_num %>">
8 <a href="#L<%= line_num %>"><%= line_num %></a>
8 <a href="#L<%= line_num %>"><%= line_num %></a>
9 </th>
9 </th>
10 <td class="line-code">
10 <td class="line-code">
11 <pre><%= line %></pre>
11 <pre><%= line.html_safe %></pre>
12 </td>
12 </td>
13 </tr>
13 </tr>
14 <% line_num += 1 %>
14 <% line_num += 1 %>
@@ -14,14 +14,14
14 <table class="filecontent annotate syntaxhl">
14 <table class="filecontent annotate syntaxhl">
15 <tbody>
15 <tbody>
16 <% line_num = 1 %>
16 <% line_num = 1 %>
17 <% syntax_highlight(@path, Redmine::CodesetUtil.to_utf8_by_setting(@annotate.content)).each_line do |line| %>
17 <% syntax_highlight_lines(@path, Redmine::CodesetUtil.to_utf8_by_setting(@annotate.content)).each do |line| %>
18 <% revision = @annotate.revisions[line_num - 1] %>
18 <% revision = @annotate.revisions[line_num - 1] %>
19 <tr class="bloc-<%= revision.nil? ? 0 : colors[revision.identifier || revision.revision] %>">
19 <tr class="bloc-<%= revision.nil? ? 0 : colors[revision.identifier || revision.revision] %>">
20 <th class="line-num" id="L<%= line_num %>"><a href="#L<%= line_num %>"><%= line_num %></a></th>
20 <th class="line-num" id="L<%= line_num %>"><a href="#L<%= line_num %>"><%= line_num %></a></th>
21 <td class="revision">
21 <td class="revision">
22 <%= (revision.identifier ? link_to_revision(revision, @repository) : format_revision(revision)) if revision %></td>
22 <%= (revision.identifier ? link_to_revision(revision, @repository) : format_revision(revision)) if revision %></td>
23 <td class="author"><%= h(revision.author.to_s.split('<').first) if revision %></td>
23 <td class="author"><%= h(revision.author.to_s.split('<').first) if revision %></td>
24 <td class="line-code"><pre><%= line %></pre></td>
24 <td class="line-code"><pre><%= line.html_safe %></pre></td>
25 </tr>
25 </tr>
26 <% line_num += 1 %>
26 <% line_num += 1 %>
27 <% end %>
27 <% end %>
General Comments 0
You need to be logged in to leave comments. Login now