From b60f3deb90cb445b6fd258bb0b7ef614f015a54e Mon Sep 17 00:00:00 2001 From: Aevann Date: Thu, 26 Oct 2023 17:58:58 +0300 Subject: [PATCH] show appropriate author credit for emojis --- files/assets/js/emoji_modal.js | 15 +++++---------- files/routes/static.py | 7 ++++++- files/templates/emojis.html | 6 +++--- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/files/assets/js/emoji_modal.js b/files/assets/js/emoji_modal.js index 163b374f0..e9810a2e0 100644 --- a/files/assets/js/emoji_modal.js +++ b/files/assets/js/emoji_modal.js @@ -163,7 +163,7 @@ function fetchEmojis() { if (! (emojis instanceof Array )) throw new TypeError("[EMOJI DIALOG] rDrama's server should have sent a JSON-coded Array!"); - globalEmojis = emojis.map(({name, author, count}) => ({name, author, count})); + globalEmojis = emojis.map(({name, author_username, count}) => ({name, author_username, count})); let classes = ["Marsey", "Platy", "Wolf", "Donkey Kong", "Tay", "Capy", "Carp", "Marsey Flags", "Marsey Alphabet", "Classic", "Rage", "Wojak", "Misc"] @@ -175,14 +175,11 @@ function fetchEmojis() { emojisSearchDictionary.updateTag(emoji.name, emoji.name); - if (emoji.author_username !== undefined && emoji.author_username !== null) + if (!emoji.author_username.endsWith(' user')) { emojisSearchDictionary.updateTag(`@${emoji.author_username.toLowerCase()}`, emoji.name); - - if (emoji.author_original_username !== undefined && emoji.author_original_username !== null) emojisSearchDictionary.updateTag(`@${emoji.author_original_username.toLowerCase()}`, emoji.name); - - if (emoji.author_prelock_username !== undefined && emoji.author_prelock_username !== null) emojisSearchDictionary.updateTag(`@${emoji.author_prelock_username.toLowerCase()}`, emoji.name); + } if (emoji.tags instanceof Array) for(let i = 0; i < emoji.tags.length; i++) @@ -192,8 +189,7 @@ function fetchEmojis() { const emojiDOM = document.importNode(emojiButtonTemplateDOM.content, true).children[0]; emojiDOM.title = emoji.name - if (emoji.author_username !== undefined && emoji.author_username !== null) - emojiDOM.title += "\nauthor\t" + emoji.author_username + emojiDOM.title += "\nauthor\t" + emoji.author_username if (emoji.count !== undefined) emojiDOM.title += "\nused\t" + emoji.count; emojiDOM.dataset.className = emoji.kind; @@ -414,8 +410,7 @@ function populate_speed_emoji_modal(results, textbox) emoji_option_text.title = name; - if (emoji.author_username !== undefined && emoji.author_username !== null) - emoji_option_text.title += "\nauthor\t" + emoji.author_username + emoji_option_text.title += "\nauthor\t" + emoji.author_username if (emoji.count !== undefined) emoji_option_text.title += "\nused\t" + emoji.count; diff --git a/files/routes/static.py b/files/routes/static.py index d522e5d8d..460fa5e28 100644 --- a/files/routes/static.py +++ b/files/routes/static.py @@ -99,7 +99,12 @@ def get_emojis(nsfw): collected = [] for emoji, author in emojis: - if FEATURES['EMOJI_SUBMISSIONS']: + if author.id == 2: + if SITE == 'rdrama.net': + emoji.author_username = 'a WPD user' + else: + emoji.author_username = 'an rDrama user' + else: emoji.author_username = author.username emoji.author_original_username = author.original_username emoji.author_prelock_username = author.prelock_username diff --git a/files/templates/emojis.html b/files/templates/emojis.html index 71f750bd9..c0b88cf2c 100644 --- a/files/templates/emojis.html +++ b/files/templates/emojis.html @@ -46,10 +46,10 @@ {% if FEATURES['EMOJI_SUBMISSIONS'] %} {% if emoji.author_id == 2 %} - {% if SITE_NAME == 'WPD' %} - an rDrama user - {% else %} + {% if SITE == 'rdrama.net' %} a WPD user + {% else %} + an rDrama user {% endif %} {% else %} {% set user = emoji.user %}