Show More
source.mako
89 lines
| 3.3 KiB
| application/x-mako
|
MakoHtmlLexer
r1282 | <%def name="render_line(line_num, tokens, | |||
annotation=None, | ||||
r1412 | bgcolor=None, show_annotation=None)"> | |||
r1282 | <% | |||
from rhodecode.lib.codeblocks import render_tokenstream | ||||
# avoid module lookup for performance | ||||
r1843 | tooltip = h.tooltip | |||
r1282 | %> | |||
r1412 | <tr class="cb-line cb-line-fresh ${'cb-annotate' if show_annotation else ''}" | |||
r1282 | %if annotation: | |||
r3105 | data-revision="${annotation.idx}" | |||
r1282 | %endif | |||
> | ||||
r1412 | ||||
% if annotation: | ||||
% if show_annotation: | ||||
r4026 | <td class="cb-annotate-info"> | |||
${h.gravatar_with_user(request, annotation.author, 16, tooltip=True) | n} | ||||
<div class="tooltip cb-annotate-message truncate-wrap" title="SHA: ${h.show_id(annotation)}<br/>Date: ${annotation.date}<br/>${annotation.message | entity}">${h.chop_at_smart(annotation.message, '\n', suffix_if_chopped='...')}</div> | ||||
r1412 | </td> | |||
r1413 | <td class="cb-annotate-message-spacer"> | |||
r1927 | <a class="tooltip" href="#show-previous-annotation" onclick="return annotationController.previousAnnotation('${annotation.raw_id}', '${c.f_path}', ${line_num})" title="${tooltip(_('view annotation from before this change'))}"> | |||
r1413 | <i class="icon-left"></i> | |||
</a> | ||||
</td> | ||||
r1412 | <td | |||
class="cb-annotate-revision" | ||||
r3105 | data-revision="${annotation.idx}" | |||
onclick="$('[data-revision=${annotation.idx}]').toggleClass('cb-line-fresh')" | ||||
r1412 | style="background: ${bgcolor}"> | |||
r1951 | <a class="cb-annotate" href="${h.route_path('repo_commit',repo_name=c.repo_name,commit_id=annotation.raw_id)}"> | |||
r3105 | r${annotation.idx} | |||
r1412 | </a> | |||
</td> | ||||
% else: | ||||
<td></td> | ||||
<td class="cb-annotate-message-spacer"></td> | ||||
<td | ||||
class="cb-annotate-revision" | ||||
r3105 | data-revision="${annotation.idx}" | |||
onclick="$('[data-revision=${annotation.idx}]').toggleClass('cb-line-fresh')" | ||||
r1412 | style="background: ${bgcolor}"> | |||
</td> | ||||
% endif | ||||
% else: | ||||
<td colspan="3"></td> | ||||
% endif | ||||
r1282 | <td class="cb-lineno" id="L${line_num}"> | |||
<a data-line-no="${line_num}" href="#L${line_num}"></a> | ||||
</td> | ||||
<td class="cb-content cb-content-fresh" | ||||
%if bgcolor: | ||||
style="background: ${bgcolor}" | ||||
%endif | ||||
> | ||||
## newline at end is necessary for highlight to work when line is empty | ||||
## and for copy pasting code to work as expected | ||||
<span class="cb-code">${render_tokenstream(tokens)|n}${'\n'}</span> | ||||
</td> | ||||
</tr> | ||||
</%def> | ||||
<%def name="render_annotation_lines(annotation, lines, color_hasher)"> | ||||
r1412 | % for line_num, tokens in lines: | |||
r1282 | ${render_line(line_num, tokens, | |||
bgcolor=color_hasher(annotation and annotation.raw_id or ''), | ||||
r1412 | annotation=annotation, show_annotation=loop.first | |||
r1282 | )} | |||
r1412 | % endfor | |||
r1413 | <script> | |||
var AnnotationController = function() { | ||||
var self = this; | ||||
r1412 | ||||
r1927 | this.previousAnnotation = function(commitId, fPath, lineNo) { | |||
r1413 | var params = { | |||
'repo_name': templateContext.repo_name, | ||||
r1927 | 'commit_id': commitId, | |||
'f_path': fPath, | ||||
'line_anchor': lineNo | ||||
r1413 | }; | |||
r1927 | window.location = pyroutes.url('repo_files:annotated_previous', params); | |||
r1413 | return false; | |||
}; | ||||
}; | ||||
var annotationController = new AnnotationController(); | ||||
</script> | ||||
r1282 | </%def> | |||