forked from MarseyWorld/MarseyWorld
dedup sorting in the jinja templates
parent
462bb23e6d
commit
f2ed74ec6a
|
@ -326,11 +326,33 @@ PIN_AWARD_TEXT = " (pin award)"
|
|||
THEMES = ["4chan","classic","classic_dark","coffee","dark","dramblr","light","midnight","tron","win98"]
|
||||
LIGHT_THEMES = ["4chan","classic","coffee","light","win98"]
|
||||
BACKGROUND_CATEGORIES = ["glitter", "anime", "fantasy", "solarpunk", "pixelart"]
|
||||
COMMENT_SORTS = ["hot", "new", "old", "top", "bottom", "controversial", "random"]
|
||||
SORTS = COMMENT_SORTS + ["bump", "comments", "views", "subscriptions", "saves"]
|
||||
TIME_FILTERS = ["hour", "day", "week", "month", "year", "all"]
|
||||
PAGE_SIZES = (10, 25, 50, 100)
|
||||
|
||||
TIME_FILTERS = {
|
||||
"hour": "clock",
|
||||
"day": "calendar-day",
|
||||
"week": "calendar-week",
|
||||
"month": "calendar-alt",
|
||||
"year": "calendar",
|
||||
"all": "infinity",
|
||||
}
|
||||
COMMENT_SORTS = {
|
||||
"hot": "fire",
|
||||
"new": "sparkles",
|
||||
"old": "book",
|
||||
"top": "arrow-alt-circle-up",
|
||||
"bottom": "arrow-alt-circle-down",
|
||||
"controversial": "bullhorn",
|
||||
"random": "random",
|
||||
}
|
||||
POST_SORTS = COMMENT_SORTS | {
|
||||
"bump": "arrow-up",
|
||||
"comments": "comments",
|
||||
"views": "eye",
|
||||
"subscriptions": "bell",
|
||||
"saves": "save"
|
||||
}
|
||||
|
||||
################################################################################
|
||||
### COLUMN INFO
|
||||
################################################################################
|
||||
|
|
|
@ -1358,7 +1358,7 @@ def remove_post(post_id, v):
|
|||
v.pay_account('coins', 1)
|
||||
g.db.add(v)
|
||||
|
||||
for sort in COMMENT_SORTS:
|
||||
for sort in COMMENT_SORTS.keys():
|
||||
cache.delete(f'post_{post.id}_{sort}')
|
||||
|
||||
return {"message": "Post removed!"}
|
||||
|
@ -1395,7 +1395,7 @@ def approve_post(post_id, v):
|
|||
v.charge_account('coins', 1)
|
||||
g.db.add(v)
|
||||
|
||||
for sort in COMMENT_SORTS:
|
||||
for sort in COMMENT_SORTS.keys():
|
||||
cache.delete(f'post_{post.id}_{sort}')
|
||||
|
||||
return {"message": "Post approved!"}
|
||||
|
@ -1606,7 +1606,7 @@ def remove_comment(c_id, v):
|
|||
g.db.add(ma)
|
||||
|
||||
if comment.parent_post:
|
||||
for sort in COMMENT_SORTS:
|
||||
for sort in COMMENT_SORTS.keys():
|
||||
cache.delete(f'post_{comment.parent_post}_{sort}')
|
||||
|
||||
return {"message": "Comment removed!"}
|
||||
|
@ -1639,7 +1639,7 @@ def approve_comment(c_id, v):
|
|||
g.db.add(comment)
|
||||
|
||||
if comment.parent_post:
|
||||
for sort in COMMENT_SORTS:
|
||||
for sort in COMMENT_SORTS.keys():
|
||||
cache.delete(f'post_{comment.parent_post}_{sort}')
|
||||
|
||||
return {"message": "Comment approved!"}
|
||||
|
|
|
@ -415,7 +415,7 @@ def comment(v):
|
|||
g.db.flush()
|
||||
|
||||
if c.parent_post:
|
||||
for sort in COMMENT_SORTS:
|
||||
for sort in COMMENT_SORTS.keys():
|
||||
cache.delete(f'post_{c.parent_post}_{sort}')
|
||||
|
||||
if v.client: return c.json
|
||||
|
@ -444,7 +444,7 @@ def delete_comment(cid, v):
|
|||
cache.delete_memoized(comment_idlist)
|
||||
|
||||
if c.parent_post:
|
||||
for sort in COMMENT_SORTS:
|
||||
for sort in COMMENT_SORTS.keys():
|
||||
cache.delete(f'post_{c.parent_post}_{sort}')
|
||||
|
||||
return {"message": "Comment deleted!"}
|
||||
|
@ -469,7 +469,7 @@ def undelete_comment(cid, v):
|
|||
cache.delete_memoized(comment_idlist)
|
||||
|
||||
if c.parent_post:
|
||||
for sort in COMMENT_SORTS:
|
||||
for sort in COMMENT_SORTS.keys():
|
||||
cache.delete(f'post_{c.parent_post}_{sort}')
|
||||
|
||||
return {"message": "Comment undeleted!"}
|
||||
|
|
|
@ -41,12 +41,11 @@ def post_embed(id, v):
|
|||
def template_asset(ctx, asset_path):
|
||||
return assetcache_path(asset_path)
|
||||
|
||||
|
||||
@app.template_filter("change_page")
|
||||
def template_change_page(new_page, url):
|
||||
@app.template_filter("change_arg")
|
||||
def template_change_arg(arg, value, url):
|
||||
parsed = urlsplit(url)
|
||||
query_dict = parse_qs(parsed.query)
|
||||
query_dict["page"] = new_page
|
||||
query_dict[arg] = value
|
||||
query_new = urlencode(query_dict, doseq=True)
|
||||
parsed = parsed._replace(query=query_new)
|
||||
return parsed.geturl()
|
||||
|
@ -119,7 +118,7 @@ def inject_constants():
|
|||
"TELEGRAM_ID":TELEGRAM_ID, "TRUESCORE_DONATE_MINIMUM":TRUESCORE_DONATE_MINIMUM, "PROGSTACK_ID":PROGSTACK_ID,
|
||||
"DONATE_LINK":DONATE_LINK, "DONATE_SERVICE":DONATE_SERVICE,
|
||||
"HOUSE_JOIN_COST":HOUSE_JOIN_COST, "HOUSE_SWITCH_COST":HOUSE_SWITCH_COST, "IMAGE_FORMATS":','.join(IMAGE_FORMATS),
|
||||
"PAGE_SIZES":PAGE_SIZES, "THEMES":THEMES, "COMMENT_SORTS":COMMENT_SORTS, "SORTS":SORTS,
|
||||
"PAGE_SIZES":PAGE_SIZES, "THEMES":THEMES, "COMMENT_SORTS":COMMENT_SORTS, "POST_SORTS":POST_SORTS,
|
||||
"TIME_FILTERS":TIME_FILTERS, "HOUSES":HOUSES, "TIER_TO_NAME":TIER_TO_NAME,
|
||||
"DEFAULT_CONFIG_VALUE":DEFAULT_CONFIG_VALUE, "IS_LOCALHOST":IS_LOCALHOST, "BACKGROUND_CATEGORIES":BACKGROUND_CATEGORIES, "PAGE_SIZE":PAGE_SIZE, "TAGLINES":TAGLINES, "get_alt_graph":get_alt_graph, "current_registered_users":current_registered_users,
|
||||
"git_head":git_head, "max_days":max_days, "EMOJI_KINDS":EMOJI_KINDS,
|
||||
|
|
|
@ -706,7 +706,7 @@ def delete_post_pid(pid, v):
|
|||
v.post_count -= 1
|
||||
g.db.add(v)
|
||||
|
||||
for sort in COMMENT_SORTS:
|
||||
for sort in COMMENT_SORTS.keys():
|
||||
cache.delete(f'post_{p.id}_{sort}')
|
||||
|
||||
return {"message": "Post deleted!"}
|
||||
|
@ -731,7 +731,7 @@ def undelete_post_pid(pid, v):
|
|||
v.post_count += 1
|
||||
g.db.add(v)
|
||||
|
||||
for sort in COMMENT_SORTS:
|
||||
for sort in COMMENT_SORTS.keys():
|
||||
cache.delete(f'post_{p.id}_{sort}')
|
||||
|
||||
return {"message": "Post undeleted!"}
|
||||
|
|
|
@ -120,7 +120,7 @@ def settings_personal_post(v):
|
|||
opt = request.values.get(api_name)
|
||||
if opt: opt = opt.strip()
|
||||
if not opt: return False
|
||||
if opt in valid_values:
|
||||
if opt in valid_values.keys():
|
||||
setattr(v, column_name, opt)
|
||||
return True
|
||||
abort(400, f"'{opt}' is not a valid {error_msg}")
|
||||
|
@ -316,7 +316,7 @@ def settings_personal_post(v):
|
|||
else: abort(400)
|
||||
|
||||
updated = updated or set_selector_option("defaultsortingcomments", "defaultsortingcomments", COMMENT_SORTS, "comment sort")
|
||||
updated = updated or set_selector_option("defaultsorting", "defaultsorting", SORTS, "post sort")
|
||||
updated = updated or set_selector_option("defaultsorting", "defaultsorting", POST_SORTS, "post sort")
|
||||
updated = updated or set_selector_option("defaulttime", "defaulttime", TIME_FILTERS, "time filter")
|
||||
|
||||
theme = request.values.get("theme")
|
||||
|
|
|
@ -81,58 +81,9 @@
|
|||
<button type="submit" class="btn btn-{{pcolor}} text-{{pcolor}} mx-2"><i type="submit" class="fas fas fa-thumbtack fa-rotate--45 mr-2"></i>Pins</button>
|
||||
</form>
|
||||
|
||||
<div class="dropdown dropdown-actions mx-2">
|
||||
<button type="button" class="btn btn-secondary dropdown-toggle" id="dropdownMenuButton" data-bs-toggle="dropdown">
|
||||
{% if t=="hour" %}<i class="fas fa-clock mr-2"></i>
|
||||
{% elif t=="day" %}<i class="fas fa-calendar-day mr-2"></i>
|
||||
{% elif t=="week" %}<i class="fas fa-calendar-week mr-2"></i>
|
||||
{% elif t=="month" %}<i class="fas fa-calendar-alt mr-2"></i>
|
||||
{% elif t=="year" %}<i class="fas fa-calendar mr-2"></i>
|
||||
{% elif t=="all" %}<i class="fas fa-infinity mr-2"></i>
|
||||
{% endif %}
|
||||
{{t | capitalize}}
|
||||
</button>
|
||||
<div class="dropdown-menu" 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"><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>
|
||||
|
||||
<div class="dropdown dropdown-actions ml-2">
|
||||
<button type="button" class="btn btn-secondary dropdown-toggle" id="dropdownMenuButton2" data-bs-toggle="dropdown">
|
||||
{% if sort=="hot" %}<i class="fas fa-fire mr-1"></i>{% endif %}
|
||||
{% if sort=="views" %}<i class="fas fa-eye mr-1"></i>{% endif %}
|
||||
{% if sort=="bump" %}<i class="fas fa-arrow-up mr-1"></i>{% endif %}
|
||||
{% if sort=="top" %}<i class="fas fa-arrow-alt-circle-up mr-1"></i>{% endif %}
|
||||
{% if sort=="bottom" %}<i class="fas fa-arrow-alt-circle-down mr-1"></i>{% endif %}
|
||||
{% if sort=="new" %}<i class="fas fa-sparkles mr-1"></i>{% endif %}
|
||||
{% if sort=="old" %}<i class="fas fa-book mr-1"></i>{% endif %}
|
||||
{% if sort=="controversial" %}<i class="fas fa-bullhorn mr-1"></i>{% endif %}
|
||||
{% if sort=="comments" %}<i class="fas fa-comments mr-1"></i>{% endif %}
|
||||
{% if sort=="subscriptions" %}<i class="fas fa-bell mr-1"></i>{% endif %}
|
||||
{% if sort=="saves" %}<i class="fas fa-save mr-1"></i>{% endif %}
|
||||
{% if sort=="random" %}<i class="fas fa-random mr-1"></i>{% endif %}
|
||||
{{sort | capitalize}}
|
||||
</button>
|
||||
<div class="dropdown-menu" 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}}"><i class="fas fa-fire mr-2"></i>Hot</a>{% endif %}
|
||||
{% if sort != "views" %}<a class="dropdown-item" href="?sort=views&t={{t}}"><i class="fas fa-eye mr-2"></i>Views</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 %}
|
||||
{% if sort != "subscriptions" %}<a class="dropdown-item" href="?sort=subscriptions&t={{t}}"><i class="fas fa-bell mr-2"></i>Subscriptions</a>{% endif %}
|
||||
{% if sort != "saves" %}<a class="dropdown-item" href="?sort=saves&t={{t}}"><i class="fas fa-save mr-2"></i>Saves</a>{% endif %}
|
||||
{% if sort != "random" %}<a class="dropdown-item" href="?sort=random&t={{t}}"><i class="fas fa-random mr-2"></i>Random</a>{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{%- import 'util/macros.html' as macros with context -%}
|
||||
{{- macros.time_filter_buttons() -}}
|
||||
{{- macros.sorting_buttons(POST_SORTS) -}}
|
||||
</div>
|
||||
{% endblock %}
|
||||
</div>
|
||||
|
|
|
@ -6,50 +6,10 @@
|
|||
|
||||
{% block content %}
|
||||
<div class="d-flex justify-content-between align-items-center mt-1 mb-2">
|
||||
|
||||
<div class="d-flex px-2 align-items-center mt-4">
|
||||
<div class="dropdown dropdown-actions">
|
||||
<button type="button" class="btn btn-secondary dropdown-toggle" id="dropdownMenuButton" data-bs-toggle="dropdown">
|
||||
{% if t=="hour" %}<i class="fas fa-clock mr-1"></i>
|
||||
{% elif t=="day" %}<i class="fas fa-calendar-day mr-1"></i>
|
||||
{% elif t=="week" %}<i class="fas fa-calendar-week mr-1"></i>
|
||||
{% elif t=="month" %}<i class="fas fa-calendar-alt mr-1"></i>
|
||||
{% elif t=="year" %}<i class="fas fa-calendar mr-1"></i>
|
||||
{% elif t=="all" %}<i class="fas fa-infinity mr-1"></i>
|
||||
{% endif %}
|
||||
{{t | capitalize}}
|
||||
</button>
|
||||
<div class="dropdown-menu" 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"><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>
|
||||
|
||||
<div class="dropdown dropdown-actions ml-3">
|
||||
<button type="button" class="btn btn-secondary dropdown-toggle" id="dropdownMenuButton2" data-bs-toggle="dropdown">
|
||||
{% if sort=="top" %}<i class="fas fa-arrow-alt-circle-up mr-1"></i>{% endif %}
|
||||
{% if sort=="bottom" %}<i class="fas fa-arrow-alt-circle-down mr-1"></i>{% endif %}
|
||||
{% if sort=="new" %}<i class="fas fa-sparkles mr-1"></i>{% endif %}
|
||||
{% if sort=="old" %}<i class="fas fa-book mr-1"></i>{% endif %}
|
||||
{% if sort=="controversial" %}<i class="fas fa-bullhorn mr-1"></i>{% endif %}
|
||||
{% if sort=="saves" %}<i class="fas fa-save mr-1"></i>{% endif %}
|
||||
{% if sort=="random" %}<i class="fas fa-random mr-1"></i>{% endif %}
|
||||
{{sort | capitalize}}
|
||||
</button>
|
||||
<div class="dropdown-menu" x-placement="bottom-start" style="position: absolute; will-change: transform; top: 0px; left: 0px; transform: translate3d(0px, 31px, 0px);">
|
||||
{% 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 != "saves" %}<a class="dropdown-item" href="?sort=saves&t={{t}}"><i class="fas fa-save mr-2"></i>Saves</a>{% endif %}
|
||||
{% if sort != "random" %}<a class="dropdown-item" href="?sort=random&t={{t}}"><i class="fas fa-random mr-2"></i>Random</a>{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{%- import 'util/macros.html' as macros with context -%}
|
||||
{{- macros.time_filter_buttons() -}}
|
||||
{{- macros.sorting_buttons(COMMENT_SORTS) -}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -26,12 +26,12 @@
|
|||
|
||||
{% if ns.start_point > 1 %}
|
||||
<li class="page-item">
|
||||
<small><a class="page-link" href="{{1|change_page(request.full_path)|safe}}">1</a></small>
|
||||
<small><a class="page-link" href="{{'page'|change_arg(1, request.full_path)|safe}}">1</a></small>
|
||||
</li>
|
||||
|
||||
{% if ns.start_point == 3 %}
|
||||
<li class="page-item">
|
||||
<small><a class="page-link" href="{{2|change_page(request.full_path)|safe}}">2</a></small>
|
||||
<small><a class="page-link" href="{{'page'|change_arg(2, request.full_path)|safe}}">2</a></small>
|
||||
</li>
|
||||
{% elif ns.start_point != 2 %}
|
||||
<li class="page-item">
|
||||
|
@ -43,14 +43,14 @@
|
|||
|
||||
{% for x in range(ns.start_point, end_point+1) %}
|
||||
<li class="page-item">
|
||||
<small><a class="page-link {% if x == page %}active disabled{% endif %}" href="{{x|change_page(request.full_path)|safe}}">{{x}}</a></small>
|
||||
<small><a class="page-link {% if x == page %}active disabled{% endif %}" href="{{'page'|change_arg(x, request.full_path)|safe}}">{{x}}</a></small>
|
||||
</li>
|
||||
{% endfor %}
|
||||
|
||||
{% if end_point < num_pages %}
|
||||
{% if end_point == num_pages-2 %}
|
||||
<li class="page-item">
|
||||
<small><a class="page-link" href="{{(num_pages-1)|change_page(request.full_path)|safe}}">{{num_pages-1}}</a></small>
|
||||
<small><a class="page-link" href="{{'page'|change_arg(num_pages-1, request.full_path)|safe}}">{{num_pages-1}}</a></small>
|
||||
</li>
|
||||
{% elif end_point != num_pages-1 %}
|
||||
<li class="page-item">
|
||||
|
@ -59,7 +59,7 @@
|
|||
{% endif %}
|
||||
|
||||
<li class="page-item">
|
||||
<small><a class="page-link" href="{{num_pages|change_page(request.full_path)|safe}}">{{num_pages}}</a></small>
|
||||
<small><a class="page-link" href="{{'page'|change_arg(num_pages, request.full_path)|safe}}">{{num_pages}}</a></small>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
|
|
|
@ -284,27 +284,8 @@
|
|||
<div class="row border-md-0 comment-section pb-3">
|
||||
<div class="col border-top">
|
||||
<div class="comments-count py-3">
|
||||
<div class="dropdown dropdown-actions">
|
||||
<button type="button" class="btn btn-secondary dropdown-toggle" id="dropdownMenuButton" data-bs-toggle="dropdown" style="margin-right:0.5em;">
|
||||
{% if sort=="hot" %}<i class="fas fa-fire mr-1"></i>{% endif %}
|
||||
{% if sort=="top" %}<i class="fas fa-arrow-alt-circle-up mr-1"></i>{% endif %}
|
||||
{% if sort=="bottom" %}<i class="fas fa-arrow-alt-circle-down mr-1"></i>{% endif %}
|
||||
{% if sort=="new" %}<i class="fas fa-sparkles mr-1"></i>{% endif %}
|
||||
{% if sort=="old" %}<i class="fas fa-book mr-1"></i>{% endif %}
|
||||
{% if sort=="controversial" %}<i class="fas fa-bullhorn mr-1"></i>{% endif %}
|
||||
{% if sort=="random" %}<i class="fas fa-random mr-1"></i>{% endif %}
|
||||
{{sort | capitalize}}
|
||||
</button>
|
||||
<div class="dropdown-menu" x-placement="bottom-start" style="position: absolute; will-change: transform; top: 0px; left: 0px; transform: translate3d(0px, 31px, 0px);">
|
||||
{% if sort != "hot" %}<a class="dropdown-item" href="?sort=hot"><i class="fas fa-fire mr-2"></i>Hot</a>{% endif %}
|
||||
{% if sort != "top" %}<a class="dropdown-item" href="?sort=top"><i class="fas fa-arrow-alt-circle-up mr-2"></i>Top</a>{% endif %}
|
||||
{% if sort != "bottom" %}<a class="dropdown-item" href="?sort=bottom"><i class="fas fa-arrow-alt-circle-down mr-2"></i>Bottom</a>{% endif %}
|
||||
{% if sort != "new" %}<a class="dropdown-item" href="?sort=new"><i class="fas fa-sparkles mr-2"></i>New</a>{% endif %}
|
||||
{% if sort != "old" %}<a class="dropdown-item" href="?sort=old"><i class="fas fa-book mr-2"></i>Old</a>{% endif %}
|
||||
{% if sort != "controversial" %}<a class="dropdown-item" href="?sort=controversial"><i class="fas fa-bullhorn mr-2"></i>Controversial</a>{% endif %}
|
||||
{% if sort != "random" %}<a class="dropdown-item" href="?sort=random"><i class="fas fa-random mr-2"></i>Random</a>{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{%- import 'util/macros.html' as macros with context -%}
|
||||
{{- macros.sorting_buttons(COMMENT_SORTS) -}}
|
||||
</div>
|
||||
|
||||
{{macros.comment_reply_box(p.fullname, 'comment-reply-' + p.fullname, subwrapper_css_classes='mb-3', enable_cancel_button=false)}}
|
||||
|
|
|
@ -58,27 +58,8 @@
|
|||
</div>
|
||||
|
||||
<div class="comments-count py-3">
|
||||
<div class="dropdown dropdown-actions">
|
||||
<button type="button" class="btn btn-secondary dropdown-toggle" id="dropdownMenuButton" data-bs-toggle="dropdown" style="margin-right:0.5em;">
|
||||
{% if sort=="hot" %}<i class="fas fa-fire mr-1"></i>{% endif %}
|
||||
{% if sort=="top" %}<i class="fas fa-arrow-alt-circle-up mr-1"></i>{% endif %}
|
||||
{% if sort=="bottom" %}<i class="fas fa-arrow-alt-circle-down mr-1"></i>{% endif %}
|
||||
{% if sort=="new" %}<i class="fas fa-sparkles mr-1"></i>{% endif %}
|
||||
{% if sort=="old" %}<i class="fas fa-book mr-1"></i>{% endif %}
|
||||
{% if sort=="controversial" %}<i class="fas fa-bullhorn mr-1"></i>{% endif %}
|
||||
{% if sort=="random" %}<i class="fas fa-random mr-1"></i>{% endif %}
|
||||
{{sort | capitalize}}
|
||||
</button>
|
||||
<div class="dropdown-menu" x-placement="bottom-start" style="position: absolute; will-change: transform; top: 0px; left: 0px; transform: translate3d(0px, 31px, 0px);">
|
||||
{% if sort != "hot" %}<a class="dropdown-item" href="?sort=hot"><i class="fas fa-fire mr-2"></i>Hot</a>{% endif %}
|
||||
{% if sort != "top" %}<a class="dropdown-item" href="?sort=top"><i class="fas fa-arrow-alt-circle-up mr-2"></i>Top</a>{% endif %}
|
||||
{% if sort != "bottom" %}<a class="dropdown-item" href="?sort=bottom"><i class="fas fa-arrow-alt-circle-down mr-2"></i>Bottom</a>{% endif %}
|
||||
{% if sort != "new" %}<a class="dropdown-item" href="?sort=new"><i class="fas fa-sparkles mr-2"></i>New</a>{% endif %}
|
||||
{% if sort != "old" %}<a class="dropdown-item" href="?sort=old"><i class="fas fa-book mr-2"></i>Old</a>{% endif %}
|
||||
{% if sort != "controversial" %}<a class="dropdown-item" href="?sort=controversial"><i class="fas fa-bullhorn mr-2"></i>Controversial</a>{% endif %}
|
||||
{% if sort != "random" %}<a class="dropdown-item" href="?sort=random"><i class="fas fa-random mr-2"></i>Random</a>{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{%- import 'util/macros.html' as macros with context -%}
|
||||
{{- macros.sorting_buttons(COMMENT_SORTS) -}}
|
||||
</div>
|
||||
|
||||
<div class="comment-section">
|
||||
|
|
|
@ -95,54 +95,13 @@
|
|||
|
||||
{% if not '/users' in request.path %}
|
||||
<div class="mt-3 d-flex align-items-center fl-r">
|
||||
<div class="dropdown dropdown-actions mr-2">
|
||||
<button type="button" class="btn btn-secondary dropdown-toggle" id="dropdownMenuButton" data-bs-toggle="dropdown">
|
||||
{% if t=="hour" %}<i class="fas fa-clock mr-1"></i>
|
||||
{% elif t=="day" %}<i class="fas fa-calendar-day mr-1"></i>
|
||||
{% elif t=="week" %}<i class="fas fa-calendar-week mr-1"></i>
|
||||
{% elif t=="month" %}<i class="fas fa-calendar-alt mr-1"></i>
|
||||
{% elif t=="year" %}<i class="fas fa-calendar mr-1"></i>
|
||||
{% elif t=="all" %}<i class="fas fa-infinity mr-1"></i>
|
||||
{% endif %}
|
||||
{{t | capitalize}}
|
||||
</button>
|
||||
<div class="dropdown-menu" 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="?q={{query | urlencode}}&sort={{sort}}&t=hour"><i class="fas fa-clock mr-2"></i>Hour</a>{% endif %}
|
||||
{% if t != "day" %}<a class="dropdown-item" href="?q={{query | urlencode}}&sort={{sort}}&t=day"><i class="fas fa-calendar-day mr-2"></i>Day</a>{% endif %}
|
||||
{% if t != "week" %}<a class="dropdown-item" href="?q={{query | urlencode}}&sort={{sort}}&t=week"><i class="fas fa-calendar-week mr-2"></i>Week</a>{% endif %}
|
||||
{% if t != "month" %}<a class="dropdown-item" href="?q={{query | urlencode}}&sort={{sort}}&t=month"><i class="fas fa-calendar-alt mr-2"></i>Month</a>{% endif %}
|
||||
{% if t != "year" %}<a class="dropdown-item" href="?q={{query | urlencode}}&sort={{sort}}&t=year"><i class="fas fa-calendar mr-2"></i>Year</a>{% endif %}
|
||||
{% if t != "all" %}<a class="dropdown-item" href="?q={{query | urlencode}}&sort={{sort}}&t=all"><i class="fas fa-infinity mr-2"></i>All</a>{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="dropdown dropdown-actions ml-2">
|
||||
<button type="button" class="btn btn-secondary dropdown-toggle" id="dropdownMenuButton2" data-bs-toggle="dropdown">
|
||||
{% if sort=="views" %}<i class="fas fa-eye mr-1"></i>{% endif %}
|
||||
{% if sort=="top" %}<i class="fas fa-arrow-alt-circle-up mr-1"></i>{% endif %}
|
||||
{% if sort=="bottom" %}<i class="fas fa-arrow-alt-circle-down mr-1"></i>{% endif %}
|
||||
{% if sort=="new" %}<i class="fas fa-sparkles mr-1"></i>{% endif %}
|
||||
{% if sort=="old" %}<i class="fas fa-book mr-1"></i>{% endif %}
|
||||
{% if sort=="controversial" %}<i class="fas fa-bullhorn mr-1"></i>{% endif %}
|
||||
{% if sort=="comments" %}<i class="fas fa-comments mr-1"></i>{% endif %}
|
||||
{% if sort=="subscriptions" %}<i class="fas fa-bell mr-1"></i>{% endif %}
|
||||
{% if sort=="saves" %}<i class="fas fa-save mr-1"></i>{% endif %}
|
||||
{% if sort=="random" %}<i class="fas fa-random mr-1"></i>{% endif %}
|
||||
{{sort | capitalize}}
|
||||
</button>
|
||||
<div class="dropdown-menu" x-placement="bottom-start" style="position: absolute; will-change: transform; top: 0px; left: 0px; transform: translate3d(0px, 31px, 0px);">
|
||||
{% if sort != "views" and "/posts" in request.path %}<a class="dropdown-item" href="?q={{query | urlencode}}&sort=views&t={{t}}"><i class="fas fa-eye mr-2"></i>Views</a>{% endif %}
|
||||
{% if sort != "top" %}<a class="dropdown-item" href="?q={{query | urlencode}}&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="?q={{query | urlencode}}&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="?q={{query | urlencode}}&sort=new&t={{t}}"><i class="fas fa-sparkles mr-2"></i>New</a>{% endif %}
|
||||
{% if sort != "old" %}<a class="dropdown-item" href="?q={{query | urlencode}}&sort=old&t={{t}}"><i class="fas fa-book mr-2"></i>Old</a>{% endif %}
|
||||
{% if sort != "controversial" %}<a class="dropdown-item" href="?q={{query | urlencode}}&sort=controversial&t={{t}}"><i class="fas fa-bullhorn mr-2"></i>Controversial</a>{% endif %}
|
||||
{% if sort != "comments" and "/posts" in request.path %}<a class="dropdown-item" href="?q={{query | urlencode}}&sort=comments&t={{t}}"><i class="fas fa-comments mr-2"></i>Comments</a>{% endif %}
|
||||
{% if sort != "subscriptions" and "/posts" in request.path %}<a class="dropdown-item" href="?q={{query | urlencode}}&sort=subscriptions&t={{t}}"><i class="fas fa-bell mr-2"></i>Subscriptions</a>{% endif %}
|
||||
{% if sort != "saves" %}<a class="dropdown-item" href="?q={{query | urlencode}}&sort=saves&t={{t}}"><i class="fas fa-save mr-2"></i>Saves</a>{% endif %}
|
||||
{% if sort != "random" %}<a class="dropdown-item" href="?q={{query | urlencode}}&sort=random&t={{t}}"><i class="fas fa-random mr-2"></i>Random</a>{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{%- import 'util/macros.html' as macros with context -%}
|
||||
{{- macros.time_filter_buttons() -}}
|
||||
{% if "/posts" in request.path %}
|
||||
{{- macros.sorting_buttons(POST_SORTS) -}}
|
||||
{% else %}
|
||||
{{- macros.sorting_buttons(COMMENT_SORTS) -}}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
|
|
@ -56,7 +56,7 @@
|
|||
<p>Change the default sorting for comments.</p>
|
||||
<div class="input-group">
|
||||
<select autocomplete="off" id='defaultsortingcomments' class="form-control setting_select" data-nonce="{{g.nonce}}" form="profile-settings" name="defaultsortingcomments">
|
||||
{% for entry in COMMENT_SORTS %}
|
||||
{% for entry in COMMENT_SORTS.keys() %}
|
||||
<option value="{{entry}}"{{' selected' if v.defaultsortingcomments==entry}}>{{entry}}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
|
@ -71,7 +71,7 @@
|
|||
<p>Change the default sorting for posts.</p>
|
||||
<div class="input-group">
|
||||
<select autocomplete="off" id='defaultsorting' class="form-control setting_select" data-nonce="{{g.nonce}}" form="profile-settings" name="defaultsorting">
|
||||
{% for entry in SORTS %}
|
||||
{% for entry in POST_SORTS.keys() %}
|
||||
<option value="{{entry}}"{{' selected' if v.defaultsorting==entry}}>{{entry}}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
|
@ -86,7 +86,7 @@
|
|||
<p>Change the default time filter for posts.</p>
|
||||
<div class="input-group">
|
||||
<select autocomplete="off" id='defaulttime' class="form-control setting_select" data-nonce="{{g.nonce}}" form="profile-settings" name="defaulttime">
|
||||
{% for entry in TIME_FILTERS %}
|
||||
{% for entry in TIME_FILTERS.keys() %}
|
||||
<option value="{{entry}}"{{' selected' if v.defaulttime==entry}}>{{entry}}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
|
|
|
@ -31,48 +31,13 @@
|
|||
<div class="d-flex justify-content-between align-items-center" style="padding-top:10px">
|
||||
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="dropdown dropdown-actions">
|
||||
<button type="button" class="btn btn-secondary dropdown-toggle" id="dropdownMenuButton" data-bs-toggle="dropdown">
|
||||
{% if t=="hour" %}<i class="fas fa-clock mr-1"></i>
|
||||
{% elif t=="day" %}<i class="fas fa-calendar-day mr-1"></i>
|
||||
{% elif t=="week" %}<i class="fas fa-calendar-week mr-1"></i>
|
||||
{% elif t=="month" %}<i class="fas fa-calendar-alt mr-1"></i>
|
||||
{% elif t=="year" %}<i class="fas fa-calendar mr-1"></i>
|
||||
{% elif t=="all" %}<i class="fas fa-infinity mr-1"></i>
|
||||
{% endif %}
|
||||
{{t | capitalize}}
|
||||
</button>
|
||||
<div class="dropdown-menu" 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"><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>
|
||||
|
||||
<div class="dropdown dropdown-actions ml-3">
|
||||
<button type="button" class="btn btn-secondary dropdown-toggle" id="dropdownMenuButton2" data-bs-toggle="dropdown">
|
||||
{% if sort=="top" %}<i class="fas fa-arrow-alt-circle-up mr-1"></i>{% endif %}
|
||||
{% if sort=="bottom" %}<i class="fas fa-arrow-alt-circle-down mr-1"></i>{% endif %}
|
||||
{% if sort=="new" %}<i class="fas fa-sparkles mr-1"></i>{% endif %}
|
||||
{% if sort=="old" %}<i class="fas fa-book mr-1"></i>{% endif %}
|
||||
{% if sort=="controversial" %}<i class="fas fa-bullhorn mr-1"></i>{% endif %}
|
||||
{% if sort=="random" %}<i class="fas fa-random mr-1"></i>{% endif %}
|
||||
{{sort | capitalize}}
|
||||
</button>
|
||||
<div class="dropdown-menu" x-placement="bottom-start" style="position: absolute; will-change: transform; top: 0px; left: 0px; transform: translate3d(0px, 31px, 0px);">
|
||||
{% 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 != "subscriptions" and "/posts" in request.path %}<a class="dropdown-item" href="?sort=subscriptions&t={{t}}"><i class="fas fa-bell mr-2"></i>Subscriptions</a>{% endif %}
|
||||
{% if sort != "saves" %}<a class="dropdown-item" href="?sort=saves&t={{t}}"><i class="fas fa-save mr-2"></i>Saves</a>{% endif %}
|
||||
{% if sort != "random" %}<a class="dropdown-item" href="?sort=random&t={{t}}"><i class="fas fa-random mr-2"></i>Random</a>{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{%- import 'util/macros.html' as macros with context -%}
|
||||
{{- macros.time_filter_buttons() -}}
|
||||
{% if "/posts" in request.path %}
|
||||
{{- macros.sorting_buttons(POST_SORTS) -}}
|
||||
{% else %}
|
||||
{{- macros.sorting_buttons(COMMENT_SORTS) -}}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
|
|
@ -350,3 +350,41 @@
|
|||
<div id="online" class="mt-3"></div>
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
||||
{% macro time_filter_buttons() %}
|
||||
<div class="dropdown dropdown-actions mr-2">
|
||||
<button type="button" class="btn btn-secondary dropdown-toggle" id="dropdownMenuButton" data-bs-toggle="dropdown">
|
||||
<i class="fas fa-{{TIME_FILTERS[t]}} mr-2"></i>
|
||||
{{t | capitalize}}
|
||||
</button>
|
||||
<div class="dropdown-menu" x-placement="bottom-start" style="position: absolute; will-change: transform; top: 0px; left: 0px;">
|
||||
{% for new_time, icon in TIME_FILTERS.items() %}
|
||||
{% if t != new_time %}
|
||||
<a class="dropdown-item" href="{{'t'|change_arg(new_time, request.full_path)|safe}}">
|
||||
<i class="fas fa-{{icon}} mr-2"></i>
|
||||
{{new_time | capitalize}}
|
||||
</a>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
||||
{% macro sorting_buttons(sorts) %}
|
||||
<div class="dropdown dropdown-actions">
|
||||
<button type="button" class="btn btn-secondary dropdown-toggle" id="dropdownMenuButton2" data-bs-toggle="dropdown">
|
||||
<i class="fas fa-{{sorts[sort]}} mr-1"></i>
|
||||
{{sort | capitalize}}
|
||||
</button>
|
||||
<div class="dropdown-menu" x-placement="bottom-start" style="position: absolute; will-change: transform; top: 0px; left: 0px;">
|
||||
{% for new_sort, icon in sorts.items() %}
|
||||
{% if sort != new_sort %}
|
||||
<a class="dropdown-item" href="{{'sort'|change_arg(new_sort, request.full_path)|safe}}">
|
||||
<i class="fas fa-{{icon}} mr-2"></i>
|
||||
{{new_sort | capitalize}}
|
||||
</a>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
|
Loading…
Reference in New Issue