forked from MarseyWorld/MarseyWorld
sfd
parent
2d4cf226e4
commit
e73fcbd56a
|
@ -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"<SubSubscription(user_id={self.user_id}, sub={self.sub})>"
|
|
@ -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')
|
||||
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -6,54 +6,6 @@ from .front import frontlist
|
|||
|
||||
|
||||
|
||||
@app.post("/h/<sub>/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/<sub>/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/<sub>/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/<pid>")
|
||||
@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):
|
||||
|
|
|
@ -44,36 +44,9 @@
|
|||
{% if v %}
|
||||
<div class="mt-3 d-lg-none">
|
||||
{% if sub %}
|
||||
{% if v.subs == 1 %}
|
||||
<a class="btn btn-primary btn-block {% if v.subscribed_to(sub.name) %}d-none{% endif %}" onclick="post_toast(this,'/h/{{sub.name}}/subscribe','subscribe-sub','unsubscribe-sub');this.classList.toggle('d-none');nextElementSibling.classList.toggle('d-none')">Subscribe to /h/{{sub.name}}</a>
|
||||
<a class="btn btn-primary btn-block {% if not v.subscribed_to(sub.name) %}d-none{% endif %}" onclick="post_toast(this,'/h/{{sub.name}}/unsubscribe','subscribe-sub','unsubscribe-sub');this.classList.toggle('d-none');previousElementSibling.classList.toggle('d-none')">Unsubscribe from /h/{{sub.name}}</a>
|
||||
{% else %}
|
||||
<a class="btn btn-primary btn-block {% if v.blocks(sub.name) %}d-none{% endif %}" onclick="post_toast(this,'/h/{{sub.name}}/block','block-sub','unblock-sub');this.classList.toggle('d-none');nextElementSibling.classList.toggle('d-none')">Block /h/{{sub.name}}</a>
|
||||
<a class="btn btn-primary btn-block {% if not v.blocks(sub.name) %}d-none{% endif %}" onclick="post_toast(this,'/h/{{sub.name}}/unblock','block-sub','unblock-sub');this.classList.toggle('d-none');previousElementSibling.classList.toggle('d-none')">Unblock /h/{{sub.name}}</a>
|
||||
{% endif %}
|
||||
{% elif SITE_NAME == 'rDrama' %}
|
||||
<div class="dropdown dropdown-actions mx-2">
|
||||
<button class="btn btn-primary btn-block dropdown-toggle" type="button" id="dropdownMenuButton" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<i class="fas fa-circle mr-3 "></i>
|
||||
{% if v.subs == 1 %}
|
||||
Include subscribed holes
|
||||
{% elif v.subs == 2 %}
|
||||
Include all holes
|
||||
{% elif v.subs == 3 %}
|
||||
View holes only
|
||||
{% endif %}
|
||||
</button>
|
||||
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton" x-placement="bottom-start" style="position: absolute; will-change: transform; top: 0px; left: 0px; transform: translate3d(0px, 31px, 0px);min-width:100%">
|
||||
<form action="/sub_toggle" method="post">
|
||||
<input type="hidden" name="formkey" value="{{v.formkey}}">
|
||||
|
||||
{% if v.subs != 1 %}<button class="dropdown-item text-center" type="submit" name="mode" value="1"><i class="fas fa-circle mr-3"></i>Include subscribed holes</button>{% endif %}
|
||||
{% if v.subs != 2 %}<button class="dropdown-item text-center" type="submit" name="mode" value="2"><i class="fas fa-circle mr-3"></i>Include all holes</button>{% endif %}
|
||||
{% if v.subs != 3 %}<button class="dropdown-item text-center" type="submit" name="mode" value="3"><i class="fas fa-circle mr-3"></i>View holes only</button>{% endif %}
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
|
@ -89,28 +62,6 @@
|
|||
<a data-bs-toggle="tooltip" data-bs-placement="bottom" title="Only show country club posts" class="btn btn-secondary mx-2" href="?sort={{sort}}&t={{t}}&ccmode=true"><i class="fas fa-golf-club mr-2 "></i>CC</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
<div class="dropdown dropdown-actions mx-2 d-none d-lg-block">
|
||||
<button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<i class="fas fa-circle mr-2"></i>
|
||||
{% if v.subs == 1 %}
|
||||
Include subscribed holes
|
||||
{% elif v.subs == 2 %}
|
||||
Include all holes
|
||||
{% elif v.subs == 3 %}
|
||||
View holes only
|
||||
{% endif %}
|
||||
</button>
|
||||
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton" x-placement="bottom-start" style="position: absolute; will-change: transform; top: 0px; left: 0px; transform: translate3d(0px, 31px, 0px);">
|
||||
<form action="/sub_toggle" method="post">
|
||||
<input type="hidden" name="formkey" value="{{v.formkey}}">
|
||||
|
||||
{% if v.subs != 1 %}<button class="dropdown-item" type="submit" name="mode" value="1"><i class="fas fa-circle mr-2"></i>Include subscribed holes</button>{% endif %}
|
||||
{% if v.subs != 2 %}<button class="dropdown-item" type="submit" name="mode" value="2"><i class="fas fa-circle mr-2"></i>Include all holes</button>{% endif %}
|
||||
{% if v.subs != 3 %}<button class="dropdown-item" type="submit" name="mode" value="3"><i class="fas fa-circle mr-2"></i>View holes only</button>{% endif %}
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="dropdown dropdown-actions mx-2">
|
||||
|
|
|
@ -9,13 +9,8 @@
|
|||
{% endif %}
|
||||
{% if v %}
|
||||
<div class="d-lg-block d-none btn-block">
|
||||
{% if v.subs == 1 %}
|
||||
<a class="btn btn-primary btn-block {% if v.subscribed_to(sub.name) %}d-none{% endif %}" onclick="post_toast(this,'/h/{{sub.name}}/subscribe','subscribe-sub','unsubscribe-sub');this.classList.toggle('d-none');nextElementSibling.classList.toggle('d-none')">SUBSCRIBE TO HOLE</a>
|
||||
<a class="btn btn-primary btn-block {% if not v.subscribed_to(sub.name) %}d-none{% endif %}" onclick="post_toast(this,'/h/{{sub.name}}/unsubscribe','subscribe-sub','unsubscribe-sub');this.classList.toggle('d-none');previousElementSibling.classList.toggle('d-none')">UNSUBSCRIBE FROM HOLE</a>
|
||||
{% else %}
|
||||
<a class="btn btn-primary btn-block {% if v.blocks(sub.name) %}d-none{% endif %}" onclick="post_toast(this,'/h/{{sub.name}}/block','block-sub','unblock-sub');this.classList.toggle('d-none');nextElementSibling.classList.toggle('d-none')">BLOCK HOLE</a>
|
||||
<a class="btn btn-primary btn-block {% if not v.blocks(sub.name) %}d-none{% endif %}" onclick="post_toast(this,'/h/{{sub.name}}/unblock','block-sub','unblock-sub');this.classList.toggle('d-none');previousElementSibling.classList.toggle('d-none')">UNBLOCK HOLE</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
<a class="btn btn-primary btn-block" href="/h/{{sub.name}}/mods">HOLE MODS</a>
|
||||
|
|
|
@ -19,13 +19,8 @@
|
|||
{% endif %}
|
||||
{% if v %}
|
||||
<div class="d-lg-block d-none btn-block">
|
||||
{% if v.subs == 1 %}
|
||||
<a class="btn btn-primary btn-block mb-3 {% if v.subscribed_to(sub.name) %}d-none{% endif %}" onclick="post_toast(this,'/h/{{sub.name}}/subscribe','subscribe-sub','unsubscribe-sub');this.classList.toggle('d-none');nextElementSibling.classList.toggle('d-none')">SUBSCRIBE TO HOLE</a>
|
||||
<a class="btn btn-primary btn-block mb-3 {% if not v.subscribed_to(sub.name) %}d-none{% endif %}" onclick="post_toast(this,'/h/{{sub.name}}/unsubscribe','subscribe-sub','unsubscribe-sub');this.classList.toggle('d-none');previousElementSibling.classList.toggle('d-none')">UNSUBSCRIBE FROM HOLE</a>
|
||||
{% else %}
|
||||
<a class="btn btn-primary btn-block mb-3 {% if v.blocks(sub.name) %}d-none{% endif %}" onclick="post_toast(this,'/h/{{sub.name}}/block','block-sub','unblock-sub');this.classList.toggle('d-none');nextElementSibling.classList.toggle('d-none')">BLOCK HOLE</a>
|
||||
<a class="btn btn-primary btn-block mb-3 {% if not v.blocks(sub.name) %}d-none{% endif %}" onclick="post_toast(this,'/h/{{sub.name}}/unblock','block-sub','unblock-sub');this.classList.toggle('d-none');previousElementSibling.classList.toggle('d-none')">UNBLOCK HOLE</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% if v.admin_level > 2 %}
|
||||
|
@ -36,7 +31,6 @@
|
|||
{% endif %}
|
||||
{% endif %}
|
||||
<a class="btn btn-primary btn-block mb-3" href="/h/{{sub.name}}/mods">HOLE MODS</a>
|
||||
<a class="btn btn-primary btn-block mb-3" href="/h/{{sub.name}}/subscribers">HOLE SUBSCRIBERS</a>
|
||||
<a class="btn btn-primary btn-block mb-3" href="/h/{{sub.name}}/exilees">HOLE EXILEES</a>
|
||||
<a class="btn btn-primary btn-block mb-3" href="/h/{{sub.name}}/blockers">HOLE BLOCKERS</a>
|
||||
{% else %}
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
<th>#</th>
|
||||
<th>Name</th>
|
||||
<th role="button" onclick="sort_table(2)">Posts</th>
|
||||
{% if SITE_NAME == 'rDrama' %}<th role="button" onclick="sort_table(3)">Subscribers</th>{% endif %}
|
||||
<th role="button" onclick="sort_table(4)">Blockers</th>
|
||||
|
||||
</tr>
|
||||
|
@ -25,7 +24,6 @@
|
|||
<td>{{loop.index}}</td>
|
||||
<td><a href="/h/{{sub.name}}">{{sub.name}}</a></td>
|
||||
<td><a href="/h/{{sub.name}}">{{count}}</a></td>
|
||||
{% if SITE_NAME == 'rDrama' %}<td><a href="/h/{{sub.name}}/subscribers">{{sub.subscription_num}}</a></td>{% endif %}
|
||||
<td><a href="/h/{{sub.name}}/blockers">{{sub.block_num}}</a></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
|
Loading…
Reference in New Issue