From fcb74c7c9b0028676a974ff22a84ceb6a55c1b9b Mon Sep 17 00:00:00 2001 From: Aevann Date: Wed, 5 Jul 2023 00:40:00 +0300 Subject: [PATCH] convert /marseys into /emojis --- files/helpers/config/const.py | 1 - files/routes/asset_submissions.py | 6 +-- files/routes/static.py | 40 +++++++++---------- files/templates/{marseys.html => emojis.html} | 24 +++++------ files/templates/sidebar_WPD.html | 1 + files/templates/sidebar_rDrama.html | 2 +- 6 files changed, 34 insertions(+), 40 deletions(-) rename files/templates/{marseys.html => emojis.html} (56%) diff --git a/files/helpers/config/const.py b/files/helpers/config/const.py index 451468d04..f860daebc 100644 --- a/files/helpers/config/const.py +++ b/files/helpers/config/const.py @@ -557,7 +557,6 @@ PERMS = { # Minimum admin_level to perform action. } FEATURES = { - 'MARSEYS': True, 'MARSEYBUX': True, 'AWARDS': True, 'CHAT': True, diff --git a/files/routes/asset_submissions.py b/files/routes/asset_submissions.py index fcd40a20e..148306d51 100644 --- a/files/routes/asset_submissions.py +++ b/files/routes/asset_submissions.py @@ -184,8 +184,7 @@ def approve_emoji(v, name): cache.delete("emojis") - if emoji.kind == "Marsey": - cache.delete("marseys") + cache.delete("emoji_list") purge_files_in_cache(f"https://{SITE}/e/{emoji.name}/webp") @@ -494,8 +493,7 @@ def update_emoji(v): g.db.add(ma) cache.delete("emojis") - if existing.kind == "Marsey": - cache.delete("marseys") + cache.delete("emoji_list") return render_template("admin/update_assets.html", v=v, msg=f"'{name}' updated successfully!", name=name, tags=tags, kind=kind, type="Emoji") diff --git a/files/routes/static.py b/files/routes/static.py index 70ccc20fb..6760d318a 100644 --- a/files/routes/static.py +++ b/files/routes/static.py @@ -41,33 +41,29 @@ def reddit_post(subreddit, v, path): return redirect(f'https://{reddit}/{post_id}') -@cache.cached(key_prefix="marseys") -def get_marseys(): - if not FEATURES['MARSEYS']: return [] - marseys = [] - 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()): - marsey.author = author.username if FEATURES['ASSET_SUBMISSIONS'] else None - marseys.append(marsey) - return marseys +@cache.cached(key_prefix="emoji_list") +def get_emoji_list(): + 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()): + emoji.author = author.username if FEATURES['ASSET_SUBMISSIONS'] else None + emojis.append(emoji) + return emojis -@app.get("/marseys") +@app.get("/emojis") @limiter.limit(DEFAULT_RATELIMIT) @limiter.limit(DEFAULT_RATELIMIT, key_func=get_ID) -@auth_desired_with_logingate -def marseys(v:User): - if SITE_NAME != 'rDrama': - abort(404) - - marseys = get_marseys() - authors = get_accounts_dict([m.author_id for m in marseys], v=v, graceful=True) +@auth_required +def emoji_list(v:User): + emojis = get_emoji_list() + authors = get_accounts_dict([e.author_id for e in emojis], v=v, graceful=True) original = os.listdir("/asset_submissions/emojis/original") - for marsey in marseys: - marsey.user = authors.get(marsey.author_id) + for emoji in emojis: + emoji.user = authors.get(emoji.author_id) for x in IMAGE_FORMATS: - if f'{marsey.name}.{x}' in original: - marsey.og = f'{marsey.name}.{x}' + if f'{emoji.name}.{x}' in original: + emoji.og = f'{emoji.name}.{x}' 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, key_func=get_ID) @auth_required -def emoji_list(v): +def emojis(v): return get_emojis() diff --git a/files/templates/marseys.html b/files/templates/emojis.html similarity index 56% rename from files/templates/marseys.html rename to files/templates/emojis.html index 0a9de3e19..fb5f8f894 100644 --- a/files/templates/marseys.html +++ b/files/templates/emojis.html @@ -1,13 +1,13 @@ {% extends "default.html" %} -{% block pagetitle %}Marseys{% endblock %} -{% block pagetype %}marseys{% endblock %} +{% block pagetitle %}Emojis{% endblock %} +{% block pagetype %}emojis{% endblock %} {% block content %}
- + {% if FEATURES['ASSET_SUBMISSIONS'] %} @@ -18,22 +18,22 @@ {% endif %} - -{% for marsey in marseys %} + +{% for emoji in emojis %} - - - + + + {% if FEATURES['ASSET_SUBMISSIONS'] %} - {% set user = marsey.user %} + {% set user = emoji.user %} {% endif %} - + {% if FEATURES['ASSET_SUBMISSIONS'] %} {% endif %} diff --git a/files/templates/sidebar_WPD.html b/files/templates/sidebar_WPD.html index cd285de41..9bf373d7e 100644 --- a/files/templates/sidebar_WPD.html +++ b/files/templates/sidebar_WPD.html @@ -22,6 +22,7 @@

+ diff --git a/files/templates/sidebar_rDrama.html b/files/templates/sidebar_rDrama.html index d714e9eb7..945b4625d 100644 --- a/files/templates/sidebar_rDrama.html +++ b/files/templates/sidebar_rDrama.html @@ -28,7 +28,7 @@

- +

# NameMarseyEmoji UsageAuthor
{{loop.index}}{{marsey.name}}:#{{marsey.name}}:{{marsey.count}}{{emoji.name}}:#{{emoji.name}}:{{emoji.count}}{% include "user_in_table.html" %} - {% if marsey.og %} - {{marsey.og}} + {% if emoji.og %} + {{emoji.og}} {% endif %}