header generates username now. also added setting editor.

master
endorphant 2016-05-01 23:26:12 -04:00
parent c16662192e
commit 27119152cc
3 changed files with 51 additions and 20 deletions

View File

@ -2,4 +2,4 @@
| TILDE TOWN | | TILDE TOWN |
| BLOGGING | | BLOGGING |
| PLATFORM | | PLATFORM |
============== ver 0.2 (highly unstable) ============== ver 0.2.1 (highly unstable)

View File

@ -6,7 +6,7 @@
</head> </head>
<body> <body>
<div id="meta"> <div id="meta">
<h1><a href="#">~$USER</a>@<a href="~endorphant/ttbp">TTBP</a></h1> <h1><a href="#">~$USER</a>@<a href="/~endorphant/ttbp">TTBP</a></h1>
</div> </div>
<div id="tlogs"> <div id="tlogs">

View File

@ -19,13 +19,14 @@ USERFILE = os.path.join("/home", "endorphant", "projects", "ttbp", "users.txt")
## user globals ## user globals
USER = os.path.basename(os.path.expanduser("~")) USER = os.path.basename(os.path.expanduser("~"))
PATH = os.path.join("/home", USER, ".ttbp") PATH = os.path.join("/home", USER, ".ttbp")
PUBLIC = os.path.join("/home", USER, "public_html")
WWW = os.path.join(PATH, "www") WWW = os.path.join(PATH, "www")
CONFIG = os.path.join(PATH, "config") CONFIG = os.path.join(PATH, "config")
TTBPRC = os.path.join(CONFIG, "ttbprc") TTBPRC = os.path.join(CONFIG, "ttbprc")
DATA = os.path.join(PATH, "entries") DATA = os.path.join(PATH, "entries")
SETTINGS = { SETTINGS = {
"editor":"vim", "editor": "none",
"publish dir":"blog" "publish dir": False
} }
## ui globals ## ui globals
@ -99,14 +100,37 @@ def init():
subprocess.call(["mkdir", PATH]) subprocess.call(["mkdir", PATH])
subprocess.call(["mkdir", CONFIG]) subprocess.call(["mkdir", CONFIG])
subprocess.call(["mkdir", DATA]) subprocess.call(["mkdir", DATA])
subprocess.call(["cp", os.path.join(SOURCE, "config", "defaults", "header.txt"), CONFIG]) #subprocess.call(["cp", os.path.join(SOURCE, "config", "defaults", "header.txt"), CONFIG])
header = gen_header()
headerfile = open(os.path.join(CONFIG, "header.txt"), 'w')
for line in header:
headerfile.write(line)
headerfile.close()
subprocess.call(["cp", os.path.join(SOURCE, "config", "defaults", "footer.txt"), CONFIG]) subprocess.call(["cp", os.path.join(SOURCE, "config", "defaults", "footer.txt"), CONFIG])
subprocess.call(["cp", os.path.join(SOURCE, "config", "defaults", "style.css"), CONFIG]) subprocess.call(["cp", os.path.join(SOURCE, "config", "defaults", "style.css"), WWW])
setup() setup()
core.load() core.load()
raw_input("\nyou're all good to go, "+chatter.say("friend")+"! hit <enter> to continue.\n\n")
return "" return ""
def gen_header():
header = []
header.append("<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 3.2//EN\">")
header.append("<html>")
header.append("\t<head>")
header.append("\t\t<title>~"+USER+"on TTBP</title>")
header.append("\t\t<link rel=\"stylesheet\" href=\"style.css\" />")
header.append("\t</head>")
header.append("\t<body>")
header.append("\t\t<div id=\"meta\">")
header.append("\t\t\t<h1><a href=\"#\">~"+USER+"</a>@<a href=\"/~endorphant/ttbp\">TTBP</a></h1>")
header.append("\t\t</div>\n")
header.append("\t\t<div id=\"tlogs\">")
return header
def setup_handler(): def setup_handler():
print("\nyour ttbp configuration doesn't look right. let's make you a fresh copy.\n\n") print("\nyour ttbp configuration doesn't look right. let's make you a fresh copy.\n\n")
try: try:
@ -125,20 +149,22 @@ def setup():
choice = raw_input("\nplease pick a number from the list: ") choice = raw_input("\nplease pick a number from the list: ")
SETTINGS["editor"] = EDITORS[int(choice)] SETTINGS["editor"] = EDITORS[int(choice)]
print("\ntext editor set to >"+SETTINGS["editor"]) redraw("text editor set to: "+SETTINGS["editor"])
# publish directory selection # publish directory selection
choice = raw_input("\n\nwhere do you want your blog published? (leave blank to use default \"blog\") ") if SETTINGS["publish dir"]:
print("\tcurrent publish dir:\t"+os.path.join(PUBLIC, SETTINGS["publish dir"])+"\n\n")
choice = raw_input("\nwhere do you want your blog published? (leave blank to use default \"blog\") ")
if not choice: if not choice:
choice = "blog" choice = "blog"
publishing = os.path.join("/home", USER, "public_html", choice) publishing = os.path.join(PUBLIC, choice)
while os.path.exists(publishing): while os.path.exists(publishing):
second = raw_input("\n"+publishing+" already exists!\nif you're sure you want to use it, hit <enter> to confirm. otherwise, pick another location: ") second = raw_input("\n"+publishing+" already exists!\nif you're sure you want to use it, hit <enter> to confirm. otherwise, pick another location: ")
if second == "": if second == "":
break break
choice = second choice = second
publishing = os.path.join("/home", USER, "public_html", choice) publishing = os.path.join(PUBLIC, choice)
SETTINGS["publish dir"] = choice SETTINGS["publish dir"] = choice
@ -152,15 +178,13 @@ def setup():
if os.path.exists(WWW): if os.path.exists(WWW):
subprocess.call(["rm", WWW]) subprocess.call(["rm", WWW])
subprocess.call(["ln", "-s", publishing, WWW]) subprocess.call(["ln", "-s", publishing, WWW])
print("\npublishing to "+LIVE+USER+"/"+SETTINGS["publish dir"]+"/\n\n") print("\n\tpublishing to "+LIVE+USER+"/"+SETTINGS["publish dir"]+"/\n\n")
# save settings # save settings
ttbprc = open(TTBPRC, "w") ttbprc = open(TTBPRC, "w")
ttbprc.write(json.dumps(SETTINGS, sort_keys=True, indent=2, separators=(',',':'))) ttbprc.write(json.dumps(SETTINGS, sort_keys=True, indent=2, separators=(',',':')))
ttbprc.close() ttbprc.close()
raw_input("\nyou're all good to go, "+chatter.say("friend")+"! hit <enter> to continue.")
return SETTINGS return SETTINGS
## menus ## menus
@ -182,10 +206,10 @@ def main_menu():
#redraw() #redraw()
menuOptions = [ menuOptions = [
"record feelings", "record feelings",
"check out neighbors", "(wip) check out neighbors",
"change settings", "change settings",
"send feedback", "send feedback",
"see credits"] "(wip) see credits"]
#print(SPACER) #print(SPACER)
print("you're at ttbp home. remember, you can always press <ctrl-c> to come back here.\n\n") print("you're at ttbp home. remember, you can always press <ctrl-c> to come back here.\n\n")
print_menu(menuOptions) print_menu(menuOptions)
@ -204,7 +228,13 @@ def main_menu():
elif choice == '1': elif choice == '1':
redraw(DUST) redraw(DUST)
elif choice == '2': elif choice == '2':
redraw(DUST) pretty_settings = "\n\ttext editor:\t" +SETTINGS["editor"]
pretty_settings += "\n\tpublish dir:\t" +os.path.join(PUBLIC, SETTINGS["publish dir"])
redraw("now changing your settings. press <ctrl-c> if you didn't mean to do this.\n\ncurrent settings "+pretty_settings+"\n")
setup()
raw_input("\nyou're all good to go, "+chatter.say("friend")+"! hit <enter> to continue.\n\n")
redraw()
elif choice == '3': elif choice == '3':
redraw() redraw()
feedback_menu() feedback_menu()
@ -255,7 +285,8 @@ def send_feedback(subject="none", mailbox=os.path.join(FEEDBACK, USER+"-"+str(in
outfile = open(mailbox, 'w') outfile = open(mailbox, 'w')
outfile.write("from:\t\t~"+USER+"\n") outfile.write("from:\t\t~"+USER+"\n")
outfile.write("subject:\t"+subject+"\n\n") outfile.write("subject:\t"+subject+"\n")
outfile.write("date:\t"+time.stfrtime("%d %B %y")+"\n")
outfile.write(mail) outfile.write(mail)
outfile.close() outfile.close()