forked from expo/troggle
fix frontmatter/endmatter
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user