From: Brian Warner Date: Sat, 7 Jul 2007 18:31:07 +0000 (-0700) Subject: webish.py: add links to JSON/etc representations of directory contents to the listing X-Git-Url: https://git.rkrishnan.org/(%5B%5E?a=commitdiff_plain;h=7d92b8a123403b4ff4462e4fece3e4c5f9313fe1;p=tahoe-lafs%2Ftahoe-lafs.git webish.py: add links to JSON/etc representations of directory contents to the listing --- diff --git a/docs/webapi.txt b/docs/webapi.txt index 49a4a9ae..f0076899 100644 --- a/docs/webapi.txt +++ b/docs/webapi.txt @@ -117,6 +117,12 @@ for files and directories which do not yet exist. This returns the URI of the given file in the HTTP response body. + GET FILEURL?t=readonly-uri + + This also returns the URI of the given file. For now, all files are + immutable, so t=uri and t=readonly-uri return the same value. In the + future, when we have mutable files, they will return different values. + === Directories === GET DIRURL @@ -148,6 +154,10 @@ for files and directories which do not yet exist. Return a URI for this dirnode in the HTTP response body. If the dirnode is read-only, the t=uri and t=readonly-uri responses will be the same. + GET DIRURL?t=manifest + + Return an HTML-formatted manifest of the given directory, for debugging. + PUT NEWDIRURL?t=mkdir Create a new empty directory at the given path. The HTTP response contains diff --git a/src/allmydata/web/directory.xhtml b/src/allmydata/web/directory.xhtml index 6ec85ba3..b482f0fa 100644 --- a/src/allmydata/web/directory.xhtml +++ b/src/allmydata/web/directory.xhtml @@ -35,14 +35,14 @@ Filename Type Size - URI + other representations -
+ diff --git a/src/allmydata/webish.py b/src/allmydata/webish.py index 47d536b6..f4c89cac 100644 --- a/src/allmydata/webish.py +++ b/src/allmydata/webish.py @@ -99,20 +99,30 @@ class Directory(rend.Page): delete = "-" ctx.fillSlots("delete", delete) + childdata = [T.a(href="%s?t=json" % name)["JSON"], ", ", + T.a(href="%s?t=xml" % name)["XML"], ", ", + T.a(href="%s?t=uri" % name)["URI"], ", ", + T.a(href="%s?t=readonly-uri" % name)["readonly-URI"], ", ", + T.a(href="/uri/%s" % target.get_uri())["URI-link"], + ] + ctx.fillSlots("data", childdata) + if IFileNode.providedBy(target): # file dlurl = urllib.quote(name) ctx.fillSlots("filename", T.a(href=dlurl)[html.escape(name)]) ctx.fillSlots("type", "FILE") - uri = target.uri - dl_uri_url = url.root.child("download_uri").child(uri) - # add a filename= query argument to give it a Content-Type - dl_uri_url = dl_uri_url.add("filename", name) - ctx.fillSlots("uri", T.a(href=dl_uri_url)[html.escape(uri)]) + + + #uri = target.uri + #dl_uri_url = url.root.child("download_uri").child(uri) + ## add a filename= query argument to give it a Content-Type + #dl_uri_url = dl_uri_url.add("filename", name) + #ctx.fillSlots("uri", T.a(href=dl_uri_url)[html.escape(uri)]) #extract and display file size - ctx.fillSlots("size", unpack_uri(uri)['size']) + ctx.fillSlots("size", unpack_uri(target.get_uri())['size']) elif IDirectoryNode.providedBy(target): # directory @@ -125,7 +135,6 @@ class Directory(rend.Page): dirtype = "DIR-RO" ctx.fillSlots("type", dirtype) ctx.fillSlots("size", "-") - ctx.fillSlots("uri", "-") else: raise RuntimeError("unknown thing %s" % (target,)) return ctx.tag @@ -747,6 +756,8 @@ class VDrive(rend.Page): return FileXMLMetadata(node), () elif t == "uri": return FileURI(node), () + elif t == "readonly-uri": + return FileURI(node), () else: raise RuntimeError("bad t=%s" % t) elif IDirectoryNode.providedBy(node):