webish.py: add a web page to display the manifest for any particular directory

This commit is contained in:
Brian Warner 2007-06-26 19:55:21 -07:00
parent 18ab5ce837
commit 1d86cd161b
3 changed files with 48 additions and 0 deletions

View File

@ -13,6 +13,7 @@
<div><a href=".">Refresh this view</a></div>
<div><a href="..">Parent Directory</a></div>
<div><a href="@manifest">Manifest for this directory</a></div>
<div>To share this directory, paste the following URI string into an
"Add Shared Directory" box:
<pre class="overflow" n:render="string" n:data="share_uri" /></div>

View File

@ -0,0 +1,27 @@
<html xmlns:n="http://nevow.com/ns/nevow/0.1">
<head>
<title n:render="title"></title>
<!-- <link href="http://www.allmydata.com/common/css/styles.css"
rel="stylesheet" type="text/css"/> -->
<link href="/tahoe_css" rel="stylesheet" type="text/css"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<h1><p n:render="header"></p></h1>
<table n:render="sequence" n:data="items" border="1">
<tr n:pattern="header">
<td>Refresh Capabilities</td>
</tr>
<tr n:pattern="item" n:render="row">
<td><n:slot name="refresh_capability"/></td>
</tr>
<tr n:pattern="empty"><td>no items in the manifest!</td></tr>
</table>
</body>
</html>

View File

@ -114,6 +114,8 @@ class Directory(rend.Page):
def childFactory(self, ctx, name):
if name.startswith("freeform"): # ick
return None
if name == "@manifest": # ick, this time it's my fault
return Manifest(self._dirnode, self._dirname)
if self._dirname == "/":
dirname = "/" + name
else:
@ -350,6 +352,24 @@ class Downloader(resource.Resource):
self._filenode.download(WebDownloadTarget(req))
return server.NOT_DONE_YET
class Manifest(rend.Page):
docFactory = getxmlfile("manifest.xhtml")
def __init__(self, dirnode, dirname):
self._dirnode = dirnode
self._dirname = dirname
def render_title(self, ctx):
return T.title["Manifest of %s" % self._dirname]
def render_header(self, ctx):
return T.p["Manifest of %s" % self._dirname]
def data_items(self, ctx, data):
return self._dirnode.build_manifest()
def render_row(self, ctx, refresh_cap):
ctx.fillSlots("refresh_capability", refresh_cap)
return ctx.tag
class Root(rend.Page):