2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2025-12-17 07:27:19 +00:00

fix frontmatter/endmatter

This commit is contained in:
2022-12-21 02:05:26 +00:00
parent 517da57a0c
commit ec040824f6
3 changed files with 61 additions and 18 deletions

View File

@@ -181,7 +181,16 @@ def exportlogbook(request,year=None,extension=None):
response['Content-Disposition'] = 'attachment; filename='+filename
t=loader.get_template(template)
logbookfile = (t.render({'logbook_entries':logbook_entries}))
endpath = Path(settings.EXPOWEB, "years", year, "endmatter.html")
endmatter = ""
if endpath.is_file():
try:
with open(endpath,"r") as end:
endmatter = end.read()
except:
print(" ! Very Bad Error opening " + endpath)
frontpath = Path(settings.EXPOWEB, "years", year, "frontmatter.html")
if frontpath.is_file():
try:
@@ -189,9 +198,9 @@ def exportlogbook(request,year=None,extension=None):
frontmatter = front.read()
except:
print(" ! Very Bad Error opening " + frontpath)
logbookfile = re.sub(r"<body>", "<body>\n"+frontmatter , logbookfile)
logbookfile = re.sub(r"<body>", "<body>\n"+frontmatter+endmatter , logbookfile)
else:
logbookfile = re.sub(r"<body>", f"<body>\n<h1>Expo {year}</h1>\n", logbookfile)
logbookfile = re.sub(r"<body>", f"<body>\n<h1>Expo {year}</h1>\n"+endmatter, logbookfile)
dir = Path(settings.EXPOWEB) / "years" / year