diff --git a/webapp_post.py b/webapp_post.py index fc9c6173f..08115cb34 100644 --- a/webapp_post.py +++ b/webapp_post.py @@ -1442,7 +1442,7 @@ def _get_blog_citations_html(box_name: str, '' + citation_name + '\n' if citations_str: - translated_citations_str = 'Citations' + translated_citations_str: str = 'Citations' if translate.get(translated_citations_str): translated_citations_str = translate[translated_citations_str] citations_str = '

' + translated_citations_str + ':

' + \ @@ -1453,7 +1453,7 @@ def _get_blog_citations_html(box_name: str, def _boost_own_post_html(translate: {}) -> str: """The html title for announcing your own post """ - announces_str = 'announces' + announces_str: str = 'announces' if translate.get(announces_str): announces_str = translate[announces_str] return ' ' + \
@@ -1492,12 +1492,12 @@ def _announce_with_display_name_html(translate: {},
                                      announce_handle: str) -> str:
     str: """Returns html for a title which is a reply to yourself """ - replying_to_themselves_str = 'replying to themselves' + replying_to_themselves_str: str = 'replying to themselves' if translate.get(replying_to_themselves_str): replying_to_themselves_str = translate[replying_to_themselves_str] - title_str = \ + title_str: str = \ ' ' + replying_to_themselves_str + \
@@ -1664,7 +1664,7 @@ def _reply_to_yourself_html(translate: {}, software_name: str) -> str:
 def _replying_to_with_scope(post_json_object: {}, translate: {}) -> str:
     str: """Returns the html title for a reply to an unknown handle """ - replying_to_str = _replying_to_with_scope(post_json_object, translate) - post_id = get_reply_to(post_json_object['object']) - post_bookmark = '#' + bookmark_from_id(post_id) - post_link = '/users/' + nickname + '?convthread=' + \ + replying_to_str: str = _replying_to_with_scope(post_json_object, translate) + post_id: str = get_reply_to(post_json_object['object']) + post_bookmark: str = '#' + bookmark_from_id(post_id) + post_link: str = '/users/' + nickname + '?convthread=' + \ post_id.replace('--', '/') + post_bookmark - title_str = \ + title_str: str = \ ' ' + \
         replying_to_str + '\n' footer_str += \ reply_str + announce_str + like_str + bookmark_str + reaction_str @@ -2059,8 +2059,8 @@ def _get_footer_with_icons(show_icons: bool, footer_str += _get_copyright_footer(content_license_url, translate) # show the date - post_bookmark = '#' + bookmark_from_id(published_link) - date_link = '/users/' + nickname + '?convthread=' + \ + post_bookmark: str = '#' + bookmark_from_id(published_link) + date_link: str = '/users/' + nickname + '?convthread=' + \ published_link.replace('--', '/') + post_bookmark footer_str += '' + \ @@ -2251,8 +2259,8 @@ def _get_buy_footer(buy_links: {}, translate: {}) -> str: """ if not buy_links: return '' - icon_filename = 'buy.png' - description = translate['Buy'] + icon_filename: str = 'buy.png' + description: str = translate['Buy'] buy_str: str = '' for _, buy_url in buy_links.items(): buy_str = \ @@ -2269,7 +2277,7 @@ def _get_buy_footer(buy_links: {}, translate: {}) -> str: def remove_incomplete_code_tags(content: str) -> str: """Remove any uncompleted code tags """ - tags = ('code', 'pre') + tags: list[str] = ('code', 'pre') for tag_name in tags: if '<' + tag_name not in content and \ ' str: """Show an individual post as html """ - original_post_json = post_json_object + original_post_json: dict = post_json_object post_str: str = '' by_str: str = '' by_text: str = '' @@ -3616,10 +3624,10 @@ def html_individual_post(recent_posts_cache: {}, max_recent_posts: int, block_government, block_bluesky, block_nostr) - message_id = remove_id_ending(post_json_object['id']) + message_id: str = remove_id_ending(post_json_object['id']) # show the previous posts - obj = post_json_object + obj: dict = post_json_object if has_object_dict(post_json_object): obj = post_json_object['object'] post_id = True @@ -3722,14 +3730,15 @@ def html_individual_post(recent_posts_cache: {}, max_recent_posts: int, block_government, block_bluesky, block_nostr) - css_filename = base_dir + '/epicyon-profile.css' + css_filename: str = base_dir + '/epicyon-profile.css' if is_a_file(base_dir + '/epicyon.css'): css_filename = base_dir + '/epicyon.css' - instance_title = \ + instance_title: str = \ get_config_param(base_dir, 'instanceTitle') - metadata_str = _html_post_metadata_open_graph(domain, original_post_json, - system_language) + metadata_str: str = \ + _html_post_metadata_open_graph(domain, original_post_json, + system_language) if post_json_object.get('id'): # https://swicg.github.io/activitypub-html-discovery/#html-link-element # link to the activitypub post @@ -3741,7 +3750,7 @@ def html_individual_post(recent_posts_cache: {}, max_recent_posts: int, # activitypub-html-discovery/#discovering-author-html # link to the author's actor if obj.get('attributedTo'): - actor = get_attributed_to(obj['attributedTo']) + actor: str = get_attributed_to(obj['attributedTo']) if actor: metadata_str += \ '
\n' + \ @@ -3898,31 +3908,32 @@ def html_emoji_reaction_picker(recent_posts_cache: {}, max_recent_posts: int, block_bluesky, block_nostr) - reactions_filename = base_dir + '/emoji/reactions.json' + reactions_filename: str = base_dir + '/emoji/reactions.json' if not is_a_file(reactions_filename): reactions_filename = base_dir + '/emoji/default_reactions.json' - reactions_json = load_json(reactions_filename) + reactions_json: dict = load_json(reactions_filename) emoji_picks_str: str = '' - base_url = '/users/' + nickname - post_id = remove_id_ending(post_json_object['id']) - actor_url = get_actor_from_post(post_json_object) + base_url: str = '/users/' + nickname + post_id: str = remove_id_ending(post_json_object['id']) + actor_url: str = get_actor_from_post(post_json_object) for _, item in reactions_json.items(): emoji_picks_str += '
\n' for emoji_content in item: emoji_content_encoded = urllib.parse.quote_plus(emoji_content) - emoji_url = \ + emoji_url: str = \ base_url + '?react=' + post_id + \ '?actor=' + actor_url + \ '?tl=' + box_name + \ '?page=' + str(page_number) + \ '?emojreact=' + emoji_content_encoded - emoji_label = '' + emoji_label: str = \ + '' emoji_picks_str += \ ' ' + \ emoji_label + '\n' emoji_picks_str += '
\n' - css_filename = base_dir + '/epicyon-profile.css' + css_filename: str = base_dir + '/epicyon-profile.css' if is_a_file(base_dir + '/epicyon.css'): css_filename = base_dir + '/epicyon.css' @@ -3930,10 +3941,10 @@ def html_emoji_reaction_picker(recent_posts_cache: {}, max_recent_posts: int, banner_file, _ = \ get_banner_file(base_dir, nickname, domain, theme_name) - instance_title = get_config_param(base_dir, 'instanceTitle') + instance_title: str = get_config_param(base_dir, 'instanceTitle') metadata: str = '' preload_images: list[str] = [] - header_str = \ + header_str: str = \ html_header_with_external_style(css_filename, instance_title, metadata, preload_images)