remotes/1693045480750635534/spooky-22
Aevann1 2022-05-06 06:55:15 +02:00
parent 0447c9c09e
commit ca61569b44
6 changed files with 41 additions and 19 deletions

View File

@ -59,9 +59,16 @@ def pusher_thread(interests, c, username):
@app.get("/post/<pid>/<anything>/<cid>")
@app.get("/h/<sub>/comment/<cid>")
@app.get("/h/<sub>/post/<pid>/<anything>/<cid>")
@app.get("/logged_out/comment/<cid>")
@app.get("/logged_out/post/<pid>/<anything>/<cid>")
@app.get("/logged_out/h/<sub>/comment/<cid>")
@app.get("/logged_out/h/<sub>/post/<pid>/<anything>/<cid>")
@auth_desired
def post_pid_comment_cid(cid, pid=None, anything=None, v=None, sub=None):
if not v and not request.path.startswith('/logged_out'): return redirect(f"/logged_out{request.full_path}")
if v and request.path.startswith('/logged_out'): v = None
try: cid = int(cid)
except: abort(404)

View File

@ -161,9 +161,17 @@ def notifications(v):
@app.get("/catalog")
@app.get("/h/<sub>")
@app.get("/s/<sub>")
@app.get("/logged_out")
@app.get("/logged_out/catalog")
@app.get("/logged_out/h/<sub>")
@app.get("/logged_out/s/<sub>")
@limiter.limit("3/second;30/minute;5000/hour;10000/day")
@auth_desired
def front_all(v, sub=None, subdomain=None):
if not v and not request.path.startswith('/logged_out'): return redirect(f"/logged_out{request.full_path}")
if v and request.path.startswith('/logged_out'): v = None
if sub: sub = g.db.query(Sub).filter_by(name=sub.strip().lower()).one_or_none()
if (request.path.startswith('/h/') or request.path.startswith('/s/')) and not sub: abort(404)

View File

@ -114,9 +114,16 @@ def submit_get(v, sub=None):
@app.get("/post/<pid>/<anything>")
@app.get("/h/<sub>/post/<pid>")
@app.get("/h/<sub>/post/<pid>/<anything>")
@app.get("/logged_out/post/<pid>")
@app.get("/logged_out/post/<pid>/<anything>")
@app.get("/logged_out/h/<sub>/post/<pid>")
@app.get("/logged_out/h/<sub>/post/<pid>/<anything>")
@auth_desired
def post_id(pid, anything=None, v=None, sub=None):
if not v and not request.path.startswith('/logged_out'): return redirect(f"/logged_out{request.full_path}")
if v and request.path.startswith('/logged_out'): v = None
try: pid = int(pid)
except Exception as e: pass

View File

@ -16,24 +16,6 @@ def rdrama(id, title):
id = ''.join(f'{x}/' for x in id)
return redirect(f'/archives/drama/comments/{id}{title}.html')
@app.get('/logged_out/')
@app.get('/logged_out/<path:old>')
def logged_out(old = ""):
# Remove trailing question mark from request.full_path which flask adds if there are no query parameters
redirect_url = request.full_path.replace("/logged_out", "", 1)
if redirect_url.endswith("?"):
redirect_url = redirect_url[:-1]
# Handle cases like /logged_out?asdf by adding a slash to the beginning
if not redirect_url.startswith('/'):
redirect_url = f"/{redirect_url}"
# Prevent redirect loop caused by visiting /logged_out/logged_out/logged_out/etc...
if redirect_url.startswith('/logged_out'):
abort(400)
return redirect(redirect_url)
@app.get("/marseys")
@auth_required
@ -75,8 +57,13 @@ def marsey_list():
@app.get('/rules')
@app.get('/sidebar')
@app.get('/logged_out/rules')
@app.get('/logged_out/sidebar')
@auth_desired
def sidebar(v):
if not v and not request.path.startswith('/logged_out'): return redirect(f"/logged_out{request.full_path}")
if v and request.path.startswith('/logged_out'): v = None
return render_template('sidebar.html', v=v)

View File

@ -862,9 +862,12 @@ def visitors(v):
@app.get("/@<username>")
@app.get("/logged_out/@<username>")
@auth_desired
def u_username(username, v=None):
if not v and not request.path.startswith('/logged_out'): return redirect(f"/logged_out{request.full_path}")
if v and request.path.startswith('/logged_out'): v = None
u = get_user(username, v=v)
@ -948,9 +951,13 @@ def u_username(username, v=None):
@app.get("/@<username>/comments")
@app.get("/logged_out/@<username>/comments")
@auth_desired
def u_username_comments(username, v=None):
if not v and not request.path.startswith('/logged_out'): return redirect(f"/logged_out{request.full_path}")
if v and request.path.startswith('/logged_out'): v = None
user = get_user(username, v=v)
if username != user.username: return redirect(f'/@{user.username}/comments')
@ -1134,9 +1141,15 @@ def remove_follow(username, v):
@app.get("/pp/<id>")
@app.get("/uid/<id>/pic")
@app.get("/uid/<id>/pic/profile")
@app.get("/logged_out/pp/<id>")
@app.get("/logged_out/uid/<id>/pic")
@app.get("/logged_out/uid/<id>/pic/profile")
@limiter.exempt
@auth_desired
def user_profile_uid(v, id):
if not v and not request.path.startswith('/logged_out'): return redirect(f"/logged_out{request.full_path}")
if v and request.path.startswith('/logged_out'): v = None
try: id = int(id)
except:
try: id = int(id, 36)

View File

@ -111,7 +111,7 @@
required="">
<div class="custom-control custom-checkbox mt-4">
<input autocomplete="off" type="checkbox" class="custom-control-input" id="termsCheck" required>
<label class="custom-control-label terms" for="termsCheck">I accept the <a href="/sidebar">rules</a></label>
<label class="custom-control-label terms" for="termsCheck">I accept the <a href="/logged_out/sidebar">rules</a></label>
</div>
{% if hcaptcha %}