mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2025-12-16 06:57:12 +00:00
Merge branch 'python3-new' of ssh://expo.survex.com/home/expo/troggle into python3-new
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
import os
|
||||
import re
|
||||
|
||||
from sys import getfilesystemencoding as sys_getfilesystemencoding
|
||||
|
||||
from pathlib import Path
|
||||
from urllib.parse import urljoin, unquote as urlunquote
|
||||
from urllib.request import urlopen
|
||||
@@ -126,7 +129,12 @@ def expowebpage(request, expowebpath, path):
|
||||
# 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")
|
||||
|
||||
|
||||
# print(f' - {sys_getfilesystemencoding()=}')
|
||||
if (sys_getfilesystemencoding() != "utf-8"):
|
||||
return HttpResponse(default_head + '<h3>UTF-8 Parsing Failure:<br>Default file encoding on this Troggle installation is not UTF-8:<br>failure detected in expowebpage in views.expo.py</h3> Please Please reconfigure Debian/Apache/Django to fix this, i.e. contact Wookey. </body' )
|
||||
|
||||
# This next bit can be drastically simplified now that we know that the system encoding actually is utf-8
|
||||
try:
|
||||
with open(expowebpath / path, "r", encoding='utf-8') as o:
|
||||
html = o.read()
|
||||
@@ -221,9 +229,13 @@ def expopage(request, path):
|
||||
# do not redirect to a file path without the slash as we may get in a loop. Let the user fix it:
|
||||
return render(request, 'dirnotfound.html', {'path': path, 'subpath': path[0:-1]})
|
||||
|
||||
# So it must be a file in /expoweb/ but not .htm or .html probably an image
|
||||
# So it must be a file in /expoweb/ but not .htm or .html probably an image, maybe a txt file
|
||||
filetobeopened = expowebpath / path
|
||||
|
||||
|
||||
# print(f' - {sys_getfilesystemencoding()=}')
|
||||
if (sys_getfilesystemencoding() != "utf-8"):
|
||||
return HttpResponse(default_head + '<h3>UTF-8 Parsing Failure:<br>Default file encoding on this Troggle installation is not UTF-8:<br>failure detected in expowebpage in views.expo.py</h3> Please Please reconfigure Debian/Apache/Django to fix this, i.e. contact Wookey. </body' )
|
||||
|
||||
try:
|
||||
content = open(filetobeopened, "rb")
|
||||
content_type=getmimetype(path)
|
||||
@@ -279,6 +291,10 @@ def editexpopage(request, path):
|
||||
except Cave.DoesNotExist:
|
||||
pass
|
||||
|
||||
print(f' - {sys_getfilesystemencoding()=}')
|
||||
if (sys_getfilesystemencoding() != "utf-8"):
|
||||
return HttpResponse(default_head + '<h3>UTF-8 Parsing Failure:<br>Default file encoding on this Troggle installation is not UTF-8:<br>failure detected in expowebpage in views.expo.py</h3> Please Please reconfigure Debian/Apache/Django to fix this, i.e. contact Wookey. </body' )
|
||||
|
||||
try:
|
||||
filepath = Path(settings.EXPOWEB) / path
|
||||
o = open(filepath, "r", encoding="utf8")
|
||||
@@ -350,8 +366,6 @@ def editexpopage(request, path):
|
||||
pageform = ExpoPageForm({"html": body, "title": "Missing"})
|
||||
return render(request, 'editexpopage.html', {'path': path, 'form': pageform, })
|
||||
|
||||
|
||||
|
||||
class ExpoPageForm(forms.Form):
|
||||
'''The form used by the editexpopage function
|
||||
'''
|
||||
|
||||
Reference in New Issue
Block a user