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

make some pages sensitive to current_expo()

This commit is contained in:
Philip Sargent 2024-07-08 20:22:42 +02:00
parent 35e6bbe1ac
commit a68ef27284
2 changed files with 27 additions and 4 deletions

View File

@ -14,7 +14,7 @@ from django.views.decorators.csrf import ensure_csrf_cookie
import troggle.core.views.caves
import troggle.settings as settings
from troggle.core.models.caves import Cave
from troggle.core.utils import WriteAndCommitError, write_and_commit
from troggle.core.utils import WriteAndCommitError, write_and_commit, current_expo
from troggle.core.views.editor_helpers import HTMLarea
from troggle.core.views.uploads import edittxtpage
@ -132,7 +132,27 @@ def expofilesdir(request, dirpath, filepath):
{"filepath": urlpath, "fileitems": fileitems, "diritems": diritems, "settings": settings},
)
def pubspage(request):
"""This is a single-page function, specifically to cope with the updated "current year"
which is hard-coded into the HTML of the page.
This is a placeholder, we need to do something like what is done in indexpage() below...
"""
expowebpath = Path(settings.EXPOWEB)
return expowebpage(request, expowebpath, "pubs.htm")
def indexpage(request):
"""This is a single-page function, specifically to cope with the updated "current year"
which is hard-coded into the HTML of the page.
This edits the most recent year on the fly..
This now works.
"""
subpath = Path(settings.EXPOWEB) / "index00.htm"
with open(subpath, "r") as o:
html = o.read()
html = html.replace('2xxx', f"{current_expo()}")
content_type = "text/html"
return HttpResponse(html, content_type=content_type)
def expowebpage(request, expowebpath, path):
"""Adds menus and serves an HTML page"""
if not os.path.isfile(expowebpath / path):
@ -236,7 +256,7 @@ def mediapage(request, subpath=None, doc_root=None):
"""This is for special prefix paths /photos/ /site_media/, /static/ etc.
as defined in urls.py . If given a directory, gives a failure page.
"""
# print(" - XXXXX_ROOT: {} ...{}".format(doc_root, subpath))
print("mediapath", subpath)
if doc_root is not None:
filetobeopened = Path(doc_root, subpath)
if filetobeopened.is_dir():

View File

@ -11,7 +11,7 @@ from troggle.core.views.caves import (cave3d, caveindex, entranceindex, caveslis
edit_entrance, get_entrances, qm, expo_kml, expo_kmz)
from troggle.core.views.drawings import dwgallfiles, dwgfilesingle
from troggle.core.views.editor_helpers import image_selector, new_image_form
from troggle.core.views.expo import (editexpopage, expofiles_redirect,
from troggle.core.views.expo import (pubspage, indexpage, editexpopage, expofiles_redirect,
expofilessingle, expopage, map, mapfile,
mediapage, spider)
from troggle.core.views.logbooks import (QMs_jsonListView, Expeditions_jsonListView,
@ -91,6 +91,9 @@ else:
# /home/philip/p11d5/lib/python3.11/site-packages/django/contrib/admin/sites.py
trogglepatterns = [
path('pubs.htm', pubspage, name="pubspage"), # ~165 hrefs to this url in expoweb files
path('index.htm', indexpage, name="indexpage"), # ~1,212 hrefs to this url in expoweb files
path('expofiles/', include(expofilesurls)), # intercepted by Apache, if it is running.
path('expofiles', include(expofilesurls)), # curious interaction with the include() here, not just a slash problem.