summaryrefslogtreecommitdiffstats
path: root/core/utils.py
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@gmail.com>2024-12-28 22:43:21 +0000
committerPhilip Sargent <philip.sargent@gmail.com>2024-12-28 22:43:21 +0000
commite7444d20a4759cc3b1a9232c5129499ba5e1abfc (patch)
tree5974caee3e4609609d87f82d9751815bdb80b863 /core/utils.py
parentecd187e88eb4da7a15a949e46f202605928993ce (diff)
downloadtroggle-e7444d20a4759cc3b1a9232c5129499ba5e1abfc.tar.gz
troggle-e7444d20a4759cc3b1a9232c5129499ba5e1abfc.tar.bz2
troggle-e7444d20a4759cc3b1a9232c5129499ba5e1abfc.zip
cave edit working with cookies
Diffstat (limited to 'core/utils.py')
-rw-r--r--core/utils.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/core/utils.py b/core/utils.py
index 904faad..5ba1b4b 100644
--- a/core/utils.py
+++ b/core/utils.py
@@ -198,6 +198,13 @@ def parse_aliases(aliasfile):
return [(None, None)], "Fail on file reading"
return aliases, report
+def get_cookie(request):
+ NO_COOKIE_DEFAULT = 'H&ouml;hlenforscher <hohlenforscher@stonebridge.expo>'
+ print(f"-- Getting cookie...")
+ editor_id = request.COOKIES.get('editor_id', NO_COOKIE_DEFAULT) # if no cookie, then default string
+ editor = git_string(editor_id) # belt and braces, should have been validity checked on saving already
+ print(f"-- Cookie to be used: {editor=}")
+ return editor
def git_string(author_string):
"""Rewrites the supplied editor string intoa git-complient author string
@@ -207,13 +214,13 @@ def git_string(author_string):
author_regex = re.compile(r'^[a-zA-Z][\w\s\_\.\-]* <[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-_]+\.[a-zA-Z]{2,}>$')
if author_regex.match(author_string):
- print(f"Valid git-compatible author string: '{author_string}'")
+ print(f"++ Is valid git-compatible author string: '{author_string}'")
return author_string
else:
editor = author_string.replace("@","_at_")
editor = re.sub('[^0-9a-zA-Z_\.]+', '*', editor)
editor += f" <{editor}@potatohut.expo>"
- print(f"Not git-compatible author string, replacing as '{editor}'")
+ print(f"++ Not git-compatible author string '{author_string}', replacing as '{editor}'")
return editor