diff --git a/ttbp/config/__init__.py b/ttbp/config/__init__.py index 860266e..ee66099 100644 --- a/ttbp/config/__init__.py +++ b/ttbp/config/__init__.py @@ -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 diff --git a/ttbp/gopher.py b/ttbp/gopher.py index a8fbb7b..17f02a3 100644 --- a/ttbp/gopher.py +++ b/ttbp/gopher.py @@ -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]) diff --git a/ttbp/ttbp.py b/ttbp/ttbp.py index e92d1db..2c13d88 100644 --- a/ttbp/ttbp.py +++ b/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,10 +985,12 @@ 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(""" account deleted! if you ever want to come back, you're always welcome to start @@ -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("