#!/usr/bin/env python3 import sys, os, uuid, shutil, subprocess, markdown, re, datetime targetdir = os.path.expanduser("~/www/i21k.de/posts/") fileending = "" def edit(headline): editor = os.getenv("EDITOR") if not editor: editor = "vim" subprocess.call([editor, headline]) return 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 optwords = ["--html", "--stdout"] outfile = "" args = sys.argv myname = args.pop(0) for wish in optwords: if args.count(wish): if wish == "--html": fileending = ".html" args.pop(args.index(wish)) if wish == "--stdout": outfile = sys.stdout args.pop(args.index(wish)) if len(args) == 1: headline = args[0] elif len(args) == 0: headline = input("Please enter a headline: ") elif len(args) > 1: sys.exit("Too much or wrong parameters:\n" + myname + ' [--html] [--stdout] ["Some Topic"] ') headlinemd = headline + ".md" headlinehtml = headline + fileending creationtime = datetime.datetime.now().strftime("%Y-%m-%d %H:00 ") creationtimeheader = datetime.datetime.now().strftime("%Y-%m-%d %H:%M") if outfile != sys.stdout: new_file_name = targetdir + creationtime + " " + headline + fileending else: new_file_name = "STDOUT" print("You will edit now: ", headlinemd, "\n", "Outputfile= ", new_file_name) a = input("Press to continue or to stop: ") edit(headlinemd) if outfile != sys.stdout: html_out_file = open(new_file_name, "w") else: html_out_file = outfile head1 = ( '\n\ \n' + headline + '\n\ \n\ \n\ \n\ ' ) # Some fancy css for minimalistic terminal style styles = "