From f63e22d464b96366fc3fbe55188f80387165abb9 Mon Sep 17 00:00:00 2001 From: Wolfgang Nowak Date: Sat, 12 Feb 2022 02:27:34 +0100 Subject: [PATCH] webgen v4.0.3 + mkdirindex on files + blockqoute autoinsert + vars cleaned up --- webgen.py | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/webgen.py b/webgen.py index d259a46..39baad3 100755 --- a/webgen.py +++ b/webgen.py @@ -6,8 +6,16 @@ from dialog import Dialog # If not choosen stdout as output, where should the generated file go to and what # 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/") +### for module mkdirindex: +filesdir = webbasedir + "files/" +indexfilename = "index.html" +filesdirheadline = "Files" +dirindexfile = open(filesdir + indexfilename, "w") +#### + fileending = "" locale.setlocale(locale.LC_ALL, "") 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 ywidth = os.get_terminal_size()[1] - 3 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 creationtime = datetime.datetime.now().strftime("%Y-%m-%d %H:00 ") # generate a more precise ctime to be included in the resulting webpage @@ -188,8 +188,8 @@ head1 = ( style_fn = '' head2 = "\n" -body1 = 'Back
' -foot = "

\n" +body1 = 'Back
Moin

' +foot = "


\n" # write beginning of html-file html_out_file.write(head1 + style_fn + head2 + body1) @@ -211,7 +211,7 @@ if outfile != sys.stdout: head1 = ( '\n \n' - + filedirheadline + + filesdirheadline + '\n \n \n ' @@ -227,9 +227,9 @@ foot = "
You can't avoid chaos.

100000000000: sizestr = str(int(size / 1073741824)) + " GiB" elif size > 100000000: @@ -243,4 +243,5 @@ for file in os.listdir(filedir): dirindexfile.write(line) dirindexfile.write(foot) + # Have a nice time.