2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-22 07:11:52 +00:00

first attempt EtP fix for cave pages

This commit is contained in:
Philip Sargent 2021-12-30 14:15:08 +00:00
parent 1da2be03e6
commit 26454bf6c6
2 changed files with 4 additions and 1 deletions

View File

@ -121,6 +121,8 @@ def expowebpage(request, expowebpath, path):
'''Adds menus and serves an HTML page
'''
if not Path(expowebpath / path).is_file():
# Should not get here if the path has suffix "_edit"
print(f' - 404 error in expowebpage() {path}')
return render(request, 'pagenotfound.html', {'path': path}, status="404")
with open(os.path.normpath(expowebpath / path), "r") as o:
@ -264,7 +266,7 @@ def editexpopage(request, path):
filepath = Path(settings.EXPOWEB) / path
o = open(filepath, "r")
html = o.read()
autogeneratedmatch = re.search(r"\<\!--\s*(.*?(Do not edit|auto-generated).*?)\s*--\>", html, re.DOTALL + re.IGNORECASE)
autogeneratedmatch = re.search(r"\<\!--\s*(.*?(Do not edit|It is auto-generated).*?)\s*--\>", html, re.DOTALL + re.IGNORECASE)
if autogeneratedmatch:
return HttpResponse(autogeneratedmatch.group(1))
m = re.search(r"(.*)<head([^>]*)>(.*)</head>(.*)<body([^>]*)>(.*)</body>(.*)", html, re.DOTALL + re.IGNORECASE)

View File

@ -126,6 +126,7 @@ trogglepatterns = [
re_path(r'^cave/(?P<slug>[^/]+)/edit/$', caves.edit_cave, name="edit_cave"),
re_path(r'^(?P<karea>\d\d\d\d)(?P<subpath>.*)$', cavepage, name="cavepage"), # shorthand /1623/264 BUT url links break! Stop this..
# Note that urls eg '1623/161/l/rl89a.htm' are handled by cavepage which redirects them to 'expopage'
# Note that _edit$ for a cave description page in a subfolder e.g. /1623/via204.html_edit gets caught here and breaks with 404
# Entrances
re_path(r'^cave/entrance/([^/]+)/?$', caves.caveEntrance), # lists all entrances !!!BAD, local links fail