diff options
author | Philip Sargent <philip.sargent@gmail.com> | 2022-12-16 19:57:56 +0000 |
---|---|---|
committer | Philip Sargent <philip.sargent@gmail.com> | 2022-12-16 19:57:56 +0000 |
commit | f80e4efed8b6a329a7c92b9e0c68bb12faa9b517 (patch) | |
tree | 76503a47a8926f2c026887c3c149d65cda778870 /core/views/other.py | |
parent | 5e9fd7fd77f2e94f433e9fa530b3c3e098d3dfa9 (diff) | |
download | troggle-f80e4efed8b6a329a7c92b9e0c68bb12faa9b517.tar.gz troggle-f80e4efed8b6a329a7c92b9e0c68bb12faa9b517.tar.bz2 troggle-f80e4efed8b6a329a7c92b9e0c68bb12faa9b517.zip |
parse several UK caving blogs per year - working
Diffstat (limited to 'core/views/other.py')
-rw-r--r-- | core/views/other.py | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/core/views/other.py b/core/views/other.py index 88d0589..b590f21 100644 --- a/core/views/other.py +++ b/core/views/other.py @@ -27,11 +27,9 @@ Also has code to download a logbook in a choice of formats (why?!) ''' todo = ''' -- Check that the logbookdownloader works by testing with a round trip. -- Use it to convert all older logbooks into the 2005-variant of HTML then we can - get rid of the parsers for older formats. There are no images stored in the database, - so this is only a tool for a first pass, to be followed by extensive hand-editing! +- Use logbookdownloader to convert all older logbooks into the 2005-variant of HTML then we can + get rid of the parsers for older formats. When we have done all the old logbooks, delete this function and the two templates. @@ -152,7 +150,7 @@ def exportlogbook(request,year=None,extension=None): for the current year. Formats available are HTML2005 (others old & broken or not written yet) There are no images stored in the database, so this is only a tool for a first pass, to be followed by - hand-editing. However links to images work int he HTML text of a logbook entry + hand-editing. However links to images work in the HTML text of a logbook entry NEED TO ADD IN THE MATERIAL WHICH IS NOT IN ANY LBE ! e.g. front matter. @@ -183,6 +181,18 @@ 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})) + + frontpath = Path(settings.EXPOWEB, "years", year, "frontmatter.html") + if frontpath.is_file(): + try: + with open(frontpath,"r") as front: + frontmatter = front.read() + except: + print(" ! Very Bad Error opening " + frontpath) + logbookfile = re.sub(r"<body>", "<body>\n"+frontmatter , logbookfile) + else: + logbookfile = re.sub(r"<body>", f"<body>\n<h1>Expo {year}</h1>\n", logbookfile) + dir = Path(settings.EXPOWEB) / "years" / year filepath = Path(dir, filename) |