##// END OF EJS Templates
files: don't use safe_unicode calls
super-admin -
r5004:81bea8a2 default
parent child Browse files
Show More
@@ -1,379 +1,379 b''
1 1 <%inherit file="/base/base.mako"/>
2 2
3 3 <%def name="title(*args)">
4 4 ${_('{} Files').format(c.repo_name)}
5 5 %if hasattr(c,'file'):
6 &middot; ${(h.safe_unicode(c.file.path) or '\\')}
6 &middot; ${(h.safe_str(c.file.path) or '\\')}
7 7 %endif
8 8
9 9 %if c.rhodecode_name:
10 10 &middot; ${h.branding(c.rhodecode_name)}
11 11 %endif
12 12 </%def>
13 13
14 14 <%def name="breadcrumbs_links()">
15 15 ${_('Files')}
16 16 %if c.file:
17 17 @ ${h.show_id(c.commit)}
18 18 %endif
19 19 </%def>
20 20
21 21 <%def name="menu_bar_nav()">
22 22 ${self.menu_items(active='repositories')}
23 23 </%def>
24 24
25 25 <%def name="menu_bar_subnav()">
26 26 ${self.repo_menu(active='files')}
27 27 </%def>
28 28
29 29 <%def name="main()">
30 30 <script type="text/javascript">
31 31 var fileSourcePage = ${c.file_source_page};
32 32 var atRef = '${request.GET.get('at', '')}';
33 33
34 34 // global state for fetching metadata
35 35 metadataRequest = null;
36 36
37 37 // global metadata about URL
38 38 filesUrlData = ${h.files_url_data(request)|n};
39 39 </script>
40 40
41 41 <div>
42 42 <div>
43 43 <%include file='files_pjax.mako'/>
44 44 </div>
45 45 </div>
46 46
47 47 <script type="text/javascript">
48 48
49 49 var initFileJS = function () {
50 50 var state = getFileState();
51 51
52 52 // select code link event
53 53 $("#hlcode").mouseup(getSelectionLink);
54 54
55 55 // file history select2 used for history of file, and switch to
56 56 var initialCommitData = {
57 57 at_ref: atRef,
58 58 id: null,
59 59 text: '${c.commit.raw_id}',
60 60 type: 'sha',
61 61 raw_id: '${c.commit.raw_id}',
62 62 idx: ${c.commit.idx},
63 63 files_url: null,
64 64 };
65 65
66 66 // check if we have ref info.
67 67 var selectedRef = fileTreeRefs[atRef];
68 68 if (selectedRef !== undefined) {
69 69 $.extend(initialCommitData, selectedRef)
70 70 }
71 71
72 72 var loadUrl = pyroutes.url('repo_file_history', {'repo_name': templateContext.repo_name, 'commit_id': state.commit_id,'f_path': state.f_path});
73 73 var cacheKey = '__SINGLE_FILE_REFS__';
74 74 var cachedDataSource = {};
75 75
76 76 var loadRefsData = function (query) {
77 77 $.ajax({
78 78 url: loadUrl,
79 79 data: {},
80 80 dataType: 'json',
81 81 type: 'GET',
82 82 success: function (data) {
83 83 cachedDataSource[cacheKey] = data;
84 84 query.callback({results: data.results});
85 85 }
86 86 });
87 87 };
88 88
89 89 var feedRefsData = function (query, cachedData) {
90 90 var data = {results: []};
91 91 //filter results
92 92 $.each(cachedData.results, function () {
93 93 var section = this.text;
94 94 var children = [];
95 95 $.each(this.children, function () {
96 96 if (query.term.length === 0 || this.text.toUpperCase().indexOf(query.term.toUpperCase()) >= 0) {
97 97 children.push(this)
98 98 }
99 99 });
100 100 data.results.push({
101 101 'text': section,
102 102 'children': children
103 103 })
104 104 });
105 105
106 106 query.callback(data);
107 107 };
108 108
109 109 var select2FileHistorySwitcher = function (targetElement, loadUrl, initialData) {
110 110 var formatResult = function (result, container, query) {
111 111 return formatSelect2SelectionRefs(result);
112 112 };
113 113
114 114 var formatSelection = function (data, container) {
115 115 var commit_ref = data;
116 116
117 117 var tmpl = '';
118 118 if (commit_ref.type === 'sha') {
119 119 tmpl = (commit_ref.raw_id || "").substr(0,8);
120 120 } else if (commit_ref.type === 'branch') {
121 121 tmpl = tmpl.concat('<i class="icon-branch"></i> ');
122 122 tmpl = tmpl.concat(escapeHtml(commit_ref.text));
123 123 } else if (commit_ref.type === 'tag') {
124 124 tmpl = tmpl.concat('<i class="icon-tag"></i> ');
125 125 tmpl = tmpl.concat(escapeHtml(commit_ref.text));
126 126 } else if (commit_ref.type === 'book') {
127 127 tmpl = tmpl.concat('<i class="icon-bookmark"></i> ');
128 128 tmpl = tmpl.concat(escapeHtml(commit_ref.text));
129 129 }
130 130 var idx = commit_ref.idx || 0;
131 131 if (idx !== 0) {
132 132 tmpl = tmpl.concat('<span class="select-index-number">r{0}</span>'.format(idx));
133 133 }
134 134 return tmpl
135 135 };
136 136
137 137 $(targetElement).select2({
138 138 dropdownAutoWidth: true,
139 139 width: "resolve",
140 140 containerCssClass: "drop-menu",
141 141 dropdownCssClass: "drop-menu-dropdown",
142 142 query: function(query) {
143 143 var cachedData = cachedDataSource[cacheKey];
144 144 if (cachedData) {
145 145 feedRefsData(query, cachedData)
146 146 } else {
147 147 loadRefsData(query)
148 148 }
149 149 },
150 150 initSelection: function(element, callback) {
151 151 callback(initialData);
152 152 },
153 153 formatResult: formatResult,
154 154 formatSelection: formatSelection
155 155 });
156 156
157 157 };
158 158
159 159 select2FileHistorySwitcher('#file_refs_filter', loadUrl, initialCommitData);
160 160
161 161 // switcher for files
162 162 $('#file_refs_filter').on('change', function(e) {
163 163 var data = $('#file_refs_filter').select2('data');
164 164 var commit_id = data.id;
165 165 var params = {
166 166 'repo_name': templateContext.repo_name,
167 167 'commit_id': commit_id,
168 168 'f_path': state.f_path
169 169 };
170 170
171 171 if(data.at_rev !== undefined && data.at_rev !== "") {
172 172 params['at'] = data.at_rev;
173 173 }
174 174
175 175 if ("${c.annotate}" === "True") {
176 176 var url = pyroutes.url('repo_files:annotated', params);
177 177 } else {
178 178 var url = pyroutes.url('repo_files', params);
179 179 }
180 180 window.location = url;
181 181
182 182 });
183 183
184 184 // load file short history
185 185 $('#file_history_overview').on('click', function(e) {
186 186 e.preventDefault();
187 187 path = state.f_path;
188 188 if (path.indexOf("#") >= 0) {
189 189 path = path.slice(0, path.indexOf("#"));
190 190 }
191 191 var url = pyroutes.url('repo_commits_file',
192 192 {'repo_name': templateContext.repo_name,
193 193 'commit_id': state.commit_id, 'f_path': path, 'limit': 6});
194 194 $('#file_history_container').show();
195 195 $('#file_history_container').html('<div class="file-history-inner">{0}</div>'.format(_gettext('Loading ...')));
196 196
197 197 $.pjax({
198 198 url: url,
199 199 container: '#file_history_container',
200 200 push: false,
201 201 timeout: 5000
202 202 }).complete(function () {
203 203 tooltipActivate();
204 204 });
205 205 });
206 206
207 207 };
208 208
209 209 var initTreeJS = function () {
210 210 var state = getFileState();
211 211 getFilesMetadata();
212 212
213 213 // fuzzy file filter
214 214 fileBrowserListeners(state.node_list_url, state.url_base);
215 215
216 216 // switch to widget
217 217 var initialCommitData = {
218 218 at_ref: atRef,
219 219 id: null,
220 220 text: '${c.commit.raw_id}',
221 221 type: 'sha',
222 222 raw_id: '${c.commit.raw_id}',
223 223 idx: ${c.commit.idx},
224 224 files_url: null,
225 225 };
226 226
227 227 // check if we have ref info.
228 228 var selectedRef = fileTreeRefs[atRef];
229 229 if (selectedRef !== undefined) {
230 230 $.extend(initialCommitData, selectedRef)
231 231 }
232 232
233 233 var loadUrl = pyroutes.url('repo_refs_data', {'repo_name': templateContext.repo_name});
234 234 var cacheKey = '__ALL_FILE_REFS__';
235 235 var cachedDataSource = {};
236 236
237 237 var loadRefsData = function (query) {
238 238 $.ajax({
239 239 url: loadUrl,
240 240 data: {},
241 241 dataType: 'json',
242 242 type: 'GET',
243 243 success: function (data) {
244 244 cachedDataSource[cacheKey] = data;
245 245 query.callback({results: data.results});
246 246 }
247 247 });
248 248 };
249 249
250 250 var feedRefsData = function (query, cachedData) {
251 251 var data = {results: []};
252 252 //filter results
253 253 $.each(cachedData.results, function () {
254 254 var section = this.text;
255 255 var children = [];
256 256 $.each(this.children, function () {
257 257 if (query.term.length === 0 || this.text.toUpperCase().indexOf(query.term.toUpperCase()) >= 0) {
258 258 children.push(this)
259 259 }
260 260 });
261 261 data.results.push({
262 262 'text': section,
263 263 'children': children
264 264 })
265 265 });
266 266
267 267 //push the typed in commit idx
268 268 if (!isNaN(query.term)) {
269 269 var files_url = pyroutes.url('repo_files',
270 270 {'repo_name': templateContext.repo_name,
271 271 'commit_id': query.term, 'f_path': state.f_path});
272 272
273 273 data.results.push({
274 274 'text': _gettext('go to numeric commit'),
275 275 'children': [{
276 276 at_ref: null,
277 277 id: null,
278 278 text: 'r{0}'.format(query.term),
279 279 type: 'sha',
280 280 raw_id: query.term,
281 281 idx: query.term,
282 282 files_url: files_url,
283 283 }]
284 284 });
285 285 }
286 286 query.callback(data);
287 287 };
288 288
289 289 var select2RefFileSwitcher = function (targetElement, loadUrl, initialData) {
290 290 var formatResult = function (result, container, query) {
291 291 return formatSelect2SelectionRefs(result);
292 292 };
293 293
294 294 var formatSelection = function (data, container) {
295 295 var commit_ref = data;
296 296
297 297 var tmpl = '';
298 298 if (commit_ref.type === 'sha') {
299 299 tmpl = (commit_ref.raw_id || "").substr(0,8);
300 300 } else if (commit_ref.type === 'branch') {
301 301 tmpl = tmpl.concat('<i class="icon-branch"></i> ');
302 302 tmpl = tmpl.concat(escapeHtml(commit_ref.text));
303 303 } else if (commit_ref.type === 'tag') {
304 304 tmpl = tmpl.concat('<i class="icon-tag"></i> ');
305 305 tmpl = tmpl.concat(escapeHtml(commit_ref.text));
306 306 } else if (commit_ref.type === 'book') {
307 307 tmpl = tmpl.concat('<i class="icon-bookmark"></i> ');
308 308 tmpl = tmpl.concat(escapeHtml(commit_ref.text));
309 309 }
310 310
311 311 var idx = commit_ref.idx || 0;
312 312 if (idx !== 0) {
313 313 tmpl = tmpl.concat('<span class="select-index-number">r{0}</span>'.format(idx));
314 314 }
315 315 return tmpl
316 316 };
317 317
318 318 $(targetElement).select2({
319 319 dropdownAutoWidth: true,
320 320 width: "resolve",
321 321 containerCssClass: "drop-menu",
322 322 dropdownCssClass: "drop-menu-dropdown",
323 323 query: function(query) {
324 324
325 325 var cachedData = cachedDataSource[cacheKey];
326 326 if (cachedData) {
327 327 feedRefsData(query, cachedData)
328 328 } else {
329 329 loadRefsData(query)
330 330 }
331 331 },
332 332 initSelection: function(element, callback) {
333 333 callback(initialData);
334 334 },
335 335 formatResult: formatResult,
336 336 formatSelection: formatSelection
337 337 });
338 338
339 339 };
340 340
341 341 select2RefFileSwitcher('#refs_filter', loadUrl, initialCommitData);
342 342
343 343 // switcher for file tree
344 344 $('#refs_filter').on('change', function(e) {
345 345 var data = $('#refs_filter').select2('data');
346 346 window.location = data.files_url
347 347 });
348 348
349 349 };
350 350
351 351 $(document).ready(function() {
352 352 timeagoActivate();
353 353 tooltipActivate();
354 354
355 355 if ($('#trimmed_message_box').height() < 50) {
356 356 $('#message_expand').hide();
357 357 }
358 358
359 359 $('#message_expand').on('click', function(e) {
360 360 $('#trimmed_message_box').css('max-height', 'none');
361 361 $(this).hide();
362 362 });
363 363
364 364 if (fileSourcePage) {
365 365 initFileJS()
366 366 } else {
367 367 initTreeJS()
368 368 }
369 369
370 370 var search_GET = "${request.GET.get('search','')}";
371 371 if (search_GET === "1") {
372 372 NodeFilter.initFilter();
373 373 NodeFilter.focus();
374 374 }
375 375 });
376 376
377 377 </script>
378 378
379 379 </%def> No newline at end of file
@@ -1,98 +1,98 b''
1 1 <%namespace name="base" file="/base/base.mako"/>
2 2
3 3 <%
4 4 at_ref = request.GET.get('at')
5 5 if at_ref:
6 6 query={'at': at_ref}
7 7 default_landing_ref = at_ref or c.rhodecode_db_repo.landing_ref_name
8 8 else:
9 9 query=None
10 10 default_landing_ref = c.commit.raw_id
11 11 %>
12 12 <div id="file-tree-wrapper" class="browser-body ${('full-load' if c.full_load else '')}">
13 13 <table class="code-browser rctable table-bordered">
14 14 <thead>
15 15 <tr>
16 16 <th>${_('Name')}</th>
17 17 <th>${_('Size')}</th>
18 18 <th>${_('Modified')}</th>
19 19 <th>${_('Last Commit')}</th>
20 20 <th>${_('Author')}</th>
21 21 </tr>
22 22 </thead>
23 23
24 24 <tbody id="tbody">
25 25 <tr>
26 26 <td colspan="5">
27 27 ${h.files_breadcrumbs(c.repo_name, c.rhodecode_db_repo.repo_type, c.commit.raw_id, c.file.path, c.rhodecode_db_repo.landing_ref_name, request.GET.get('at'), limit_items=True)}
28 28 </td>
29 29 </tr>
30 30
31 31 <% has_files = False %>
32 32 % for cnt,node in enumerate(c.file):
33 33 <% has_files = True %>
34 34 <tr class="parity${(cnt % 2)}">
35 35 <td class="td-componentname">
36 36 % if node.is_submodule():
37 37 <span class="submodule-dir">
38 38 % if node.url.startswith('http://') or node.url.startswith('https://'):
39 39 <a href="${node.url}">
40 40 <i class="icon-directory browser-dir"></i>${node.name}
41 41 </a>
42 42 % else:
43 43 <i class="icon-directory browser-dir"></i>${node.name}
44 44 % endif
45 45 </span>
46 46 % else:
47 <a href="${h.repo_files_by_ref_url(c.repo_name, c.rhodecode_db_repo.repo_type, f_path=h.safe_unicode(node.path), ref_name=default_landing_ref, commit_id=c.commit.raw_id, query=query)}">
47 <a href="${h.repo_files_by_ref_url(c.repo_name, c.rhodecode_db_repo.repo_type, f_path=h.safe_str(node.path), ref_name=default_landing_ref, commit_id=c.commit.raw_id, query=query)}">
48 48 <i class="${('icon-file-text browser-file' if node.is_file() else 'icon-directory browser-dir')}"></i>${node.name}
49 49 </a>
50 50 % endif
51 51 </td>
52 52 %if node.is_file():
53 53 <td class="td-size" data-attr-name="size">
54 54 % if c.full_load:
55 55 <span data-size="${node.size}">${h.format_byte_size_binary(node.size)}</span>
56 56 % else:
57 57 ${_('Loading ...')}
58 58 % endif
59 59 </td>
60 60 <td class="td-time" data-attr-name="modified_at">
61 61 % if c.full_load:
62 62 <span data-date="${node.last_commit.date}">${h.age_component(node.last_commit.date)}</span>
63 63 % endif
64 64 </td>
65 65 <td class="td-hash" data-attr-name="commit_id">
66 66 % if c.full_load:
67 67 <div class="tooltip-hovercard" data-hovercard-alt="${node.last_commit.message}" data-hovercard-url="${h.route_path('hovercard_repo_commit', repo_name=c.repo_name, commit_id=node.last_commit.raw_id)}">
68 68 <pre data-commit-id="${node.last_commit.raw_id}">r${node.last_commit.idx}:${node.last_commit.short_id}</pre>
69 69 </div>
70 70 % endif
71 71 </td>
72 72 <td class="td-user" data-attr-name="author">
73 73 % if c.full_load:
74 74 <span data-author="${node.last_commit.author}">${h.gravatar_with_user(request, node.last_commit.author, tooltip=True)|n}</span>
75 75 % endif
76 76 </td>
77 77 %else:
78 78 <td></td>
79 79 <td></td>
80 80 <td></td>
81 81 <td></td>
82 82 %endif
83 83 </tr>
84 84 % endfor
85 85
86 86 % if not has_files:
87 87 <tr>
88 88 <td colspan="5">
89 89 ##empty-dir mostly SVN
90 90 &nbsp;
91 91 </td>
92 92 </tr>
93 93 % endif
94 94
95 95 </tbody>
96 96 <tbody id="tbody_filtered"></tbody>
97 97 </table>
98 98 </div>
@@ -1,34 +1,34 b''
1 1 <%def name="title(*args)">
2 2 ${_('{} Files').format(c.repo_name)}
3 3 %if hasattr(c,'file'):
4 &middot; ${(h.safe_unicode(c.file.path) or '\\')}
4 &middot; ${(h.safe_str(c.file.path) or '\\')}
5 5 %endif
6 6
7 7 %if c.rhodecode_name:
8 8 &middot; ${h.branding(c.rhodecode_name)}
9 9 %endif
10 10 </%def>
11 11
12 12 <div>
13 13
14 14 <div class="summary-detail">
15 15 <div class="summary-detail-header">
16 16
17 17 </div><!--end summary-detail-header-->
18 18
19 19 % if c.file.is_submodule():
20 20 <span class="submodule-dir">Submodule ${h.escape(c.file.name)}</span>
21 21 % elif c.file.is_dir():
22 22 <%include file='files_tree_header.mako'/>
23 23 % else:
24 24 <%include file='files_source_header.mako'/>
25 25 % endif
26 26
27 27 </div> <!--end summary-detail-->
28 28 % if c.file.is_dir():
29 29 <%include file='files_browser.mako'/>
30 30 % else:
31 31 <%include file='files_source.mako'/>
32 32 % endif
33 33
34 34 </div>
General Comments 0
You need to be logged in to leave comments. Login now