From 153fb4e2a2af5c3b668c4f0a785e6a6430585853 Mon Sep 17 00:00:00 2001 From: justcool393 Date: Mon, 21 Nov 2022 00:52:22 -0800 Subject: [PATCH] [DO NOT MERGE] titlesssssssssss (#468) * titles * testing * self * Revert "self" This reverts commit d6c12d5a5ba125feb44673f55e1fdac75f151cb5. * Revert "testing" This reverts commit 86d800f9fd552196b31f0e0b3891d4fc072a9bc0. * testing on devrama * rewrite the html head * reference error or smth idk * tempalte debug * template debug redux * default2 * rename default2 -> root, page title * fix settings2 * include the set_variables block * root scope variables 2 * test 3 * remove unnecessary set * add pagetitles to all settings2 pages * add pagetitle to casino * remove bloat * remove duplicate site name thingy * page titles 2 * page titles 3 * remove duplicate imports and add page titles everywhere iirc * ok but actually this time * remove unnecessary newlines * fix title lol * > * fsdfsfsfsfsfs * fsfs * template configurations * fix 500 * reduce login template bloat * move files and add status codes where needful * move authfroms to login * remove 2fa bloat * verification code * sign up fixes * readability * fssfsfsfs * move forgot password to login/ * readability * don't emit comments * add page titles where needful * gsgsgs * modals: move to respective pages * testing on devrama * get home garbage out of title * remove insane amount of icon duplication * sign up text * add votes pagetitle * fix blank lines * Revert "fix blank lines" This reverts commit b2c54339970725d00b6fc82bb458c1757909952c. * Fix blank lines on sign_up.html. * title: votes.html more meaningful identifier. * titles: Lottery, Directory, Notifications * head final in submission.html * fix missing comma * > * test * title: /comments * fsfsfsfsf * titles: user_cards * head: only load video and audio meta attributes if they actually exist * titlessssss: /admin/lottery/participants * titlessssssss: extra quote in search.html * titlessssss: userpage voters. * titties: /h//{followers,blockers,exilees[sic]} * test banner * Revert "test banner" This reverts commit c3d875d03f3e60d72a60dab7d28bf108554a5826. * make submit.html inherit from default.html Co-authored-by: TLSM --- files/routes/admin.py | 1 + files/routes/hats.py | 1 + files/routes/login.py | 48 +++-- files/routes/users.py | 1 + files/templates/admin/admin_home.html | 2 +- files/templates/admin/alts.html | 2 +- files/templates/admin/badge_admin.html | 15 +- files/templates/admin/banned_domains.html | 5 +- files/templates/admin/loggedin.html | 2 +- files/templates/admin/loggedout.html | 2 +- files/templates/admin/lottery.html | 2 +- files/templates/admin/shadowbanned.html | 2 +- files/templates/app.html | 6 +- files/templates/badges.html | 1 + files/templates/banned.html | 2 +- files/templates/blocks.html | 2 - files/templates/casino.html | 2 +- files/templates/casino/game_screen.html | 4 +- files/templates/casino/rehab.html | 5 +- files/templates/chat.html | 13 +- files/templates/chuds.html | 3 +- files/templates/default.html | 91 +++------- files/templates/donate_PCM.html | 6 +- files/templates/donate_rDrama.html | 6 +- files/templates/forgot_password.html | 28 --- files/templates/grassed.html | 2 +- files/templates/hats.html | 2 +- files/templates/home.html | 57 +++--- files/templates/home_comments.html | 1 + files/templates/live.html | 6 +- files/templates/login.html | 76 -------- files/templates/{ => login}/authforms.html | 43 ++--- files/templates/login/forgot_password.html | 15 ++ files/templates/login/login.html | 42 +++++ files/templates/login/login_2fa.html | 33 ++++ files/templates/login/lost_2fa.html | 17 ++ files/templates/login/reset_password.html | 17 ++ files/templates/login/sign_up.html | 117 ++++++++++++ files/templates/login/sign_up_failed_ref.html | 25 +++ files/templates/login_2fa.html | 78 -------- files/templates/lost_2fa.html | 35 ---- files/templates/lottery.html | 11 +- files/templates/marseys.html | 2 + files/templates/megathread_index.html | 3 +- files/templates/message_success.html | 7 +- files/templates/mine.html | 39 ---- files/templates/modals/2fa.html | 54 ++++++ files/templates/modals/blockuser.html | 22 +++ files/templates/notifications.html | 10 +- files/templates/patrons.html | 2 +- files/templates/reset_password.html | 33 ---- files/templates/root.html | 32 ++++ files/templates/search.html | 31 +--- files/templates/search_users.html | 2 - files/templates/settings.html | 92 +--------- files/templates/settings/advanced.html | 3 +- files/templates/settings/apps.html | 2 +- files/templates/settings/css.html | 2 +- files/templates/settings/personal.html | 3 +- files/templates/settings/security.html | 26 +-- files/templates/settings2.html | 55 ++---- files/templates/shop.html | 2 +- files/templates/sign_up.html | 139 --------------- files/templates/sign_up_failed_ref.html | 55 ------ files/templates/stats.html | 2 +- files/templates/sub/blockers.html | 1 + files/templates/sub/exilees.html | 1 + files/templates/sub/mods.html | 1 + files/templates/sub/settings.html | 5 +- files/templates/sub/subs.html | 1 + files/templates/submission.html | 29 +-- files/templates/submit.html | 64 ++----- files/templates/transfers.html | 11 +- files/templates/user_cards.html | 33 +++- files/templates/user_listing.html | 1 - files/templates/userpage.html | 7 +- files/templates/userpage/blockers.html | 1 + files/templates/userpage/blocking.html | 11 +- files/templates/userpage/followers.html | 1 + files/templates/userpage/following.html | 1 + files/templates/userpage/viewers.html | 1 + files/templates/userpage/voters.html | 1 + files/templates/{ => util}/html_head.html | 168 ++---------------- files/templates/votes.html | 2 +- 84 files changed, 628 insertions(+), 1159 deletions(-) delete mode 100644 files/templates/forgot_password.html delete mode 100644 files/templates/login.html rename files/templates/{ => login}/authforms.html (75%) create mode 100644 files/templates/login/forgot_password.html create mode 100644 files/templates/login/login.html create mode 100644 files/templates/login/login_2fa.html create mode 100644 files/templates/login/lost_2fa.html create mode 100644 files/templates/login/reset_password.html create mode 100644 files/templates/login/sign_up.html create mode 100644 files/templates/login/sign_up_failed_ref.html delete mode 100644 files/templates/login_2fa.html delete mode 100644 files/templates/lost_2fa.html delete mode 100644 files/templates/mine.html create mode 100644 files/templates/modals/2fa.html create mode 100644 files/templates/modals/blockuser.html delete mode 100644 files/templates/reset_password.html create mode 100644 files/templates/root.html delete mode 100644 files/templates/sign_up.html delete mode 100644 files/templates/sign_up_failed_ref.html rename files/templates/{ => util}/html_head.html (63%) diff --git a/files/routes/admin.py b/files/routes/admin.py index f24c9d805..ab2cc0cdf 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -619,6 +619,7 @@ def users_list(v): users=users, next_exists=next_exists, page=page, + user_cards_title="Users Feed", ) diff --git a/files/routes/hats.py b/files/routes/hats.py index 84f8f0d69..998e42cbc 100644 --- a/files/routes/hats.py +++ b/files/routes/hats.py @@ -129,4 +129,5 @@ def hat_owners(v, hat_id): users=users, next_exists=next_exists, page=page, + user_cards_title="Hat Owners", ) diff --git a/files/routes/login.py b/files/routes/login.py index 43cb9bcbf..6cd003703 100644 --- a/files/routes/login.py +++ b/files/routes/login.py @@ -27,8 +27,7 @@ def login_get(v): if not is_site_url(redir) or redir in NO_LOGIN_REDIRECT_URLS: redir = "/" if v: return redirect(redir) - - return render_template("login.html", failed=False, redirect=redir) + return render_template("login/login.html", failed=False, redirect=redir), 401 def login_deduct_when(resp): if not g: @@ -58,20 +57,20 @@ def login_post(): if not account: time.sleep(random.uniform(0, 2)) - return render_template("login.html", failed=True) + return render_template("login/login.html", failed=True), 401 if request.values.get("password"): if not account.verifyPass(request.values.get("password")): log_failed_admin_login_attempt(account, "password") time.sleep(random.uniform(0, 2)) - return render_template("login.html", failed=True) + return render_template("login/login.html", failed=True), 401 if account.mfa_secret: now = int(time.time()) hash = generate_hash(f"{account.id}+{now}+2fachallenge") g.login_failed = False - return render_template("login_2fa.html", + return render_template("login/login_2fa.html", v=account, time=now, hash=hash, @@ -93,12 +92,12 @@ def login_post(): if not account.validate_2fa(request.values.get("2fa_token", "").strip()): hash = generate_hash(f"{account.id}+{now}+2fachallenge") log_failed_admin_login_attempt(account, "2FA token") - return render_template("login_2fa.html", + return render_template("login/login_2fa.html", v=account, time=now, hash=hash, failed=True, - ) + ), 401 else: abort(400) @@ -166,7 +165,7 @@ def sign_up_get(v): ref_user = None if ref_user and (ref_user.id in session.get("history", [])): - return render_template("sign_up_failed_ref.html") + return render_template("login/sign_up_failed_ref.html"), 403 now = int(time.time()) token = secrets.token_hex(16) @@ -185,14 +184,16 @@ def sign_up_get(v): if redir: if not is_site_url(redir): redir = "/" - return render_template("sign_up.html", + status_code = 200 if not error else 400 + + return render_template("login/sign_up.html", formkey=formkey, now=now, ref_user=ref_user, turnstile=TURNSTILE_SITEKEY, error=error, redirect=redir - ) + ), status_code @app.post("/signup") @@ -345,7 +346,7 @@ def sign_up_post(v): @app.get("/forgot") def get_forgot(): - return render_template("forgot_password.html") + return render_template("login/forgot_password.html") @app.post("/forgot") @@ -358,7 +359,7 @@ def post_forgot(): email = request.values.get("email",'').strip().lower() if not email_regex.fullmatch(email): - return render_template("forgot_password.html", error="Invalid email.") + return render_template("login/forgot_password.html", error="Invalid email."), 400 username = username.lstrip('@').replace('\\', '').replace('_', '\_').replace('%', '').strip() @@ -380,8 +381,8 @@ def post_forgot(): v=user) ) - return render_template("forgot_password.html", - msg="If the username and email matches an account, you will be sent a password reset email. You have ten minutes to complete the password reset process.") + return render_template("login/forgot_password.html", + msg="If the username and email matches an account, you will be sent a password reset email. You have ten minutes to complete the password reset process."), 202 @app.get("/reset") @@ -405,7 +406,7 @@ def get_reset(): reset_token = generate_hash(f"{user.id}+{timestamp}+reset+{user.login_nonce}") - return render_template("reset_password.html", + return render_template("login/reset_password.html", v=user, token=reset_token, time=timestamp, @@ -437,11 +438,11 @@ def post_reset(v): abort(400) if password != confirm_password: - return render_template("reset_password.html", + return render_template("login/reset_password.html", v=user, token=token, time=timestamp, - error="Passwords didn't match.") + error="Passwords didn't match."), 400 user.passhash = hash_password(password) g.db.add(user) @@ -455,10 +456,7 @@ def post_reset(v): @auth_desired def lost_2fa(v): if v and not v.mfa_secret: abort(400, "You don't have 2FA enabled") - return render_template( - "lost_2fa.html", - v=v - ) + return render_template("login/lost_2fa.html", v=v) @app.post("/request_2fa_disable") @limiter.limit("1/second;6/minute;200/hour;1000/day") @@ -468,7 +466,7 @@ def request_2fa_disable(): if not user or not user.email or not user.mfa_secret: return render_template("message.html", title="Removal request received", - message="If username, password, and email match, we will send you an email.") + message="If username, password, and email match, we will send you an email."), 202 email=request.values.get("email").strip().lower() @@ -480,7 +478,7 @@ def request_2fa_disable(): if not user.verifyPass(password): return render_template("message.html", title="Removal request received", - message="If username, password, and email match, we will send you an email.") + message="If username, password, and email match, we will send you an email."), 202 valid=int(time.time()) token=generate_hash(f"{user.id}+{user.username}+disable2fa+{valid}+{user.mfa_secret}+{user.login_nonce}") @@ -496,7 +494,7 @@ def request_2fa_disable(): return render_template("message.html", title="Removal request received", - message="If username, password, and email match, we will send you an email.") + message="If username, password, and email match, we will send you an email."), 202 @app.get("/reset_2fa") def reset_2fa(): @@ -520,10 +518,8 @@ def reset_2fa(): abort(403) user.mfa_secret=None - g.db.add(user) - return render_template("message_success.html", title="Two-factor authentication removed.", message="Login normally to access your account.") diff --git a/files/routes/users.py b/files/routes/users.py index ca6a3931d..f367ee8cf 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -1052,6 +1052,7 @@ def bid_list(v, bid): users=users, next_exists=next_exists, page=page, + user_cards_title="Badge Owners", ) diff --git a/files/templates/admin/admin_home.html b/files/templates/admin/admin_home.html index 284bea757..2387ad9b6 100644 --- a/files/templates/admin/admin_home.html +++ b/files/templates/admin/admin_home.html @@ -1,5 +1,5 @@ {% extends "default.html" %} -{% block pagetitle %}{{SITE_NAME}}{% endblock %} +{% block pagetitle %}Admin Home{% endblock %} {% block customPadding %}px-3{% endblock %} {% block content %}

Admin Tools

diff --git a/files/templates/admin/alts.html b/files/templates/admin/alts.html index 0bb8d66fc..2ef58ed52 100644 --- a/files/templates/admin/alts.html +++ b/files/templates/admin/alts.html @@ -1,11 +1,11 @@ {% extends "settings2.html" %} +{% block pagetitle %}Alts{% if u %} for @{{u.username}}{% endif %}{% endblock %} {% block content %} {% if u %}
Alts for @{{u.username}}
{% else %}
Alts
{% endif %} -{%- import 'util/macros.html' as macros with context -%}
diff --git a/files/templates/admin/badge_admin.html b/files/templates/admin/badge_admin.html index 8c9dbe73f..ca68effd7 100644 --- a/files/templates/admin/badge_admin.html +++ b/files/templates/admin/badge_admin.html @@ -1,12 +1,6 @@ {% extends "default.html" %} -{% if grant %} - {% set title="Badge Grant" %} -{% else %} - {% set title="Badge Remove" %} -{% endif %} -{% block pagetitle %}{{title}}{% endblock %} +{% block pagetitle %}{{"Badge Grant" if grant else "Badge Remove"}}{% endblock %} {% block pagetype %}message{% endblock %} - {% block content %} {% if error %}