def write_entry(entry=os.path.join(DATA, "test.txt")): ''' main feels-recording handler ''' entered = raw_input(""" feels will be recorded for today, """+time.strftime("%d %B %Y")+""". if you've already started recording feels for this day, you can pick up where you left off. you can write your feels in plaintext, markdown, html, or a mixture of these. press <enter> to begin recording your feels in your chosen text editor. """) if entered: entryFile = open(entry, "a") entryFile.write("\n"+entered+"\n") entryFile.close() subprocess.call([SETTINGS.get("editor"), entry]) left = "" if core.publishing(): core.load_files() core.write("index.html") left = "posted to "+LIVE+USER+"/"+str(SETTINGS.get("publish dir"))+"/index.html\n\n>" redraw(left + " thanks for sharing your feels!") return
def write_entry(entry=os.path.join(DATA, "test.txt")): entered = raw_input(""" """+util.hilight("new feature!")+""" you can now use standard markdown in your entry text! raw html is still valid, and you can mix them together. feels will be recorded for today, """+time.strftime("%d %B %Y")+""". if you've already started recording feels for this day, you can pick up where you left off. press <enter> to begin recording your feels. """) if entered: entryFile = open(entry, "a") entryFile.write("\n"+entered+"\n") entryFile.close() subprocess.call([SETTINGS["editor"], entry]) left = "" if publishing(): core.load_files() core.write("index.html") left = "posted to "+LIVE+USER+"/"+SETTINGS["publish dir"]+"/index.html" redraw(left + " thanks for sharing your feels!") return
def setup(): global SETTINGS # editor selection SETTINGS.update({"editor": select_editor()}) redraw("text editor set to: "+SETTINGS["editor"]) # publishing selection SETTINGS.update({"publishing":select_publishing()}) redraw("blog publishing: "+str(publishing())) if publishing(): oldDir = SETTINGS.get("publish dir") newDir = select_publish_dir() SETTINGS.update({"publish dir": newDir}) subprocess.call(["rm", "-rf", os.path.join(PUBLIC, oldDir)]) make_publish_dir(newDir) core.load_files() core.write("index.html") else: unpublish() # save settings ttbprc = open(TTBPRC, "w") ttbprc.write(json.dumps(SETTINGS, sort_keys=True, indent=2, separators=(',',':'))) ttbprc.close() return SETTINGS
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]) core.load_files() core.write("index.html") redraw("posted to "+LIVE+USER+"/"+SETTINGS["publish dir"]+"/index.html\n\nthanks for sharing your feelings!") return
def update_publishing(): ''' updates publishing directory if user is publishing. otherwise, wipe it. ''' global SETTINGS if core.publishing(): oldDir = SETTINGS.get("publish dir") newDir = select_publish_dir() SETTINGS.update({"publish dir": newDir}) if oldDir: subprocess.call(["rm", os.path.join(PUBLIC, oldDir)]) make_publish_dir(newDir) core.load_files() core.write("index.html") else: unpublish() SETTINGS.update({"publish dir": None}) core.load(SETTINGS)
def update_version(): ''' updates user to current version ''' global SETTINGS versionFile = os.path.join(PATH, "version") print("ttbp had some updates!") print("\ngive me a second to update you to version "+__version__+"...\n") time.sleep(1) print("...") time.sleep(2) userVersion = "" if not os.path.isfile(versionFile): # from 0.8.5 to 0.8.6: # change style.css location if os.path.isfile(os.path.join(WWW, "style.css")): subprocess.call(["mv", os.path.join(WWW, "style.css"), CONFIG]) # change www symlink if os.path.exists(WWW): subprocess.call(["rm", WWW]) subprocess.call(["mkdir", WWW]) subprocess.call(["ln", "-s", os.path.join(CONFIG, "style.css"), os.path.join(WWW, "style.css")]) publishDir = os.path.join(PUBLIC, SETTINGS.get("publish dir")) if os.path.exists(publishDir): subprocess.call(["rm", "-rf", publishDir]) subprocess.call(["ln", "-s", WWW, os.path.join(PUBLIC, SETTINGS.get("publish dir"))]) # repopulate html files core.load_files() core.write("index.html") # add publishing setting print("\nnew feature!\n") SETTINGS.update({"publishing":select_publishing()}) update_publishing() ttbprc = open(TTBPRC, "w") ttbprc.write(json.dumps(SETTINGS, sort_keys=True, indent=2, separators=(',',':'))) ttbprc.close() else: # version at least 0.8.6 userVersion = open(versionFile, "r").read().rstrip() # from 0.8.6 if userVersion == "0.8.6": print("\nresetting your publishing settings...\n") SETTINGS.update({"publishing":select_publishing()}) update_publishing() ttbprc = open(TTBPRC, "w") ttbprc.write(json.dumps(SETTINGS, sort_keys=True, indent=2, separators=(',',':'))) ttbprc.close() # increment user versionfile open(versionFile, "w").write(__version__) print(""" you're all good to go, """+chatter.say("friend")+"""! please contact ~endorphant if somehing strange happened to you during this update. """) # show patch notes if userVersion != "0.9.0" and userVersion != "0.9.0b": # version 0.9.0 patch notes: print(""" ver. 0.9.0 features: * browsing other people's feels from neighbor view * documentation browser """) # version 0.9.1 patch notes print(""" ver 0.9.1 features: * graffiti wall """)
def update_version(): ''' updates user to current version ''' global SETTINGS versionFile = os.path.join(PATH, "version") print("ttbp had some updates!") print("\ngive me a second to update you to version "+__version__+"...\n") time.sleep(1) print("...") time.sleep(2) userVersion = "" if not os.path.isfile(versionFile): # from 0.8.5 to 0.8.6: # change style.css location if os.path.isfile(os.path.join(WWW, "style.css")): subprocess.call(["mv", os.path.join(WWW, "style.css"), CONFIG]) # change www symlink if os.path.exists(WWW): subprocess.call(["rm", WWW]) subprocess.call(["mkdir", WWW]) subprocess.call(["ln", "-s", os.path.join(CONFIG, "style.css"), os.path.join(WWW, "style.css")]) publishDir = os.path.join(PUBLIC, SETTINGS.get("publish dir")) if os.path.exists(publishDir): subprocess.call(["rm", "-rf", publishDir]) subprocess.call(["ln", "-s", WWW, os.path.join(PUBLIC, SETTINGS.get("publish dir"))]) # repopulate html files core.load_files() core.write("index.html") # add publishing setting print("\nnew feature!\n") SETTINGS.update({"publishing":select_publishing()}) update_publishing() ttbprc = open(TTBPRC, "w") ttbprc.write(json.dumps(SETTINGS, sort_keys=True, indent=2, separators=(',',':'))) ttbprc.close() else: # version at least 0.8.6 userVersion = open(versionFile, "r").read().rstrip() # from 0.8.6 if userVersion == "0.8.6": print("\nresetting your publishing settings...\n") SETTINGS.update({"publishing":select_publishing()}) update_publishing() ttbprc = open(TTBPRC, "w") ttbprc.write(json.dumps(SETTINGS, sort_keys=True, indent=2, separators=(',',':'))) ttbprc.close() # increment user versionfile open(versionFile, "w").write(__version__) print(""" you're all good to go, """+chatter.say("friend")+"""! please contact ~endorphant if somehing strange happened to you during this update. """) # show patch notes #if userVersion != "0.9.0" and userVersion != "0.9.0b": if userVersion[0:5] < "0.9.0": # version 0.9.0 patch notes: print(""" ver. 0.9.0 features: * browsing other people's feels from neighbor view * documentation browser """) if userVersion[0:5] < "0.9.1": # version 0.9.1 patch notes print(""" ver 0.9.1 features: * graffiti wall """)
def main_menu(): ''' main navigation menu ''' menuOptions = [ "record your feels", "review your feels", "check out your neighbors", "browse global feels", "scribble some graffiti\t(new!)", "change your settings", "send some feedback", "see credits", "read documentation"] print("you're at ttbp home. remember, you can always press <ctrl-c> to come back here.\n") util.print_menu(menuOptions, RAINBOW) try: choice = raw_input("\ntell me about your feels (or 'quit' to exit): ") except KeyboardInterrupt: redraw(EJECT) return main_menu() if choice == '0': redraw() today = time.strftime("%Y%m%d") write_entry(os.path.join(DATA, today+".txt")) core.www_neighbors() elif choice == '1': if core.publishing(): intro = "here are some options for reviewing your feels:" redraw(intro) review_menu(intro) core.load_files() core.write("index.html") else: redraw("your recorded feels, listed by date:") view_feels(USER) elif choice == '2': users = core.find_ttbps() redraw("the following "+p.no("user", len(users))+" "+p.plural("is", len(users))+" recording feels on ttbp:") view_neighbors(users) elif choice == '3': redraw("most recent global entries") view_feed() elif choice == '4': graffiti_handler() elif choice == '5': redraw("now changing your settings. press <ctrl-c> if you didn't mean to do this.") try: core.load(setup()) # reload settings to core except KeyboardInterrupt(): redraw(EJECT) redraw() elif choice == '6': redraw("you're about to send mail to ~endorphant about ttbp") feedback_menu() elif choice == '7': redraw() show_credits() elif choice == '8': subprocess.call(["lynx", os.path.join(SOURCE, "..", "README.html")]) redraw() elif choice in QUITS: return stop() else: redraw(INVALID) return main_menu()