path fixes in ship view
This commit is contained in:
parent
e21eb55e67
commit
d46244ff93
7
app.py
7
app.py
|
@ -158,6 +158,7 @@ def ship(request,ship=None):
|
|||
global DESC_PRE_SHIPS
|
||||
if ship is None: return Response(Status.BAD_REQUEST,"Bad Request")
|
||||
ship_unquoted = urllib.parse.unquote(ship)
|
||||
urlencoded = urllib.parse.quote(ship,safe='')
|
||||
if not os.path.isdir(os.path.join("/var/gopher",ship_unquoted)): return Response(Status.NOT_FOUND,"Not Found")
|
||||
def __generator():
|
||||
description = os.path.join("/var/gopher",ship_unquoted,".description")
|
||||
|
@ -171,7 +172,7 @@ def ship(request,ship=None):
|
|||
yield "```"
|
||||
yield "\n"
|
||||
if os.path.exists(os.path.join("/var/gopher",ship_unquoted,"AUTHOR")):
|
||||
yield f"=> /{ship}/AUTHOR Author {ship_unquoted}\n"
|
||||
yield f"=> /{urlencoded}/AUTHOR Author {ship_unquoted}\n"
|
||||
yield f"# {ship_unquoted} - Ship Log\n"
|
||||
yield from reverse_listing_generator(filter_line=lambda line: line.startswith("0"+ship_unquoted))
|
||||
yield '\n\n'
|
||||
|
@ -180,7 +181,7 @@ def ship(request,ship=None):
|
|||
if os.path.exists(author_file):
|
||||
with open(author_file) as f:
|
||||
author = f.readline().strip()
|
||||
yield f"=> /{ship}/AUTHOR © {year} {author}\n"
|
||||
yield f"=> /{urlencoded}/AUTHOR © {year} {author}\n"
|
||||
else:
|
||||
username = (subprocess.run(["/usr/bin/stat","-c","%U",os.path.join("/var/gopher",ship_unquoted)],stdout=subprocess.PIPE).stdout or b"unknown").decode("utf-8").strip()
|
||||
yield f"© {year} {username}\n"
|
||||
|
@ -188,7 +189,7 @@ def ship(request,ship=None):
|
|||
if os.path.exists(license_file):
|
||||
with open(license_file) as f:
|
||||
license_name = f.readline().strip()
|
||||
yield f"=> /{ship}/LICENSE {license_name}\n"
|
||||
yield f"=> /{urlencoded}/LICENSE {license_name}\n"
|
||||
else:
|
||||
yield "All rights reserved.\n"
|
||||
return __generator()
|
||||
|
|
Loading…
Reference in New Issue