diff --git a/webgen.py b/webgen.py index c4e8761..fcca2f4 100755 --- a/webgen.py +++ b/webgen.py @@ -3,9 +3,7 @@ import sys, os, uuid, shutil, subprocess, markdown, re, datetime -sourcedir = os.path.expanduser("~/") -sourcefile = sourcedir + "up.php" -targetdir = os.path.expanduser("~/www/i21k.de/") +targetdir = os.path.expanduser("~/www/i21k.de/posts/") fileending = "" @@ -18,15 +16,20 @@ def edit(headline): # Parse arguments "--html" and "Some Headline" +# there are 2 parameters. if --html is given, the fileending will be .html. +# Else there will be no fileending, but it will still contain html +# there is no parameter: if len(sys.argv) == 1: headline = input("Bitte gib eine Headline ein: ") +# there is 1 parameter elif len(sys.argv) == 2: if sys.argv[1] == "--html": fileending = ".html" headline = input("Bitte gib eine Headline ein: ") else: headline = str(sys.argv[1]) +# there are 2 parameters. if --html is given, the fileending will be .html. E elif len(sys.argv) == 3: if sys.argv[1] == "--html": fileending = ".html" @@ -35,32 +38,26 @@ elif len(sys.argv) == 3: fileending = ".html" headline = str(sys.argv[1]) else: - sys.exit(str(sys.argv[0]) + ' [--html] "some Headline"\nIf --html is choosen, output will be written to STDOUT.') + sys.exit(str(sys.argv[0]) + ' [--html] "some Headline"\n') headlinemd = headline + ".md" headlinehtml = headline + fileending -print("Headlinefile= ", headlinemd, "\n", "Outputfile= ", headlinehtml) -a = input("Press to continue: ") -edit(headlinemd) - -mark_down_file = headlinemd - creationtime = datetime.datetime.now().strftime("%Y-%m-%d %H:00 ") creationtimeheader = datetime.datetime.now().strftime("%Y-%m-%d %H:%M") +new_file_name = targetdir + creationtime + " " + headline + fileending + +print("You will edit now: ", headlinemd, "\n", "Outputfile= ", new_file_name) +a = input("Press to continue or to stop: ") +edit(headlinemd) + +html_out_file = open(new_file_name, "w") -if re.match(".*\.md$", mark_down_file): - new_file_name = creationtime + " " + re.sub(".md$", fileending, mark_down_file) - html_out_file = open(new_file_name, "w") - title_of_tfileending = re.sub(".md$", "", mark_down_file) -else: - html_out_file = sys.stdout - title_of_tfileending = mark_down_file head1 = ( '\n\ \n' - + title_of_tfileending + + headline + '\n\ \n\ ' ) +# Some fancy css for minimalistic terminal style + styles = "