relpath out and indexed

This commit is contained in:
Gitea 2021-12-12 11:48:29 +00:00
parent 33a12cca03
commit 0fa929af41

View File

@ -294,14 +294,13 @@ def main (args):
# Not sure this goes here but fixing relpaths with output is quite nice... # Not sure this goes here but fixing relpaths with output is quite nice...
if args.output: if args.output:
outpath = Path(args.output).parent outpath = str(Path(args.output).parent)
for v in p["versions"]: for v in p["versions"]:
if v["type"] != "pad": if v["type"] != "pad":
vpath = Path(v["path"])
try: try:
# 2 types (pathlib or os.path) # 2 types (pathlib or os.path)
# v["path"] = vpath.parent.relative_to(outpath).joinpath(vpath.name) # v["path"] = vpath.parent.relative_to(outpath).joinpath(vpath.name)
v["path"] = os.path.join(os.path.relpath(vpath.parent, outpath), vpath.name) v["path"] = os.path.relpath(v["path"], outpath)
# path or url??? if it's a file based publishing ethos, it should be path non? # path or url??? if it's a file based publishing ethos, it should be path non?
# puttting this here since templates are using url... # puttting this here since templates are using url...
@ -310,9 +309,8 @@ def main (args):
pass pass
if not p["link"].startswith("http"): if not p["link"].startswith("http"):
vpath = Path(p["link"])
try: try:
p["link"] = os.path.join(os.path.relpath(vpath.parent, outpath), vpath.name) p["link"] = os.path.relpath(p["link"], outpath)
except Exception as e: except Exception as e:
pass pass