setup and posting function running
This commit is contained in:
		
							parent
							
								
									b727bbd916
								
							
						
					
					
						commit
						c16662192e
					
				| @ -2,4 +2,4 @@ | |||||||
| | TILDE TOWN | | | TILDE TOWN | | ||||||
| |  BLOGGING  | | |  BLOGGING  | | ||||||
| |  PLATFORM  | | |  PLATFORM  | | ||||||
| ==============   ver 0.1 (highly unstable) | ==============   ver 0.2 (highly unstable) | ||||||
|  | |||||||
| @ -1,12 +1,12 @@ | |||||||
| <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN"> | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN"> | ||||||
| <html> | <html> | ||||||
|   <head> |   <head> | ||||||
|     <title>~endorphant</title> |     <title>$USER on TTBP</title> | ||||||
|     <link rel="stylesheet" href="style.css" /> |     <link rel="stylesheet" href="style.css" /> | ||||||
|   </head> |   </head> | ||||||
|   <body> |   <body> | ||||||
|     <div id="meta"> |     <div id="meta"> | ||||||
|       <h1><a href="#">~endorphant</a>@<a href="../">tilde.town</a></h1> |       <h1><a href="#">~$USER</a>@<a href="~endorphant/ttbp">TTBP</a></h1> | ||||||
|     </div> |     </div> | ||||||
| 
 | 
 | ||||||
|     <div id="tlogs"> |     <div id="tlogs"> | ||||||
| @ -32,13 +32,18 @@ MONTHS = { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| def load(): | def load(): | ||||||
|     global FILES |  | ||||||
|     global HEADER |     global HEADER | ||||||
|     global FOOTER |     global FOOTER | ||||||
| 
 | 
 | ||||||
|     HEADER = open(os.path.join(CONFIG, "header.txt")).read() |     HEADER = open(os.path.join(CONFIG, "header.txt")).read() | ||||||
|     FOOTER = open(os.path.join(CONFIG, "footer.txt")).read() |     FOOTER = open(os.path.join(CONFIG, "footer.txt")).read() | ||||||
| 
 | 
 | ||||||
|  |     load_files() | ||||||
|  | 
 | ||||||
|  | def load_files(): | ||||||
|  |     global FILES | ||||||
|  | 
 | ||||||
|  |     FILES = [] | ||||||
|     for file in os.listdir(DATA): |     for file in os.listdir(DATA): | ||||||
|         filename = os.path.join(DATA, file) |         filename = os.path.join(DATA, file) | ||||||
|         if os.path.isfile(filename) and os.path.splitext(filename)[1] == ".txt": |         if os.path.isfile(filename) and os.path.splitext(filename)[1] == ".txt": | ||||||
|  | |||||||
							
								
								
									
										47
									
								
								bin/ttbp.py
									
									
									
									
									
								
							
							
						
						
									
										47
									
								
								bin/ttbp.py
									
									
									
									
									
								
							| @ -7,13 +7,14 @@ import subprocess | |||||||
| import time | import time | ||||||
| import json | import json | ||||||
| 
 | 
 | ||||||
| #import core | import core | ||||||
| import chatter | import chatter | ||||||
| 
 | 
 | ||||||
| ## system globals | ## system globals | ||||||
| SOURCE = os.path.join("/home", "endorphant", "projects", "ttbp", "bin") | SOURCE = os.path.join("/home", "endorphant", "projects", "ttbp", "bin") | ||||||
| LIVE = "http://tilde.town/~" | LIVE = "http://tilde.town/~" | ||||||
| FEEDBACK = os.path.join("/home", "endorphant", "ttbp-mail") | FEEDBACK = os.path.join("/home", "endorphant", "ttbp-mail") | ||||||
|  | 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("~")) | ||||||
| @ -51,7 +52,7 @@ def start(): | |||||||
|   redraw() |   redraw() | ||||||
|   #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()) |   print(check_init()) | ||||||
| 
 | 
 | ||||||
|   try: |   try: | ||||||
| @ -69,8 +70,9 @@ def stop(): | |||||||
| 
 | 
 | ||||||
| def check_init(): | def check_init(): | ||||||
|   global SETTINGS |   global SETTINGS | ||||||
|  |   print("\n\n") | ||||||
|   if os.path.exists(os.path.join(os.path.expanduser("~"),".ttbp")): |   if os.path.exists(os.path.join(os.path.expanduser("~"),".ttbp")): | ||||||
|       print("welcome back, "+USER+".") |       print(chatter.say("greet")+", "+USER+".") | ||||||
|       while not os.path.isfile(TTBPRC): |       while not os.path.isfile(TTBPRC): | ||||||
|         setup_handler() |         setup_handler() | ||||||
|       try: |       try: | ||||||
| @ -78,13 +80,31 @@ def check_init(): | |||||||
|       except ValueError: |       except ValueError: | ||||||
|         setup_handler() |         setup_handler() | ||||||
| 
 | 
 | ||||||
|       raw_input("\n\npress enter to explore your feelings.\n\n") |       raw_input("\n\npress <enter> to explore your feelings.\n\n") | ||||||
|  |       core.load() | ||||||
|       return "" |       return "" | ||||||
|   else: |   else: | ||||||
|     return init() |     return init() | ||||||
| 
 | 
 | ||||||
| def init(): | def init(): | ||||||
|     raw_input("i don't recognize you, stranger. let's make friends someday.\n\npress enter to explore some options.\n\n") |     try: | ||||||
|  |         raw_input("i don't recognize you, stranger. let's make friends.\n\npress <enter> to begin, or <ctrl-c> to get out of here. \n\n") | ||||||
|  |     except KeyboardInterrupt: | ||||||
|  |         print("\n\nthanks for checking in! i'll always be here.\n\n") | ||||||
|  |         quit()  | ||||||
|  | 
 | ||||||
|  |     users = open(USERFILE, 'a') | ||||||
|  |     users.write(USER+"\n") | ||||||
|  |     users.close() | ||||||
|  |     subprocess.call(["mkdir", PATH]) | ||||||
|  |     subprocess.call(["mkdir", CONFIG]) | ||||||
|  |     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", "footer.txt"), CONFIG]) | ||||||
|  |     subprocess.call(["cp", os.path.join(SOURCE, "config", "defaults", "style.css"), CONFIG]) | ||||||
|  | 
 | ||||||
|  |     setup() | ||||||
|  |     core.load() | ||||||
|     return "" |     return "" | ||||||
| 
 | 
 | ||||||
| def setup_handler(): | def setup_handler(): | ||||||
| @ -129,7 +149,8 @@ def setup(): | |||||||
|         index = open(os.path.join(publishing, "index.html"), "w") |         index = open(os.path.join(publishing, "index.html"), "w") | ||||||
|         index.write("<h1>ttbp blog placeholder</h1>") |         index.write("<h1>ttbp blog placeholder</h1>") | ||||||
|         index.close() |         index.close() | ||||||
|     subprocess.call(["rm", WWW]) |     if os.path.exists(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("\npublishing to "+LIVE+USER+"/"+SETTINGS["publish dir"]+"/\n\n") | ||||||
| 
 | 
 | ||||||
| @ -138,6 +159,8 @@ def setup(): | |||||||
|     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 | ||||||
| @ -164,7 +187,7 @@ def main_menu(): | |||||||
|             "send feedback", |             "send feedback", | ||||||
|             "see credits"] |             "see credits"] | ||||||
|     #print(SPACER) |     #print(SPACER) | ||||||
|     print("you're at ttbp home now. 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) | ||||||
|     #print("how are you feeling today? ") |     #print("how are you feeling today? ") | ||||||
| 
 | 
 | ||||||
| @ -175,7 +198,9 @@ def main_menu(): | |||||||
|         return main_menu() |         return main_menu() | ||||||
| 
 | 
 | ||||||
|     if choice == '0': |     if choice == '0': | ||||||
|         redraw(DUST) |         redraw() | ||||||
|  |         today = time.strftime("%Y%m%d") | ||||||
|  |         write_entry(os.path.join(DATA, today+".txt")) | ||||||
|     elif choice == '1': |     elif choice == '1': | ||||||
|         redraw(DUST) |         redraw(DUST) | ||||||
|     elif choice == '2': |     elif choice == '2': | ||||||
| @ -213,8 +238,12 @@ def feedback_menu(): | |||||||
| 
 | 
 | ||||||
| def write_entry(entry=os.path.join(DATA, "test.txt")): | def write_entry(entry=os.path.join(DATA, "test.txt")): | ||||||
| 
 | 
 | ||||||
|  |     raw_input("\nfeelings will be recorded for today, "+time.strftime("%d %B %Y")+".\n\nif you've already started recording feelings for this day, you \ncan pick up where you left off.\n\npress <enter> to begin recording your feelings.\n\n")  | ||||||
|     subprocess.call([SETTINGS["editor"], entry]) |     subprocess.call([SETTINGS["editor"], entry]) | ||||||
|     return "wrote to "+entry |     core.load_files() | ||||||
|  |     core.write("index.html") | ||||||
|  |     redraw("new entry posted to "+LIVE+USER+"/"+SETTINGS["publish dir"]+"/index.html\n\nthanks for sharing your feelings!") | ||||||
|  |     return | ||||||
| 
 | 
 | ||||||
| def send_feedback(subject="none", mailbox=os.path.join(FEEDBACK, USER+"-"+str(int(time.time()))+".msg")): | def send_feedback(subject="none", mailbox=os.path.join(FEEDBACK, USER+"-"+str(int(time.time()))+".msg")): | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -2,4 +2,5 @@ | |||||||
| 
 | 
 | ||||||
| import core | import core | ||||||
| 
 | 
 | ||||||
|  | core.load() | ||||||
| print("\n blog updated at "+core.write("index.html")+"\n") | print("\n blog updated at "+core.write("index.html")+"\n") | ||||||
|  | |||||||
| @ -6,19 +6,19 @@ | |||||||
|     "good morning", |     "good morning", | ||||||
|     "good afternoon", |     "good afternoon", | ||||||
|     "good day", |     "good day", | ||||||
|     "good evening" |     "good evening", | ||||||
|  |     "welcome back" | ||||||
|       ], |       ], | ||||||
|   "bye":[ |   "bye":[ | ||||||
|     "see you later", |     "see you later, space cowboy", | ||||||
|     "bye", |     "bye, townie", | ||||||
|     "later" |     "until next time, friend" | ||||||
|       ], |       ], | ||||||
|   "friend":[ |   "friend":[ | ||||||
|     "friend", |     "friend", | ||||||
|     "pal", |     "pal", | ||||||
|     "buddy", |     "buddy", | ||||||
|     "townie", |     "townie" | ||||||
|     "fellow" |  | ||||||
|     ], |     ], | ||||||
|   "months":{ |   "months":{ | ||||||
|     "01":"january", |     "01":"january", | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user