From c341f878167de7d543402f0d028566dcc48537ec Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 17 Jan 2025 19:28:38 +0000 Subject: [PATCH] Fixing emojis --- content.py | 2 +- tests.py | 39 +++++++++++++++++++++++++++++++++++++++ webapp_profile.py | 4 ---- 3 files changed, 40 insertions(+), 5 deletions(-) diff --git a/content.py b/content.py index 34529e04f..a6e295aa8 100644 --- a/content.py +++ b/content.py @@ -476,7 +476,7 @@ def replace_emoji_from_tags(session, base_dir: str, icon_name = tag_url.split('/')[-1] if len(icon_name) <= 1: continue - if not (icon_name[0].isdigit() and '.' in icon_name): + if '.' not in icon_name: continue icon_name = icon_name.split('.')[0] # see https://unicode.org/ diff --git a/tests.py b/tests.py index 863876b80..367284e0a 100644 --- a/tests.py +++ b/tests.py @@ -227,6 +227,7 @@ from reading import get_reading_status from reading import store_book_events from conversation import conversation_tag_to_convthread_id from conversation import convthread_id_to_conversation_tag +from webapp_utils import add_emoji_to_display_name TEST_SERVER_GROUP_RUNNING = False @@ -4103,6 +4104,44 @@ def _test_addemoji(base_dir: str): print('content_modified: ' + content_modified) assert content_modified == expected_content + profile_description = \ + "

Software engineer developing federated and decentralized " + \ + "systems for a more habitable, resillient and human-scale " + \ + "internet, respecting people and the planet. Founder of the " + \ + "" + \ + "#LibreServer" + \ + " and #" + \ + "Epicyon projects. Anarcho-gardener. " + \ + ":cupofcoffee: #" + \ + "fedi22 #" + \ + "debian #" + \ + "python #" + \ + "selfhosting #" + \ + "smalltech #" + \ + "nobridge

" + session = None + profile_description2 = \ + add_emoji_to_display_name(session, base_dir, http_prefix, + nickname, domain, + profile_description, False, translate) + assert ':cupofcoffee:' in profile_description + assert ':cupofcoffee:' not in profile_description2 + os.chdir(base_dir_original) shutil.rmtree(base_dir_original + '/.tests', ignore_errors=False) diff --git a/webapp_profile.py b/webapp_profile.py index c7d6a5f4c..43fce5be7 100644 --- a/webapp_profile.py +++ b/webapp_profile.py @@ -1095,18 +1095,14 @@ def html_profile(signing_priv_key_pem: str, profile_description = profile_json['summary'] else: profile_description = remove_html(profile_json['summary']) - print('TEST profile description 1: ' + profile_description) profile_description = \ remove_link_trackers_from_content(profile_description) - print('TEST profile description 2: ' + profile_description) profile_description = \ add_emoji_to_display_name(session, base_dir, http_prefix, nickname, domain, profile_description, False, translate) - print('TEST profile description 3: ' + profile_description) if profile_description: profile_description = standardize_text(profile_description) - print('TEST profile description 4: ' + profile_description) featured_hashtags = \ get_featured_hashtags_as_html(profile_json, profile_description) posts_button = 'button'