Show More
@@ -1,101 +1,101 b'' | |||
|
1 | 1 | <%def name="highlight_text_file(terms, text, url, line_context=3, |
|
2 | 2 | max_lines=10, |
|
3 | 3 | mimetype=None, filepath=None)"> |
|
4 | 4 | <% |
|
5 | 5 | lines = text.split('\n') |
|
6 | 6 | lines_of_interest = set() |
|
7 | 7 | matching_lines = h.get_matching_line_offsets(lines, terms) |
|
8 | 8 | shown_matching_lines = 0 |
|
9 | 9 | |
|
10 | 10 | for line_number in matching_lines: |
|
11 | 11 | if len(lines_of_interest) < max_lines: |
|
12 | 12 | lines_of_interest |= set(range( |
|
13 | 13 | max(line_number - line_context, 0), |
|
14 | min(line_number + line_context, len(lines)))) | |
|
14 | min(line_number + line_context, len(lines) + 1))) | |
|
15 | 15 | shown_matching_lines += 1 |
|
16 | 16 | |
|
17 | 17 | %> |
|
18 | 18 | ${h.code_highlight( |
|
19 | 19 | text, |
|
20 | 20 | h.get_lexer_safe( |
|
21 | 21 | mimetype=mimetype, |
|
22 | 22 | filepath=filepath, |
|
23 | 23 | ), |
|
24 | 24 | h.SearchContentCodeHtmlFormatter( |
|
25 | 25 | linenos=True, |
|
26 | 26 | cssclass="code-highlight", |
|
27 | 27 | url=url, |
|
28 | 28 | query_terms=terms, |
|
29 | 29 | only_line_numbers=lines_of_interest |
|
30 | 30 | ))|n} |
|
31 | 31 | %if len(matching_lines) > shown_matching_lines: |
|
32 | 32 | <a href="${url}"> |
|
33 | 33 | ${len(matching_lines) - shown_matching_lines} ${_('more matches in this file')} |
|
34 | 34 | </p> |
|
35 | 35 | %endif |
|
36 | 36 | </%def> |
|
37 | 37 | |
|
38 | 38 | <div class="search-results"> |
|
39 | 39 | %for entry in c.formatted_results: |
|
40 | 40 | ## search results are additionally filtered, and this check is just a safe gate |
|
41 | 41 | % if h.HasRepoPermissionAny('repository.write','repository.read','repository.admin')(entry['repository'], 'search results content check'): |
|
42 | 42 | <div id="codeblock" class="codeblock"> |
|
43 | 43 | <div class="codeblock-header"> |
|
44 | 44 | <h2> |
|
45 | 45 | %if h.get_repo_type_by_name(entry.get('repository')) == 'hg': |
|
46 | 46 | <i class="icon-hg"></i> |
|
47 | 47 | %elif h.get_repo_type_by_name(entry.get('repository')) == 'git': |
|
48 | 48 | <i class="icon-git"></i> |
|
49 | 49 | %elif h.get_repo_type_by_name(entry.get('repository')) == 'svn': |
|
50 | 50 | <i class="icon-svn"></i> |
|
51 | 51 | %endif |
|
52 | 52 | ${h.link_to(entry['repository'], h.url('summary_home',repo_name=entry['repository']))} |
|
53 | 53 | </h2> |
|
54 | 54 | <div class="stats"> |
|
55 | 55 | ${h.link_to(h.literal(entry['f_path']), h.url('files_home',repo_name=entry['repository'],revision=entry.get('commit_id', 'tip'),f_path=entry['f_path']))} |
|
56 | 56 | %if entry.get('lines'): |
|
57 | 57 | | ${entry.get('lines', 0.)} ${ungettext('line', 'lines', entry.get('lines', 0.))} |
|
58 | 58 | %endif |
|
59 | 59 | %if entry.get('size'): |
|
60 | 60 | | ${h.format_byte_size_binary(entry['size'])} |
|
61 | 61 | %endif |
|
62 | 62 | %if entry.get('mimetype'): |
|
63 | 63 | | ${entry.get('mimetype', "unknown mimetype")} |
|
64 | 64 | %endif |
|
65 | 65 | </div> |
|
66 | 66 | <div class="buttons"> |
|
67 | 67 | <a id="file_history_overview_full" href="${h.url('changelog_file_home',repo_name=entry.get('repository',''),revision=entry.get('commit_id', 'tip'),f_path=entry.get('f_path',''))}"> |
|
68 | 68 | ${_('Show Full History')} |
|
69 | 69 | </a> | |
|
70 | 70 | ${h.link_to(_('Annotation'), h.url('files_annotate_home', repo_name=entry.get('repository',''),revision=entry.get('commit_id', 'tip'),f_path=entry.get('f_path','')))} |
|
71 | 71 | | ${h.link_to(_('Raw'), h.url('files_raw_home', repo_name=entry.get('repository',''),revision=entry.get('commit_id', 'tip'),f_path=entry.get('f_path','')))} |
|
72 | 72 | | <a href="${h.url('files_rawfile_home',repo_name=entry.get('repository',''),revision=entry.get('commit_id', 'tip'),f_path=entry.get('f_path',''))}"> |
|
73 | 73 | ${_('Download')} |
|
74 | 74 | </a> |
|
75 | 75 | </div> |
|
76 | 76 | </div> |
|
77 | 77 | <div class="code-body search-code-body"> |
|
78 | 78 | ${highlight_text_file(c.cur_query, entry['content'], |
|
79 | 79 | url=h.url('files_home',repo_name=entry['repository'],revision=entry.get('commit_id', 'tip'),f_path=entry['f_path']), |
|
80 | 80 | mimetype=entry.get('mimetype'), filepath=entry.get('path'))} |
|
81 | 81 | </div> |
|
82 | 82 | </div> |
|
83 | 83 | % endif |
|
84 | 84 | %endfor |
|
85 | 85 | </div> |
|
86 | 86 | %if c.cur_query and c.formatted_results: |
|
87 | 87 | <div class="pagination-wh pagination-left" > |
|
88 | 88 | ${c.formatted_results.pager('$link_previous ~2~ $link_next')} |
|
89 | 89 | </div> |
|
90 | 90 | %endif |
|
91 | 91 | |
|
92 | 92 | %if c.cur_query: |
|
93 | 93 | <script type="text/javascript"> |
|
94 | 94 | $(function(){ |
|
95 | 95 | $(".code").mark( |
|
96 | 96 | '${' '.join(h.normalize_text_for_matching(c.cur_query).split())}', |
|
97 | 97 | {"className": 'match', |
|
98 | 98 | }); |
|
99 | 99 | }) |
|
100 | 100 | </script> |
|
101 | 101 | %endif No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now