2022-01-07 14:18:46 +01:00
|
|
|
#!/usr/bin/python3
|
|
|
|
|
|
|
|
import sys, re, os, glob
|
|
|
|
|
2022-01-30 01:07:41 +01:00
|
|
|
filedir = "/home/wn/www/i21k.de/mudw/"
|
2022-01-28 14:52:37 +01:00
|
|
|
indexfilename = "index.html"
|
2022-01-07 14:18:46 +01:00
|
|
|
headline = "Files"
|
2022-01-28 14:52:37 +01:00
|
|
|
dirindexfile = open(filedir + indexfilename, "w")
|
2022-01-07 14:18:46 +01:00
|
|
|
|
|
|
|
|
|
|
|
head1 = (
|
|
|
|
'<!DOCTYPE HTML><html><head>\n <meta http-equiv="content-type" content="text/html; charset=UTF-8">\n<title>'
|
|
|
|
+ headline
|
|
|
|
+ '</title>\n <meta name="syntax" content="markdown">\n <meta name="generator" content="'
|
|
|
|
+ "webgen.py"
|
|
|
|
+ ' markdown2htmlconverter">\n <meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy=">'
|
|
|
|
)
|
|
|
|
|
|
|
|
style_fn = '<link rel="stylesheet" type="text/css" href="/vimstyles.css">'
|
|
|
|
head2 = "</head><body>"
|
|
|
|
body1 = '<a class="Statement" href="../">Back</a><br/><br/><hr>'
|
|
|
|
body1 += '<div class="Statement"> Some files. Maybe useful or not.</div> '
|
|
|
|
body1 += '<table border="0" class="Neutral">'
|
2022-01-28 14:52:37 +01:00
|
|
|
foot = "</table><br/><strong>You can't avoid chaos.</strong><br/><hr></body> </html>\n"
|
2022-01-07 14:18:46 +01:00
|
|
|
|
|
|
|
|
2022-01-28 14:52:37 +01:00
|
|
|
dirindexfile.write(head1 + style_fn + head2 + body1)
|
2022-01-07 14:18:46 +01:00
|
|
|
|
|
|
|
for file in os.listdir(filedir):
|
2022-01-28 14:52:37 +01:00
|
|
|
if not re.match("^\.", file) and not file == indexfilename:
|
2022-01-07 14:18:46 +01:00
|
|
|
size = os.lstat(filedir + file).st_size
|
|
|
|
if size > 100000000000:
|
|
|
|
sizestr = str(int(size / 1073741824)) + " GiB"
|
|
|
|
elif size > 100000000:
|
|
|
|
sizestr = str(int(size / 1048576)) + " MiB"
|
|
|
|
elif size > 10000:
|
|
|
|
sizestr = str(int(size / 1024)) + " KiB"
|
|
|
|
else:
|
|
|
|
sizestr = str(size) + " B"
|
|
|
|
|
2022-01-28 14:52:37 +01:00
|
|
|
line = str('<tr><td><a href="' + str(file) + '">' + str(file) + "</a></td><td> "+sizestr+ "</td></tr>")
|
|
|
|
dirindexfile.write(line)
|
2022-01-07 14:18:46 +01:00
|
|
|
|
2022-01-28 14:52:37 +01:00
|
|
|
dirindexfile.write(foot)
|