handle_ctrl_c()
-def _compute_breadcrumbs(path):
+def _compute_breadcrumbs(path, show_hidden=False):
"""Returns a list of breadcrumb objects for a path."""
breadcrumbs = []
breadcrumbs.append(('[root]', '/'))
path_parts = path.split('/')[1:-1]
full_path = '/'
for part in path_parts:
- full_path += part + '/'
- breadcrumbs.append((part, full_path))
+ full_path += part + "/"
+ url_append = ""
+ if show_hidden:
+ url_append = '?hidden=1'
+ breadcrumbs.append((part, full_path+url_append))
return breadcrumbs
for sub in n:
display = link = sub.name
- if not show_hidden and len(display)>1 and display.startswith('.'):
- continue
-
# link should be based on fully resolved type to avoid extra
# HTTP redirect.
if stat.S_ISDIR(sub.try_resolve().mode):
link = sub.name + "/"
+ 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 + '/'
else:
size = sub.size()
- yield (display, link, size)
+ yield (display, link + url_append, size)
class BupRequestHandler(tornado.web.RequestHandler):
self.render(
'list-directory.html',
path=path,
- breadcrumbs=_compute_breadcrumbs(path),
+ breadcrumbs=_compute_breadcrumbs(path, show_hidden),
files_hidden=_contains_hidden_files(n),
hidden_shown=show_hidden,
- dir_contents=_compute_dir_contents(n, show_hidden),
- # We need the standard url_escape so we don't escape /
- url_escape=urllib.quote)
+ dir_contents=_compute_dir_contents(n, show_hidden))
def _get_file(self, path, n):
"""Process a request on a file.
settings = dict(
debug = 1,
template_path = resource_path('web'),
+ static_path = resource_path('web/static')
)
# Disable buffering on stdout, for debug messages
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <title>Directory listing for {{ escape(path) }}</title>
- <style type="text/css">
- body, table { font-family: sans-serif }
- #breadcrumb { margin: 10px 0; }
- .dir-name { text-align: left }
- .dir-size { text-align: right }
- </style>
- </head>
- <body>
- <div id="breadcrumb">
- {% for (display, part_path) in breadcrumbs[:-1] %}
- <a href="{{ url_escape(part_path) }}">{{ escape(display) }}</a> /
- {% end %}
- <strong>{{ escape(breadcrumbs[-1][0]) }}</strong>
- </div>
- {% if files_hidden %}
- <div id="message">
- {% if hidden_shown %}
- <a href=".">Hide hidden files</a>
- {% else %}
- <a href="?hidden=1">Show hidden files</a>
- {% end %}
- </div>
- {% end %}
- <table>
- <tr>
- <th class="dir-name">Name</th>
- <th class="dir-size">Size</th>
- </tr>
- {% for (display, link, size) in dir_contents %}
- <tr>
- <td class="dir-name"><a href="{{ url_escape(link) }}">{{ escape(display) }}</a></td>
- <td class="dir-size">{% if size != None %}{{ size }}{% else %} {% end %}</td>
- </tr>
- {% end %}
- </table>
- </body>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>Directory listing for {{ escape(path) }}</title>
+ <link rel="stylesheet" href="/static/styles.css" />
+ </head>
+ <body>
+ <div id="wrapper">
+ <div id="breadcrumb">
+ {% for (display, part_path) in breadcrumbs[:-1] %}
+ <a href="{{ part_path }}">{{ display }}</a> /
+ {% end %}
+ <strong>{{ breadcrumbs[-1][0] }}</strong>
+ </div>
+ {% if files_hidden %}
+ <div id="message">
+ {% if hidden_shown %}
+ <a href=".">Hide hidden files</a>
+ {% else %}
+ <a href="?hidden=1">Show hidden files</a>
+ {% end %}
+ </div>
+ {% end %}
+ <table>
+ <tr>
+ <th class="dir-name">Name</th>
+ <th class="dir-size">Size</th>
+ </tr>
+ {% for (display, link, size) in dir_contents %}
+ <tr>
+ <td class="dir-name"><a href="{{ link }}">{{ display }}</a></td>
+ <td class="dir-size">{% if size != None %}{{ size }}{% else %} {% end %}</td>
+ </tr>
+ {% end %}
+ </table>
+ </div>
+ </body>
</html>
-