summaryrefslogtreecommitdiffstats
path: root/core/views/expo.py
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@gmail.com>2024-07-03 11:48:38 +0300
committerPhilip Sargent <philip.sargent@gmail.com>2024-07-03 11:48:38 +0300
commitcb81a066dbbc61bd55adac3180533eaf8f073064 (patch)
tree6d6d493765723bfceac160c4815804f9da1fe336 /core/views/expo.py
parent704ff8335dc78b497586e773c4ed7a596672b920 (diff)
downloadtroggle-cb81a066dbbc61bd55adac3180533eaf8f073064.tar.gz
troggle-cb81a066dbbc61bd55adac3180533eaf8f073064.tar.bz2
troggle-cb81a066dbbc61bd55adac3180533eaf8f073064.zip
initial text file editing stuff
Diffstat (limited to 'core/views/expo.py')
-rw-r--r--core/views/expo.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/core/views/expo.py b/core/views/expo.py
index fadc6ed..4902502 100644
--- a/core/views/expo.py
+++ b/core/views/expo.py
@@ -16,12 +16,15 @@ import troggle.settings as settings
from troggle.core.models.caves import Cave
from troggle.core.utils import WriteAndCommitError, write_and_commit
from troggle.core.views.editor_helpers import HTMLarea
+from troggle.core.views.uploads import edittxtpage
from .auth import login_required_if_public
"""Formerly a separate package called 'flatpages' written by Martin Green 2011.
This was NOT django.contrib.flatpages which stores HTML in the database, so the name was changed to expopages.
Then it was incorporated into troggle directly, rather than being an unnecessary external package.
+
+This is a succession of hacks and needs to be redisgned and refactored.
"""
default_head = """<head>
@@ -356,7 +359,7 @@ def getmimetype(path):
return "application/zip"
return ""
-
+
@login_required_if_public
@ensure_csrf_cookie
def editexpopage(request, path):
@@ -377,6 +380,12 @@ def editexpopage(request, path):
+ "<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"
)
+ # detect if this is a text file for editing
+ filepath = Path(settings.EXPOWEB) / path
+ if filepath.suffix == ".txt":
+ print("Editing TEXT file", filepath)
+ return edittxtpage(request, path, filepath)
+
try:
filepath = Path(settings.EXPOWEB) / path
o = open(filepath, "r", encoding="utf8")