From: David Roda Date: Thu, 23 Sep 2010 12:35:55 +0000 (-0400) Subject: If not directory root, prepend list with ".." X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=a1427e95bf2be72467076e7b36e01ec53e5529a9;p=packages%2Fb%2Fbup.git If not directory root, prepend list with ".." Add a link to the file list to traverse up a directory if we are not already at the top Signed-off-by: David Roda --- diff --git a/cmd/web-cmd.py b/cmd/web-cmd.py index 568811c..959b4f9 100755 --- a/cmd/web-cmd.py +++ b/cmd/web-cmd.py @@ -34,8 +34,14 @@ def _contains_hidden_files(n): return False -def _compute_dir_contents(n, show_hidden=False): +def _compute_dir_contents(n, path, show_hidden=False): """Given a vfs node, returns an iterator for display info of all subs.""" + url_append = "" + if show_hidden: + url_append = "?hidden=1" + + if path != "/": + yield('..', '../' + url_append, '') for sub in n: display = link = sub.name @@ -47,10 +53,6 @@ def _compute_dir_contents(n, show_hidden=False): if not show_hidden and len(display)>1 and display.startswith('.'): continue - url_append = "" - if show_hidden: - url_append = "?hidden=1" - size = None if stat.S_ISDIR(sub.mode): display = sub.name + '/' @@ -105,7 +107,7 @@ class BupRequestHandler(tornado.web.RequestHandler): breadcrumbs=_compute_breadcrumbs(path, show_hidden), files_hidden=_contains_hidden_files(n), hidden_shown=show_hidden, - dir_contents=_compute_dir_contents(n, show_hidden)) + dir_contents=_compute_dir_contents(n, path, show_hidden)) def _get_file(self, path, n): """Process a request on a file.