@@ -345,11 +333,11 @@ def valid_setup():
global SETTINGS
- if not os.path.isfile(TTBPRC):
+ if not os.path.isfile(config.TTBPRC):
return False
try:
- SETTINGS = json.load(open(TTBPRC))
+ SETTINGS = json.load(open(config.TTBPRC))
except ValueError:
return False
@@ -357,10 +345,10 @@ def valid_setup():
if not SETTINGS.get("publish dir"):
return False
- if not os.path.exists(WWW):
+ if not os.path.exists(config.WWW):
return False
- if not os.path.exists(os.path.join(WWW, SETTINGS.get("pubish dir"))):
+ if not os.path.exists(os.path.join(config.WWW, SETTINGS.get("pubish dir"))):
return False
return True
@@ -396,7 +384,7 @@ def setup():
print("\n\ttext editor:\t" +SETTINGS.get("editor"))
if core.publishing():
- print("\tpublish dir:\t" +os.path.join(PUBLIC, str(SETTINGS.get("publish dir"))))
+ print("\tpublish dir:\t" +os.path.join(config.PUBLIC, str(SETTINGS.get("publish dir"))))
print("\tpubishing:\t"+str(SETTINGS.get("publishing"))+"\n")
# editor selection
@@ -410,10 +398,10 @@ def setup():
redraw("blog publishing: "+str(core.publishing()))
if core.publishing():
- print("publish directory: ~"+USER+"/public_html/"+SETTINGS.get("publish dir"))
+ print("publish directory: ~"+config.USER+"/public_html/"+SETTINGS.get("publish dir"))
# save settings
- ttbprc = open(TTBPRC, "w")
+ ttbprc = open(config.TTBPRC, "w")
ttbprc.write(json.dumps(SETTINGS, sort_keys=True, indent=2, separators=(',',':')))
ttbprc.close()
@@ -452,7 +440,7 @@ def main_menu():
if choice == '0':
redraw()
today = time.strftime("%Y%m%d")
- write_entry(os.path.join(DATA, today+".txt"))
+ write_entry(os.path.join(config.USER_DATA, today+".txt"))
core.www_neighbors()
elif choice == '1':
if core.publishing():
@@ -463,7 +451,7 @@ def main_menu():
core.write("index.html")
else:
redraw("your recorded feels, listed by date:")
- view_feels(USER)
+ view_feels(config.USER)
elif choice == '2':
users = core.find_ttbps()
prompt = "the following "+p.no("user", len(users))+" "+p.plural("is", len(users))+" recording feels on ttbp:"
@@ -488,7 +476,7 @@ def main_menu():
redraw()
show_credits()
elif choice == '8':
- subprocess.call(["lynx", os.path.join(SOURCE, "..", "README.html")])
+ subprocess.call(["lynx", os.path.join(config.INSTALL_PATH, "..", "README.html")])
redraw()
elif choice in QUITS:
return stop()
@@ -541,7 +529,7 @@ def review_menu(intro=""):
if choice is not False:
if choice == 0:
redraw("your recorded feels, listed by date:")
- view_feels(USER)
+ view_feels(config.USER)
elif choice == 1:
redraw("here's your current nopub status:")
set_nopubs()
@@ -568,7 +556,7 @@ def view_neighbors(users, prompt):
## retrieve publishing url, if it exists
url="\t\t\t"
if userRC.get("publish dir"):
- url = LIVE+user+"/"+userRC.get("publish dir")
+ url = config.LIVE+user+"/"+userRC.get("publish dir")
## find last entry
files = os.listdir(os.path.join("/home", user, ".ttbp", "entries"))
@@ -628,8 +616,8 @@ def view_feels(townie):
filenames = []
showpub = False
- if townie == USER:
- entryDir = DATA
+ if townie == config.USER:
+ entryDir = config.USER_DATA
owner = "your"
if core.publishing():
showpub = True
@@ -683,7 +671,7 @@ thanks to everyone who reads, listens, writes, and feels.\
## handlers
-def write_entry(entry=os.path.join(DATA, "test.txt")):
+def write_entry(entry=os.path.join(config.USER_DATA, "test.txt")):
'''
main feels-recording handler
'''
@@ -713,7 +701,7 @@ editor.
if core.publishing():
core.load_files()
core.write("index.html")
- left = "posted to "+LIVE+USER+"/"+str(SETTINGS.get("publish dir"))+"/index.html\n\n>"
+ left = "posted to "+config.LIVE+config.USER+"/"+str(SETTINGS.get("publish dir"))+"/index.html\n\n>"
redraw(left + " thanks for sharing your feels!")
return
@@ -743,8 +731,8 @@ def send_feedback(entered, subject="none"):
if message:
id = "#"+util.genID(3)
mail = MIMEText(message)
- mail['To'] = FEEDBOX
- mail['From'] = USER+"@tilde.town"
+ mail['To'] = config.FEEDBOX
+ mail['From'] = config.USER+"@tilde.town"
mail['Subject'] = " ".join(["[ttbp]", subject, id])
m = os.popen("/usr/sbin/sendmail -t -oi", 'w')
m.write(mail.as_string())
@@ -836,10 +824,10 @@ def graffiti_handler():
Main graffiti handler.
'''
- if os.path.isfile(WALL_LOCK):
+ if os.path.isfile(config.WALL_LOCK):
redraw("sorry, "+chatter.say("friend")+", but someone's there right now. try again in a few!")
else:
- subprocess.call(["touch", WALL_LOCK])
+ subprocess.call(["touch", config.WALL_LOCK])
redraw()
print("""\
the graffiti wall is a world-writeable text file. anyone can
@@ -853,8 +841,8 @@ your changes by exiting without saving.
""")
raw_input("press to visit the wall\n\n")
- subprocess.call([SETTINGS.get("editor"), WALL])
- subprocess.call(["rm", WALL_LOCK])
+ subprocess.call([SETTINGS.get("editor"), config.WALL])
+ subprocess.call(["rm", config.WALL_LOCK])
redraw("thanks for visiting the graffiti wall!")
@@ -884,14 +872,14 @@ def select_publish_dir():
republish = False
if current:
- print("\ncurrent publish dir:\t"+os.path.join(PUBLIC, SETTINGS["publish dir"]))
+ print("\ncurrent publish dir:\t"+os.path.join(config.PUBLIC, SETTINGS["publish dir"]))
republish = True
choice = raw_input("\nwhere do you want your blog published? (leave blank to use default \"blog\") ")
if not choice:
choice = "blog"
- publishDir = os.path.join(PUBLIC, choice)
+ publishDir = os.path.join(config.PUBLIC, choice)
while os.path.exists(publishDir):
second = raw_input("\n"+publishDir+"""\
already exists!
@@ -905,7 +893,7 @@ otherwise, pick another location: """)
if second == "":
break
choice = second
- publishDir = os.path.join(PUBLIC, choice)
+ publishDir = os.path.join(config.PUBLIC, choice)
return choice
@@ -936,10 +924,9 @@ def unpublish():
'''
remove user's published directory, if it exists. this should only remove the symlink in public_html.
'''
-
- dir = SETTINGS.get("publish dir")
- if dir:
- publishDir = os.path.join(PUBLIC, dir)
+ directory = SETTINGS.get("publish dir")
+ if directory:
+ publishDir = os.path.join(config.PUBLIC, directory)
subprocess.call(["rm", publishDir])
def update_publishing():
@@ -954,7 +941,7 @@ def update_publishing():
newDir = select_publish_dir()
SETTINGS.update({"publish dir": newDir})
if oldDir:
- subprocess.call(["rm", os.path.join(PUBLIC, oldDir)])
+ subprocess.call(["rm", os.path.join(config.PUBLIC, oldDir)])
make_publish_dir(newDir)
core.load_files()
core.write("index.html")
@@ -969,21 +956,21 @@ def make_publish_dir(dir):
setup helper to create publishing directory
'''
- if not os.path.exists(WWW):
- subprocess.call(["mkdir", WWW])
- subprocess.call(["ln", "-s", os.path.join(CONFIG, "style.css"), os.path.join(WWW, "style.css")])
- subprocess.call(["touch", os.path.join(WWW, "index.html")])
- index = open(os.path.join(WWW, "index.html"), "w")
+ if not os.path.exists(config.WWW):
+ subprocess.call(["mkdir", config.WWW])
+ subprocess.call(["ln", "-s", os.path.join(config.USER_CONFIG, "style.css"), os.path.join(config.WWW, "style.css")])
+ subprocess.call(["touch", os.path.join(config.WWW, "index.html")])
+ index = open(os.path.join(config.WWW, "index.html"), "w")
index.write("
ttbp blog placeholder
")
index.close()
- publishDir = os.path.join(PUBLIC, dir)
+ publishDir = os.path.join(config.PUBLIC, dir)
if os.path.exists(publishDir):
subprocess.call(["rm", publishDir])
- subprocess.call(["ln", "-s", WWW, publishDir])
+ subprocess.call(["ln", "-s", config.WWW, publishDir])
- print("\n\tpublishing to "+LIVE+USER+"/"+SETTINGS.get("publish dir")+"/\n\n")
+ print("\n\tpublishing to "+config.LIVE+config.USER+"/"+SETTINGS.get("publish dir")+"/\n\n")
##### PATCHING UTILITIES
@@ -992,7 +979,7 @@ def build_mismatch():
checks to see if user's last run build is the same as this session
'''
- versionFile = os.path.join(PATH, "version")
+ versionFile = os.path.join(config.PATH, "version")
if not os.path.exists(versionFile):
return False
@@ -1018,7 +1005,7 @@ def switch_build(ver):
print("\nswitching you over to the "+build+" version...\n")
time.sleep(1)
print("...")
- versionFile = os.path.join(PATH, "version")
+ versionFile = os.path.join(config.PATH, "version")
open(versionFile, "w").write(ver)
time.sleep(1)
#print("\nall good!\n")
@@ -1028,7 +1015,7 @@ def updated():
checks to see if current user is up to the same version as system
'''
- versionFile = os.path.join(PATH, "version")
+ versionFile = os.path.join(config.PATH, "version")
if not os.path.exists(versionFile):
return False
@@ -1046,7 +1033,7 @@ def update_version():
global SETTINGS
- versionFile = os.path.join(PATH, "version")
+ versionFile = os.path.join(config.PATH, "version")
print("ttbp had some updates!")
@@ -1063,22 +1050,22 @@ def update_version():
# change style.css location
if core.publishing():
- if os.path.isfile(os.path.join(WWW, "style.css")):
- subprocess.call(["mv", os.path.join(WWW, "style.css"), CONFIG])
+ if os.path.isfile(os.path.join(config.WWW, "style.css")):
+ subprocess.call(["mv", os.path.join(config.WWW, "style.css"), config.USER_CONFIG])
# change www symlink
- if os.path.exists(WWW):
- subprocess.call(["rm", WWW])
+ if os.path.exists(config.WWW):
+ subprocess.call(["rm", config.WWW])
- subprocess.call(["mkdir", WWW])
+ subprocess.call(["mkdir", config.WWW])
- subprocess.call(["ln", "-s", os.path.join(CONFIG, "style.css"), os.path.join(WWW, "style.css")])
+ subprocess.call(["ln", "-s", os.path.join(config.USER_CONFIG, "style.css"), os.path.join(config.WWW, "style.css")])
- publishDir = os.path.join(PUBLIC, SETTINGS.get("publish dir"))
+ publishDir = os.path.join(config.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"))])
+ subprocess.call(["ln", "-s", config.WWW, os.path.join(config.PUBLIC, SETTINGS.get("publish dir"))])
# repopulate html files
core.load_files()
@@ -1088,7 +1075,7 @@ def update_version():
print("\nnew feature!\n")
SETTINGS.update({"publishing":select_publishing()})
update_publishing()
- ttbprc = open(TTBPRC, "w")
+ ttbprc = open(config.TTBPRC, "w")
ttbprc.write(json.dumps(SETTINGS, sort_keys=True, indent=2, separators=(',',':')))
ttbprc.close()
@@ -1100,7 +1087,7 @@ def update_version():
print("\nresetting your publishing settings...\n")
SETTINGS.update({"publishing":select_publishing()})
update_publishing()
- ttbprc = open(TTBPRC, "w")
+ ttbprc = open(config.TTBPRC, "w")
ttbprc.write(json.dumps(SETTINGS, sort_keys=True, indent=2, separators=(',',':')))
ttbprc.close()
@@ -1111,6 +1098,9 @@ you're all good to go, """+chatter.say("friend")+"""! please contact ~endorphant
somehing strange happened to you during this update.
""")
+ # TODO these conditionals will need to change if we increment the Y level
+ # to 10.
+
# show patch notes
#if userVersion != "0.9.0" and userVersion != "0.9.0b":
if userVersion[0:5] < "0.9.0":
@@ -1138,6 +1128,16 @@ ver 0.9.2 features:
* expanded menu for viewing your own feels (further
features to be implemented)
""")
+ if userVersion[0:5] < "0.9.3":
+ # version 0.9.3 patch notes
+ print()
+ print("""
+ version 0.9.3 features:
+ * ttbp is now packaged, making it easier to contribute to.
+ * things should otherwise be the same!
+ * check out https://github.com/modgethanc/ttbp if you'd like to contribute.
+ * takes advantage of new /var/global
+ """.lstrip())
#####
diff --git a/bin/update.py b/ttbp/update.py
similarity index 100%
rename from bin/update.py
rename to ttbp/update.py
diff --git a/bin/util.py b/ttbp/util.py
similarity index 100%
rename from bin/util.py
rename to ttbp/util.py
index 269e692..567fa8c 100644
--- a/bin/util.py
+++ b/ttbp/util.py
@@ -23,11 +23,11 @@ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
'''
-
-import inflect
-import time
import random
+import time
+
import colorama
+import inflect
## misc globals
BACKS = ['back', 'b', 'q']