##// 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 669 c.file_source_page = 'true'
670 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 675 if c.annotate: # annotation has precedence over renderer
673 676 c.annotated_lines = filenode_as_annotated_lines_tokens(
674 677 c.file
@@ -60,14 +60,28 b''
60 60 <div class="file-stats">
61 61
62 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 71 <span> | ${h.format_byte_size_binary(c.file.size)}</span>
66 72 % if c.lf_node:
67 73 <span title="${_('This file is a pointer to large binary file')}"> | ${_('LargeFile')} ${h.format_byte_size_binary(c.lf_node.size)} </span>
68 74 % endif
69 <span> | ${c.file.mimetype} </span>
70 <span> | ${h.get_lexer_for_filenode(c.file).__class__.__name__}</span>
75 <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 85 </div>
72 86 </div>
73 87 </div>
@@ -94,46 +108,45 b''
94 108 </div>
95 109
96 110 <div class="code-body clear-fix ">
97
98 111 %if c.file.is_binary:
99 112 <% rendered_binary = h.render_binary(c.repo_name, c.file)%>
100 113 % if rendered_binary:
101 114 ${rendered_binary}
102 115 % else:
103 116 <div>
104 ${_('Binary file (%s)') % c.file.mimetype}
117 ${_('Binary file ({})').format(c.file.mimetype)}
105 118 </div>
106 119 % endif
107 120 %else:
108 % if c.file.size < c.visual.cut_off_limit_file:
109 %if c.renderer and not c.annotate:
110 ## pick relative url based on renderer
111 <%
112 relative_urls = {
113 'raw': h.route_path('repo_file_raw',repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path),
114 'standard': h.route_path('repo_files',repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path),
115 }
116 %>
117 ${h.render(c.file.content, renderer=c.renderer, relative_urls=relative_urls)}
118 %else:
119 <table class="cb codehilite">
120 %if c.annotate:
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
121 % if c.file_size_too_big:
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'),
123 h.route_path('repo_file_raw',repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path))}
124 % else:
125 %if c.renderer and not c.annotate:
126 ## pick relative url based on renderer
127 <%
128 relative_urls = {
129 'raw': h.route_path('repo_file_raw',repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path),
130 'standard': h.route_path('repo_files',repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path),
131 }
132 %>
133 ${h.render(c.file.content, renderer=c.renderer, relative_urls=relative_urls)}
125 134 %else:
126 %for line_num, tokens in enumerate(c.lines, 1):
127 ${sourceblock.render_line(line_num, tokens)}
128 %endfor
135 <table class="cb codehilite">
136 %if c.annotate:
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 147 %endif
130 </table>
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))}
148 % endif
135 149 %endif
136 %endif
137 150 </div>
138 151
139 152 </div>
General Comments 0
You need to be logged in to leave comments. Login now