making some gopher directory adjustments

master
Vincent Zeng 2017-12-31 13:40:20 -05:00
parent 22c03ccc75
commit 844d103041
3 changed files with 15 additions and 10 deletions

View File

@ -67,6 +67,7 @@ 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_PATH = os.path.join(USER_HOME, 'public_gopher', 'feels')
USER_CONFIG = os.path.join(PATH, 'config')
TTBPRC = os.path.join(USER_CONFIG, 'ttbprc')
USER_DATA = os.path.join(PATH, 'entries')

View File

@ -70,13 +70,6 @@ def publish_gopher(gopher_path, entry_filenames):
for entry_filename in entry_filenames:
filename = os.path.basename(entry_filename)
''' old file copying bit
with open(os.path.join(ttbp_gopher, filename), 'w') as gopher_entry:
with open(entry_filename, 'r') as source_entry:
gopher_entry.write(source_entry.read())
'''
# symlink instead
gopher_entry_symlink = os.path.join(ttbp_gopher, os.path.basename(entry_filename))
if not os.path.exists(gopher_entry_symlink):
subprocess.call(["ln", "-s", entry_filename, gopher_entry_symlink])
@ -86,7 +79,6 @@ def publish_gopher(gopher_path, entry_filenames):
file_label=label,
filename=filename))
def setup_gopher(gopher_path):
"""Given a path relative to ~/public_gopher, this function:
@ -97,11 +89,16 @@ def setup_gopher(gopher_path):
function.
"""
public_gopher = os.path.expanduser('~/public_gopher')
if not os.path.isdir(public_gopher):
"""
print("\n\tERROR: you don't seem to have gopher set up (no public_gopher directory)")
return
"""
os.makedirs(public_gopher)
ttbp_gopher = os.path.join(public_gopher, gopher_path)
if os.path.isdir(ttbp_gopher):
print("\n\tERROR: gopher path is already set up. quitting so we don't overwrite anything.")
return

View File

@ -1014,14 +1014,21 @@ please enter\
return publish
def unpublish():
'''remove all published entries in html and gopher.
'''
remove user's published directory, if it exists. this should only remove the symlink in public_html.
'''
global SETTINGS
directory = SETTINGS.get("publish dir")
if directory:
publishDir = os.path.join(config.PUBLIC, directory)
subprocess.call(["rm", publishDir])
if SETTINGS.get("gopher"):
SETTINGS.update({"gopher": False})
subprocess.call(["rm", config.GOPHER_PATH])
def update_publishing():
'''
updates publishing directory if user is publishing. otherwise, wipe it.