fixed changing publish directory
changing publish directory now correctly blanks old file and sets up new direcotry, including copying over style.css and regenerating html entries.master
parent
1ff8fe39cd
commit
ae067e4053
82
bin/_ttbp.py
82
bin/_ttbp.py
|
@ -133,7 +133,7 @@ press <enter> to begin, or <ctrl-c> to get out of here.
|
||||||
subprocess.call(["cp", os.path.join(SOURCE, "config", "defaults", "footer.txt"), CONFIG])
|
subprocess.call(["cp", os.path.join(SOURCE, "config", "defaults", "footer.txt"), CONFIG])
|
||||||
|
|
||||||
setup()
|
setup()
|
||||||
subprocess.call(["cp", os.path.join(SOURCE, "config", "defaults", "style.css"), WWW])
|
#subprocess.call(["cp", os.path.join(SOURCE, "config", "defaults", "style.css"), WWW])
|
||||||
core.load()
|
core.load()
|
||||||
|
|
||||||
raw_input("\nyou're all good to go, "+chatter.say("friend")+"! hit <enter> to continue.\n\n")
|
raw_input("\nyou're all good to go, "+chatter.say("friend")+"! hit <enter> to continue.\n\n")
|
||||||
|
@ -192,53 +192,20 @@ def setup():
|
||||||
SETTINGS.update({"editor": select_editor()})
|
SETTINGS.update({"editor": select_editor()})
|
||||||
redraw("text editor set to: "+SETTINGS["editor"])
|
redraw("text editor set to: "+SETTINGS["editor"])
|
||||||
|
|
||||||
# set up public publish option
|
# publishing selection
|
||||||
#publish = input_yn("""\
|
|
||||||
#do you want to publish your feels online?
|
|
||||||
|
|
||||||
#if yes, i'll make a directory in your public_html where your blog posts
|
|
||||||
#will be published. if not, your posts will only be readable from
|
|
||||||
#within the tilde.town network.
|
|
||||||
|
|
||||||
#you can change this option any time.
|
|
||||||
|
|
||||||
#please enter\
|
|
||||||
#""")
|
|
||||||
SETTINGS.update({"publishing":select_publishing()})
|
SETTINGS.update({"publishing":select_publishing()})
|
||||||
redraw("blog publishing: "+str(publishing()))
|
redraw("blog publishing: "+str(publishing()))
|
||||||
|
|
||||||
# publish directory selection
|
|
||||||
#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:
|
|
||||||
# choice = "blog"
|
|
||||||
|
|
||||||
#publishing = os.path.join(PUBLIC, choice)
|
|
||||||
#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: ")
|
|
||||||
# if second == "":
|
|
||||||
# break
|
|
||||||
# choice = second
|
|
||||||
# publishing = os.path.join(PUBLIC, choice)
|
|
||||||
|
|
||||||
#SETTINGS.update({"publish dir": choice})
|
|
||||||
if publishing():
|
if publishing():
|
||||||
SETTINGS.update({"publish dir": select_publish_dir()})
|
oldDir = SETTINGS.get("publish dir")
|
||||||
|
newDir = select_publish_dir()
|
||||||
# set up publish directory
|
SETTINGS.update({"publish dir": newDir})
|
||||||
#publishing = os.path.join(PUBLIC, SETTINGS.get("publish dir"))
|
make_publish_dir(newDir)
|
||||||
#if not os.path.exists(publishing):
|
subprocess.call(["rm", "-rf", os.path.join(PUBLIC, oldDir)])
|
||||||
# subprocess.call(["mkdir", publishing])
|
core.load_files()
|
||||||
# subprocess.call(["touch", os.path.join(publishing, "index.html")])
|
core.write("index.html")
|
||||||
# index = open(os.path.join(publishing, "index.html"), "w")
|
else:
|
||||||
# index.write("<h1>ttbp blog placeholder</h1>")
|
unpublish()
|
||||||
# index.close()
|
|
||||||
#if os.path.exists(WWW):
|
|
||||||
# subprocess.call(["rm", WWW])
|
|
||||||
#subprocess.call(["ln", "-s", publishing, WWW])
|
|
||||||
#print("\n\tpublishing to "+LIVE+USER+"/"+SETTINGS.get("publish dir")+"/\n\n")
|
|
||||||
make_publish_dir()
|
|
||||||
|
|
||||||
# save settings
|
# save settings
|
||||||
ttbprc = open(TTBPRC, "w")
|
ttbprc = open(TTBPRC, "w")
|
||||||
|
@ -648,8 +615,13 @@ def select_editor():
|
||||||
def select_publish_dir():
|
def select_publish_dir():
|
||||||
# setup helper for publish directory selection
|
# setup helper for publish directory selection
|
||||||
|
|
||||||
if SETTINGS["publish dir"]:
|
current = SETTINGS.get("publish dir")
|
||||||
|
republish = False
|
||||||
|
|
||||||
|
if current:
|
||||||
print("\tcurrent publish dir:\t"+os.path.join(PUBLIC, SETTINGS["publish dir"])+"\n\n")
|
print("\tcurrent publish dir:\t"+os.path.join(PUBLIC, SETTINGS["publish dir"])+"\n\n")
|
||||||
|
republish = True
|
||||||
|
|
||||||
choice = raw_input("\nwhere do you want your blog published? (leave blank to use default \"blog\") ")
|
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"
|
||||||
|
@ -667,7 +639,7 @@ def select_publish_dir():
|
||||||
def select_publishing():
|
def select_publishing():
|
||||||
# setup helper for toggling publishing
|
# setup helper for toggling publishing
|
||||||
|
|
||||||
return input_yn("""\
|
publishing = input_yn("""\
|
||||||
do you want to publish your feels online?
|
do you want to publish your feels online?
|
||||||
|
|
||||||
if yes, i'll make a directory in your public_html where your blog posts
|
if yes, i'll make a directory in your public_html where your blog posts
|
||||||
|
@ -679,10 +651,23 @@ you can change this option any time.
|
||||||
please enter\
|
please enter\
|
||||||
""")
|
""")
|
||||||
|
|
||||||
def make_publish_dir():
|
return publishing
|
||||||
# setup helper to create publishing directory
|
|
||||||
|
def unpublish():
|
||||||
|
# remove user's published directory, if it exists
|
||||||
|
|
||||||
publishing = os.path.join(PUBLIC, SETTINGS.get("publish dir"))
|
publishing = os.path.join(PUBLIC, SETTINGS.get("publish dir"))
|
||||||
|
|
||||||
|
if os.path.exists(publishing):
|
||||||
|
subprocess.call(["rm", "-rf", publishing])
|
||||||
|
subprocess.call(["rm", "-rf", WWW])
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
def make_publish_dir(dir):
|
||||||
|
# setup helper to create publishing directory
|
||||||
|
|
||||||
|
publishing = os.path.join(PUBLIC, dir)
|
||||||
if not os.path.exists(publishing):
|
if not os.path.exists(publishing):
|
||||||
subprocess.call(["mkdir", publishing])
|
subprocess.call(["mkdir", publishing])
|
||||||
subprocess.call(["touch", os.path.join(publishing, "index.html")])
|
subprocess.call(["touch", os.path.join(publishing, "index.html")])
|
||||||
|
@ -692,6 +677,7 @@ def make_publish_dir():
|
||||||
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])
|
||||||
|
subprocess.call(["cp", os.path.join(SOURCE, "config", "defaults", "style.css"), WWW])
|
||||||
print("\n\tpublishing to "+LIVE+USER+"/"+SETTINGS.get("publish dir")+"/\n\n")
|
print("\n\tpublishing to "+LIVE+USER+"/"+SETTINGS.get("publish dir")+"/\n\n")
|
||||||
|
|
||||||
#####
|
#####
|
||||||
|
|
Loading…
Reference in New Issue