comparison pylons_app/lib/helpers.py @ 102:2dc0c8e4f384

Updated tempaltes, added file browser breadcrumbs, and feed icons
author Marcin Kuzminski <marcin@python-works.com>
date Sun, 25 Apr 2010 18:42:58 +0200
parents 01d0f363f36d
children 4cea52709743
comparison
equal deleted inserted replaced
101:8b06c420491d 102:2dc0c8e4f384
67 return _("%.1f KB") % (bytes / 1024) 67 return _("%.1f KB") % (bytes / 1024)
68 if bytes < 1024 * 1024 * 1024: 68 if bytes < 1024 * 1024 * 1024:
69 return _("%.1f MB") % (bytes / (1024 * 1024)) 69 return _("%.1f MB") % (bytes / (1024 * 1024))
70 return _("%.1f GB") % (bytes / (1024 * 1024 * 1024)) 70 return _("%.1f GB") % (bytes / (1024 * 1024 * 1024))
71 71
72 class _FilesBreadCrumbs(object):
73
74 def __call__(self, repo_name, rev, paths):
75 url_l = [link_to(repo_name, url('files_home', repo_name=repo_name, f_path=''))]
76 paths_l = paths.split('/')
77
78 for cnt, p in enumerate(paths_l, 1):
79 if p != '':
80 url_l.append(link_to(p, url('files_home', repo_name=repo_name, f_path='/'.join(paths_l[:cnt]))))
72 81
82 return literal(' / '.join(url_l))
73 83
74 def pygmentize(code, **kwargs): 84 def pygmentize(code, **kwargs):
75 ''' 85 '''
76 Filter for chunks of html to replace code tags with pygmented code 86 Filter for chunks of html to replace code tags with pygmented code
77 ''' 87 '''
78 return literal(highlight(code, guess_lexer(code), HtmlFormatter(**kwargs))) 88 return literal(highlight(code, guess_lexer(code), HtmlFormatter(**kwargs)))
79 89
80 90
81 91 files_breadcrumbs = _FilesBreadCrumbs()
82 filesizeformat = _FileSizeFormat() 92 filesizeformat = _FileSizeFormat()
83 link = _Link() 93 link = _Link()
84 flash = _Flash() 94 flash = _Flash()
85 get_error = _GetError() 95 get_error = _GetError()