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