From 19c82b7ea13bfa636c79aab31d35f0617629d808 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sun, 26 Jun 2022 06:33:41 +0200 Subject: [PATCH] put custom CSS into HTML templates --- files/routes/subs.py | 9 --------- files/routes/users.py | 28 ---------------------------- files/templates/authforms.html | 4 +++- files/templates/chat.html | 4 +++- files/templates/default.html | 8 ++++++-- files/templates/log.html | 4 +++- files/templates/settings.html | 4 +++- files/templates/submit.html | 4 +++- files/templates/userpage.html | 4 +++- 9 files changed, 24 insertions(+), 45 deletions(-) diff --git a/files/routes/subs.py b/files/routes/subs.py index b776cc5c7..ec8a6d942 100644 --- a/files/routes/subs.py +++ b/files/routes/subs.py @@ -417,15 +417,6 @@ def post_sub_css(v, sub): return redirect(f'/h/{sub.name}/settings') -@app.get("/h//css") -def get_sub_css(sub): - sub = g.db.query(Sub).filter_by(name=sub.strip().lower()).one_or_none() - if not sub: abort(404) - resp=make_response(sub.css or "") - resp.headers.add("Content-Type", "text/css") - return resp - - @app.post("/h//banner") @limiter.limit("1/second;10/day") @limiter.limit("1/second;10/day", key_func=lambda:f'{request.host}-{session.get("lo_user")}') diff --git a/files/routes/users.py b/files/routes/users.py index 15b938de5..b08af592a 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -584,34 +584,6 @@ def leaderboard(v): users13=users13_25, pos13=pos13, users14=users14, pos14=pos14, users15=users15, pos15=pos15, usersBlk=usersBlk) -@app.get("/@/css") -def get_css(username): - user = get_user(username) - resp = make_response(user.css or "") - resp.headers["Content-Type"] = "text/css" - resp.headers["Referrer-Policy"] = "no-referrer" - return resp - -@app.get("/@/profilecss") -def get_profilecss(username): - user = get_user(username) - if user.profilecss: profilecss = user.profilecss - else: profilecss = "" - resp = make_response(profilecss) - resp.headers["Content-Type"] = "text/css" - resp.headers["Referrer-Policy"] = "no-referrer" - return resp - -@app.get("/id//profilecss") -def get_profilecss_id(id): - user = get_account(id) - if user.profilecss: profilecss = user.profilecss - else: profilecss = "" - resp = make_response(profilecss) - resp.headers["Content-Type"] = "text/css" - resp.headers["Referrer-Policy"] = "no-referrer" - return resp - @app.get("/@/song") def usersong(username): user = get_user(username) diff --git a/files/templates/authforms.html b/files/templates/authforms.html index 5ad2868dc..bef3e1751 100644 --- a/files/templates/authforms.html +++ b/files/templates/authforms.html @@ -40,7 +40,9 @@ } {% elif v.css %} - + {% endif %} {% else %} diff --git a/files/templates/chat.html b/files/templates/chat.html index 0440f2f7e..6ec281d82 100644 --- a/files/templates/chat.html +++ b/files/templates/chat.html @@ -19,7 +19,9 @@ {% if v.css %} - + {% endif %} {% elif v.css %} - + {% endif %} {% else %} @@ -61,7 +63,9 @@ {% endif %} {% if sub and sub.css and not request.path.endswith('settings') %} - + {% endif %} {% if v and v.themecolor == '30409f' %} diff --git a/files/templates/log.html b/files/templates/log.html index 37d347dce..8eb74ed18 100644 --- a/files/templates/log.html +++ b/files/templates/log.html @@ -27,7 +27,9 @@ } {% elif v.css %} - + {% endif %} {% else %} diff --git a/files/templates/settings.html b/files/templates/settings.html index 19b4444a5..5a8c8864f 100644 --- a/files/templates/settings.html +++ b/files/templates/settings.html @@ -56,7 +56,9 @@ } {% elif v.css and not request.path.startswith('/settings/css') %} - + {% endif %} diff --git a/files/templates/submit.html b/files/templates/submit.html index 80607f3d6..9637f696f 100644 --- a/files/templates/submit.html +++ b/files/templates/submit.html @@ -49,7 +49,9 @@ } {% elif v.css %} - + {% endif %} {% else %} diff --git a/files/templates/userpage.html b/files/templates/userpage.html index 3623d40e6..2c8b13bac 100644 --- a/files/templates/userpage.html +++ b/files/templates/userpage.html @@ -6,7 +6,9 @@ {% block title %} {% if u and u.profilecss and not request.values.get('nocss') %} - + {% endif %} {{u.username}}'s profile - {{SITE_NAME}}