]> arthur.barton.de Git - bup.git/commitdiff
Added breadcrumb navigation to bup-web.
authorZoran Zaric <zz@zoranzaric.de>
Fri, 16 Jul 2010 18:37:58 +0000 (20:37 +0200)
committerAvery Pennarun <apenwarr@gmail.com>
Fri, 16 Jul 2010 19:51:04 +0000 (15:51 -0400)
Signed-off-by: Zoran Zaric <zz@zoranzaric.de>
cmd/web-cmd.py

index f853e7ce072cde1c05b0f477db1d6982c97ea5f7..a3ee220b9d727f2707b9f071c5de1503f440419d 100755 (executable)
@@ -70,18 +70,31 @@ class BupRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
     <TITLE>Directory listing for %(displaypath)s</TITLE>
     <STYLE>
       BODY, TABLE { font-family: sans-serif }
+      #breadcrumb { margin: 10px 0; }
       .dir-name { text-align: left }
       .dir-size { text-align: right }
     </STYLE>
   </HEAD>
   <BODY>
-    <H2>Directory listing for %(displaypath)s</H2>
+    <DIV id="breadcrumb">
+""" % { 'displaypath': displaypath })
+        if self.path == "/":
+            f.write("""<STRONG>[root]</STRONG>""")
+        else:
+            f.write("""<A href="/">[root]</A> """)
+            path_parts = self.path.split("/")
+            path_parts_cleaned = path_parts[1:len(path_parts)-1]
+            for index, value in enumerate(path_parts_cleaned[0:len(path_parts_cleaned)-1]):
+                f.write("""/ <A href="/%(path)s/">%(element)s</A> """ % { 'path' : "/".join(path_parts_cleaned[0:(index + 1)]) , 'element' : value})
+            f.write("""/ <STRONG>%s</STRONG>""" % path_parts_cleaned[len(path_parts_cleaned)-1])
+        f.write("""
+    </DIV>
     <TABLE>
       <TR>
         <TH class="dir-name">Name</TH>
         <TH class="dir-size">Size<TH>
       </TR>
-""" % { 'displaypath': displaypath })
+""")
         for sub in n:
             displayname = linkname = sub.name
             # Append / for directories or @ for symbolic links