From 50b012103fd006275a1ee11c58697f2623877f7b Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 12 Nov 2003 22:15:56 +0000 Subject: add file size to listing git-svn-id: file:///home/lennart/svn/public/syrep-chub/trunk@7 4c8cc7d0-f3cb-0310-ad32-ddc431b48844 --- list.cgi | 15 ++++++++++++--- style.css | 1 + 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/list.cgi b/list.cgi index 92dd7e2..73f981b 100755 --- a/list.cgi +++ b/list.cgi @@ -3,6 +3,14 @@ import cgi, cgitb, os, time, urllib, sch, stat cgitb.enable() +def bsize(s): + if s > 1024*1024: + return "%lu MB" % s/1024/1024 + elif s > 1024: + return "%lu KB" % s/1024 + else: + return "%lu B" % s + def list_files(): d = os.listdir(sch.repository_directory) @@ -18,16 +26,17 @@ def list_files(): print '' % cgi.escape(f) print '%s' % (urllib.quote_plus(f), cgi.escape(f)) - print '%s' % time.strftime("%c", time.localtime(st.st_mtime)) + print '%s' % time.strftime("%c", time.localtime(st.st_mtime)) + print '%s' % bsize(st.st_size) sch.print_header("File Listing") -print '
' +print '
File nameModification date
' list_files() -print '
File nameModification dateSize
' +print '
' print '' diff --git a/style.css b/style.css index a723911..dc29031 100644 --- a/style.css +++ b/style.css @@ -3,6 +3,7 @@ td { padding: 5px; } td.filename { width: 50ex; } td.filedate { color: darkgray; font-size: small; text-align: right; } +td.filedate { color: darkgray; font-size: small; text-align: right; } th { text-align: left; background: #f0f0f0; border-bottom-width: 1px; border-bottom-style:solid; border-bottom-color: darkblue; padding: 5px;} table { border-width: 1px; border-style:solid; border-color: darkblue; border-spacing: 0; empty-cells:show; } td.buttons { border-top-width: 1px; border-top-style:solid; border-top-color: darkblue; background: #f0f0f0; padding: 5px; text-align: center; } -- cgit