master
Aevann1 2022-02-21 08:24:35 +02:00
parent c9a905fd94
commit c53c916e6e
2 changed files with 36 additions and 22 deletions

View File

@ -162,6 +162,7 @@ def front_all(v, sub=None):
sort=request.values.get("sort", defaultsorting)
t=request.values.get('t', defaulttime)
ccmode=request.values.get('ccmode', "false")
subs=request.values.get('subs', "false")
try: gt=int(request.values.get("utc_greater_than", 0))
except: gt=0
@ -174,6 +175,7 @@ def front_all(v, sub=None):
t=t,
v=v,
ccmode=ccmode,
subs=subs,
filter_words=v.filter_words if v else [],
gt=gt,
lt=lt,
@ -259,17 +261,20 @@ def front_all(v, sub=None):
g.db.commit()
if request.headers.get("Authorization"): return {"data": [x.json for x in posts], "next_exists": next_exists}
return render_template("home.html", v=v, listing=posts, next_exists=next_exists, sort=sort, t=t, page=page, ccmode=ccmode, sub=sub, home=True)
return render_template("home.html", v=v, listing=posts, next_exists=next_exists, sort=sort, t=t, page=page, ccmode=ccmode, subs=subs, sub=sub, home=True)
@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):
def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, ccmode="false", subs="false", filter_words='', gt=0, lt=0, sub=None, site=None):
posts = g.db.query(Submission)
if sub: posts = posts.filter_by(sub=sub.name)
elif SITE_NAME == 'Drama': posts = posts.filter(Submission.sub == None)
elif subs == "true":
if v and v.all_blocks: posts = posts.filter(or_(Submission.sub == None, Submission.sub.notin_(v.all_blocks)))
else:
if SITE_NAME == 'Drama': posts = posts.filter(Submission.sub == None)
else:
if SITE_NAME == 'Ruqqus':
posts = posts.filter(Submission.sub != None)
@ -348,7 +353,10 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, ccmode="false"
if (sort == "hot" or (v and v.id == Q_ID)) and page == 1 and ccmode == "false" and not gt and not lt:
pins = g.db.query(Submission).filter(Submission.stickied != None, Submission.is_banned == False)
if sub: pins = pins.filter_by(sub=sub.name)
elif SITE_NAME == 'Drama': pins = pins.filter(Submission.sub == None)
elif subs == "true":
if v and v.all_blocks: posts = posts.filter(or_(Submission.sub == None, Submission.sub.notin_(v.all_blocks)))
else:
if SITE_NAME == 'Drama': pins = pins.filter(Submission.sub == None)
else:
if SITE_NAME == 'Ruqqus':
pins = pins.filter(Submission.sub != None)

View File

@ -43,8 +43,14 @@
<div class="text-small font-weight-bold mr-2"></div>
{% if request.path == '/' and v.paid_dues %}
{% if ccmode=="true"%}<a class="btn btn-secondary text-primary text-small-m" href="?sort={{sort}}&t={{t}}&ccmode=false"><i class="fas fa-angry mr-2"></i>CC Mode: Activated</a>{% endif %}
{% if ccmode=="false" %}<a class="btn btn-secondary text-small-m" href="?sort={{sort}}&t={{t}}&ccmode=true"><i class="fas fa-angry mr-2"></i>CC Mode</a>{% endif %}
{% if ccmode=="true"%}<a class="btn btn-secondary text-primary text-small-m" href="?sort={{sort}}&t={{t}}&ccmode=false"><i class="fas fa-angry mr-2"></i>CC</a>{% endif %}
{% if ccmode=="false" %}<a class="btn btn-secondary text-small-m" href="?sort={{sort}}&t={{t}}&ccmode=true"><i class="fas fa-angry mr-2"></i>CC</a>{% endif %}
<div class="text-small font-weight-bold ml-3 mr-2"></div>
{% endif %}
{% if request.path == '/' and v and v.admin_level > 1 %}
{% if subs=="true"%}<a class="btn btn-secondary text-primary text-small-m" href="?sort={{sort}}&t={{t}}&subs=false"><i class="fas fa-angry mr-2"></i>Subs</a>{% endif %}
{% if subs=="false" %}<a class="btn btn-secondary text-small-m" href="?sort={{sort}}&t={{t}}&subs=true"><i class="fas fa-angry mr-2"></i>Subs</a>{% endif %}
<div class="text-small font-weight-bold ml-3 mr-2"></div>
{% endif %}
@ -60,12 +66,12 @@
{{t | capitalize}}
</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);">
{% if t != "hour" %}<a class="dropdown-item" href="?sort={{sort}}&t=hour&ccmode={{ccmode}}"><i class="fas fa-clock mr-2"></i>Hour</a>{% endif %}
{% if t != "day" %}<a class="dropdown-item" href="?sort={{sort}}&t=day&ccmode={{ccmode}}"><i class="fas fa-calendar-day mr-2"></i>Day</a>{% endif %}
{% if t != "week" %}<a class="dropdown-item" href="?sort={{sort}}&t=week&ccmode={{ccmode}}"><i class="fas fa-calendar-week mr-2"></i>Week</a>{% endif %}
{% if t != "month" %}<a class="dropdown-item" href="?sort={{sort}}&t=month&ccmode={{ccmode}}"><i class="fas fa-calendar-alt mr-2"></i>Month</a>{% endif %}
{% if t != "year" %}<a class="dropdown-item" href="?sort={{sort}}&t=year&ccmode={{ccmode}}"><i class="fas fa-calendar mr-2"></i>Year</a>{% endif %}
{% if t != "all" %}<a class="dropdown-item" href="?sort={{sort}}&t=all&ccmode={{ccmode}}"><i class="fas fa-infinity mr-2"></i>All</a>{% endif %}
{% if t != "hour" %}<a class="dropdown-item" href="?sort={{sort}}&t=hour&ccmode={{ccmode}}&subs={{subs}}"><i class="fas fa-clock mr-2"></i>Hour</a>{% endif %}
{% if t != "day" %}<a class="dropdown-item" href="?sort={{sort}}&t=day&ccmode={{ccmode}}&subs={{subs}}"><i class="fas fa-calendar-day mr-2"></i>Day</a>{% endif %}
{% if t != "week" %}<a class="dropdown-item" href="?sort={{sort}}&t=week&ccmode={{ccmode}}&subs={{subs}}"><i class="fas fa-calendar-week mr-2"></i>Week</a>{% endif %}
{% if t != "month" %}<a class="dropdown-item" href="?sort={{sort}}&t=month&ccmode={{ccmode}}&subs={{subs}}"><i class="fas fa-calendar-alt mr-2"></i>Month</a>{% endif %}
{% if t != "year" %}<a class="dropdown-item" href="?sort={{sort}}&t=year&ccmode={{ccmode}}&subs={{subs}}"><i class="fas fa-calendar mr-2"></i>Year</a>{% endif %}
{% if t != "all" %}<a class="dropdown-item" href="?sort={{sort}}&t=all&ccmode={{ccmode}}&subs={{subs}}"><i class="fas fa-infinity mr-2"></i>All</a>{% endif %}
</div>
</div>
@ -155,14 +161,14 @@
<ul class="pagination pagination-sm mb-0">
{% if page>1 %}
<li class="page-item">
<small><a class="page-link" href="?sort={{sort}}&page={{page-1}}&t={{t}}&ccmode={{ccmode}}" tabindex="-1">Prev</a></small>
<small><a class="page-link" href="?sort={{sort}}&page={{page-1}}&t={{t}}&ccmode={{ccmode}}&subs={{subs}}" tabindex="-1">Prev</a></small>
</li>
{% else %}
<li class="page-item disabled"><span class="page-link">Prev</span></li>
{% endif %}
{% if next_exists %}
<li class="page-item">
<small><a class="page-link" href="?sort={{sort}}&page={{page+1}}&t={{t}}&ccmode={{ccmode}}">Next</a></small>
<small><a class="page-link" href="?sort={{sort}}&page={{page+1}}&t={{t}}&ccmode={{ccmode}}&subs={{subs}}">Next</a></small>
</li>
{% else %}
<li class="page-item disabled"><span class="page-link">Next</span></li>