]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
include the filename on URI-link urls for files
authorrobk-org <robk-org@allmydata.com>
Wed, 11 Jul 2007 22:26:47 +0000 (15:26 -0700)
committerrobk-org <robk-org@allmydata.com>
Wed, 11 Jul 2007 22:26:47 +0000 (15:26 -0700)
this is likely to induce browsers to do more useful things with the result
than they would when given neither content-type nor filename.  (i.e. they
can guess that a .jpg file is an image, even with a bogus content type)

src/allmydata/webish.py

index 2da53fd8cec4e4e35ca11db05c1e04b148043c50..8c13a1b8c0fb23fcef8cced08a741f1d762fff96 100644 (file)
@@ -83,13 +83,8 @@ class Directory(rend.Page):
             delete = "-"
         ctx.fillSlots("delete", delete)
 
+        # build the base of the uri_link link url
         uri_link = urllib.quote(target.get_uri().replace("/", "!"))
-        childdata = [T.a(href="%s?t=json" % name)["JSON"], ", ",
-                     T.a(href="%s?t=uri" % name)["URI"], ", ",
-                     T.a(href="%s?t=readonly-uri" % name)["readonly-URI"], ", ",
-                     T.a(href="/uri/%s" % uri_link)["URI-link"],
-                     ]
-        ctx.fillSlots("data", childdata)
 
         if IFileNode.providedBy(target):
             # file
@@ -112,6 +107,9 @@ class Directory(rend.Page):
                 size = "?"
             ctx.fillSlots("size", size)
 
+            # if we're a file, add the filename to the uri_link url
+            uri_link += '?%s' % (urllib.urlencode({'filename': name}),)
+
         elif IDirectoryNode.providedBy(target):
             # directory
             subdir_url = urllib.quote(name)
@@ -125,6 +123,14 @@ class Directory(rend.Page):
             ctx.fillSlots("size", "-")
         else:
             raise RuntimeError("unknown thing %s" % (target,))
+
+        childdata = [T.a(href="%s?t=json" % name)["JSON"], ", ",
+                     T.a(href="%s?t=uri" % name)["URI"], ", ",
+                     T.a(href="%s?t=readonly-uri" % name)["readonly-URI"], ", ",
+                     T.a(href="/uri/%s" % uri_link)["URI-link"],
+                     ]
+        ctx.fillSlots("data", childdata)
+
         return ctx.tag
 
     def render_forms(self, ctx, data):