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')
|
||||
PUBLIC = os.path.join(USER_HOME, 'public_html')
|
||||
WWW = os.path.join(PATH, 'www')
|
||||
GOPHER_ENTRIES = os.path.join(PATH, 'gopher')
|
||||
GOPHER_PATH = os.path.join(USER_HOME, 'public_gopher', 'feels')
|
||||
USER_CONFIG = os.path.join(PATH, 'config')
|
||||
TTBPRC = os.path.join(USER_CONFIG, 'ttbprc')
|
||||
MAIN_FEELS = os.path.join(PATH, 'entries')
|
||||
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')
|
||||
|
||||
## UI
|
||||
|
|
|
@ -7,6 +7,7 @@ import time
|
|||
import subprocess
|
||||
|
||||
from . import util
|
||||
from . import config
|
||||
#from .core import parse_date
|
||||
|
||||
GOPHER_PROMPT = """
|
||||
|
@ -107,3 +108,11 @@ def setup_gopher(gopher_path):
|
|||
os.makedirs(gopher_entries)
|
||||
|
||||
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])
|
||||
|
|
32
ttbp/ttbp.py
32
ttbp/ttbp.py
|
@ -926,6 +926,7 @@ type the following purge code:
|
|||
print("...")
|
||||
time.sleep(0.5)
|
||||
unpublish()
|
||||
|
||||
if not subprocess.call(["rm", "-rf", config.MAIN_FEELS]):
|
||||
subprocess.call(["mkdir", config.MAIN_FEELS])
|
||||
core.load_files()
|
||||
|
@ -984,9 +985,11 @@ purge code:
|
|||
print("...")
|
||||
time.sleep(0.5)
|
||||
unpublish()
|
||||
publishDir = os.path.join(config.PUBLIC, SETTINGS.get("publish dir"))
|
||||
if os.path.exists(publishDir):
|
||||
subprocess.call(["rm", "-rf", publishDir])
|
||||
|
||||
if core.publishing():
|
||||
publishDir = os.path.join(config.PUBLIC, SETTINGS.get("publish dir"))
|
||||
make_publish_dir(publishDir)
|
||||
|
||||
|
||||
if not subprocess.call(["rm", "-rf", config.PATH]):
|
||||
print("""
|
||||
|
@ -1525,12 +1528,12 @@ def unpublish():
|
|||
publishDir = os.path.join(config.PUBLIC, directory)
|
||||
if os.path.exists(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})
|
||||
|
||||
if SETTINGS.get("gopher"):
|
||||
#SETTINGS.update({"gopher": False})
|
||||
subprocess.call(["rm", config.GOPHER_PATH])
|
||||
gopher.unpublish()
|
||||
|
||||
def update_publishing():
|
||||
'''
|
||||
|
@ -1553,7 +1556,7 @@ def update_publishing():
|
|||
|
||||
core.load(SETTINGS)
|
||||
|
||||
def make_publish_dir(dir):
|
||||
def make_publish_dir(publish_dir):
|
||||
'''
|
||||
setup helper to create publishing directory
|
||||
'''
|
||||
|
@ -1566,13 +1569,18 @@ def make_publish_dir(dir):
|
|||
index.write("<h1>ttbp blog placeholder</h1>")
|
||||
index.close()
|
||||
|
||||
publishDir = os.path.join(config.PUBLIC, dir)
|
||||
if os.path.exists(publishDir):
|
||||
subprocess.call(["rm", publishDir])
|
||||
if core.publishing():
|
||||
live = os.path.join(config.PUBLIC, publish_dir)
|
||||
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():
|
||||
'''
|
||||
|
|
Loading…
Reference in New Issue