From bbb7046a764a9dc6e7ad1ecf00c22f3d40937fad Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 13 Aug 2021 20:53:11 +0200 Subject: [PATCH] fdfd --- files/helpers/jinja2.py | 5 +++-- files/routes/comments.py | 4 ++-- files/routes/front.py | 2 +- files/routes/posts.py | 2 +- files/routes/users.py | 4 ++-- files/templates/submission.html | 9 +++++++-- files/templates/submission_banned.html | 4 ++-- 7 files changed, 18 insertions(+), 12 deletions(-) diff --git a/files/helpers/jinja2.py b/files/helpers/jinja2.py index 8c6e63e09..46eb6a7e7 100644 --- a/files/helpers/jinja2.py +++ b/files/helpers/jinja2.py @@ -13,9 +13,10 @@ def app_config(x): return app.config.get(x) @app.template_filter("post_embed") -def crosspost_embed(id): +def post_embed(id): - id = int(id) + try: id = int(id) + except: return None p = get_post(id, graceful=True) diff --git a/files/routes/comments.py b/files/routes/comments.py index 3c2e74cee..955fe2911 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -35,8 +35,8 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None): if not v and "logged_out" not in request.path: return redirect(f"/logged_out/comment/{cid}") - if v and "logged_out" in request.full_path: return redirect(f"/comment/{cid}") - + if v and "logged_out" in request.full_path: v = None + try: cid = int(cid) except: try: cid = int(cid, 36) diff --git a/files/routes/front.py b/files/routes/front.py index 50f860687..75d69e477 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -191,7 +191,7 @@ def front_all(v): if not v and request.path == "/": return redirect("/logged_out") - if v and "logged_out" in request.full_path: return redirect("/") + if v and "logged_out" in request.full_path: v = None try: page = int(request.args.get("page") or 1) except: abort(400) diff --git a/files/routes/posts.py b/files/routes/posts.py index 1cb9a5ee2..76f309e7d 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -54,7 +54,7 @@ def post_id(pid, anything=None, v=None): if not v and "logged_out" not in request.path: return redirect(f"/logged_out/post/{pid}") - if v and "logged_out" in request.full_path: return redirect(f"/post/{pid}") + if v and "logged_out" in request.full_path: v = None try: pid = int(pid) except Exception as e: pass diff --git a/files/routes/users.py b/files/routes/users.py index 632ca2f0c..bf930aa9e 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -281,7 +281,7 @@ def u_username(username, v=None): if not v and "logged_out" not in request.path: return redirect(f"/logged_out/@{username}") - if v and "logged_out" in request.full_path: return redirect(f"/@{username}") + if v and "logged_out" in request.full_path: v = None # username is unique so at most this returns one result. Otherwise 404 @@ -402,7 +402,7 @@ def u_username_comments(username, v=None): if not v and "logged_out" not in request.path: return redirect(f"/logged_out/@{username}/comments") - if v and "logged_out" in request.full_path: return redirect(f"/@{username}/comments") + if v and "logged_out" in request.full_path: v = None # username is unique so at most this returns one result. Otherwise 404 diff --git a/files/templates/submission.html b/files/templates/submission.html index 8e41d5d02..38616dc7b 100644 --- a/files/templates/submission.html +++ b/files/templates/submission.html @@ -9,7 +9,12 @@ {% endif %} +{% if v %} +{% set title=p.realtitle(v) %} +{% else %} {% set title=p.title %} +{% endif %} + {% set ups=p.upvotes_fuzzed %} {% set downs=p.downvotes_fuzzed %} {% set score=ups-downs %} @@ -58,7 +63,7 @@ {% if p.edited_utc %}{% endif %} - + @@ -69,7 +74,7 @@ - + diff --git a/files/templates/submission_banned.html b/files/templates/submission_banned.html index 5624e0b34..29d8ae90d 100644 --- a/files/templates/submission_banned.html +++ b/files/templates/submission_banned.html @@ -10,7 +10,7 @@ {% endif %} {% block title %} -{{p.title}} +{{p.realtitle(v)}} {% if p.is_banned %} {% else %} @@ -55,7 +55,7 @@
-
{{p.title}}
+
{{p.realtitle(v)}}