display file size in directory.xhtml

This commit is contained in:
Faried Nawaz 2007-05-04 13:07:32 -07:00
parent 5b3a1cdc56
commit 2016b846b9
2 changed files with 8 additions and 0 deletions

View File

@ -17,12 +17,14 @@
<tr n:pattern="header"> <tr n:pattern="header">
<td>Filename</td> <td>Filename</td>
<td>Type</td> <td>Type</td>
<td>Size</td>
<td>URI</td> <td>URI</td>
<td></td> <td></td>
</tr> </tr>
<tr n:pattern="item" n:render="row"> <tr n:pattern="item" n:render="row">
<td><n:slot name="filename"/></td> <td><n:slot name="filename"/></td>
<td><n:slot name="type"/></td> <td><n:slot name="type"/></td>
<td><n:slot name="size"/></td>
<td><n:slot name="uri"/></td> <td><n:slot name="uri"/></td>
<td><n:slot name="delete"/></td> <td><n:slot name="delete"/></td>
</tr> </tr>

View File

@ -4,6 +4,7 @@ from twisted.web import static, resource, server, html
from twisted.python import util, log from twisted.python import util, log
from nevow import inevow, rend, loaders, appserver, url, tags as T from nevow import inevow, rend, loaders, appserver, url, tags as T
from allmydata.util import idlib from allmydata.util import idlib
from allmydata.uri import unpack_uri
from allmydata.interfaces import IDownloadTarget#, IDownloader from allmydata.interfaces import IDownloadTarget#, IDownloader
from allmydata import upload from allmydata import upload
from zope.interface import implements, Interface from zope.interface import implements, Interface
@ -126,6 +127,10 @@ class Directory(rend.Page):
dl_uri_url = dl_uri_url.add("filename", name) dl_uri_url = dl_uri_url.add("filename", name)
ctx.fillSlots("uri", T.a(href=dl_uri_url)[html.escape(uri)]) ctx.fillSlots("uri", T.a(href=dl_uri_url)[html.escape(uri)])
#extract and display file size
unpacked = unpack_uri(uri)
ctx.fillSlots("size", unpacked[9])
# this creates a button which will cause our child__delete method # this creates a button which will cause our child__delete method
# to be invoked, which deletes the file and then redirects the # to be invoked, which deletes the file and then redirects the
# browser back to this directory # browser back to this directory
@ -142,6 +147,7 @@ class Directory(rend.Page):
ctx.fillSlots("filename", ctx.fillSlots("filename",
T.a(href=subdir_url)[html.escape(name)]) T.a(href=subdir_url)[html.escape(name)])
ctx.fillSlots("type", "DIR") ctx.fillSlots("type", "DIR")
ctx.fillSlots("size", "-")
ctx.fillSlots("uri", "-") ctx.fillSlots("uri", "-")
ctx.fillSlots("delete", "-") ctx.fillSlots("delete", "-")
return ctx.tag return ctx.tag