From: robk-org Date: Wed, 11 Jul 2007 22:26:47 +0000 (-0700) Subject: include the filename on URI-link urls for files X-Git-Url: https://git.rkrishnan.org/pf/content/en/service/FOOURL?a=commitdiff_plain;h=cacc9ac7b1af9e0ac80431597a0d8b4adeebd721;p=tahoe-lafs%2Ftahoe-lafs.git include the filename on URI-link urls for files 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) --- diff --git a/src/allmydata/webish.py b/src/allmydata/webish.py index 2da53fd8..8c13a1b8 100644 --- a/src/allmydata/webish.py +++ b/src/allmydata/webish.py @@ -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):