forked from endorphant/ttbp
cleaned up ^c and ^d exits by adding in a loop for main menu loading.
added a credits page.master
parent
ed2a14b846
commit
30426ab016
181
bin/ttbp.py
181
bin/ttbp.py
|
@ -38,7 +38,7 @@ SPACER = "\n\n\n"
|
||||||
INVALID = "please pick a number from the list of options!\n\n"
|
INVALID = "please pick a number from the list of options!\n\n"
|
||||||
DUST = "sorry about the dust, but this part is still under construction. check back later!\n\n"
|
DUST = "sorry about the dust, but this part is still under construction. check back later!\n\n"
|
||||||
QUITS = ['exit', 'quit', 'q', 'x']
|
QUITS = ['exit', 'quit', 'q', 'x']
|
||||||
BACKS = ['back', 'b']
|
BACKS = ['back', 'b', 'q']
|
||||||
EJECT = "eject button fired! going home now."
|
EJECT = "eject button fired! going home now."
|
||||||
|
|
||||||
## ref
|
## ref
|
||||||
|
@ -60,19 +60,24 @@ def start():
|
||||||
#print(chatter.say("greet")+", "+chatter.say("friend"))
|
#print(chatter.say("greet")+", "+chatter.say("friend"))
|
||||||
#print("(remember, you can always press ctrl-c to come home)\n")
|
#print("(remember, you can always press ctrl-c to come home)\n")
|
||||||
print("if you don't want to be here at any point, press <ctrl-d> and it'll all go away.\njust keep in mind that you might lose anything you've started here.\n")
|
print("if you don't want to be here at any point, press <ctrl-d> and it'll all go away.\njust keep in mind that you might lose anything you've started here.\n")
|
||||||
print(check_init())
|
try:
|
||||||
|
print(check_init())
|
||||||
|
except EOFError:
|
||||||
|
print(stop())
|
||||||
|
return
|
||||||
|
|
||||||
redraw()
|
redraw()
|
||||||
|
|
||||||
try:
|
while 1:
|
||||||
print(main_menu())
|
try:
|
||||||
#except ValueError or SyntaxError:
|
print(main_menu())
|
||||||
# redraw("oh no i didn't understand that. let's go home and start over.")
|
except EOFError:
|
||||||
# print(main_menu())
|
print(stop())
|
||||||
except EOFError:
|
break
|
||||||
print(stop())
|
except KeyboardInterrupt:
|
||||||
except KeyboardInterrupt:
|
redraw(EJECT)
|
||||||
redraw(EJECT)
|
else:
|
||||||
print(main_menu())
|
break
|
||||||
|
|
||||||
def stop():
|
def stop():
|
||||||
return "\n\n\t"+chatter.say("bye")+"\n\n"
|
return "\n\n\t"+chatter.say("bye")+"\n\n"
|
||||||
|
@ -223,7 +228,8 @@ def main_menu():
|
||||||
"send some feedback",
|
"send some feedback",
|
||||||
"(wip) 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("you're at ttbp home.\n\n")
|
||||||
print_menu(menuOptions)
|
print_menu(menuOptions)
|
||||||
#print("how are you feeling today? ")
|
#print("how are you feeling today? ")
|
||||||
|
|
||||||
|
@ -247,7 +253,7 @@ def main_menu():
|
||||||
view_own()
|
view_own()
|
||||||
elif choice == '2':
|
elif choice == '2':
|
||||||
users = find_ttbps()
|
users = find_ttbps()
|
||||||
redraw("the following "+p.no("user", len(users))+" "+p.plural("is", len(users))+" recording feels on ttbp, listed by most recently updated first:\n\n")
|
redraw("the following "+p.no("user", len(users))+" "+p.plural("is", len(users))+" recording feels on ttbp:\n\n")
|
||||||
view_neighbors(users)
|
view_neighbors(users)
|
||||||
elif choice == '3':
|
elif choice == '3':
|
||||||
redraw("now viewing most recent entries\n\n")
|
redraw("now viewing most recent entries\n\n")
|
||||||
|
@ -267,7 +273,8 @@ def main_menu():
|
||||||
redraw()
|
redraw()
|
||||||
feedback_menu()
|
feedback_menu()
|
||||||
elif choice == '6':
|
elif choice == '6':
|
||||||
redraw(DUST)
|
redraw()
|
||||||
|
show_credits()
|
||||||
elif choice in QUITS:
|
elif choice in QUITS:
|
||||||
return stop()
|
return stop()
|
||||||
else:
|
else:
|
||||||
|
@ -275,6 +282,8 @@ def main_menu():
|
||||||
|
|
||||||
return main_menu()
|
return main_menu()
|
||||||
|
|
||||||
|
###
|
||||||
|
|
||||||
def feedback_menu():
|
def feedback_menu():
|
||||||
print("you're about to send mail to ~endorphant about ttbp\n\n")
|
print("you're about to send mail to ~endorphant about ttbp\n\n")
|
||||||
|
|
||||||
|
@ -292,6 +301,77 @@ def feedback_menu():
|
||||||
|
|
||||||
return feedback_menu()
|
return feedback_menu()
|
||||||
|
|
||||||
|
def view_neighbors(users):
|
||||||
|
|
||||||
|
userList = []
|
||||||
|
|
||||||
|
for user in users:
|
||||||
|
userRC = json.load(open(os.path.join("/home", user, ".ttbp", "config", "ttbprc")))
|
||||||
|
url = LIVE+user+"/"+userRC["publish dir"]
|
||||||
|
count = 0
|
||||||
|
lastfile = ""
|
||||||
|
files = os.listdir(os.path.join("/home", user, ".ttbp", "entries"))
|
||||||
|
files.sort()
|
||||||
|
for filename in files:
|
||||||
|
if os.path.splitext(filename)[1] == ".txt" and len(os.path.splitext(filename)[0]) == 8:
|
||||||
|
count += 1
|
||||||
|
lastfile = os.path.join("/home", user, ".ttbp", "entries", filename)
|
||||||
|
|
||||||
|
ago = "never"
|
||||||
|
if lastfile:
|
||||||
|
last = os.path.getctime(lastfile)
|
||||||
|
since = time.time()-last
|
||||||
|
ago = util.pretty_time(int(since)) + " ago"
|
||||||
|
else:
|
||||||
|
last = 0
|
||||||
|
|
||||||
|
pad = ""
|
||||||
|
if len(user) < 8:
|
||||||
|
pad = "\t"
|
||||||
|
user = "~"+user
|
||||||
|
if len(user) < 8:
|
||||||
|
user += "\t"
|
||||||
|
|
||||||
|
userList.append(["\t"+user+"\t"+url+pad+"\t("+ago+")", last])
|
||||||
|
|
||||||
|
# sort user by most recent entry
|
||||||
|
userList.sort(key = lambda userdata:userdata[1])
|
||||||
|
userList.reverse()
|
||||||
|
sortedUsers = []
|
||||||
|
for user in userList:
|
||||||
|
sortedUsers.append(user[0])
|
||||||
|
|
||||||
|
print_menu(sortedUsers)
|
||||||
|
|
||||||
|
raw_input("\n\npress <enter> to go back home.\n\n")
|
||||||
|
redraw()
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
def view_own():
|
||||||
|
|
||||||
|
filenames = []
|
||||||
|
|
||||||
|
for entry in os.listdir(DATA):
|
||||||
|
filenames.append(os.path.join(DATA, entry))
|
||||||
|
metas = core.meta(filenames)
|
||||||
|
|
||||||
|
entries = []
|
||||||
|
for entry in metas:
|
||||||
|
entries.append(""+entry[4]+" ("+p.no("word", entry[2])+") ")
|
||||||
|
|
||||||
|
return view_entries(metas, entries, "here are your recorded feels, listed by date: \n\n")
|
||||||
|
|
||||||
|
def show_credits():
|
||||||
|
|
||||||
|
print("ttbp was written by ~endorphant in python. the codebase is\npublicly available on github at https://github.com/modgethanc/ttbp\n\nif you have ideas for ttbp, you are welcome to fork the repo and \nwork on it. i'm only a baby dev, so i apologize for any \nhorrendously ugly coding habits i have.\n\nthanks to everyone who reads, listens, writes, and feels.")
|
||||||
|
|
||||||
|
raw_input("\n\npress <enter> to go back home.\n\n")
|
||||||
|
redraw()
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
## handlers
|
## handlers
|
||||||
|
|
||||||
def write_entry(entry=os.path.join(DATA, "test.txt")):
|
def write_entry(entry=os.path.join(DATA, "test.txt")):
|
||||||
|
@ -324,74 +404,6 @@ def send_feedback(subject="none", mailbox=os.path.join(FEEDBACK, USER+"-"+time.s
|
||||||
|
|
||||||
return "mail sent. thanks for writing! i'll try to respond to you soon."
|
return "mail sent. thanks for writing! i'll try to respond to you soon."
|
||||||
|
|
||||||
def view_neighbors(users):
|
|
||||||
|
|
||||||
userList = []
|
|
||||||
|
|
||||||
for user in users:
|
|
||||||
userRC = json.load(open(os.path.join("/home", user, ".ttbp", "config", "ttbprc")))
|
|
||||||
url = LIVE+user+"/"+userRC["publish dir"]
|
|
||||||
count = 0
|
|
||||||
lastfile = ""
|
|
||||||
files = os.listdir(os.path.join("/home", user, ".ttbp", "entries"))
|
|
||||||
files.sort()
|
|
||||||
#for filename in os.listdir(os.path.join("/home", user, ".ttbp", "entries")).sort():
|
|
||||||
for filename in files:
|
|
||||||
if os.path.splitext(filename)[1] == ".txt" and len(os.path.splitext(filename)[0]) == 8:
|
|
||||||
count += 1
|
|
||||||
lastfile = os.path.join("/home", user, ".ttbp", "entries", filename)
|
|
||||||
|
|
||||||
ago = "never"
|
|
||||||
if lastfile:
|
|
||||||
last = os.path.getctime(lastfile)
|
|
||||||
#date = time.strftime("%Y%m%d %H%M", time.localtime(last))
|
|
||||||
since = time.time()-last
|
|
||||||
ago = util.pretty_time(int(since)) + " ago"
|
|
||||||
else:
|
|
||||||
last = 0
|
|
||||||
|
|
||||||
pad = ""
|
|
||||||
if len(user) < 8:
|
|
||||||
pad = "\t"
|
|
||||||
user = "~"+user
|
|
||||||
if len(user) < 8:
|
|
||||||
user += "\t"
|
|
||||||
|
|
||||||
userList.append(["\t"+user+"\t"+url+pad+"\t("+ago+")", last])
|
|
||||||
#userList.append(["\t"+user+"\t"+url+pad+"\t("+p.no("feel", count)+")", last])
|
|
||||||
#userList.append(["\t"+user+"\t"+url+pad+"\t("+p.no("feel", count)+") "+date, last])
|
|
||||||
|
|
||||||
# sort user by most recent entry
|
|
||||||
userList.sort(key = lambda userdata:userdata[1])
|
|
||||||
userList.reverse()
|
|
||||||
sortedUsers = []
|
|
||||||
for user in userList:
|
|
||||||
sortedUsers.append(user[0])
|
|
||||||
|
|
||||||
print_menu(sortedUsers)
|
|
||||||
|
|
||||||
raw_input("\n\npress <enter> to go back home.\n\n")
|
|
||||||
redraw()
|
|
||||||
|
|
||||||
return
|
|
||||||
|
|
||||||
def view_own():
|
|
||||||
|
|
||||||
filenames = []
|
|
||||||
|
|
||||||
for entry in os.listdir(DATA):
|
|
||||||
filenames.append(os.path.join(DATA, entry))
|
|
||||||
metas = core.meta(filenames)
|
|
||||||
|
|
||||||
entries = []
|
|
||||||
for entry in metas:
|
|
||||||
#print(entry)
|
|
||||||
entries.append(""+entry[4]+" ("+p.no("word", entry[2])+") ")
|
|
||||||
|
|
||||||
|
|
||||||
#view_entries(metas, entries, "here are your recorded feels, listed by date: \n\n")
|
|
||||||
return view_entries(metas, entries, "here are your recorded feels, listed by date: \n\n")
|
|
||||||
|
|
||||||
def view_entries(metas, entries, prompt):
|
def view_entries(metas, entries, prompt):
|
||||||
|
|
||||||
print_menu(entries)
|
print_menu(entries)
|
||||||
|
@ -403,7 +415,6 @@ def view_entries(metas, entries, prompt):
|
||||||
redraw("now reading ~"+metas[choice][5]+"'s feels on "+metas[choice][4]+"\n> press <q> to return to feels list.\n\n")
|
redraw("now reading ~"+metas[choice][5]+"'s feels on "+metas[choice][4]+"\n> press <q> to return to feels list.\n\n")
|
||||||
|
|
||||||
show_entry(metas[choice][0])
|
show_entry(metas[choice][0])
|
||||||
#redraw("here are your recorded feels, listed by date:\n\n")
|
|
||||||
redraw(prompt)
|
redraw(prompt)
|
||||||
|
|
||||||
return view_entries(metas, entries, prompt)
|
return view_entries(metas, entries, prompt)
|
||||||
|
@ -481,7 +492,7 @@ def list_select(options, prompt):
|
||||||
try:
|
try:
|
||||||
ans = int(choice)
|
ans = int(choice)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
choice = raw_input("\n\n"+prompt+"\n\n")
|
return list_select(options, prompt)
|
||||||
|
|
||||||
invalid = False
|
invalid = False
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
TO-DO:
|
TO-DO:
|
||||||
(goals for stable release)
|
(goals for stable release)
|
||||||
|
|
||||||
-add credits page
|
|
||||||
-filename validator
|
-filename validator
|
||||||
-only count/process entries if filename is
|
-only count/process entries if filename is
|
||||||
.ttbp/entries/YYMMDD.txt"
|
.ttbp/entries/YYMMDD.txt"
|
||||||
|
@ -10,7 +9,6 @@ TO-DO:
|
||||||
to a file?
|
to a file?
|
||||||
-command line flags
|
-command line flags
|
||||||
-markdown parsing
|
-markdown parsing
|
||||||
-sort out all this freaking exit problems
|
|
||||||
-neighbor view takes you to individual entry listing
|
-neighbor view takes you to individual entry listing
|
||||||
|
|
||||||
(goals for phase two)
|
(goals for phase two)
|
||||||
|
@ -28,6 +26,10 @@ TO-DO:
|
||||||
|
|
||||||
CHANGELOG:
|
CHANGELOG:
|
||||||
|
|
||||||
|
ver 0.7
|
||||||
|
-fixed program crashing? maybe?
|
||||||
|
-added credits
|
||||||
|
|
||||||
ver 0.6.5
|
ver 0.6.5
|
||||||
-renamed FEELS ENGINE
|
-renamed FEELS ENGINE
|
||||||
-changed neighbor view to show last update time instead of feels count
|
-changed neighbor view to show last update time instead of feels count
|
||||||
|
|
Loading…
Reference in New Issue