Changeset - b7eaad593cb9
[Not reviewed]
default
0 1 0
Mads Kiilerich (mads) - 5 years ago 2020-11-07 18:54:34
mads@kiilerich.com
Grafted from: 5bb4007a7df9
lib: simplify files_breadcrumbs
1 file changed with 18 insertions and 24 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/helpers.py
Show inline comments
 
@@ -134,48 +134,42 @@ def increase_context_link(GET, anchor=No
 
    """Return snippet with link to current URL with double context size"""
 
    context = get_diff_context_size(GET) * 2
 
    params = dict(GET)  # ignoring duplicates
 
    params['context'] = str(context)
 
    params['anchor'] = anchor
 
    return link_to(
 
        literal('<i class="icon-sort"></i>'),
 
        url.current(**params),
 
        title=_('Increase diff context to %(num)s lines') % {'num': context},
 
        **{'data-toggle': 'tooltip'})
 

	
 

	
 
class _FilesBreadCrumbs(object):
 

	
 
    def __call__(self, repo_name, rev, paths):
 
        url_l = [link_to(repo_name, url('files_home',
 
                                        repo_name=repo_name,
 
                                        revision=rev, f_path=''),
 
                         class_='ypjax-link')]
 
        paths_l = paths.split('/')
 
        for cnt, p in enumerate(paths_l):
 
            if p != '':
 
                url_l.append(link_to(p,
 
                                     url('files_home',
 
                                         repo_name=repo_name,
 
                                         revision=rev,
 
                                         f_path='/'.join(paths_l[:cnt + 1])
 
                                         ),
 
                                     class_='ypjax-link'
 
                                     )
 
                             )
 

	
 
        return literal('/'.join(url_l))
 

	
 

	
 
files_breadcrumbs = _FilesBreadCrumbs()
 
def files_breadcrumbs(repo_name, rev, paths):
 
    url_l = [link_to(repo_name, url('files_home',
 
                                    repo_name=repo_name,
 
                                    revision=rev, f_path=''),
 
                     class_='ypjax-link')]
 
    paths_l = paths.split('/')
 
    for cnt, p in enumerate(paths_l):
 
        if p != '':
 
            url_l.append(link_to(p,
 
                                 url('files_home',
 
                                     repo_name=repo_name,
 
                                     revision=rev,
 
                                     f_path='/'.join(paths_l[:cnt + 1])
 
                                     ),
 
                                 class_='ypjax-link'
 
                                 )
 
                         )
 
    return literal('/'.join(url_l))
 

	
 

	
 
class CodeHtmlFormatter(HtmlFormatter):
 
    """
 
    My code Html Formatter for source codes
 
    """
 

	
 
    def wrap(self, source, outfile):
 
        return self._wrap_div(self._wrap_pre(self._wrap_code(source)))
 

	
 
    def _wrap_code(self, source):
 
        for cnt, it in enumerate(source):
0 comments (0 inline, 0 general)