From e73fcbd56ad6d59a909f29c08435332255ff5875 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 29 Apr 2022 17:17:14 +0200 Subject: [PATCH] sfd --- files/classes/sub_subscription.py | 12 ------ files/helpers/sanitize.py | 2 +- files/routes/front.py | 20 ++------- files/routes/subs.py | 67 ----------------------------- files/templates/home.html | 53 +---------------------- files/templates/sidebar_PCM.html | 9 +--- files/templates/sidebar_rDrama.html | 10 +---- files/templates/sub/subs.html | 2 - 8 files changed, 11 insertions(+), 164 deletions(-) delete mode 100644 files/classes/sub_subscription.py diff --git a/files/classes/sub_subscription.py b/files/classes/sub_subscription.py deleted file mode 100644 index fbb1b0b20..000000000 --- a/files/classes/sub_subscription.py +++ /dev/null @@ -1,12 +0,0 @@ -from sqlalchemy import * -from sqlalchemy.orm import relationship -from files.__main__ import Base - -class SubSubscription(Base): - - __tablename__ = "sub_subscriptions" - user_id = Column(Integer, ForeignKey("users.id"), primary_key=True) - sub = Column(String, ForeignKey("subs.name"), primary_key=True) - - def __repr__(self): - return f"" \ No newline at end of file diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index 967a053cb..fc1ffcc52 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -12,7 +12,7 @@ import signal import time import requests -TLDS = ('ac','ad','ae','aero','af','ag','ai','al','am','an','ao','aq','ar','arpa','as','asia','at','au','aw','ax','az','ba','bb','bd','be','bf','bg','bh','bi','biz','bj','bm','bn','bo','br','bs','bt','bv','bw','by','bz','ca','cafe','cat','cc','cd','cf','cg','ch','ci','ck','cl','club','cm','cn','co','com','coop','cr','cu','cv','cx','cy','cz','de','dj','dk','dm','do','dz','ec','edu','ee','eg','er','es','et','eu','fi','fj','fk','fm','fo','fr','ga','gb','gd','ge','gf','gg','gh','gi','gl','gm','gn','gov','gp','gq','gr','gs','gt','gu','gw','gy','hk','hm','hn','hr','ht','hu','id','ie','il','im','in','info','int','io','iq','ir','is','it','je','jm','jo','jobs','jp','ke','kg','kh','ki','km','kn','kp','kr','kw','ky','kz','la','lb','lc','li','lk','lr','ls','lt','lu','lv','ly','ma','mc','md','me','mg','mh','mil','mk','ml','mm','mn','mo','mobi','mp','mq','mr','ms','mt','mu','museum','mv','mw','mx','my','mz','na','name','nc','ne','net','nf','ng','ni','nl','no','np','nr','nu','nz','om','org','pa','pe','pf','pg','ph','pk','pl','pm','pn','post','pr','pro','ps','pt','pw','py','qa','re','ro','rs','ru','rw','sa','sb','sc','sd','se','sg','sh','si','sj','sk','sl','sm','sn','so','social','sr','ss','st','su','sv','sx','sy','sz','tc','td','tel','tf','tg','th','tj','tk','tl','tm','tn','to','tp','tr','travel','tt','tv','tw','tz','ua','ug','uk','us','uy','uz','va','vc','ve','vg','vi','vn','vu','wf','win','ws','xn','xxx','ye','yt','yu','za','zm','zw') +TLDS = ('ac','ad','ae','aero','af','ag','ai','al','am','an','ao','aq','ar','arpa','as','asia','at','au','aw','ax','az','ba','bb','bd','be','bf','bg','bh','bi','biz','bj','bm','bn','bo','br','bs','bt','bv','bw','by','bz','ca','cafe','cat','cc','cd','cf','cg','ch','ci','ck','cl','club','cm','cn','co','com','coop','cr','cu','cv','cx','cy','cz','de','dj','dk','dm','do','dz','ec','edu','ee','eg','er','es','et','eu','fi','fj','fk','fm','fo','fr','ga','gb','gd','ge','gf','gg','gh','gi','gl','gm','gn','gov','gp','gq','gr','gs','gt','gu','gw','gy','hk','hm','hn','hr','ht','hu','id','ie','il','im','in','info','int','io','iq','ir','is','it','je','jm','jo','jobs','jp','ke','kg','kh','ki','km','kn','kp','kr','kw','ky','kz','la','lb','lc','li','lk','lr','ls','lt','lu','lv','ly','ma','mc','md','me','mg','mh','mil','mk','ml','mm','mn','mo','mobi','mp','mq','mr','ms','mt','mu','museum','mv','mw','mx','my','mz','na','name','nc','ne','net','nf','ng','ni','nl','no','np','nr','nu','nz','om','org','pa','pe','pf','pg','ph','pk','pl','pm','pn','post','pr','pro','ps','pt','pw','py','qa','re','ro','rs','ru','rw','sa','sb','sc','sd','se','sg','sh','si','sj','sk','sl','sm','sn','so','social','sr','ss','st','su','sv','sx','sy','sz','tc','td','tel','tf','tg','th','tj','tk','tl','tm','tn','to','tp','tr','travel','tt','tv','tw','tz','ua','ug','uk','us','uy','uz','va','vc','ve','vg','vi','vn','vu','wf','win','ws','xn','xxx','xyz','ye','yt','yu','za','zm','zw') allowed_tags = ('b','blockquote','br','code','del','em','h1','h2','h3','h4','h5','h6','hr','i','li','ol','p','pre','strong','sub','sup','table','tbody','th','thead','td','tr','ul','marquee','a','span','ruby','rp','rt','spoiler','img','lite-youtube','video','source') diff --git a/files/routes/front.py b/files/routes/front.py index a8cc06074..96f387740 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -194,9 +194,6 @@ def front_all(v, sub=None, subdomain=None): try: lt=int(request.values.get("before", 0)) except: lt=0 - if v: subs = v.subs - else: subs = 2 - ids, next_exists = frontlist(sort=sort, page=page, t=t, @@ -206,8 +203,7 @@ def front_all(v, sub=None, subdomain=None): gt=gt, lt=lt, sub=sub, - site=SITE, - subs=subs + site=SITE ) posts = get_posts(ids, v=v) @@ -300,7 +296,7 @@ def front_all(v, sub=None, subdomain=None): @cache.memoize(timeout=86400) -def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, ccmode="false", filter_words='', gt=0, lt=0, sub=None, site=None, subs=2): +def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, ccmode="false", filter_words='', gt=0, lt=0, sub=None, site=None): posts = g.db.query(Submission) @@ -312,12 +308,8 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, ccmode="false" posts = posts.filter_by(sub=sub.name) elif not v: if subs == 1: posts = posts.filter(Submission.sub == None) - elif v.subs == 1: - posts = posts.filter(or_(Submission.sub == None, Submission.sub.in_(v.subbed_subs))) - elif v.subs == 2: + else: posts = posts.filter(or_(Submission.sub == None, Submission.sub.notin_(v.all_blocks))) - elif v.subs == 3: - posts = posts.filter(Submission.sub != None, Submission.sub.notin_(v.all_blocks)) if gt: posts = posts.filter(Submission.created_utc > gt) if lt: posts = posts.filter(Submission.created_utc < lt) @@ -391,12 +383,8 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, ccmode="false" pins = pins.filter_by(sub=sub.name) elif not v: if subs == 1: pins = pins.filter(Submission.sub == None) - elif v.subs == 1: - pins = pins.filter(or_(Submission.sub == None, Submission.sub.in_(v.subbed_subs))) - elif v.subs == 2: + else: pins = pins.filter(or_(Submission.sub == None, Submission.sub.notin_(v.all_blocks))) - elif v.subs == 3: - pins = pins.filter(Submission.sub != None, Submission.sub.notin_(v.all_blocks)) if v and v.admin_level < 2: pins = pins.filter(Submission.author_id.notin_(v.userblocks)) diff --git a/files/routes/subs.py b/files/routes/subs.py index 4d348405d..7db2a6ef8 100644 --- a/files/routes/subs.py +++ b/files/routes/subs.py @@ -6,54 +6,6 @@ from .front import frontlist -@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() - if not sub: abort(404) - sub = sub.name - - existing = g.db.query(SubSubscription).filter_by(user_id=v.id, sub=sub).one_or_none() - - if not existing: - subscribe = SubSubscription(user_id=v.id, sub=sub) - g.db.add(subscribe) - g.db.commit() - cache.delete_memoized(frontlist) - - return {"message": f"Subscribed to /h/{sub}"} - - -@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() - if not sub: abort(404) - sub = sub.name - - subscribe = g.db.query(SubSubscription).filter_by(user_id=v.id, sub=sub).one_or_none() - - if subscribe: - g.db.delete(subscribe) - g.db.commit() - cache.delete_memoized(frontlist) - - return {"message": f"Unsubscribed from /h/{sub}"} - - -@app.get("/h//subscribers") -@auth_required -def subscribers(v, sub): - sub = g.db.query(Sub).filter_by(name=sub.strip().lower()).one_or_none() - if not sub: abort(404) - - users = g.db.query(User).join(SubSubscription, SubSubscription.user_id==User.id).filter_by(sub=sub.name).all() - - return render_template("sub/subscribers.html", v=v, sub=sub, users=users) - - - - @app.post("/exile/post/") @is_not_permabanned def exile_post(v, pid): @@ -459,25 +411,6 @@ def sub_sidebar(v, sub): return redirect(f'/h/{sub.name}/settings') - -@app.post("/sub_toggle") -@auth_required -def sub_toggle(v): - mode = request.values.get('mode') - try: mode = int(mode) - except: abort(400) - - if mode in (1,2,3) and v.subs != mode: - v.subs = mode - g.db.add(v) - g.db.commit() - - if request.referrer and len(request.referrer) > 1 and request.referrer.startswith(f'{SITE_FULL}/'): - return redirect(request.referrer) - - return redirect('/') - - @app.get("/holes") @auth_desired def subs(v): diff --git a/files/templates/home.html b/files/templates/home.html index b2183dc7c..58ac7d4cd 100644 --- a/files/templates/home.html +++ b/files/templates/home.html @@ -44,35 +44,8 @@ {% if v %}
{% if sub %} - {% if v.subs == 1 %} - Subscribe to /h/{{sub.name}} - Unsubscribe from /h/{{sub.name}} - {% else %} - Block /h/{{sub.name}} - Unblock /h/{{sub.name}} - {% endif %} - {% elif SITE_NAME == 'rDrama' %} - + Block /h/{{sub.name}} + Unblock /h/{{sub.name}} {% endif %}
{% endif %} @@ -89,28 +62,6 @@ CC {% endif %} {% endif %} - - {% endif %}