mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2025-12-17 14:27:12 +00:00
initial text file editing stuff
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user