From b35bab0672dc3055050fe888708d27d03c5957eb Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Wed, 9 Mar 2022 04:04:37 +0200 Subject: [PATCH] hole --- files/classes/submission.py | 2 +- files/classes/user.py | 3 +- files/helpers/alerts.py | 2 +- files/routes/comments.py | 10 ++-- files/routes/front.py | 6 +-- files/routes/posts.py | 24 ++++----- files/routes/subs.py | 62 ++++++++++++------------ files/templates/comments.html | 8 +-- files/templates/default.html | 7 +-- files/templates/header.html | 6 +-- files/templates/home.html | 18 +++---- files/templates/post_actions.html | 2 +- files/templates/post_actions_mobile.html | 2 +- files/templates/sidebar_Drama.html | 22 ++++----- files/templates/sidebar_PCM.html | 14 +++--- files/templates/sub/blockers.html | 2 +- files/templates/sub/create_sub.html | 8 +-- files/templates/sub/exilees.html | 4 +- files/templates/sub/mods.html | 6 +-- files/templates/sub/settings.html | 10 ++-- files/templates/sub/subs.html | 10 ++-- files/templates/sub/subscribers.html | 2 +- files/templates/submission.html | 4 +- files/templates/submission_listing.html | 6 +-- files/templates/submit.html | 6 +-- files/templates/userpage.html | 4 +- 26 files changed, 124 insertions(+), 126 deletions(-) diff --git a/files/classes/submission.py b/files/classes/submission.py index 72e6caabe..f7976eaea 100644 --- a/files/classes/submission.py +++ b/files/classes/submission.py @@ -209,7 +209,7 @@ class Submission(Base): @lazy def shortlink(self): link = f"/post/{self.id}" - if self.sub: link = f"/s/{self.sub}{link}" + if self.sub: link = f"/h/{self.sub}{link}" if self.club: return link + '/-' diff --git a/files/classes/user.py b/files/classes/user.py index 815190df4..8f4c0ae22 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -483,7 +483,8 @@ class User(Base): return self.profileurl if SITE_NAME == 'Drama': self.profileurl = '/e/' + random.choice(marseys_const) + '.webp' - g.db.add(self) + try: g.db.add(self) + except: pass g.db.commit() return self.profileurl return f"{SITE_FULL}/static/assets/images/default-profile-pic.webp?v=1008" diff --git a/files/helpers/alerts.py b/files/helpers/alerts.py index 897cc3897..8ad257e19 100644 --- a/files/helpers/alerts.py +++ b/files/helpers/alerts.py @@ -73,7 +73,7 @@ def notif_comment2(p): if existing: return existing[0] else: text = f"@{p.author.username} has mentioned you: [{p.title}](/post/{p.id})" - if p.sub: text += f" in /s/{p.sub}" + if p.sub: text += f" in /h/{p.sub}" text_html = sanitize(text, alert=True) return create_comment(text_html) diff --git a/files/routes/comments.py b/files/routes/comments.py index 1106daff4..950a8626a 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -62,10 +62,10 @@ def pusher_thread(interests, c): @app.get("/post///") @app.get("/logged_out/comment/") @app.get("/logged_out/post///") -@app.get("/s//comment/") -@app.get("/s//post///") -@app.get("/logged_out/s//comment/") -@app.get("/logged_out/s//post///") +@app.get("/h//comment/") +@app.get("/h//post///") +@app.get("/logged_out/h//comment/") +@app.get("/logged_out/h//post///") @auth_desired def post_pid_comment_cid(cid, pid=None, anything=None, v=None, sub=None): @@ -185,7 +185,7 @@ def api_comment(v): parent_post = get_post(parent_submission, v=v) sub = parent_post.sub - if sub and v.exiled_from(sub): return {"error": f"You're exiled from /s/{sub}"}, 403 + if sub and v.exiled_from(sub): return {"error": f"You're exiled from /h/{sub}"}, 403 if parent_post.club and not (v and (v.paid_dues or v.id == parent_post.author_id)): abort(403) diff --git a/files/routes/front.py b/files/routes/front.py index 46f53772b..75f433912 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -133,14 +133,14 @@ def notifications(v): @app.get("/") @app.get("/logged_out") -@app.get("/s/") -@app.get("/logged_out/s/") +@app.get("/h/") +@app.get("/logged_out/h/") @limiter.limit("3/second;30/minute;1000/hour;5000/day") @auth_desired def front_all(v, sub=None, subdomain=None): if sub: sub = g.db.query(Sub).filter_by(name=sub.strip().lower()).one_or_none() - if request.path.startswith('/s/') and not sub: abort(404) + if request.path.startswith('/h/') and not sub: abort(404) if g.webview and not session.get("session_id"): session.permanent = True diff --git a/files/routes/posts.py b/files/routes/posts.py index d24efdcc8..3b827158b 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -80,7 +80,7 @@ def publish(pid, v): if v.followers: text = f"@{v.username} has made a new post: [{post.title}]({post.shortlink})" - if post.sub: text += f" in /s/{post.sub}" + if post.sub: text += f" in /h/{post.sub}" cid = notif_comment(text, autojanny=True) for follow in v.followers: @@ -101,12 +101,12 @@ def publish(pid, v): return {"message": "Post published!"} @app.get("/submit") -@app.get("/s//submit") +@app.get("/h//submit") @auth_required def submit_get(v, sub=None): if sub: sub = g.db.query(Sub.name).filter_by(name=sub.strip().lower()).one_or_none() - if request.path.startswith('/s/') and not sub: abort(404) + if request.path.startswith('/h/') and not sub: abort(404) SUBS = [x[0] for x in g.db.query(Sub.name).order_by(Sub.name).all()] @@ -116,10 +116,10 @@ def submit_get(v, sub=None): @app.get("/post//") @app.get("/logged_out/post/") @app.get("/logged_out/post//") -@app.get("/s//post/") -@app.get("/s//post//") -@app.get("/logged_out/s//post/") -@app.get("/logged_out/s//post//") +@app.get("/h//post/") +@app.get("/h//post//") +@app.get("/logged_out/h//post/") +@app.get("/logged_out/h//post//") @auth_desired def post_id(pid, anything=None, v=None, sub=None): if not v and not request.path.startswith('/logged_out') and not request.headers.get("Authorization"): @@ -783,7 +783,7 @@ def thumbnail_thread(pid): @app.post("/submit") -@app.post("/s//submit") +@app.post("/h//submit") @limiter.limit("1/second;6/minute;200/hour;1000/day") @auth_required def submit_post(v, sub=None): @@ -802,14 +802,14 @@ def submit_post(v, sub=None): sub = request.values.get("sub") - if sub: sub = sub.replace('/s/','').replace('s/','') + if sub: sub = sub.replace('/h/','').replace('s/','') if sub and sub != 'none': sname = sub.strip().lower() sub = g.db.query(Sub.name).filter_by(name=sname).one_or_none() - if not sub: return error(f"/s/{sname} not found!") + if not sub: return error(f"/h/{sname} not found!") sub = sub[0] - if v.exiled_from(sub): return error(f"You're exiled from /s/{sub}") + if v.exiled_from(sub): return error(f"You're exiled from /h/{sub}") else: sub = None if v.is_suspended: return error("You can't perform this action while banned.") @@ -1141,7 +1141,7 @@ def submit_post(v, sub=None): if request.values.get('followers') and v.followers: text = f"@{v.username} has made a new post: [{post.title}]({post.shortlink})" - if post.sub: text += f" in /s/{post.sub}" + if post.sub: text += f" in /h/{post.sub}" cid = notif_comment(text, autojanny=True) for follow in v.followers: diff --git a/files/routes/subs.py b/files/routes/subs.py index 3813d1b96..63ecc6991 100644 --- a/files/routes/subs.py +++ b/files/routes/subs.py @@ -6,7 +6,7 @@ from .front import frontlist -@app.post("/s//subscribe") +@app.post("/h//subscribe") @auth_required def subscribe_sub(v, sub): sub = g.db.query(Sub).filter_by(name=sub.strip().lower()).one_or_none() @@ -24,7 +24,7 @@ def subscribe_sub(v, sub): return {"message": "Subscribed to sub!"} -@app.post("/s//unsubscribe") +@app.post("/h//unsubscribe") @auth_required def unsubscribe_sub(v, sub): sub = g.db.query(Sub).filter_by(name=sub.strip().lower()).one_or_none() @@ -41,7 +41,7 @@ def unsubscribe_sub(v, sub): return {"message": "Unsubscribed from sub!"} -@app.get("/s//subscribers") +@app.get("/h//subscribers") @auth_required def subscribers(v, sub): sub = g.db.query(Sub).filter_by(name=sub.strip().lower()).one_or_none() @@ -74,7 +74,7 @@ def exile_post(v, pid): exile = Exile(user_id=u.id, sub=sub, exiler_id=v.id) g.db.add(exile) - send_notification(u.id, f"@{v.username} has exiled you from /s/{sub} for [{p.title}]({p.shortlink})") + send_notification(u.id, f"@{v.username} has exiled you from /h/{sub} for [{p.title}]({p.shortlink})") g.db.commit() @@ -102,14 +102,14 @@ def exile_comment(v, cid): exile = Exile(user_id=u.id, sub=sub, exiler_id=v.id) g.db.add(exile) - send_notification(u.id, f"@{v.username} has exiled you from /s/{sub} for [{c.permalink}]({c.shortlink})") + send_notification(u.id, f"@{v.username} has exiled you from /h/{sub} for [{c.permalink}]({c.shortlink})") g.db.commit() return {"message": "User exiled successfully!"} -@app.post("/s//unexile/") +@app.post("/h//unexile/") @is_not_permabanned def unexile(v, sub, uid): u = get_account(uid) @@ -120,13 +120,13 @@ def unexile(v, sub, uid): exile = g.db.query(Exile).filter_by(user_id=u.id, sub=sub).one_or_none() g.db.delete(exile) - send_notification(u.id, f"@{v.username} has revoked your exile from /s/{sub}") + send_notification(u.id, f"@{v.username} has revoked your exile from /h/{sub}") g.db.commit() if request.headers.get("Authorization") or request.headers.get("xhr"): return {"message": "User unexiled successfully!"} - return redirect(f'/s/{sub}/exilees') + return redirect(f'/h/{sub}/exilees') @@ -134,7 +134,7 @@ def unexile(v, sub, uid): -@app.post("/s//block") +@app.post("/h//block") @auth_required def block_sub(v, sub): sub = g.db.query(Sub).filter_by(name=sub.strip().lower()).one_or_none() @@ -154,7 +154,7 @@ def block_sub(v, sub): return {"message": "Sub blocked successfully!"} -@app.post("/s//unblock") +@app.post("/h//unblock") @auth_required def unblock_sub(v, sub): sub = g.db.query(Sub).filter_by(name=sub.strip().lower()).one_or_none() @@ -170,7 +170,7 @@ def unblock_sub(v, sub): return {"message": "Sub unblocked successfully!"} -@app.get("/s//mods") +@app.get("/h//mods") @auth_required def mods(v, sub): sub = g.db.query(Sub).filter_by(name=sub.strip().lower()).one_or_none() @@ -181,7 +181,7 @@ def mods(v, sub): return render_template("sub/mods.html", v=v, sub=sub, users=users) -@app.get("/s//exilees") +@app.get("/h//exilees") @auth_required def exilees(v, sub): sub = g.db.query(Sub).filter_by(name=sub.strip().lower()).one_or_none() @@ -192,7 +192,7 @@ def exilees(v, sub): return render_template("sub/exilees.html", v=v, sub=sub, users=users) -@app.get("/s//blockers") +@app.get("/h//blockers") @auth_required def blockers(v, sub): sub = g.db.query(Sub).filter_by(name=sub.strip().lower()).one_or_none() @@ -204,7 +204,7 @@ def blockers(v, sub): -@app.post("/s//add_mod") +@app.post("/h//add_mod") @limiter.limit("1/second;5/day") @is_not_permabanned def add_mod(v, sub): @@ -227,14 +227,14 @@ def add_mod(v, sub): g.db.add(mod) if v.id != user.id: - send_repeatable_notification(user.id, f"@{v.username} has added you as a mod to /s/{sub}") + send_repeatable_notification(user.id, f"@{v.username} has added you as a mod to /h/{sub}") g.db.commit() - return redirect(f'/s/{sub}/mods') + return redirect(f'/h/{sub}/mods') -@app.post("/s//remove_mod") +@app.post("/h//remove_mod") @is_not_permabanned def remove_mod(v, sub): sub = g.db.query(Sub).filter_by(name=sub.strip().lower()).one_or_none() @@ -262,11 +262,11 @@ def remove_mod(v, sub): g.db.delete(mod) if v.id != user.id: - send_repeatable_notification(user.id, f"@{v.username} has removed you as a mod from /s/{sub}") + send_repeatable_notification(user.id, f"@{v.username} has removed you as a mod from /h/{sub}") g.db.commit() - return redirect(f'/s/{sub}/mods') + return redirect(f'/h/{sub}/mods') @app.get("/create_sub") @is_not_permabanned @@ -319,7 +319,7 @@ def create_sub2(v): g.db.add(mod) g.db.commit() - return redirect(f'/s/{sub.name}') + return redirect(f'/h/{sub.name}') @app.post("/kick/") @is_not_permabanned @@ -341,7 +341,7 @@ def kick(v, pid): return {"message": "Post kicked successfully!"} -@app.get('/s//settings') +@app.get('/h//settings') @is_not_permabanned def sub_settings(v, sub): sub = g.db.query(Sub).filter_by(name=sub.strip().lower()).one_or_none() @@ -352,7 +352,7 @@ def sub_settings(v, sub): return render_template('sub/settings.html', v=v, sidebar=sub.sidebar, sub=sub) -@app.post('/s//sidebar') +@app.post('/h//sidebar') @limiter.limit("1/second;30/minute;200/hour;1000/day") @is_not_permabanned def post_sub_sidebar(v, sub): @@ -369,10 +369,10 @@ def post_sub_sidebar(v, sub): g.db.commit() - return redirect(f'/s/{sub.name}/settings') + return redirect(f'/h/{sub.name}/settings') -@app.post('/s//css') +@app.post('/h//css') @limiter.limit("1/second;30/minute;200/hour;1000/day") @is_not_permabanned def post_sub_css(v, sub): @@ -386,10 +386,10 @@ def post_sub_css(v, sub): g.db.commit() - return redirect(f'/s/{sub.name}/settings') + return redirect(f'/h/{sub.name}/settings') -@app.get("/s//css") +@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) @@ -398,7 +398,7 @@ def get_sub_css(sub): return resp -@app.post("/s//banner") +@app.post("/h//banner") @limiter.limit("1/second;10/day") @is_not_permabanned def sub_banner(v, sub): @@ -427,9 +427,9 @@ def sub_banner(v, sub): g.db.add(sub) g.db.commit() - return redirect(f'/s/{sub.name}/settings') + return redirect(f'/h/{sub.name}/settings') -@app.post("/s//sidebar_image") +@app.post("/h//sidebar_image") @limiter.limit("1/second;10/day") @is_not_permabanned def sub_sidebar(v, sub): @@ -457,7 +457,7 @@ def sub_sidebar(v, sub): g.db.add(sub) g.db.commit() - return redirect(f'/s/{sub.name}/settings') + return redirect(f'/h/{sub.name}/settings') @app.get("/sub_toggle/") @@ -477,7 +477,7 @@ def sub_toggle(mode, v): return redirect('/') -@app.get("/subs") +@app.get("/holes") @auth_desired def subs(v): subs = g.db.query(Sub, func.count(Submission.sub)).outerjoin(Submission, Sub.name == Submission.sub).group_by(Sub.name).order_by(func.count(Submission.sub).desc()).all() diff --git a/files/templates/comments.html b/files/templates/comments.html index b04a55ae8..f1fc77404 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -136,7 +136,7 @@ {% endif %} {% if c.post.sub %} - in /s/{{c.post.sub}} + in /h/{{c.post.sub}} {% endif %} {% elif c.author_id==NOTIFICATIONS_ID or c.author_id==AUTOJANNY_ID %} Notification @@ -177,7 +177,7 @@ {% if c.post %} {% set sub = c.post.sub %} {% if sub and c.author.exiled_from(sub) %} - + {% endif %} {% endif %} @@ -498,7 +498,7 @@ {% set sub = c.post.sub %} {% if sub and v.mods(sub) and not c.author.mods(sub) %} - + {% endif %} {% endif %} @@ -674,7 +674,7 @@ {% set sub = c.post.sub %} {% if sub and v.mods(sub) and not c.author.mods(sub) %} Exile user - Unexile user + Unexile user {% endif %} {% endif %} {% endif %} diff --git a/files/templates/default.html b/files/templates/default.html index a42b873e3..fae0d078e 100644 --- a/files/templates/default.html +++ b/files/templates/default.html @@ -33,14 +33,11 @@ {% else %} - {% if SITE_NAME == 'Drama' and not request.path.startswith('/s/') %} - - {% endif %} {% endif %} {% if sub and sub.css and not request.path.endswith('settings') %} - + {% endif %} {% if v and v.themecolor == '30409f' %} @@ -233,7 +230,7 @@ {% if v %} {% if sub %} - /s/{{sub.name}} banner + /h/{{sub.name}} banner {% elif SITE_NAME == 'Drama' %} {% set path = "assets/images/" + SITE_NAME + "/banners" %} {% set image = "/static/" + path + "/" + listdir('files/' + path)|random() + '?v=22' %} diff --git a/files/templates/header.html b/files/templates/header.html index 4fb6d187a..180134ccc 100644 --- a/files/templates/header.html +++ b/files/templates/header.html @@ -42,7 +42,7 @@ {% if SITE_NAME == 'Drama' %} logo {% elif sub %} - /s/{{sub.name}} + /h/{{sub.name}} {% endif %} @@ -72,7 +72,7 @@ {% endif %} {% if v %} - + {% else %} {% endif %} @@ -112,7 +112,7 @@ {% endif %}