forked from MarseyWorld/MarseyWorld
replace cc toggle with holes toggle
parent
8bd89b042d
commit
2fe10e9644
|
@ -63,7 +63,6 @@ def front_all(v, sub=None, subdomain=None):
|
|||
|
||||
sort=request.values.get("sort", defaultsorting)
|
||||
t=request.values.get('t', defaulttime)
|
||||
ccmode=request.values.get('ccmode', "false").lower()
|
||||
|
||||
try: gt=int(request.values.get("after", 0))
|
||||
except: gt=0
|
||||
|
@ -75,18 +74,19 @@ def front_all(v, sub=None, subdomain=None):
|
|||
else: default = False
|
||||
|
||||
pins = session.get(sort, default)
|
||||
holes = session.get('holes', True)
|
||||
|
||||
ids, next_exists = frontlist(sort=sort,
|
||||
page=page,
|
||||
t=t,
|
||||
v=v,
|
||||
ccmode=ccmode,
|
||||
filter_words=v.filter_words if v else [],
|
||||
gt=gt,
|
||||
lt=lt,
|
||||
sub=sub,
|
||||
site=SITE,
|
||||
pins=pins
|
||||
pins=pins,
|
||||
holes=holes
|
||||
)
|
||||
|
||||
posts = get_posts(ids, v=v)
|
||||
|
@ -96,12 +96,12 @@ def front_all(v, sub=None, subdomain=None):
|
|||
award_timers(v)
|
||||
|
||||
if v and v.client: 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, pins=pins)
|
||||
return render_template("home.html", v=v, listing=posts, next_exists=next_exists, sort=sort, t=t, page=page, sub=sub, home=True, pins=pins, holes=holes)
|
||||
|
||||
|
||||
|
||||
@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, pins=True):
|
||||
def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words='', gt=0, lt=0, sub=None, site=None, pins=True, holes=True):
|
||||
|
||||
posts = g.db.query(Submission)
|
||||
|
||||
|
@ -118,15 +118,15 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, ccmode="false"
|
|||
if not gt and not lt:
|
||||
posts = apply_time_filter(t, posts, Submission)
|
||||
|
||||
if (ccmode == "true") and FEATURES['COUNTRY_CLUB']:
|
||||
posts = posts.filter(Submission.club == True)
|
||||
|
||||
posts = posts.filter_by(is_banned=False, private=False, deleted_utc = 0)
|
||||
|
||||
if pins and ccmode == "false" and not gt and not lt:
|
||||
if pins and not gt and not lt:
|
||||
if sub: posts = posts.filter_by(hole_pinned=None)
|
||||
else: posts = posts.filter_by(stickied=None)
|
||||
|
||||
if not sub and not holes:
|
||||
posts = posts.filter_by(sub=None)
|
||||
|
||||
if v:
|
||||
posts = posts.filter(Submission.author_id.notin_(v.userblocks))
|
||||
|
||||
|
@ -151,7 +151,7 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, ccmode="false"
|
|||
next_exists = (len(posts) > size)
|
||||
posts = posts[:size]
|
||||
|
||||
if pins and page == 1 and ccmode == "false" and not gt and not lt:
|
||||
if pins and page == 1 and not gt and not lt:
|
||||
if sub:
|
||||
pins = g.db.query(Submission).filter(Submission.sub == sub.name, Submission.hole_pinned != None)
|
||||
else:
|
||||
|
|
|
@ -1011,6 +1011,16 @@ def toggle_pins(sort):
|
|||
return redirect('/')
|
||||
|
||||
|
||||
@app.get("/toggle_holes")
|
||||
def toggle_holes():
|
||||
holes = session.get('holes', True)
|
||||
session["holes"] = not holes
|
||||
|
||||
if is_site_url(request.referrer):
|
||||
return redirect(request.referrer)
|
||||
return redirect('/')
|
||||
|
||||
|
||||
@app.get("/badge_owners/<bid>")
|
||||
@auth_required
|
||||
def bid_list(v, bid):
|
||||
|
|
|
@ -67,25 +67,27 @@
|
|||
{% block navbar %}
|
||||
<div class="d-flex align-items-center">
|
||||
{% if request.path=='/catalog' %}
|
||||
<a data-bs-toggle="tooltip" data-bs-placement="bottom" title="Catalog View" class="btn btn-primary text-primary mx-2 d-mob-none" href="/?sort={{sort}}&t={{t}}&ccmode=false"><i class="fas fa-columns-3 mr-2 "></i>Catalog</a>
|
||||
<a data-bs-toggle="tooltip" data-bs-placement="bottom" title="Catalog View" class="btn btn-primary text-primary mx-2 d-mob-none" href="/?sort={{sort}}&t={{t}}"><i class="fas fa-columns-3 mr-2 "></i>Catalog</a>
|
||||
{% else %}
|
||||
<a data-bs-toggle="tooltip" data-bs-placement="bottom" title="Catalog View" class="btn btn-secondary mx-2 d-mob-none" href="/catalog?sort={{sort}}&t={{t}}&ccmode=false"><i class="fas fa-columns-3 mr-2 "></i>Catalog</a>
|
||||
<a data-bs-toggle="tooltip" data-bs-placement="bottom" title="Catalog View" class="btn btn-secondary mx-2 d-mob-none" href="/catalog?sort={{sort}}&t={{t}}"><i class="fas fa-columns-3 mr-2 "></i>Catalog</a>
|
||||
{% endif %}
|
||||
|
||||
{% if pins %}
|
||||
{% set bcolor = "primary" %}
|
||||
{% set pcolor = "primary" %}
|
||||
{% else %}
|
||||
{% set bcolor = "secondary" %}
|
||||
{% set pcolor = "secondary" %}
|
||||
{% endif %}
|
||||
|
||||
<a data-bs-toggle="tooltip" title="Toggle Pins" class="btn btn-{{bcolor}} text-{{bcolor}} mx-2 smol-fp" href="/toggle_pins/{{sort}}"><i class="fas fas fa-thumbtack fa-rotate--45 mr-2 "></i>Pins</a>
|
||||
{% if v.paid_dues %}
|
||||
{% if ccmode=="true" %}
|
||||
<a data-bs-toggle="tooltip" data-bs-placement="bottom" title="Only show country club posts" class="btn btn-primary text-primary mx-2 smol-fp" href="?sort={{sort}}&t={{t}}&ccmode=false"><i class="fas fa-golf-club mr-2 "></i>CC</a>
|
||||
{% else %}
|
||||
<a data-bs-toggle="tooltip" data-bs-placement="bottom" title="Only show country club posts" class="btn btn-secondary mx-2 smol-fp" href="?sort={{sort}}&t={{t}}&ccmode=true"><i class="fas fa-golf-club mr-2 "></i>CC</a>
|
||||
{% endif %}
|
||||
<a data-bs-toggle="tooltip" title="Toggle Pins" class="btn btn-{{pcolor}} text-{{pcolor}} mx-2 smol-fp" href="/toggle_pins/{{sort}}"><i class="fas fas fa-thumbtack fa-rotate--45 mr-2 "></i>Pins</a>
|
||||
|
||||
{% if SITE_NAME != 'WPD' and not sub %}
|
||||
{% if holes %}
|
||||
{% set hcolor = "primary" %}
|
||||
{% else %}
|
||||
{% set hcolor = "secondary" %}
|
||||
{% endif %}
|
||||
|
||||
<a data-bs-toggle="tooltip" title="Toggle Holes" class="btn btn-{{hcolor}} text-{{hcolor}} mx-2 smol-fp" href="/toggle_holes"><i class="fas fas fa-manhole mr-2 "></i>Holes</a>
|
||||
{% endif %}
|
||||
|
||||
<div data-bs-toggle="tooltip" title="Time Filter" class="dropdown dropdown-actions mx-2">
|
||||
|
@ -100,12 +102,12 @@
|
|||
{{t | capitalize}}
|
||||
</button>
|
||||
<div class="dropdown-menu smol-fp" aria-labelledby="dropdownMenuButton" x-placement="bottom-start" style="position: absolute; will-change: transform; top: 0px; left: 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"><i class="fas fa-clock mr-2 "></i>Hour</a>{% endif %}
|
||||
{% if t != "day" %}<a class="dropdown-item" href="?sort={{sort}}&t=day"><i class="fas fa-calendar-day mr-2 "></i>Day</a>{% endif %}
|
||||
{% if t != "week" %}<a class="dropdown-item" href="?sort={{sort}}&t=week"><i class="fas fa-calendar-week mr-2 "></i>Week</a>{% endif %}
|
||||
{% if t != "month" %}<a class="dropdown-item" href="?sort={{sort}}&t=month"><i class="fas fa-calendar-alt mr-2 "></i>Month</a>{% endif %}
|
||||
{% if t != "year" %}<a class="dropdown-item" href="?sort={{sort}}&t=year"><i class="fas fa-calendar mr-2 "></i>Year</a>{% endif %}
|
||||
{% if t != "all" %}<a class="dropdown-item" href="?sort={{sort}}&t=all"><i class="fas fa-infinity mr-2 "></i>All</a>{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -122,14 +124,14 @@
|
|||
{{sort | capitalize}}
|
||||
</button>
|
||||
<div class="dropdown-menu smol-fp" aria-labelledby="dropdownMenuButton2" x-placement="bottom-start" style="position: absolute; will-change: transform; top: 0px; left: 0px;">
|
||||
{% if sort != "hot" %}<a class="dropdown-item" href="?sort=hot&t={{t}}&ccmode={{ccmode}}"><i class="fas fa-fire mr-2 "></i>Hot</a>{% endif %}
|
||||
{% if sort != "bump" %}<a class="dropdown-item" href="?sort=bump&t={{t}}&ccmode={{ccmode}}"><i class="fas fa-arrow-up mr-2 "></i>Bump</a>{% endif %}
|
||||
{% if sort != "top" %}<a class="dropdown-item" href="?sort=top&t={{t}}&ccmode={{ccmode}}"><i class="fas fa-arrow-alt-circle-up mr-2 "></i>Top</a>{% endif %}
|
||||
{% if sort != "bottom" %}<a class="dropdown-item" href="?sort=bottom&t={{t}}&ccmode={{ccmode}}"><i class="fas fa-arrow-alt-circle-down mr-2 "></i>Bottom</a>{% endif %}
|
||||
{% if sort != "new" %}<a class="dropdown-item" href="?sort=new&t={{t}}&ccmode={{ccmode}}"><i class="fas fa-sparkles mr-2 "></i>New</a>{% endif %}
|
||||
{% if sort != "old" %}<a class="dropdown-item" href="?sort=old&t={{t}}&ccmode={{ccmode}}"><i class="fas fa-book mr-2 "></i>Old</a>{% endif %}
|
||||
{% if sort != "controversial" %}<a class="dropdown-item" href="?sort=controversial&t={{t}}&ccmode={{ccmode}}"><i class="fas fa-bullhorn mr-2 "></i>Controversial</a>{% endif %}
|
||||
{% if sort != "comments" %}<a class="dropdown-item" href="?sort=comments&t={{t}}&ccmode={{ccmode}}"><i class="fas fa-comments mr-2 "></i>Comments</a>{% endif %}
|
||||
{% if sort != "hot" %}<a class="dropdown-item" href="?sort=hot&t={{t}}"><i class="fas fa-fire mr-2 "></i>Hot</a>{% endif %}
|
||||
{% if sort != "bump" %}<a class="dropdown-item" href="?sort=bump&t={{t}}"><i class="fas fa-arrow-up mr-2 "></i>Bump</a>{% endif %}
|
||||
{% if sort != "top" %}<a class="dropdown-item" href="?sort=top&t={{t}}"><i class="fas fa-arrow-alt-circle-up mr-2 "></i>Top</a>{% endif %}
|
||||
{% if sort != "bottom" %}<a class="dropdown-item" href="?sort=bottom&t={{t}}"><i class="fas fa-arrow-alt-circle-down mr-2 "></i>Bottom</a>{% endif %}
|
||||
{% if sort != "new" %}<a class="dropdown-item" href="?sort=new&t={{t}}"><i class="fas fa-sparkles mr-2 "></i>New</a>{% endif %}
|
||||
{% if sort != "old" %}<a class="dropdown-item" href="?sort=old&t={{t}}"><i class="fas fa-book mr-2 "></i>Old</a>{% endif %}
|
||||
{% if sort != "controversial" %}<a class="dropdown-item" href="?sort=controversial&t={{t}}"><i class="fas fa-bullhorn mr-2 "></i>Controversial</a>{% endif %}
|
||||
{% if sort != "comments" %}<a class="dropdown-item" href="?sort=comments&t={{t}}"><i class="fas fa-comments mr-2 "></i>Comments</a>{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -165,14 +167,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}}" 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}}">Next</a></small>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="page-item disabled"><span class="page-link">Next</span></li>
|
||||
|
|
Loading…
Reference in New Issue