Show More
@@ -181,7 +181,7 b' class TestFilesViews(object):' | |||
|
181 | 181 | landing_rev = backend.repo.landing_ref_name |
|
182 | 182 | files_url = route_path('repo_files:default_path', |
|
183 | 183 | repo_name=backend.repo_name, |
|
184 | commit_id=landing_rev) | |
|
184 | commit_id=landing_rev, params={'at': landing_rev}) | |
|
185 | 185 | |
|
186 | 186 | assert landing_rev != 'tip' |
|
187 | 187 | response.mustcontain( |
@@ -589,6 +589,20 b' class RepoFilesView(RepoAppView):' | |||
|
589 | 589 | raise HTTPFound(compare_url) |
|
590 | 590 | |
|
591 | 591 | @LoginRequired() |
|
592 | @view_config( | |
|
593 | route_name='repo_files:default_commit', request_method='GET', | |
|
594 | renderer=None) | |
|
595 | def repo_files_default(self): | |
|
596 | c = self.load_default_context() | |
|
597 | ||
|
598 | landing_url = h.route_path( | |
|
599 | 'repo_files', repo_name=c.repo_name, | |
|
600 | commit_id=c.rhodecode_db_repo.landing_ref_name, f_path='', | |
|
601 | _query={'at': c.rhodecode_db_repo.landing_ref_name}) | |
|
602 | ||
|
603 | raise HTTPFound(landing_url) | |
|
604 | ||
|
605 | @LoginRequired() | |
|
592 | 606 | @HasRepoPermissionAnyDecorator( |
|
593 | 607 | 'repository.read', 'repository.write', 'repository.admin') |
|
594 | 608 | @view_config( |
@@ -598,9 +612,6 b' class RepoFilesView(RepoAppView):' | |||
|
598 | 612 | route_name='repo_files:default_path', request_method='GET', |
|
599 | 613 | renderer=None) |
|
600 | 614 | @view_config( |
|
601 | route_name='repo_files:default_commit', request_method='GET', | |
|
602 | renderer=None) | |
|
603 | @view_config( | |
|
604 | 615 | route_name='repo_files:rendered', request_method='GET', |
|
605 | 616 | renderer=None) |
|
606 | 617 | @view_config( |
@@ -256,11 +256,17 b' tooltip = _ToolTip()' | |||
|
256 | 256 | files_icon = u'<i class="file-breadcrumb-copy tooltip icon-clipboard clipboard-action" data-clipboard-text="{}" title="Copy file path"></i>' |
|
257 | 257 | |
|
258 | 258 | |
|
259 |
def files_breadcrumbs(repo_name, commit_id, file_path, at_ref=None, |
|
|
259 | def files_breadcrumbs(repo_name, commit_id, file_path, landing_ref_name=None, at_ref=None, | |
|
260 | limit_items=False, linkify_last_item=False, hide_last_item=False, copy_path_icon=True): | |
|
260 | 261 | if isinstance(file_path, str): |
|
261 | 262 | file_path = safe_unicode(file_path) |
|
262 | 263 | |
|
263 | route_qry = {'at': at_ref} if at_ref else None | |
|
264 | if at_ref: | |
|
265 | route_qry = {'at': at_ref} | |
|
266 | default_commit_id = at_ref or landing_ref_name or commit_id | |
|
267 | else: | |
|
268 | route_qry = None | |
|
269 | default_commit_id = commit_id | |
|
264 | 270 | |
|
265 | 271 | # first segment is a `..` link to repo files |
|
266 | 272 | root_name = literal(u'<i class="icon-home"></i>') |
@@ -270,7 +276,7 b' def files_breadcrumbs(repo_name, commit_' | |||
|
270 | 276 | route_path( |
|
271 | 277 | 'repo_files', |
|
272 | 278 | repo_name=repo_name, |
|
273 | commit_id=commit_id, | |
|
279 | commit_id=default_commit_id, | |
|
274 | 280 | f_path='', |
|
275 | 281 | _query=route_qry), |
|
276 | 282 | )] |
@@ -284,6 +290,10 b' def files_breadcrumbs(repo_name, commit_' | |||
|
284 | 290 | |
|
285 | 291 | last_item = cnt == last_cnt |
|
286 | 292 | |
|
293 | if last_item and hide_last_item: | |
|
294 | # iterate over and hide last element | |
|
295 | continue | |
|
296 | ||
|
287 | 297 | if last_item and linkify_last_item is False: |
|
288 | 298 | # plain version |
|
289 | 299 | url_segments.append(segment_html) |
@@ -294,7 +304,7 b' def files_breadcrumbs(repo_name, commit_' | |||
|
294 | 304 | route_path( |
|
295 | 305 | 'repo_files', |
|
296 | 306 | repo_name=repo_name, |
|
297 | commit_id=commit_id, | |
|
307 | commit_id=default_commit_id, | |
|
298 | 308 | f_path='/'.join(path_segments[:cnt + 1]), |
|
299 | 309 | _query=route_qry), |
|
300 | 310 | )) |
@@ -304,7 +314,11 b' def files_breadcrumbs(repo_name, commit_' | |||
|
304 | 314 | url_segments = limited_url_segments |
|
305 | 315 | |
|
306 | 316 | full_path = file_path |
|
307 | icon = files_icon.format(escape(full_path)) | |
|
317 | if copy_path_icon: | |
|
318 | icon = files_icon.format(escape(full_path)) | |
|
319 | else: | |
|
320 | icon = '' | |
|
321 | ||
|
308 | 322 | if file_path == '': |
|
309 | 323 | return root_name |
|
310 | 324 | else: |
@@ -365,7 +365,7 b'' | |||
|
365 | 365 | <ul id="context-pages" class="navigation horizontal-list"> |
|
366 | 366 | <li class="${h.is_active('summary', active)}"><a class="menulink" href="${h.route_path('repo_summary', repo_name=c.repo_name)}"><div class="menulabel">${_('Summary')}</div></a></li> |
|
367 | 367 | <li class="${h.is_active('commits', active)}"><a class="menulink" href="${h.route_path('repo_commits', repo_name=c.repo_name)}"><div class="menulabel">${_('Commits')}</div></a></li> |
|
368 |
<li class="${h.is_active('files', active)}"><a class="menulink" href="${h.route_path('repo_files', repo_name=c.repo_name, commit_id=c.rhodecode_db_repo.landing_ref_name, f_path='' |
|
|
368 | <li class="${h.is_active('files', active)}"><a class="menulink" href="${h.route_path('repo_files', repo_name=c.repo_name, commit_id=c.rhodecode_db_repo.landing_ref_name, f_path='', _query={'at':c.rhodecode_db_repo.landing_ref_name})}"><div class="menulabel">${_('Files')}</div></a></li> | |
|
369 | 369 | <li class="${h.is_active('compare', active)}"><a class="menulink" href="${h.route_path('repo_compare_select',repo_name=c.repo_name)}"><div class="menulabel">${_('Compare')}</div></a></li> |
|
370 | 370 | |
|
371 | 371 | ## TODO: anderson: ideally it would have a function on the scm_instance "enable_pullrequest() and enable_fork()" |
@@ -36,8 +36,7 b'' | |||
|
36 | 36 | <ul> |
|
37 | 37 | <li class="breadcrumb-path"> |
|
38 | 38 | <div> |
|
39 | <a href="${h.route_path('repo_files', repo_name=c.repo_name, commit_id=c.commit.raw_id, f_path='')}"><i class="icon-home"></i></a> / | |
|
40 | <a href="${h.route_path('repo_files', repo_name=c.repo_name, commit_id=c.commit.raw_id, f_path=c.f_path)}">${c.f_path}</a> ${('/' if c.f_path else '')} | |
|
39 | ${h.files_breadcrumbs(c.repo_name, c.commit.raw_id, c.f_path, c.rhodecode_db_repo.landing_ref_name, request.GET.get('at'), limit_items=True, hide_last_item=False, linkify_last_item=True, copy_path_icon=False)} / | |
|
41 | 40 | </div> |
|
42 | 41 | </li> |
|
43 | 42 | <li class="location-path"> |
@@ -1,10 +1,13 b'' | |||
|
1 | 1 | <%namespace name="base" file="/base/base.mako"/> |
|
2 | 2 | |
|
3 | 3 | <% |
|
4 |
|
|
|
5 | query={'at': request.GET.get('at')} | |
|
4 | at_ref = request.GET.get('at') | |
|
5 | if at_ref: | |
|
6 | query={'at': at_ref} | |
|
7 | default_commit_id = at_ref or c.rhodecode_db_repo.landing_ref_name | |
|
6 | 8 | else: |
|
7 | 9 | query=None |
|
10 | default_commit_id = c.commit.raw_id | |
|
8 | 11 | %> |
|
9 | 12 | <div id="file-tree-wrapper" class="browser-body ${('full-load' if c.full_load else '')}"> |
|
10 | 13 | <table class="code-browser rctable repo_summary"> |
@@ -21,7 +24,7 b'' | |||
|
21 | 24 | <tbody id="tbody"> |
|
22 | 25 | <tr> |
|
23 | 26 | <td colspan="5"> |
|
24 | ${h.files_breadcrumbs(c.repo_name,c.commit.raw_id,c.file.path, request.GET.get('at'), limit_items=True)} | |
|
27 | ${h.files_breadcrumbs(c.repo_name, c.commit.raw_id, c.file.path, c.rhodecode_db_repo.landing_ref_name, request.GET.get('at'), limit_items=True)} | |
|
25 | 28 | </td> |
|
26 | 29 | </tr> |
|
27 | 30 | |
@@ -41,7 +44,7 b'' | |||
|
41 | 44 | % endif |
|
42 | 45 | </span> |
|
43 | 46 | % else: |
|
44 |
<a href="${h.route_path('repo_files',repo_name=c.repo_name,commit_id= |
|
|
47 | <a href="${h.route_path('repo_files',repo_name=c.repo_name,commit_id=default_commit_id,f_path=h.safe_unicode(node.path), _query=query)}"> | |
|
45 | 48 | <i class="${('icon-file-text browser-file' if node.is_file() else 'icon-directory browser-dir')}"></i>${node.name} |
|
46 | 49 | </a> |
|
47 | 50 | % endif |
@@ -35,8 +35,7 b'' | |||
|
35 | 35 | <div class="path-items"> |
|
36 | 36 | <li class="breadcrumb-path"> |
|
37 | 37 | <div> |
|
38 | <a href="${h.route_path('repo_files', repo_name=c.repo_name, commit_id=c.commit.raw_id, f_path='')}"><i class="icon-home"></i></a> / | |
|
39 | <a href="${h.route_path('repo_files', repo_name=c.repo_name, commit_id=c.commit.raw_id, f_path=c.file.dir_path)}">${c.file.dir_path}</a> ${('/' if c.file.dir_path else '')} | |
|
38 | ${h.files_breadcrumbs(c.repo_name, c.commit.raw_id, c.file.path, c.rhodecode_db_repo.landing_ref_name, request.GET.get('at'), limit_items=True, hide_last_item=True, copy_path_icon=False)} / | |
|
40 | 39 | </div> |
|
41 | 40 | </li> |
|
42 | 41 | <li class="location-path"> |
@@ -36,8 +36,7 b'' | |||
|
36 | 36 | <ul> |
|
37 | 37 | <li class="breadcrumb-path"> |
|
38 | 38 | <div> |
|
39 | <a href="${h.route_path('repo_files', repo_name=c.repo_name, commit_id=c.commit.raw_id, f_path='')}"><i class="icon-home"></i></a> / | |
|
40 | <a href="${h.route_path('repo_files', repo_name=c.repo_name, commit_id=c.commit.raw_id, f_path=c.file.dir_path)}">${c.file.dir_path}</a> ${('/' if c.file.dir_path else '')} | |
|
39 | ${h.files_breadcrumbs(c.repo_name, c.commit.raw_id, c.file.path, c.rhodecode_db_repo.landing_ref_name, request.GET.get('at'), limit_items=True, hide_last_item=True, copy_path_icon=False)} / | |
|
41 | 40 | </div> |
|
42 | 41 | </li> |
|
43 | 42 | <li class="location-path"> |
@@ -1,5 +1,15 b'' | |||
|
1 | 1 | <%namespace name="sourceblock" file="/codeblocks/source.mako"/> |
|
2 | 2 | |
|
3 | <% | |
|
4 | at_ref = request.GET.get('at') | |
|
5 | if at_ref: | |
|
6 | query={'at': at_ref} | |
|
7 | default_commit_id = at_ref or c.rhodecode_db_repo.landing_ref_name | |
|
8 | else: | |
|
9 | query=None | |
|
10 | default_commit_id = c.commit.raw_id | |
|
11 | %> | |
|
12 | ||
|
3 | 13 | <div id="codeblock" class="browserblock"> |
|
4 | 14 | <div class="browser-header"> |
|
5 | 15 | <div class="browser-nav"> |
@@ -27,13 +37,13 b'' | |||
|
27 | 37 | ## binary files are delete only |
|
28 | 38 | % if c.file.is_binary: |
|
29 | 39 | ${h.link_to(_('Edit'), '#Edit', class_="btn btn-default disabled tooltip", title=_('Editing binary files not allowed'))} |
|
30 | ${h.link_to(_('Delete'), h.route_path('repo_files_remove_file',repo_name=c.repo_name,commit_id=c.branch_or_raw_id,f_path=c.f_path),class_="btn btn-danger")} | |
|
40 | ${h.link_to(_('Delete'), h.route_path('repo_files_remove_file',repo_name=c.repo_name,commit_id=c.branch_or_raw_id,f_path=c.f_path, _query=query),class_="btn btn-danger")} | |
|
31 | 41 | % else: |
|
32 | <a class="btn btn-default" href="${h.route_path('repo_files_edit_file',repo_name=c.repo_name,commit_id=c.branch_or_raw_id,f_path=c.f_path)}"> | |
|
42 | <a class="btn btn-default" href="${h.route_path('repo_files_edit_file',repo_name=c.repo_name,commit_id=c.branch_or_raw_id,f_path=c.f_path, _query=query)}"> | |
|
33 | 43 | ${_('Edit on branch: ')}<code>${c.branch_name}</code> |
|
34 | 44 | </a> |
|
35 | 45 | |
|
36 | <a class="btn btn-danger" href="${h.route_path('repo_files_remove_file',repo_name=c.repo_name,commit_id=c.branch_or_raw_id,f_path=c.f_path)}"> | |
|
46 | <a class="btn btn-danger" href="${h.route_path('repo_files_remove_file',repo_name=c.repo_name,commit_id=c.branch_or_raw_id,f_path=c.f_path, _query=query)}"> | |
|
37 | 47 | ${_('Delete')} |
|
38 | 48 | </a> |
|
39 | 49 | % endif |
@@ -88,7 +98,7 b'' | |||
|
88 | 98 | |
|
89 | 99 | <div class="path clear-fix"> |
|
90 | 100 | <div class="pull-left"> |
|
91 | ${h.files_breadcrumbs(c.repo_name,c.commit.raw_id,c.file.path, request.GET.get('at'))} | |
|
101 | ${h.files_breadcrumbs(c.repo_name, c.commit.raw_id, c.file.path, c.rhodecode_db_repo.landing_ref_name, request.GET.get('at'))} | |
|
92 | 102 | </div> |
|
93 | 103 | |
|
94 | 104 | <div class="pull-right stats"> |
@@ -93,7 +93,7 b'' | |||
|
93 | 93 | |
|
94 | 94 | <div class="path clear-fix"> |
|
95 | 95 | <div class="pull-left"> |
|
96 | ${h.files_breadcrumbs(entry['repository'],entry.get('commit_id', 'tip'),entry['f_path'], linkify_last_item=True)} | |
|
96 | ${h.files_breadcrumbs(entry['repository'], entry.get('commit_id', 'tip'), entry['f_path'], linkify_last_item=True)} | |
|
97 | 97 | </div> |
|
98 | 98 | |
|
99 | 99 | <div class="pull-right stats"> |
@@ -27,7 +27,7 b'' | |||
|
27 | 27 | <td class="td-componentname"> |
|
28 | 28 | <i class="icon-file"></i> |
|
29 | 29 | ${h.link_to(h.literal(entry['f_path']), |
|
30 | h.route_path('repo_files',repo_name=entry['repository'],commit_id='tip',f_path=entry['f_path']))} | |
|
30 | h.route_path('repo_files',repo_name=entry['repository'],commit_id=entry.get('commit_id', 'tip'),f_path=entry['f_path']))} | |
|
31 | 31 | </td> |
|
32 | 32 | <td> |
|
33 | 33 | %if entry.get('size'): |
@@ -82,9 +82,8 b' def test_urlify_text(url, expected_url):' | |||
|
82 | 82 | 'bX"X'), |
|
83 | 83 | |
|
84 | 84 | ], ids=['simple1', 'simple2', 'one_segment', 'empty_path', 'simple_quote']) |
|
85 | def test_files_breadcrumbs_xss( | |
|
86 | repo_name, commit_id, path, app, expected_result): | |
|
87 | result = helpers.files_breadcrumbs(repo_name, commit_id, path) | |
|
85 | def test_files_breadcrumbs_xss(repo_name, commit_id, path, app, expected_result): | |
|
86 | result = helpers.files_breadcrumbs(repo_name, 'hg', commit_id, path) | |
|
88 | 87 | # Expect it to encode all path fragments properly. This is important |
|
89 | 88 | # because it returns an instance of `literal`. |
|
90 | 89 | if path != '': |
General Comments 0
You need to be logged in to leave comments.
Login now