add kind filter in /emojis

pull/180/head
Aevann 2023-08-05 14:13:59 +03:00
parent 787863644a
commit ff78548f82
15 changed files with 27 additions and 13 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.4 KiB

View File

@ -187,7 +187,7 @@ def approve_emoji(v, name):
cache.delete("emojis")
cache.delete("emoji_list")
cache.delete(f"emoji_list_{emoji.kind}")
purge_files_in_cache(f"{SITE_FULL_IMAGES}/e/{emoji.name}/webp")
@ -494,7 +494,7 @@ def update_emoji(v):
g.db.add(ma)
cache.delete("emojis")
cache.delete("emoji_list")
cache.delete(f"emoji_list_{existing.kind}")
return render_template("admin/update_assets.html", v=v, msg=f"'{name}' updated successfully!", name=name, tags=tags, kind=kind, type="Emoji")

View File

@ -41,24 +41,25 @@ def reddit_post(subreddit, v, path):
return redirect(f'https://{reddit}/{post_id}')
@cache.cached(make_cache_key=lambda:"emoji_list")
def get_emoji_list():
@cache.cached(make_cache_key=lambda kind:f"emoji_list_{kind}")
def get_emoji_list(kind):
emojis = []
for emoji, author in g.db.query(Emoji, User).join(User, Emoji.author_id == User.id).filter(Emoji.submitter_id == None).order_by(Emoji.count.desc()):
for emoji, author in g.db.query(Emoji, User).join(User, Emoji.author_id == User.id).filter(Emoji.submitter_id == None, Emoji.kind == kind).order_by(Emoji.count.desc()):
emoji.author = author.username if FEATURES['ASSET_SUBMISSIONS'] else None
emojis.append(emoji)
return emojis
@app.get("/marseys")
def marseys_redirect():
return redirect("/emojis")
@app.get("/emojis")
def marseys_redirect():
return redirect("/emojis/Platy")
@app.get("/emojis/<kind>")
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400)
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID)
@auth_required
def emoji_list(v):
emojis = get_emoji_list()
def emoji_list(v, kind):
emojis = get_emoji_list(kind)
authors = get_accounts_dict([e.author_id for e in emojis], v=v, graceful=True)
if FEATURES['ASSET_SUBMISSIONS']:
@ -73,7 +74,7 @@ def emoji_list(v):
for emoji in emojis:
emoji.user = authors.get(emoji.author_id)
return render_template("emojis.html", v=v, emojis=emojis)
return render_template("emojis.html", v=v, emojis=emojis, kind=kind)

View File

@ -2,6 +2,19 @@
{% block pagetitle %}Emojis{% endblock %}
{% block pagetype %}emojis{% endblock %}
{% block content %}
<div class="d-flex align-items-center mt-3 mb-4">
<div class="dropdown dropdown-actions mx-auto">
<button type="button" class="btn btn-secondary dropdown-toggle" id="dropdownMenuButton" data-bs-toggle="dropdown" style="width:min(95vw, 900px)">
<img loading="lazy" src="{{SITE_FULL_IMAGES}}/e/{{kind.lower()}}.webp" alt=":{{kind.lower()}}:" class="mr-2">{{kind}}
</button>
<div class="dropdown-menu" x-placement="bottom-start" style="position: absolute; will-change: transform; top: 0px; left: 0px; transform: translate3d(0px, 31px, 0px); max-height: 50vh;overflow: auto;width:min(95vw, 900px)">
{% for kind in EMOJI_KINDS %}
<a class="dropdown-item" href="/emojis/{{kind}}"><img loading="lazy" src="{{SITE_FULL_IMAGES}}/e/{{kind.lower()}}.webp" alt=":{{kind.lower()}}:" class="mr-2">{{kind}}</a>
{% endfor %}
</div>
</div>
</div>
<div class="overflow-x-auto mt-3"><table class="table table-striped mb-5">
<thead class="bg-primary text-white">
<tr>

View File

@ -21,7 +21,7 @@
{% endif %}
<p class="text-center text-md mb-4">
<a class="sidebar-link" href="/emojis" data-bs-toggle="tooltip" data-bs-placement="top" title="Emojis"><i class="fas fa-cat"></i></a>
<a class="sidebar-link" href="/emojis/Platy" data-bs-toggle="tooltip" data-bs-placement="top" title="Emojis"><i class="fas fa-cat"></i></a>
<a class="sidebar-link" href="/badges" data-bs-toggle="tooltip" data-bs-placement="top" title="Badges"><i class="fas fa-hexagon"></i></a>
<a class="sidebar-link" href="/admins" data-bs-toggle="tooltip" data-bs-placement="top" title="Admins"><i class="fas fa-crown"></i></a>
<a class="sidebar-link" href="/log" data-bs-toggle="tooltip" data-bs-placement="top" title="Moderation Log"><i class="fas fa-scroll-old"></i></a>

View File

@ -27,7 +27,7 @@
{% endif %}
<p class="text-center text-md mb-4">
<a class="sidebar-link" href="/emojis" data-bs-toggle="tooltip" data-bs-placement="top" title="Emojis"><i class="fas fa-cat"></i></a>
<a class="sidebar-link" href="/emojis/Platy" data-bs-toggle="tooltip" data-bs-placement="top" title="Emojis"><i class="fas fa-cat"></i></a>
<a class="sidebar-link" href="/badges" data-bs-toggle="tooltip" data-bs-placement="top" title="Badges"><i class="fas fa-hexagon"></i></a>
<a class="sidebar-link" href="/admins" data-bs-toggle="tooltip" data-bs-placement="top" title="Admins"><i class="fas fa-crown"></i></a>
<a class="sidebar-link" href="/log" data-bs-toggle="tooltip" data-bs-placement="top" title="Moderation Log"><i class="fas fa-scroll-old"></i></a>