diff --git a/person.py b/person.py index a9628ba2f..d2933935b 100644 --- a/person.py +++ b/person.py @@ -1946,6 +1946,51 @@ def get_featured_hashtags(actor_json: {}) -> str: return result.strip() +def get_featured_hashtags_as_html(actor_json: {}) -> str: + """returns a html string containing featured hashtags + """ + result = '' + if not actor_json.get('tag'): + return result + if not isinstance(actor_json['tag'], list): + return result + for tag_dict in actor_json['tag']: + if not tag_dict.get('type'): + continue + if not isinstance(tag_dict['type'], str): + continue + if not tag_dict['type'].endswith('Hashtag'): + continue + if not tag_dict.get('name'): + continue + if not isinstance(tag_dict['name'], str): + continue + if not tag_dict.get('href'): + continue + if not isinstance(tag_dict['href'], str): + continue + tag_name = tag_dict['name'] + if not tag_name: + continue + if tag_name.startswith('#'): + tag_name = tag_name[1:] + if not tag_name: + continue + tag_url = tag_dict['href'] + if '://' not in tag_url: + continue + if not valid_hash_tag(tag_name): + continue + result += \ + ' ' + result = result.strip() + if result: + result = '

' + result + '

' + return result + + def set_featured_hashtags(actor_json: {}, hashtags: str, append: bool = False) -> None: """sets featured hashtags diff --git a/webapp_profile.py b/webapp_profile.py index dd6d10527..e6f0d5e8f 100644 --- a/webapp_profile.py +++ b/webapp_profile.py @@ -36,6 +36,7 @@ from utils import remove_eol from languages import get_actor_languages from skills import get_skills from theme import get_themes_list +from person import get_featured_hashtags_as_html from person import get_featured_hashtags from person import person_box_json from person import get_actor_json @@ -268,6 +269,7 @@ def html_profile_after_search(recent_posts_cache: {}, max_recent_posts: int, add_emoji_to_display_name(session, base_dir, http_prefix, nickname, domain, profile_description, False, translate) + profile_description += get_featured_hashtags_as_html(profile_json) outbox_url = None if not profile_json.get('outbox'): if debug: @@ -738,6 +740,7 @@ def html_profile(signing_priv_key_pem: str, profile_description, False, translate) if profile_description: profile_description = standardize_text(profile_description) + profile_description += get_featured_hashtags_as_html(profile_json) posts_button = 'button' following_button = 'button' moved_button = 'button'