From 12310e3b835ae8012131ba93be1b9991293bbe07 Mon Sep 17 00:00:00 2001 From: trinkey <97406176+trinkey@users.noreply.github.com> Date: Thu, 22 Feb 2024 19:42:05 -0500 Subject: [PATCH] add some stuff and whatnot --- README.md | 6 +----- _server.py | 23 +++++++++++++++++------ public/404.html | 16 ++++++++++++++++ public/js/editor.js | 4 +++- public/js/user.js | 2 +- public/user.html | 4 ++-- 6 files changed, 40 insertions(+), 15 deletions(-) create mode 100644 public/404.html diff --git a/README.md b/README.md index 82b1219..947b02a 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,8 @@ # infopage -or https://infpg.pythonanywhere.com +or https://infopg.web.app it's like pronouns.page but i made it ### todo * social links * sexuality/gender flags -* 404 page -* embed meta tags -* short url redir -* make displ name default to `x["username"]` \ No newline at end of file diff --git a/_server.py b/_server.py index fcc6fbf..674868b 100644 --- a/_server.py +++ b/_server.py @@ -15,6 +15,16 @@ from werkzeug.middleware.proxy_fix import ProxyFix app = flask.Flask(__name__) +def validate_color(color: str) -> bool: + if len(color) != 7 or color[0] != "#": + return False + + for i in color[1::]: + if i not in "abcdef0123456789": + return False + + return True + def sort_list(l: list[list[str]]) -> list[list[str]]: output = [] for i in l: @@ -128,7 +138,7 @@ def api_account_signup(): except KeyError: flask.abort(400) - if len(username) > 24 or len(username) < 1: + if len(x["username"]) > 24 or len(x["username"]) < 1: flask.abort(400) if len(passhash) != 64: @@ -158,7 +168,7 @@ def api_account_signup(): ensure_file(f"{SAVING_DIRECTORY}tokens/{token}.txt", default_value=username) ensure_file(f"{SAVING_DIRECTORY}{username}.json", default_value=json.dumps({ "username": username, - "display_name": username, + "display_name": x["username"], "description": "", "colors": { "accent": "#ff0000", @@ -192,7 +202,8 @@ def api_account_signup(): ["hot", "3"], ["pretty", "3"], ["sexy", "3"] - ], "relationship": [ + ], + "relationship": [ ["beloved", "3"], ["boyfriend", "3"], ["darling", "3"], @@ -243,13 +254,13 @@ def api_save(): user_data["description"] = x["description"] if "colors" in x: - if "accent" in x["colors"]: + if "accent" in x["colors"] and validate_color(x["colors"]["accent"]): user_data["colors"]["accent"] = x["colors"]["accent"] - if "background" in x["colors"]: + if "background" in x["colors"] and validate_color(x["colors"]["background"]): user_data["colors"]["background"] = x["colors"]["background"] - if "text" in x["colors"]: + if "text" in x["colors"] and validate_color(x["colors"]["text"]): user_data["colors"]["text"] = x["colors"]["text"] if "names" in x: diff --git a/public/404.html b/public/404.html new file mode 100644 index 0000000..4f7da04 --- /dev/null +++ b/public/404.html @@ -0,0 +1,16 @@ + + + +
+