webgen v4.0.3 + mkdirindex on files + blockqoute autoinsert + vars cleaned up

This commit is contained in:
Wolfgang Nowak 2022-02-12 02:27:34 +01:00
parent 18fe815c29
commit f63e22d464

View file

@ -6,8 +6,16 @@ from dialog import Dialog
# If not choosen stdout as output, where should the generated file go to and what # If not choosen stdout as output, where should the generated file go to and what
# fileending (f.e. .html) shall it have # fileending (f.e. .html) shall it have
targetdir = os.path.expanduser("~/www/i21k.de/posts/") webbasedir = os.path.expanduser("~/www/i21k.de/")
targetdir = webbasedir + "posts/"
sourcedir = os.path.expanduser("~/python/webgen/") sourcedir = os.path.expanduser("~/python/webgen/")
### for module mkdirindex:
filesdir = webbasedir + "files/"
indexfilename = "index.html"
filesdirheadline = "Files"
dirindexfile = open(filesdir + indexfilename, "w")
####
fileending = "" fileending = ""
locale.setlocale(locale.LC_ALL, "") locale.setlocale(locale.LC_ALL, "")
clear = "\x1b[2J\x1b[H" clear = "\x1b[2J\x1b[H"
@ -20,14 +28,6 @@ redonblack = "\x1b[38;5;9m\x1b[48;5;16m"
xwidth = os.get_terminal_size()[0] - 3 xwidth = os.get_terminal_size()[0] - 3
ywidth = os.get_terminal_size()[1] - 3 ywidth = os.get_terminal_size()[1] - 3
os.chdir(sourcedir) os.chdir(sourcedir)
### for module mkdirindex:
filedir = "/home/wn/www/i21k.de/files/"
indexfilename = "index.html"
filedirheadline = "Files"
dirindexfile = open(filedir + indexfilename, "w")
####
# Prepend an hourly tinestamp to the later name of the file # Prepend an hourly tinestamp to the later name of the file
creationtime = datetime.datetime.now().strftime("%Y-%m-%d %H:00 ") creationtime = datetime.datetime.now().strftime("%Y-%m-%d %H:00 ")
# generate a more precise ctime to be included in the resulting webpage # generate a more precise ctime to be included in the resulting webpage
@ -188,8 +188,8 @@ head1 = (
style_fn = '<link rel="stylesheet" type="text/css" href="/vimstyles.css">' style_fn = '<link rel="stylesheet" type="text/css" href="/vimstyles.css">'
head2 = "</head><body>\n" head2 = "</head><body>\n"
body1 = '<a href="./">Back</a><blockquote>' body1 = '<a href="./">Back</a><blockquote><strong>Moin</strong></p>'
foot = "</blockquote><hr /></body> </html>\n" foot = "</blockquote><p></p><hr /></body> </html>\n"
# write beginning of html-file # write beginning of html-file
html_out_file.write(head1 + style_fn + head2 + body1) html_out_file.write(head1 + style_fn + head2 + body1)
@ -211,7 +211,7 @@ if outfile != sys.stdout:
head1 = ( head1 = (
'<!DOCTYPE HTML><html><head>\n <meta http-equiv="content-type" content="text/html; charset=UTF-8">\n<title>' '<!DOCTYPE HTML><html><head>\n <meta http-equiv="content-type" content="text/html; charset=UTF-8">\n<title>'
+ filedirheadline + filesdirheadline
+ '</title>\n <meta name="syntax" content="markdown">\n <meta name="generator" content="' + '</title>\n <meta name="syntax" content="markdown">\n <meta name="generator" content="'
+ "webgen.py" + "webgen.py"
+ ' markdown2htmlconverter">\n <meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy=">' + ' markdown2htmlconverter">\n <meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy=">'
@ -227,9 +227,9 @@ foot = "</table><br/><strong>You can't avoid chaos.</strong><br/><hr></body> </h
dirindexfile.write(head1 + style_fn + head2 + body1) dirindexfile.write(head1 + style_fn + head2 + body1)
for file in os.listdir(filedir): for file in os.listdir(filesdir):
if not re.match("^\.", file) and not file == indexfilename: if not re.match("^\.", file) and not file == indexfilename:
size = os.lstat(filedir + file).st_size size = os.lstat(filesdir + file).st_size
if size > 100000000000: if size > 100000000000:
sizestr = str(int(size / 1073741824)) + " GiB" sizestr = str(int(size / 1073741824)) + " GiB"
elif size > 100000000: elif size > 100000000:
@ -243,4 +243,5 @@ for file in os.listdir(filedir):
dirindexfile.write(line) dirindexfile.write(line)
dirindexfile.write(foot) dirindexfile.write(foot)
# Have a nice time. # Have a nice time.