finish gopher support
parent
0b77ad7c6a
commit
40a2712b41
|
@ -53,12 +53,14 @@ def publish_gopher(gopher_path, entry_filenames):
|
||||||
gophermap.write(GOPHERMAP_HEADER.format(
|
gophermap.write(GOPHERMAP_HEADER.format(
|
||||||
user=getpass.getuser()))
|
user=getpass.getuser()))
|
||||||
for entry_filename in entry_filenames:
|
for entry_filename in entry_filenames:
|
||||||
gophermap.write('0{file_label}\t{filename}'.format(
|
filename = os.path.basename(entry_filename)
|
||||||
file_label=os.path.basename(entry_filename),
|
|
||||||
filename=entry_filename))
|
with open(os.path.join(ttbp_gopher, filename), 'w') as gopher_entry:
|
||||||
with open(os.path.join(ttbp_gopher, entry_filename), 'w') as gopher_entry:
|
|
||||||
with open(entry_filename, 'r') as source_entry:
|
with open(entry_filename, 'r') as source_entry:
|
||||||
gopher_entry.write(source_entry.read())
|
gopher_entry.write(source_entry.read())
|
||||||
|
gophermap.write('0{file_label}\t{filename}'.format(
|
||||||
|
file_label=os.path.basename(entry_filename),
|
||||||
|
filename=filename))
|
||||||
|
|
||||||
|
|
||||||
def setup_gopher(gopher_path):
|
def setup_gopher(gopher_path):
|
||||||
|
@ -71,9 +73,13 @@ def setup_gopher(gopher_path):
|
||||||
function.
|
function.
|
||||||
"""
|
"""
|
||||||
public_gopher = os.path.expanduser('~/public_gopher')
|
public_gopher = os.path.expanduser('~/public_gopher')
|
||||||
if not os.path.is_dir(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)")
|
print("\n\tERROR: you don't seem to have gopher set up (no public_gopher directory)")
|
||||||
return
|
return
|
||||||
|
|
||||||
ttbp_gopher = os.path.join(public_gopher, gopher_path)
|
ttbp_gopher = os.path.join(public_gopher, gopher_path)
|
||||||
os.mkdirs(ttbp_gopher)
|
if os.path.isdir(ttbp_gopher):
|
||||||
|
print("\n\tERROR: gopher path is already set up. quitting so we don't overwrite anything.")
|
||||||
|
return
|
||||||
|
|
||||||
|
os.makedirs(ttbp_gopher)
|
||||||
|
|
|
@ -393,7 +393,9 @@ def setup():
|
||||||
print("\n\ttext editor:\t" +SETTINGS.get("editor"))
|
print("\n\ttext editor:\t" +SETTINGS.get("editor"))
|
||||||
if core.publishing():
|
if core.publishing():
|
||||||
print("\tpublish dir:\t" +os.path.join(config.PUBLIC, str(SETTINGS.get("publish dir"))))
|
print("\tpublish dir:\t" +os.path.join(config.PUBLIC, str(SETTINGS.get("publish dir"))))
|
||||||
print("\tpubishing:\t"+str(SETTINGS.get("publishing"))+"\n")
|
print("\tpublishing:\t"+str(SETTINGS.get("publishing")))
|
||||||
|
print("\tgopher:\t"+str(SETTINGS.get('gopher')))
|
||||||
|
print("")
|
||||||
|
|
||||||
# editor selection
|
# editor selection
|
||||||
SETTINGS.update({"editor": select_editor()})
|
SETTINGS.update({"editor": select_editor()})
|
||||||
|
@ -410,7 +412,7 @@ def setup():
|
||||||
|
|
||||||
# gopher opt-in
|
# gopher opt-in
|
||||||
SETTINGS.update({'gopher': gopher.select_gopher()})
|
SETTINGS.update({'gopher': gopher.select_gopher()})
|
||||||
redraw('opting into gopher: ' + SETTINGS['gopher'])
|
redraw('opting into gopher: ' + str(SETTINGS['gopher']))
|
||||||
# TODO for now i'm hardcoding where people's gopher stuff is generated. if
|
# TODO for now i'm hardcoding where people's gopher stuff is generated. if
|
||||||
# there is demand for this to be configurable we can expose that.
|
# there is demand for this to be configurable we can expose that.
|
||||||
gopher.setup_gopher('feels')
|
gopher.setup_gopher('feels')
|
||||||
|
|
Loading…
Reference in New Issue