From d9d09201775ac3f3e205bdc70a24b1ecb2b4bc84 Mon Sep 17 00:00:00 2001 From: Brian Warner <warner@allmydata.com> Date: Tue, 29 Jan 2008 18:04:32 -0700 Subject: [PATCH] webish: link to directory URIs rather than a child path. Addresses #103. --- src/allmydata/test/test_web.py | 8 +++++--- src/allmydata/webish.py | 5 ++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/allmydata/test/test_web.py b/src/allmydata/test/test_web.py index 69d9bb5b..6d241e90 100644 --- a/src/allmydata/test/test_web.py +++ b/src/allmydata/test/test_web.py @@ -599,7 +599,8 @@ class Web(WebMixin, unittest.TestCase): '\s+<td>FILE</td>' '\s+<td>%d</td>' % len(self.BAR_CONTENTS) , res)) - self.failUnless(re.search(r'<td><a href="sub">sub</a></td>' + # the DIR reference just points to a URI + self.failUnless(re.search(r'<td><a href="/uri/URI%3ADIR2%3A[^"]+">sub</a></td>' '\s+<td>DIR</td>', res)) d.addCallback(_check) @@ -615,7 +616,7 @@ class Web(WebMixin, unittest.TestCase): d.addCallback(lambda res: self.GET(self.public_url, followRedirect=True)) def _check3(res): - self.failUnless(re.search(r'<td><a href="reedownlee">reedownlee</a>' + self.failUnless(re.search(r'<td><a href="/uri/URI%3ADIR2-RO%3A[^"]+">reedownlee</a>' '</td>\s+<td>DIR-RO</td>', res)) d.addCallback(_check3) @@ -653,7 +654,8 @@ class Web(WebMixin, unittest.TestCase): d.addCallback(_check) def _done(res): - self.failUnless('<a href="%d">%d</a>' % (COUNT-1, COUNT-1) in res) + m = r'<a href="/uri/URI%3ADIR2%3A[^"]+">' + ("%d" % (COUNT-1)) + r'</a>' + self.failUnless(re.search(m, res)) self.failIf("maximum recursion depth exceeded" in res) d.addCallback(_done) return d diff --git a/src/allmydata/webish.py b/src/allmydata/webish.py index d7e98630..dda50a56 100644 --- a/src/allmydata/webish.py +++ b/src/allmydata/webish.py @@ -256,9 +256,8 @@ class Directory(rend.Page): elif IDirectoryNode.providedBy(target): # directory - subdir_url = urllib.quote(name) ctx.fillSlots("filename", - T.a(href=subdir_url)[html.escape(name)]) + T.a(href=uri_link)[html.escape(name)]) if target.is_readonly(): dirtype = "DIR-RO" else: @@ -1296,7 +1295,7 @@ class Root(rend.Page): return rend.NotFound uri = segments[1] d = defer.maybeDeferred(client.create_node_from_uri, uri) - d.addCallback(lambda node: VDrive(node, "from-uri")) + d.addCallback(lambda node: VDrive(node, uri)) d.addCallback(lambda vd: vd.locateChild(ctx, segments[2:])) def _trap_KeyError(f): f.trap(KeyError) -- 2.45.2