Compare commits

...

2 Commits

Author SHA1 Message Date
Gitea
0fa929af41 relpath out and indexed 2021-12-12 11:48:29 +00:00
Gitea
33a12cca03 utf-8 encoding index writing 2021-12-12 11:40:31 +00:00

View File

@ -275,7 +275,7 @@ def main (args):
if "text" in versions_by_type:
try:
with open (versions_by_type["text"]["path"]) as f:
with open (versions_by_type["text"]["path"], encoding="utf-8") as f:
p["text"] = f.read()
except FileNotFoundError:
p['text'] = ''
@ -294,14 +294,13 @@ def main (args):
# Not sure this goes here but fixing relpaths with output is quite nice...
if args.output:
outpath = Path(args.output).parent
outpath = str(Path(args.output).parent)
for v in p["versions"]:
if v["type"] != "pad":
vpath = Path(v["path"])
try:
# 2 types (pathlib or os.path)
# 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?
# puttting this here since templates are using url...
@ -310,9 +309,8 @@ def main (args):
pass
if not p["link"].startswith("http"):
vpath = Path(p["link"])
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:
pass
@ -320,7 +318,7 @@ def main (args):
if args.output:
with open(args.output, "w") as f:
with open(args.output, "w", encoding="utf-8") as f:
print (template.render(vars(args)), file=f)
else:
print (template.render(vars(args)))