Deduplicate featured hashtags

merge-requests/30/head
Bob Mottram 2023-05-03 12:07:34 +01:00
parent aaeb49b202
commit 4be67440e9
2 changed files with 10 additions and 3 deletions

View File

@ -1950,7 +1950,8 @@ def get_featured_hashtags(actor_json: {}) -> str:
return result.strip() return result.strip()
def get_featured_hashtags_as_html(actor_json: {}) -> str: def get_featured_hashtags_as_html(actor_json: {},
profile_description: str) -> str:
"""returns a html string containing featured hashtags """returns a html string containing featured hashtags
""" """
result = '' result = ''
@ -1981,6 +1982,10 @@ def get_featured_hashtags_as_html(actor_json: {}) -> str:
tag_name = tag_name[1:] tag_name = tag_name[1:]
if not tag_name: if not tag_name:
continue continue
if '/tags/' + tag_name + '"' in profile_description:
continue
if ' #' + tag_name in profile_description:
continue
tag_url = tag_dict['href'] tag_url = tag_dict['href']
if '://' not in tag_url: if '://' not in tag_url:
continue continue

View File

@ -269,7 +269,8 @@ def html_profile_after_search(recent_posts_cache: {}, max_recent_posts: int,
add_emoji_to_display_name(session, base_dir, http_prefix, add_emoji_to_display_name(session, base_dir, http_prefix,
nickname, domain, nickname, domain,
profile_description, False, translate) profile_description, False, translate)
featured_hashtags = get_featured_hashtags_as_html(profile_json) featured_hashtags = \
get_featured_hashtags_as_html(profile_json, profile_description)
outbox_url = None outbox_url = None
if not profile_json.get('outbox'): if not profile_json.get('outbox'):
if debug: if debug:
@ -749,7 +750,8 @@ def html_profile(signing_priv_key_pem: str,
profile_description, False, translate) profile_description, False, translate)
if profile_description: if profile_description:
profile_description = standardize_text(profile_description) profile_description = standardize_text(profile_description)
featured_hashtags = get_featured_hashtags_as_html(profile_json) featured_hashtags = \
get_featured_hashtags_as_html(profile_json, profile_description)
posts_button = 'button' posts_button = 'button'
following_button = 'button' following_button = 'button'
moved_button = 'button' moved_button = 'button'