##// END OF EJS Templates
file-source: ensure over size limit files never do any content fetching when viewing the files....
dan -
r3897:66d45858 default
parent child Browse files
Show More
@@ -668,7 +668,10 b' class RepoFilesView(RepoAppView):'
668
668
669 c.file_source_page = 'true'
669 c.file_source_page = 'true'
670 c.file_last_commit = c.file.last_commit
670 c.file_last_commit = c.file.last_commit
671 if c.file.size < c.visual.cut_off_limit_diff:
671
672 c.file_size_too_big = c.file.size > c.visual.cut_off_limit_file
673
674 if not c.file_size_too_big:
672 if c.annotate: # annotation has precedence over renderer
675 if c.annotate: # annotation has precedence over renderer
673 c.annotated_lines = filenode_as_annotated_lines_tokens(
676 c.annotated_lines = filenode_as_annotated_lines_tokens(
674 c.file
677 c.file
@@ -60,14 +60,28 b''
60 <div class="file-stats">
60 <div class="file-stats">
61
61
62 <div class="stats-info">
62 <div class="stats-info">
63 <span class="stats-first-item">${c.file.lines()[0]} ${_ungettext('line', 'lines', c.file.lines()[0])}</span>
63 <span class="stats-first-item">
64 % if c.file_size_too_big:
65 0 ${(_('lines'))}
66 % else:
67 ${c.file.lines()[0]} ${_ungettext('line', 'lines', c.file.lines()[0])}
68 % endif
69 </span>
64
70
65 <span> | ${h.format_byte_size_binary(c.file.size)}</span>
71 <span> | ${h.format_byte_size_binary(c.file.size)}</span>
66 % if c.lf_node:
72 % if c.lf_node:
67 <span title="${_('This file is a pointer to large binary file')}"> | ${_('LargeFile')} ${h.format_byte_size_binary(c.lf_node.size)} </span>
73 <span title="${_('This file is a pointer to large binary file')}"> | ${_('LargeFile')} ${h.format_byte_size_binary(c.lf_node.size)} </span>
68 % endif
74 % endif
69 <span> | ${c.file.mimetype} </span>
75 <span>
70 <span> | ${h.get_lexer_for_filenode(c.file).__class__.__name__}</span>
76 | ${c.file.mimetype}
77 </span>
78
79 % if not c.file_size_too_big:
80 <span> |
81 ${h.get_lexer_for_filenode(c.file).__class__.__name__}
82 </span>
83 % endif
84
71 </div>
85 </div>
72 </div>
86 </div>
73 </div>
87 </div>
@@ -94,46 +108,45 b''
94 </div>
108 </div>
95
109
96 <div class="code-body clear-fix ">
110 <div class="code-body clear-fix ">
97
98 %if c.file.is_binary:
111 %if c.file.is_binary:
99 <% rendered_binary = h.render_binary(c.repo_name, c.file)%>
112 <% rendered_binary = h.render_binary(c.repo_name, c.file)%>
100 % if rendered_binary:
113 % if rendered_binary:
101 ${rendered_binary}
114 ${rendered_binary}
102 % else:
115 % else:
103 <div>
116 <div>
104 ${_('Binary file (%s)') % c.file.mimetype}
117 ${_('Binary file ({})').format(c.file.mimetype)}
105 </div>
118 </div>
106 % endif
119 % endif
107 %else:
120 %else:
108 % if c.file.size < c.visual.cut_off_limit_file:
121 % if c.file_size_too_big:
109 %if c.renderer and not c.annotate:
122 ${_('File size {} is bigger then allowed limit {}. ').format(h.format_byte_size_binary(c.file.size), h.format_byte_size_binary(c.visual.cut_off_limit_file))} ${h.link_to(_('Show as raw'),
110 ## pick relative url based on renderer
123 h.route_path('repo_file_raw',repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path))}
111 <%
124 % else:
112 relative_urls = {
125 %if c.renderer and not c.annotate:
113 'raw': h.route_path('repo_file_raw',repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path),
126 ## pick relative url based on renderer
114 'standard': h.route_path('repo_files',repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path),
127 <%
115 }
128 relative_urls = {
116 %>
129 'raw': h.route_path('repo_file_raw',repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path),
117 ${h.render(c.file.content, renderer=c.renderer, relative_urls=relative_urls)}
130 'standard': h.route_path('repo_files',repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path),
118 %else:
131 }
119 <table class="cb codehilite">
132 %>
120 %if c.annotate:
133 ${h.render(c.file.content, renderer=c.renderer, relative_urls=relative_urls)}
121 <% color_hasher = h.color_hasher() %>
122 %for annotation, lines in c.annotated_lines:
123 ${sourceblock.render_annotation_lines(annotation, lines, color_hasher)}
124 %endfor
125 %else:
134 %else:
126 %for line_num, tokens in enumerate(c.lines, 1):
135 <table class="cb codehilite">
127 ${sourceblock.render_line(line_num, tokens)}
136 %if c.annotate:
128 %endfor
137 <% color_hasher = h.color_hasher() %>
138 %for annotation, lines in c.annotated_lines:
139 ${sourceblock.render_annotation_lines(annotation, lines, color_hasher)}
140 %endfor
141 %else:
142 %for line_num, tokens in enumerate(c.lines, 1):
143 ${sourceblock.render_line(line_num, tokens)}
144 %endfor
145 %endif
146 </table>
129 %endif
147 %endif
130 </table>
148 % endif
131 %endif
132 %else:
133 ${_('File size {} is bigger then allowed limit {}. ').format(h.format_byte_size_binary(c.file.size), h.format_byte_size_binary(c.visual.cut_off_limit_file))} ${h.link_to(_('Show as raw'),
134 h.route_path('repo_file_raw',repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path))}
135 %endif
149 %endif
136 %endif
137 </div>
150 </div>
138
151
139 </div>
152 </div>
General Comments 0
You need to be logged in to leave comments. Login now