forked from endorphant/ttbp
cleaning up gopher/html publish/unpublish behavior for purging and loading
backupsmaster
parent
48e61c9227
commit
e1359d3899
|
@ -68,12 +68,13 @@ USER_HOME = os.path.expanduser('~')
|
||||||
PATH = os.path.join(USER_HOME, '.ttbp')
|
PATH = os.path.join(USER_HOME, '.ttbp')
|
||||||
PUBLIC = os.path.join(USER_HOME, 'public_html')
|
PUBLIC = os.path.join(USER_HOME, 'public_html')
|
||||||
WWW = os.path.join(PATH, 'www')
|
WWW = os.path.join(PATH, 'www')
|
||||||
|
GOPHER_ENTRIES = os.path.join(PATH, 'gopher')
|
||||||
GOPHER_PATH = os.path.join(USER_HOME, 'public_gopher', 'feels')
|
GOPHER_PATH = os.path.join(USER_HOME, 'public_gopher', 'feels')
|
||||||
USER_CONFIG = os.path.join(PATH, 'config')
|
USER_CONFIG = os.path.join(PATH, 'config')
|
||||||
TTBPRC = os.path.join(USER_CONFIG, 'ttbprc')
|
TTBPRC = os.path.join(USER_CONFIG, 'ttbprc')
|
||||||
MAIN_FEELS = os.path.join(PATH, 'entries')
|
MAIN_FEELS = os.path.join(PATH, 'entries')
|
||||||
BURIED_FEELS = os.path.join(PATH, 'buried')
|
BURIED_FEELS = os.path.join(PATH, 'buried')
|
||||||
NOPUB = os.path.join(USER_CONFIG, "nopub")
|
NOPUB = os.path.join(USER_CONFIG, 'nopub')
|
||||||
BACKUPS = os.path.join(PATH, 'backups')
|
BACKUPS = os.path.join(PATH, 'backups')
|
||||||
|
|
||||||
## UI
|
## UI
|
||||||
|
|
|
@ -7,6 +7,7 @@ import time
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
from . import util
|
from . import util
|
||||||
|
from . import config
|
||||||
#from .core import parse_date
|
#from .core import parse_date
|
||||||
|
|
||||||
GOPHER_PROMPT = """
|
GOPHER_PROMPT = """
|
||||||
|
@ -107,3 +108,11 @@ def setup_gopher(gopher_path):
|
||||||
os.makedirs(gopher_entries)
|
os.makedirs(gopher_entries)
|
||||||
|
|
||||||
subprocess.call(["ln", "-s", gopher_entries, ttbp_gopher])
|
subprocess.call(["ln", "-s", gopher_entries, ttbp_gopher])
|
||||||
|
|
||||||
|
def unpublish():
|
||||||
|
"""blanks all gopher things and recreates the directories."""
|
||||||
|
|
||||||
|
subprocess.call(["rm", "-rf", config.GOPHER_PATH])
|
||||||
|
subprocess.call(["rm", "-rf", config.GOPHER_ENTRIES])
|
||||||
|
os.mkdir(config.GOPHER_ENTRIES)
|
||||||
|
subprocess.call(["ln", "-s", config.GOPHER_ENTRIES, config.GOPHER_PATH])
|
||||||
|
|
30
ttbp/ttbp.py
30
ttbp/ttbp.py
|
@ -926,6 +926,7 @@ type the following purge code:
|
||||||
print("...")
|
print("...")
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
unpublish()
|
unpublish()
|
||||||
|
|
||||||
if not subprocess.call(["rm", "-rf", config.MAIN_FEELS]):
|
if not subprocess.call(["rm", "-rf", config.MAIN_FEELS]):
|
||||||
subprocess.call(["mkdir", config.MAIN_FEELS])
|
subprocess.call(["mkdir", config.MAIN_FEELS])
|
||||||
core.load_files()
|
core.load_files()
|
||||||
|
@ -984,9 +985,11 @@ purge code:
|
||||||
print("...")
|
print("...")
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
unpublish()
|
unpublish()
|
||||||
|
|
||||||
|
if core.publishing():
|
||||||
publishDir = os.path.join(config.PUBLIC, SETTINGS.get("publish dir"))
|
publishDir = os.path.join(config.PUBLIC, SETTINGS.get("publish dir"))
|
||||||
if os.path.exists(publishDir):
|
make_publish_dir(publishDir)
|
||||||
subprocess.call(["rm", "-rf", publishDir])
|
|
||||||
|
|
||||||
if not subprocess.call(["rm", "-rf", config.PATH]):
|
if not subprocess.call(["rm", "-rf", config.PATH]):
|
||||||
print("""
|
print("""
|
||||||
|
@ -1525,12 +1528,12 @@ def unpublish():
|
||||||
publishDir = os.path.join(config.PUBLIC, directory)
|
publishDir = os.path.join(config.PUBLIC, directory)
|
||||||
if os.path.exists(publishDir):
|
if os.path.exists(publishDir):
|
||||||
subprocess.call(["rm", "-rf", publishDir])
|
subprocess.call(["rm", "-rf", publishDir])
|
||||||
#make_publish_dir(directory)
|
subprocess.call(["rm", "-rf", config.WWW])
|
||||||
|
make_publish_dir(SETTINGS.get("publish dir"))
|
||||||
#SETTINGS.update({"publish dir": None})
|
#SETTINGS.update({"publish dir": None})
|
||||||
|
|
||||||
if SETTINGS.get("gopher"):
|
if SETTINGS.get("gopher"):
|
||||||
#SETTINGS.update({"gopher": False})
|
gopher.unpublish()
|
||||||
subprocess.call(["rm", config.GOPHER_PATH])
|
|
||||||
|
|
||||||
def update_publishing():
|
def update_publishing():
|
||||||
'''
|
'''
|
||||||
|
@ -1553,7 +1556,7 @@ def update_publishing():
|
||||||
|
|
||||||
core.load(SETTINGS)
|
core.load(SETTINGS)
|
||||||
|
|
||||||
def make_publish_dir(dir):
|
def make_publish_dir(publish_dir):
|
||||||
'''
|
'''
|
||||||
setup helper to create publishing directory
|
setup helper to create publishing directory
|
||||||
'''
|
'''
|
||||||
|
@ -1566,13 +1569,18 @@ def make_publish_dir(dir):
|
||||||
index.write("<h1>ttbp blog placeholder</h1>")
|
index.write("<h1>ttbp blog placeholder</h1>")
|
||||||
index.close()
|
index.close()
|
||||||
|
|
||||||
publishDir = os.path.join(config.PUBLIC, dir)
|
if core.publishing():
|
||||||
if os.path.exists(publishDir):
|
live = os.path.join(config.PUBLIC, publish_dir)
|
||||||
subprocess.call(["rm", publishDir])
|
if os.path.exists(live):
|
||||||
|
subprocess.call(["rm", live])
|
||||||
|
|
||||||
subprocess.call(["ln", "-s", config.WWW, publishDir])
|
subprocess.call(["ln", "-s", config.WWW, live])
|
||||||
|
|
||||||
print("\n\tpublishing to "+config.LIVE+config.USER+"/"+SETTINGS.get("publish dir")+"/\n\n")
|
return "\n\tpublishing to "+config.LIVE+config.USER+"/"+SETTINGS.get("publish dir")+"/\n\n"
|
||||||
|
|
||||||
|
else:
|
||||||
|
return ""
|
||||||
|
#print("\n\tpublishing to "+config.LIVE+config.USER+"/"+SETTINGS.get("publish dir")+"/\n\n")
|
||||||
|
|
||||||
def update_gopher():
|
def update_gopher():
|
||||||
'''
|
'''
|
||||||
|
|
Loading…
Reference in New Issue