convert /marseys into /emojis

master
Aevann 2023-07-05 00:40:00 +03:00
parent 225c63af0b
commit fcb74c7c9b
6 changed files with 34 additions and 40 deletions

View File

@ -557,7 +557,6 @@ PERMS = { # Minimum admin_level to perform action.
} }
FEATURES = { FEATURES = {
'MARSEYS': True,
'MARSEYBUX': True, 'MARSEYBUX': True,
'AWARDS': True, 'AWARDS': True,
'CHAT': True, 'CHAT': True,

View File

@ -184,8 +184,7 @@ def approve_emoji(v, name):
cache.delete("emojis") cache.delete("emojis")
if emoji.kind == "Marsey": cache.delete("emoji_list")
cache.delete("marseys")
purge_files_in_cache(f"https://{SITE}/e/{emoji.name}/webp") purge_files_in_cache(f"https://{SITE}/e/{emoji.name}/webp")
@ -494,8 +493,7 @@ def update_emoji(v):
g.db.add(ma) g.db.add(ma)
cache.delete("emojis") cache.delete("emojis")
if existing.kind == "Marsey": cache.delete("emoji_list")
cache.delete("marseys")
return render_template("admin/update_assets.html", v=v, msg=f"'{name}' updated successfully!", name=name, tags=tags, kind=kind, type="Emoji") 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,33 +41,29 @@ def reddit_post(subreddit, v, path):
return redirect(f'https://{reddit}/{post_id}') return redirect(f'https://{reddit}/{post_id}')
@cache.cached(key_prefix="marseys") @cache.cached(key_prefix="emoji_list")
def get_marseys(): def get_emoji_list():
if not FEATURES['MARSEYS']: return [] emojis = []
marseys = [] 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 marsey, author in g.db.query(Emoji, User).join(User, Emoji.author_id == User.id).filter(Emoji.kind == "Marsey", Emoji.submitter_id == None).order_by(Emoji.count.desc()): emoji.author = author.username if FEATURES['ASSET_SUBMISSIONS'] else None
marsey.author = author.username if FEATURES['ASSET_SUBMISSIONS'] else None emojis.append(emoji)
marseys.append(marsey) return emojis
return marseys
@app.get("/marseys") @app.get("/emojis")
@limiter.limit(DEFAULT_RATELIMIT) @limiter.limit(DEFAULT_RATELIMIT)
@limiter.limit(DEFAULT_RATELIMIT, key_func=get_ID) @limiter.limit(DEFAULT_RATELIMIT, key_func=get_ID)
@auth_desired_with_logingate @auth_required
def marseys(v:User): def emoji_list(v:User):
if SITE_NAME != 'rDrama': emojis = get_emoji_list()
abort(404) authors = get_accounts_dict([e.author_id for e in emojis], v=v, graceful=True)
marseys = get_marseys()
authors = get_accounts_dict([m.author_id for m in marseys], v=v, graceful=True)
original = os.listdir("/asset_submissions/emojis/original") original = os.listdir("/asset_submissions/emojis/original")
for marsey in marseys: for emoji in emojis:
marsey.user = authors.get(marsey.author_id) emoji.user = authors.get(emoji.author_id)
for x in IMAGE_FORMATS: for x in IMAGE_FORMATS:
if f'{marsey.name}.{x}' in original: if f'{emoji.name}.{x}' in original:
marsey.og = f'{marsey.name}.{x}' emoji.og = f'{emoji.name}.{x}'
break break
return render_template("marseys.html", v=v, marseys=marseys) return render_template("emojis.html", v=v, emojis=emojis)
@ -91,7 +87,7 @@ def get_emojis():
@limiter.limit(DEFAULT_RATELIMIT) @limiter.limit(DEFAULT_RATELIMIT)
@limiter.limit(DEFAULT_RATELIMIT, key_func=get_ID) @limiter.limit(DEFAULT_RATELIMIT, key_func=get_ID)
@auth_required @auth_required
def emoji_list(v): def emojis(v):
return get_emojis() return get_emojis()

View File

@ -1,13 +1,13 @@
{% extends "default.html" %} {% extends "default.html" %}
{% block pagetitle %}Marseys{% endblock %} {% block pagetitle %}Emojis{% endblock %}
{% block pagetype %}marseys{% endblock %} {% block pagetype %}emojis{% endblock %}
{% block content %} {% block content %}
<div class="overflow-x-auto mt-3"><table class="table table-striped mb-5"> <div class="overflow-x-auto mt-3"><table class="table table-striped mb-5">
<thead class="bg-primary text-white"> <thead class="bg-primary text-white">
<tr> <tr>
<th>#</th> <th>#</th>
<th>Name</th> <th>Name</th>
<th>Marsey</th> <th>Emoji</th>
<th>Usage</th> <th>Usage</th>
{% if FEATURES['ASSET_SUBMISSIONS'] %} {% if FEATURES['ASSET_SUBMISSIONS'] %}
<th>Author</th> <th>Author</th>
@ -18,22 +18,22 @@
{% endif %} {% endif %}
</tr> </tr>
</thead> </thead>
<tbody id="marseys-table"> <tbody id="emojis-table">
{% for marsey in marseys %} {% for emoji in emojis %}
<tr> <tr>
<td>{{loop.index}}</td> <td>{{loop.index}}</td>
<td>{{marsey.name}}</td> <td>{{emoji.name}}</td>
<td><img class="marsey" loading="lazy" data-bs-toggle="tooltip" alt=":#{{marsey.name}}:" title=":{{marsey.name}}:" src="/e/{{marsey.name}}.webp"></td> <td><img class="emoji" loading="lazy" data-bs-toggle="tooltip" alt=":#{{emoji.name}}:" title=":{{emoji.name}}:" src="/e/{{emoji.name}}.webp"></td>
<td>{{marsey.count}}</td> <td>{{emoji.count}}</td>
{% if FEATURES['ASSET_SUBMISSIONS'] %} {% if FEATURES['ASSET_SUBMISSIONS'] %}
{% set user = marsey.user %} {% set user = emoji.user %}
<td>{% include "user_in_table.html" %}</td> <td>{% include "user_in_table.html" %}</td>
{% endif %} {% endif %}
<td data-sort-key="{{marsey.created_utc or 0}}" {% if marsey.created_utc != None %}data-time="{{marsey.created_utc}}"{% endif %}></td> <td data-sort-key="{{emoji.created_utc or 0}}" {% if emoji.created_utc != None %}data-time="{{emoji.created_utc}}"{% endif %}></td>
{% if FEATURES['ASSET_SUBMISSIONS'] %} {% if FEATURES['ASSET_SUBMISSIONS'] %}
<td> <td>
{% if marsey.og %} {% if emoji.og %}
<a href="{{SITE_FULL_IMAGES}}/asset_submissions/emojis/original/{{marsey.og}}">{{marsey.og}}</a> <a href="{{SITE_FULL_IMAGES}}/asset_submissions/emojis/original/{{emoji.og}}">{{emoji.og}}</a>
{% endif %} {% endif %}
</td> </td>
{% endif %} {% endif %}

View File

@ -22,6 +22,7 @@
<p class="text-center text-md mb-4"> <p class="text-center text-md mb-4">
<a class="sidebar-link d-md-none" href="/random_user" data-bs-toggle="tooltip" data-bs-placement="top" title="Random User with a Profile Anthem"><i class="fas fa-music"></i></a> <a class="sidebar-link d-md-none" href="/random_user" data-bs-toggle="tooltip" data-bs-placement="top" title="Random User with a Profile Anthem"><i class="fas fa-music"></i></a>
<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="/badges" data-bs-toggle="tooltip" data-bs-placement="top" title="Badges"><i class="fas fa-hexagon"></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="/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> <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

@ -28,7 +28,7 @@
<p class="text-center text-md mb-4"> <p class="text-center text-md mb-4">
<a class="sidebar-link d-md-none" href="/random_user" data-bs-toggle="tooltip" data-bs-placement="top" title="Random User with a Profile Anthem"><i class="fas fa-music"></i></a> <a class="sidebar-link d-md-none" href="/random_user" data-bs-toggle="tooltip" data-bs-placement="top" title="Random User with a Profile Anthem"><i class="fas fa-music"></i></a>
<a class="sidebar-link" href="/marseys" data-bs-toggle="tooltip" data-bs-placement="top" title="Marseys"><i class="fas fa-cat"></i></a> <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="/badges" data-bs-toggle="tooltip" data-bs-placement="top" title="Badges"><i class="fas fa-hexagon"></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="/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> <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>