diff --git a/blocking.py b/blocking.py index 625bc94c1..30382a03d 100644 --- a/blocking.py +++ b/blocking.py @@ -1087,7 +1087,7 @@ def add_cw_from_lists(post_json_object: {}, cw_lists: {}, translate: {}, # match words within the content if item.get('words'): for word_str in item['words']: - if word_str in content: + if word_str in content or word_str.title() in content: if cw_text: cw_text = warning + ' / ' + cw_text else: diff --git a/content.py b/content.py index 03d9d9b77..72b778438 100644 --- a/content.py +++ b/content.py @@ -1151,7 +1151,7 @@ def load_dogwhistles(filename: str) -> {}: def add_html_tags(base_dir: str, http_prefix: str, nickname: str, domain: str, content: str, - recipients: [], hashtags: {}, + recipients: [], hashtags: {}, translate: {}, is_json_content: bool = False) -> str: """ Replaces plaintext mentions such as @nick@domain into html by matching against known following accounts @@ -1162,7 +1162,10 @@ def add_html_tags(base_dir: str, http_prefix: str, max_word_length = 40 content = content.replace('\r', '') content = content.replace('\n', ' --linebreak-- ') - content = _add_music_tag(content, 'nowplaying') + now_playing_str = 'NowPlaying' + if translate.get(now_playing_str): + now_playing_str = translate[now_playing_str] + content = _add_music_tag(content, now_playing_str) words = _get_simplified_content(content).split(' ') # remove . for words which are not mentions diff --git a/cwlists/ableist.json b/cwlists/ableist.json new file mode 100644 index 000000000..e658ed66f --- /dev/null +++ b/cwlists/ableist.json @@ -0,0 +1,18 @@ +{ + "name": "Ableism", + "warning": "Ableism", + "description": "Discrimination and social prejudice against people with disabilities.", + "words": [ + "crazy", "cripple", "turn a blind", "turn a deaf", "diffability", + "differently abled", "different abilit", + " dumb.", " dumb ", " dumb!", " dumb?", "handicap", + "idiot", "imbecil", "insanity", "insane", " lame", "lunatic", + "maniac", "moron", "retard", "spaz", "spastic", "specially-abled", + "special needs", "stupid", "blind to", "bonkers", + "wheelchair bound", "confined to a wheelchair", "deaf to", + "deranged", "derranged", "harelip", "wacko", "whacko", + "cretin", "feeble-minded", "mental defective", "mentally defective", + "mongoloid", "blinded by", "double-blind" + ], + "domains": [] +} diff --git a/daemon.py b/daemon.py index b6919db93..0dc3d98e7 100644 --- a/daemon.py +++ b/daemon.py @@ -565,7 +565,8 @@ class PubServer(BaseHTTPRequestHandler): conversation_id, self.server.low_bandwidth, self.server.content_license_url, - languages_understood) + languages_understood, + self.server.translate) if message_json: # name field contains the answer message_json['object']['name'] = answer @@ -6290,7 +6291,8 @@ class PubServer(BaseHTTPRequestHandler): http_prefix, nickname, domain_full, - bio_str, [], actor_tags) + bio_str, [], actor_tags, + self.server.translate) if actor_tags: actor_json['tag'] = [] for _, tag in actor_tags.items(): @@ -15334,8 +15336,8 @@ class PubServer(BaseHTTPRequestHandler): self.path = self.path.replace('?nodropdown', '') # redirect music to #nowplaying list - if self.path == '/music' or self.path == '/nowplaying': - self.path = '/tags/nowplaying' + if self.path == '/music' or self.path == '/NowPlaying': + self.path = '/tags/NowPlaying' if self.server.debug: print('DEBUG: GET from ' + self.server.base_dir + @@ -19049,7 +19051,8 @@ class PubServer(BaseHTTPRequestHandler): conversation_id, self.server.low_bandwidth, self.server.content_license_url, - languages_understood) + languages_understood, + self.server.translate) if message_json: if fields['schedulePost']: return 1 @@ -19140,7 +19143,8 @@ class PubServer(BaseHTTPRequestHandler): conversation_id, self.server.low_bandwidth, self.server.content_license_url, - languages_understood) + languages_understood, + self.server.translate) if message_json: if fields['schedulePost']: return 1 @@ -19195,7 +19199,9 @@ class PubServer(BaseHTTPRequestHandler): nickname, self.server.domain, fields['message'], mentioned_recipients, - hashtags_dict, True) + hashtags_dict, + self.server.translate, + True) # replace emoji with unicode tags = [] for _, tag in hashtags_dict.items(): @@ -19303,7 +19309,8 @@ class PubServer(BaseHTTPRequestHandler): conversation_id, self.server.low_bandwidth, self.server.content_license_url, - languages_understood) + languages_understood, + self.server.translate) if message_json: if fields['schedulePost']: return 1 @@ -19364,7 +19371,8 @@ class PubServer(BaseHTTPRequestHandler): conversation_id, self.server.low_bandwidth, self.server.content_license_url, - languages_understood) + languages_understood, + self.server.translate) if message_json: if fields['schedulePost']: return 1 @@ -19437,7 +19445,8 @@ class PubServer(BaseHTTPRequestHandler): self.server.low_bandwidth, content_license_url, languages_understood, - reply_is_chat) + reply_is_chat, + self.server.translate) if message_json: if fields['schedulePost']: return 1 @@ -19502,7 +19511,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.low_bandwidth, self.server.content_license_url, languages_understood, - False) + False, self.server.translate) if message_json: if fields['schedulePost']: return 1 @@ -19546,7 +19555,8 @@ class PubServer(BaseHTTPRequestHandler): fields['languagesDropdown'], self.server.low_bandwidth, self.server.content_license_url, - languages_understood) + languages_understood, + self.server.translate) if message_json: if self._post_to_outbox(message_json, self.server.project_version, @@ -19595,7 +19605,8 @@ class PubServer(BaseHTTPRequestHandler): fields['languagesDropdown'], self.server.low_bandwidth, self.server.content_license_url, - languages_understood) + languages_understood, + self.server.translate) if message_json: if self.server.debug: print('DEBUG: new Question') diff --git a/desktop_client.py b/desktop_client.py index fa1643087..325e5c928 100644 --- a/desktop_client.py +++ b/desktop_client.py @@ -464,7 +464,8 @@ def _desktop_reply_to_post(session, post_id: str, espeak, conversation_id: str, low_bandwidth: bool, content_license_url: str, - signing_priv_key_pem: str) -> None: + signing_priv_key_pem: str, + translate: {}) -> None: """Use the desktop client to send a reply to the most recent post """ if '://' not in post_id: @@ -523,7 +524,7 @@ def _desktop_reply_to_post(session, post_id: str, system_language, languages_understood, low_bandwidth, content_license_url, event_date, event_time, event_end_time, location, - debug, post_id, post_id, + translate, debug, post_id, post_id, conversation_id, subject) == 0: say_str = 'Reply sent' else: @@ -540,7 +541,8 @@ def _desktop_new_post(session, languages_understood: [], espeak, low_bandwidth: bool, content_license_url: str, - signing_priv_key_pem: str) -> None: + signing_priv_key_pem: str, + translate: {}) -> None: """Use the desktop client to create a new post """ conversation_id = None @@ -596,7 +598,7 @@ def _desktop_new_post(session, system_language, languages_understood, low_bandwidth, content_license_url, event_date, event_time, event_end_time, location, - debug, None, None, + translate, debug, None, None, conversation_id, subject) == 0: say_str = 'Post sent' else: @@ -1188,7 +1190,8 @@ def _desktop_new_dm(session, to_handle: str, languages_understood: [], espeak, low_bandwidth: bool, content_license_url: str, - signing_priv_key_pem: str) -> None: + signing_priv_key_pem: str, + translate: {}) -> None: """Use the desktop client to create a new direct message which can include multiple destination handles """ @@ -1212,7 +1215,7 @@ def _desktop_new_dm(session, to_handle: str, languages_understood, espeak, low_bandwidth, content_license_url, - signing_priv_key_pem) + signing_priv_key_pem, translate) def _desktop_new_dm_base(session, to_handle: str, @@ -1224,7 +1227,8 @@ def _desktop_new_dm_base(session, to_handle: str, languages_understood: [], espeak, low_bandwidth: bool, content_license_url: str, - signing_priv_key_pem: str) -> None: + signing_priv_key_pem: str, + translate: {}) -> None: """Use the desktop client to create a new direct message """ conversation_id = None @@ -1323,7 +1327,7 @@ def _desktop_new_dm_base(session, to_handle: str, system_language, languages_understood, low_bandwidth, content_license_url, event_date, event_time, event_end_time, location, - debug, None, None, + translate, debug, None, None, conversation_id, subject) == 0: say_str = 'Direct message sent' else: @@ -1791,7 +1795,8 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str, espeak, conversation_id, low_bandwidth, content_license_url, - signing_priv_key_pem) + signing_priv_key_pem, + translate) refresh_timeline = True print('') elif (command_str == 'post' or command_str == 'p' or @@ -1828,7 +1833,7 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str, languages_understood, espeak, low_bandwidth, content_license_url, - signing_priv_key_pem) + signing_priv_key_pem, translate) refresh_timeline = True else: # public post @@ -1841,7 +1846,7 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str, languages_understood, espeak, low_bandwidth, content_license_url, - signing_priv_key_pem) + signing_priv_key_pem, translate) refresh_timeline = True print('') elif command_str == 'like' or command_str.startswith('like '): diff --git a/epicyon.py b/epicyon.py index b82de1818..ba26f9ef3 100644 --- a/epicyon.py +++ b/epicyon.py @@ -1546,6 +1546,7 @@ def _command_options() -> None: languages_understood = [argb.language] if argb.languages_understood: languages_understood = [argb.languages_understood] + translate = {} print('Sending post to ' + argb.sendto) send_post_via_server(signing_priv_key_pem, __version__, @@ -1560,7 +1561,7 @@ def _command_options() -> None: argb.low_bandwidth, argb.content_license_url, argb.eventDate, argb.eventTime, argb.eventEndTime, - argb.eventLocation, + argb.eventLocation, translate, argb.debug, reply_to, reply_to, argb.conversationId, subject) for _ in range(10): @@ -3217,6 +3218,7 @@ def _command_options() -> None: conversation_id = None low_bandwidth = False languages_understood = [argb.language] + translate = {} create_public_post(base_dir, nickname, domain, port, http_prefix, "like this is totally just a #test man", @@ -3231,7 +3233,7 @@ def _command_options() -> None: test_event_end_time, test_location, test_is_article, argb.language, conversation_id, low_bandwidth, argb.content_license_url, - languages_understood) + languages_understood, translate) create_public_post(base_dir, nickname, domain, port, http_prefix, "Zoiks!!!", test_save_to_file, @@ -3245,7 +3247,7 @@ def _command_options() -> None: test_event_end_time, test_location, test_is_article, argb.language, conversation_id, low_bandwidth, argb.content_license_url, - languages_understood) + languages_understood, translate) create_public_post(base_dir, nickname, domain, port, http_prefix, "Hey scoob we need like a hundred more #milkshakes", test_save_to_file, @@ -3259,7 +3261,7 @@ def _command_options() -> None: test_event_end_time, test_location, test_is_article, argb.language, conversation_id, low_bandwidth, argb.content_license_url, - languages_understood) + languages_understood, translate) create_public_post(base_dir, nickname, domain, port, http_prefix, "Getting kinda spooky around here", test_save_to_file, @@ -3273,7 +3275,7 @@ def _command_options() -> None: test_event_end_time, test_location, test_is_article, argb.language, conversation_id, low_bandwidth, argb.content_license_url, - languages_understood) + languages_understood, translate) create_public_post(base_dir, nickname, domain, port, http_prefix, "And they would have gotten away with it too" + "if it wasn't for those pesky hackers", @@ -3288,7 +3290,7 @@ def _command_options() -> None: test_event_end_time, test_location, test_is_article, argb.language, conversation_id, low_bandwidth, argb.content_license_url, - languages_understood) + languages_understood, translate) create_public_post(base_dir, nickname, domain, port, http_prefix, "man these centralized sites are like the worst!", test_save_to_file, @@ -3302,7 +3304,7 @@ def _command_options() -> None: test_event_end_time, test_location, test_is_article, argb.language, conversation_id, low_bandwidth, argb.content_license_url, - languages_understood) + languages_understood, translate) create_public_post(base_dir, nickname, domain, port, http_prefix, "another mystery solved #test", test_save_to_file, @@ -3316,7 +3318,7 @@ def _command_options() -> None: test_event_end_time, test_location, test_is_article, argb.language, conversation_id, low_bandwidth, argb.content_license_url, - languages_understood) + languages_understood, translate) create_public_post(base_dir, nickname, domain, port, http_prefix, "let's go bowling", test_save_to_file, @@ -3330,7 +3332,7 @@ def _command_options() -> None: test_event_end_time, test_location, test_is_article, argb.language, conversation_id, low_bandwidth, argb.content_license_url, - languages_understood) + languages_understood, translate) domain_full = domain + ':' + str(port) clear_follows(base_dir, nickname, domain) follow_person(base_dir, nickname, domain, 'maxboardroom', domain_full, diff --git a/inbox.py b/inbox.py index b4ba1c3a0..571394713 100644 --- a/inbox.py +++ b/inbox.py @@ -3319,7 +3319,8 @@ def _bounce_dm(sender_post_id: str, session, http_prefix: str, location, system_language, conversation_id, low_bandwidth, content_license_url, - languages_understood, bounce_is_chat) + languages_understood, bounce_is_chat, + translate) if not post_json_object: print('WARN: unable to create bounce message to ' + sending_handle) return False diff --git a/newsdaemon.py b/newsdaemon.py index 78642412f..2b62b4b32 100644 --- a/newsdaemon.py +++ b/newsdaemon.py @@ -643,7 +643,7 @@ def _convert_rss_to_activitypub(base_dir: str, http_prefix: str, rss_title, system_language, conversation_id, low_bandwidth, content_license_url, - languages_understood) + languages_understood, translate) if not blog: continue diff --git a/outbox.py b/outbox.py index 9698f1a11..49f5709de 100644 --- a/outbox.py +++ b/outbox.py @@ -190,6 +190,26 @@ def _person_receive_update_outbox(base_dir: str, http_prefix: str, print('DEBUG: actor update via c2s - ' + nickname + '@' + domain) +def _capitalize_hashtag(content: str, message_json: {}, + system_language: str, translate: {}, + original_tag: str, + capitalized_tag: str) -> None: + """If a nowplaying hashtag exists then ensure it is capitalized + """ + if translate.get(original_tag) and \ + translate.get(capitalized_tag): + original_tag = translate[original_tag].replace(' ', '_') + capitalized_tag = translate[capitalized_tag].replace(' ', '_') + + if '#' + original_tag not in content: + return + content = content.replace('#' + original_tag, '#' + capitalized_tag) + if message_json['object'].get('contentMap'): + if message_json['object']['contentMap'].get(system_language): + message_json['object']['contentMap'][system_language] = content + message_json['object']['contentMap'][system_language] = content + + def post_message_to_outbox(session, translate: {}, message_json: {}, post_to_nickname: str, server, base_dir: str, http_prefix: str, @@ -243,6 +263,10 @@ def post_message_to_outbox(session, translate: {}, if has_object_dict(message_json): content_str = get_base_content_from_post(message_json, system_language) if content_str: + _capitalize_hashtag(content_str, message_json, + system_language, translate, + 'nowplaying', 'NowPlaying') + if dangerous_markup(content_str, allow_local_network_access): print('POST to outbox contains dangerous markup: ' + str(message_json)) diff --git a/posts.py b/posts.py index 8a1d07fd1..58dbbca83 100644 --- a/posts.py +++ b/posts.py @@ -1425,7 +1425,7 @@ def _create_post_base(base_dir: str, system_language: str, conversation_id: str, low_bandwidth: bool, content_license_url: str, - languages_understood: []) -> {}: + languages_understood: [], translate: {}) -> {}: """Creates a message """ content = remove_invalid_chars(content) @@ -1470,7 +1470,7 @@ def _create_post_base(base_dir: str, add_html_tags(base_dir, http_prefix, nickname, domain, content, mentioned_recipients, - hashtags_dict, True) + hashtags_dict, translate, True) # replace emoji with unicode tags = [] @@ -1837,7 +1837,7 @@ def create_public_post(base_dir: str, location: str, is_article: bool, system_language: str, conversation_id: str, low_bandwidth: bool, content_license_url: str, - languages_understood: []) -> {}: + languages_understood: [], translate: {}) -> {}: """Public post """ domain_full = get_full_domain(domain, port) @@ -1871,7 +1871,7 @@ def create_public_post(base_dir: str, event_status, ticket_url, system_language, conversation_id, low_bandwidth, content_license_url, - languages_understood) + languages_understood, translate) def _append_citations_to_blog_post(base_dir: str, @@ -1916,7 +1916,7 @@ def create_blog_post(base_dir: str, location: str, system_language: str, conversation_id: str, low_bandwidth: bool, content_license_url: str, - languages_understood: []) -> {}: + languages_understood: [], translate: {}) -> {}: blog_json = \ create_public_post(base_dir, nickname, domain, port, http_prefix, @@ -1929,7 +1929,7 @@ def create_blog_post(base_dir: str, event_date, event_time, event_end_time, location, True, system_language, conversation_id, low_bandwidth, content_license_url, - languages_understood) + languages_understood, translate) blog_json['object']['url'] = \ blog_json['object']['url'].replace('/@', '/users/') _append_citations_to_blog_post(base_dir, nickname, domain, blog_json) @@ -1945,7 +1945,7 @@ def create_news_post(base_dir: str, subject: str, system_language: str, conversation_id: str, low_bandwidth: bool, content_license_url: str, - languages_understood: []) -> {}: + languages_understood: [], translate: {}) -> {}: client_to_server = False in_reply_to = None in_reply_to_atom_uri = None @@ -1966,7 +1966,7 @@ def create_news_post(base_dir: str, event_date, event_time, event_end_time, location, True, system_language, conversation_id, low_bandwidth, content_license_url, - languages_understood) + languages_understood, translate) blog['object']['type'] = 'Article' return blog @@ -1982,7 +1982,7 @@ def create_question_post(base_dir: str, subject: str, duration_days: int, system_language: str, low_bandwidth: bool, content_license_url: str, - languages_understood: []) -> {}: + languages_understood: [], translate: {}) -> {}: """Question post with multiple choice options """ domain_full = get_full_domain(domain, port) @@ -2000,7 +2000,7 @@ def create_question_post(base_dir: str, None, None, None, None, None, None, None, None, system_language, None, low_bandwidth, content_license_url, - languages_understood) + languages_understood, translate) message_json['object']['type'] = 'Question' message_json['object']['oneOf'] = [] message_json['object']['votersCount'] = 0 @@ -2035,7 +2035,7 @@ def create_unlisted_post(base_dir: str, location: str, system_language: str, conversation_id: str, low_bandwidth: bool, content_license_url: str, - languages_understood: []) -> {}: + languages_understood: [], translate: {}) -> {}: """Unlisted post. This has the #Public and followers links inverted. """ domain_full = get_full_domain(domain, port) @@ -2054,7 +2054,8 @@ def create_unlisted_post(base_dir: str, None, None, None, event_date, event_end_time, None, None, None, None, None, system_language, conversation_id, low_bandwidth, - content_license_url, languages_understood) + content_license_url, languages_understood, + translate) def create_followers_only_post(base_dir: str, @@ -2072,7 +2073,8 @@ def create_followers_only_post(base_dir: str, location: str, system_language: str, conversation_id: str, low_bandwidth: bool, content_license_url: str, - languages_understood: []) -> {}: + languages_understood: [], + translate: {}) -> {}: """Followers only post """ domain_full = get_full_domain(domain, port) @@ -2089,7 +2091,8 @@ def create_followers_only_post(base_dir: str, None, None, None, event_date, event_end_time, None, None, None, None, None, system_language, conversation_id, low_bandwidth, - content_license_url, languages_understood) + content_license_url, languages_understood, + translate) def get_mentioned_people(base_dir: str, http_prefix: str, @@ -2145,7 +2148,7 @@ def create_direct_message_post(base_dir: str, conversation_id: str, low_bandwidth: bool, content_license_url: str, languages_understood: [], - dm_is_chat: bool) -> {}: + dm_is_chat: bool, translate: {}) -> {}: """Direct Message post """ content = resolve_petnames(base_dir, nickname, domain, content) @@ -2170,7 +2173,8 @@ def create_direct_message_post(base_dir: str, None, None, None, event_date, event_end_time, None, None, None, None, None, system_language, conversation_id, low_bandwidth, - content_license_url, languages_understood) + content_license_url, languages_understood, + translate) # mentioned recipients go into To rather than Cc message_json['to'] = message_json['object']['cc'] message_json['object']['to'] = message_json['to'] @@ -2194,7 +2198,7 @@ def create_report_post(base_dir: str, debug: bool, subject: str, system_language: str, low_bandwidth: bool, content_license_url: str, - languages_understood: []) -> {}: + languages_understood: [], translate: {}) -> {}: """Send a report to moderators """ domain_full = get_full_domain(domain, port) @@ -2273,7 +2277,7 @@ def create_report_post(base_dir: str, None, None, None, None, None, None, None, None, system_language, None, low_bandwidth, content_license_url, - languages_understood) + languages_understood, translate) if not post_json_object: continue @@ -2398,6 +2402,7 @@ def send_post(signing_priv_key_pem: str, project_version: str, shared_items_federated_domains: [], shared_item_federation_tokens: {}, low_bandwidth: bool, content_license_url: str, + translate: {}, debug: bool = False, in_reply_to: str = None, in_reply_to_atom_uri: str = None, subject: str = None) -> int: """Post to another inbox. Used by unit tests. @@ -2464,7 +2469,8 @@ def send_post(signing_priv_key_pem: str, project_version: str, None, None, None, None, None, None, None, None, system_language, conversation_id, low_bandwidth, - content_license_url, languages_understood) + content_license_url, languages_understood, + translate) # get the senders private key private_key_pem = _get_person_key(nickname, domain, base_dir, 'private') @@ -2561,7 +2567,7 @@ def send_post_via_server(signing_priv_key_pem: str, project_version: str, low_bandwidth: bool, content_license_url: str, event_date: str, event_time: str, event_end_time: str, - location: str, + location: str, translate: {}, debug: bool = False, in_reply_to: str = None, in_reply_to_atom_uri: str = None, @@ -2652,7 +2658,8 @@ def send_post_via_server(signing_priv_key_pem: str, project_version: str, None, None, None, event_date, event_end_time, None, None, None, None, None, system_language, conversation_id, low_bandwidth, - content_license_url, languages_understood) + content_license_url, languages_understood, + translate) auth_header = create_basic_auth_header(from_nickname, password) diff --git a/tests.py b/tests.py index 4bcc5c234..005e26467 100644 --- a/tests.py +++ b/tests.py @@ -763,6 +763,7 @@ def create_server_alice(path: str, domain: str, port: int, test_location = None test_is_article = False conversation_id = None + translate = {} content_license_url = 'https://creativecommons.org/licenses/by/4.0' create_public_post(path, nickname, domain, port, http_prefix, "No wise fish would go anywhere without a porpoise", @@ -778,7 +779,7 @@ def create_server_alice(path: str, domain: str, port: int, test_event_end_time, test_location, test_is_article, system_language, conversation_id, low_bandwidth, content_license_url, - languages_understood) + languages_understood, translate) create_public_post(path, nickname, domain, port, http_prefix, "Curiouser and curiouser!", test_save_to_file, @@ -793,7 +794,7 @@ def create_server_alice(path: str, domain: str, port: int, test_event_end_time, test_location, test_is_article, system_language, conversation_id, low_bandwidth, content_license_url, - languages_understood) + languages_understood, translate) create_public_post(path, nickname, domain, port, http_prefix, "In the gardens of memory, in the palace " + "of dreams, that is where you and I shall meet", @@ -809,7 +810,7 @@ def create_server_alice(path: str, domain: str, port: int, test_event_end_time, test_location, test_is_article, system_language, conversation_id, low_bandwidth, content_license_url, - languages_understood) + languages_understood, translate) regenerate_index_for_box(path, nickname, domain, 'outbox') global TEST_SERVER_ALICE_RUNNING TEST_SERVER_ALICE_RUNNING = True @@ -923,6 +924,7 @@ def create_server_bob(path: str, domain: str, port: int, test_is_article = False conversation_id = None content_license_url = 'https://creativecommons.org/licenses/by/4.0' + translate = {} create_public_post(path, nickname, domain, port, http_prefix, "It's your life, live it your way.", test_save_to_file, @@ -937,7 +939,7 @@ def create_server_bob(path: str, domain: str, port: int, test_event_end_time, test_location, test_is_article, system_language, conversation_id, low_bandwidth, content_license_url, - languages_understood) + languages_understood, translate) create_public_post(path, nickname, domain, port, http_prefix, "One of the things I've realised is that " + "I am very simple", @@ -953,7 +955,7 @@ def create_server_bob(path: str, domain: str, port: int, test_event_end_time, test_location, test_is_article, system_language, conversation_id, low_bandwidth, content_license_url, - languages_understood) + languages_understood, translate) create_public_post(path, nickname, domain, port, http_prefix, "Quantum physics is a bit of a passion of mine", test_save_to_file, @@ -968,7 +970,7 @@ def create_server_bob(path: str, domain: str, port: int, test_event_end_time, test_location, test_is_article, system_language, conversation_id, low_bandwidth, content_license_url, - languages_understood) + languages_understood, translate) regenerate_index_for_box(path, nickname, domain, 'outbox') global TEST_SERVER_BOB_RUNNING TEST_SERVER_BOB_RUNNING = True @@ -1294,6 +1296,7 @@ def test_post_message_between_servers(base_dir: str) -> None: if os.path.isfile(os.path.join(outbox_path, name))]) == 0 low_bandwidth = False signing_priv_key_pem = None + translate = {} send_result = \ send_post(signing_priv_key_pem, __version__, session_alice, alice_dir, 'alice', alice_domain, alice_port, @@ -1308,7 +1311,7 @@ def test_post_message_between_servers(base_dir: str) -> None: languages_understood, alice_shared_items_federated_domains, alice_shared_item_federation_tokens, low_bandwidth, - content_license_url, + content_license_url, translate, in_reply_to, in_reply_to_atom_uri, subject) print('send_result: ' + str(send_result)) @@ -1665,6 +1668,7 @@ def test_follow_between_servers(base_dir: str) -> None: city = 'London, England' low_bandwidth = False signing_priv_key_pem = None + translate = {} send_result = \ send_post(signing_priv_key_pem, __version__, session_alice, alice_dir, 'alice', alice_domain, alice_port, @@ -1677,7 +1681,7 @@ def test_follow_between_servers(base_dir: str) -> None: languages_understood, alice_shared_items_federated_domains, alice_shared_item_federation_tokens, low_bandwidth, - content_license_url, + content_license_url, translate, in_reply_to, in_reply_to_atom_uri, subject) print('send_result: ' + str(send_result)) @@ -2029,6 +2033,7 @@ def test_shared_items_federation(base_dir: str) -> None: city = 'London, England' low_bandwidth = False signing_priv_key_pem = None + translate = {} send_result = \ send_post(signing_priv_key_pem, __version__, session_alice, alice_dir, 'alice', alice_domain, alice_port, @@ -2041,7 +2046,7 @@ def test_shared_items_federation(base_dir: str) -> None: languages_understood, alice_shared_items_federated_domains, alice_shared_item_federation_tokens, low_bandwidth, - content_license_url, True, + content_license_url, translate, True, in_reply_to, in_reply_to_atom_uri, subject) print('send_result: ' + str(send_result)) @@ -2458,6 +2463,7 @@ def test_group_follow(base_dir: str) -> None: len([name for name in os.listdir(outbox_path) if os.path.isfile(os.path.join(outbox_path, name))]) + translate = {} send_result = \ send_post(signing_priv_key_pem, __version__, session_alice, alice_dir, 'alice', alice_domain, alice_port, @@ -2470,7 +2476,7 @@ def test_group_follow(base_dir: str) -> None: languages_understood, alice_shared_items_federated_domains, alice_shared_item_federation_tokens, low_bandwidth, - content_license_url, + content_license_url, translate, in_reply_to, in_reply_to_atom_uri, subject) print('send_result: ' + str(send_result)) @@ -2838,6 +2844,7 @@ def _test_create_person_account(base_dir: str): media_type = None conversation_id = None low_bandwidth = True + translate = {} content_license_url = 'https://creativecommons.org/licenses/by/4.0' content = \ "If your \"independent organization\" is government funded...\n\n" + \ @@ -2856,7 +2863,7 @@ def _test_create_person_account(base_dir: str): test_event_end_time, test_location, test_is_article, system_language, conversation_id, low_bandwidth, content_license_url, - languages_understood) + languages_understood, translate) assert test_post_json assert test_post_json.get('object') assert test_post_json['object']['content'] @@ -2882,7 +2889,7 @@ def _test_create_person_account(base_dir: str): test_event_end_time, test_location, test_is_article, system_language, conversation_id, low_bandwidth, content_license_url, - languages_understood) + languages_understood, translate) assert test_post_json assert test_post_json.get('object') assert test_post_json['object']['content'] @@ -3082,6 +3089,7 @@ def test_client_to_server(base_dir: str): event_time = '11:45' event_end_time = '12:30' location = "Kinshasa" + translate = {} send_result = \ send_post_via_server(signing_priv_key_pem, __version__, alice_dir, session_alice, 'alice', password, @@ -3094,7 +3102,7 @@ def test_client_to_server(base_dir: str): system_language, languages_understood, low_bandwidth, content_license_url, event_date, event_time, event_end_time, location, - True, None, None, + translate, True, None, None, conversation_id, None) print('send_result: ' + str(send_result)) @@ -3683,6 +3691,7 @@ def _test_addemoji(base_dir: str): domain = 'testdomain.net' port = 3682 recipients = [] + translate = {} hashtags = {} base_dir_original = base_dir path = base_dir + '/.tests' @@ -3709,7 +3718,7 @@ def _test_addemoji(base_dir: str): content_modified = \ add_html_tags(base_dir, http_prefix, nickname, domain, content, - recipients, hashtags, True) + recipients, hashtags, translate, True) assert ':lemon:' in content_modified assert content_modified.startswith('
') assert content_modified.endswith('
') @@ -4657,6 +4666,7 @@ def _test_reply_to_public_post(base_dir: str) -> None: conversation_id = None low_bandwidth = True content_license_url = 'https://creativecommons.org/licenses/by/4.0' + translate = {} reply = \ create_public_post(base_dir, nickname, domain, port, http_prefix, content, save_to_file, @@ -4669,7 +4679,7 @@ def _test_reply_to_public_post(base_dir: str) -> None: test_event_end_time, test_location, test_is_article, system_language, conversation_id, low_bandwidth, content_license_url, - languages_understood) + languages_understood, translate) # print(str(reply)) expected_str = \ '' + \
@@ -5588,6 +5598,7 @@ def _test_links_within_post(base_dir: str) -> None:
conversation_id = None
low_bandwidth = True
content_license_url = 'https://creativecommons.org/licenses/by/4.0'
+ translate = {}
post_json_object = \
create_public_post(base_dir, nickname, domain, port, http_prefix,
@@ -5601,7 +5612,7 @@ def _test_links_within_post(base_dir: str) -> None:
test_event_end_time, test_location,
test_is_article, system_language, conversation_id,
low_bandwidth, content_license_url,
- languages_understood)
+ languages_understood, translate)
expected_str = \
' This is a test post with links. ', '').replace('
' + \
@@ -5645,7 +5656,7 @@ def _test_links_within_post(base_dir: str) -> None:
test_event_end_time, test_location,
test_is_article, system_language, conversation_id,
low_bandwidth, content_license_url,
- languages_understood)
+ languages_understood, translate)
assert post_json_object['object']['content'] == content
assert post_json_object['object']['contentMap'][system_language] == content
@@ -6676,6 +6687,7 @@ def _test_can_replyto(base_dir: str) -> None:
conversation_id = None
low_bandwidth = True
content_license_url = 'https://creativecommons.org/licenses/by/4.0'
+ translate = {}
post_json_object = \
create_public_post(base_dir, nickname, domain, port, http_prefix,
@@ -6689,7 +6701,7 @@ def _test_can_replyto(base_dir: str) -> None:
test_event_end_time, test_location,
test_is_article, system_language, conversation_id,
low_bandwidth, content_license_url,
- languages_understood)
+ languages_understood, translate)
# set the date on the post
curr_date_str = "2021-09-08T20:45:00Z"
post_json_object['published'] = curr_date_str
diff --git a/translations/ar.json b/translations/ar.json
index cc1c0383c..8339fd807 100644
--- a/translations/ar.json
+++ b/translations/ar.json
@@ -567,5 +567,7 @@
"SHOW MEDIA": "عرض الوسائط",
"ActivityPub Specification": "مواصفات ActivityPub",
"Dogwhistle words": "كلمات Dogwhistle",
- "Content warnings will be added for the following": "ستتم إضافة تحذيرات المحتوى لما يلي"
+ "Content warnings will be added for the following": "ستتم إضافة تحذيرات المحتوى لما يلي",
+ "nowplaying": "الان العب",
+ "NowPlaying": "الان العب"
}
diff --git a/translations/bn.json b/translations/bn.json
index 7fb7c941d..cc290a96f 100644
--- a/translations/bn.json
+++ b/translations/bn.json
@@ -567,5 +567,7 @@
"SHOW MEDIA": "মিডিয়া দেখান",
"ActivityPub Specification": "ActivityPub স্পেসিফিকেশন",
"Dogwhistle words": "কুকুরের হুইসেল শব্দ",
- "Content warnings will be added for the following": "নিম্নলিখিত জন্য বিষয়বস্তু সতর্কতা যোগ করা হবে"
+ "Content warnings will be added for the following": "নিম্নলিখিত জন্য বিষয়বস্তু সতর্কতা যোগ করা হবে",
+ "nowplaying": "এখন চলছে",
+ "NowPlaying": "এখন চলছে"
}
diff --git a/translations/ca.json b/translations/ca.json
index bfd994db7..f70b13086 100644
--- a/translations/ca.json
+++ b/translations/ca.json
@@ -567,5 +567,7 @@
"SHOW MEDIA": "MOSTRA ELS MITJANS",
"ActivityPub Specification": "Especificació d'ActivityPub",
"Dogwhistle words": "Paraules de xiulet",
- "Content warnings will be added for the following": "S'afegiran advertències de contingut per al següent"
+ "Content warnings will be added for the following": "S'afegiran advertències de contingut per al següent",
+ "nowplaying": "arajugant",
+ "NowPlaying": "AraJugant"
}
diff --git a/translations/cy.json b/translations/cy.json
index ff2ab6fc4..e788810eb 100644
--- a/translations/cy.json
+++ b/translations/cy.json
@@ -567,5 +567,7 @@
"SHOW MEDIA": "DANGOS CYFRYNGAU",
"ActivityPub Specification": "Manyleb GweithgareddPub",
"Dogwhistle words": "Geiriau chwibanogl",
- "Content warnings will be added for the following": "Bydd rhybuddion cynnwys yn cael eu hychwanegu ar gyfer y canlynol"
+ "Content warnings will be added for the following": "Bydd rhybuddion cynnwys yn cael eu hychwanegu ar gyfer y canlynol",
+ "nowplaying": "nawrynchwarae",
+ "NowPlaying": "NawrYnChwarae"
}
diff --git a/translations/de.json b/translations/de.json
index 962cfcbb9..8d152ad06 100644
--- a/translations/de.json
+++ b/translations/de.json
@@ -567,5 +567,7 @@
"SHOW MEDIA": "MEDIEN ZEIGEN",
"ActivityPub Specification": "ActivityPub-Spezifikation",
"Dogwhistle words": "Hundepfeife Worte",
- "Content warnings will be added for the following": "Inhaltswarnungen werden für Folgendes hinzugefügt"
+ "Content warnings will be added for the following": "Inhaltswarnungen werden für Folgendes hinzugefügt",
+ "nowplaying": "läuftgerade",
+ "NowPlaying": "LäuftGerade"
}
diff --git a/translations/el.json b/translations/el.json
index 8a3cee2df..d6b9d34c3 100644
--- a/translations/el.json
+++ b/translations/el.json
@@ -567,5 +567,7 @@
"SHOW MEDIA": "ΔΕΙΤΕ ΜΕΣΑ",
"ActivityPub Specification": "Προδιαγραφές ActivityPub",
"Dogwhistle words": "Σφυρίχτρα λέξεις",
- "Content warnings will be added for the following": "Θα προστεθούν προειδοποιήσεις περιεχομένου για τα ακόλουθα"
+ "Content warnings will be added for the following": "Θα προστεθούν προειδοποιήσεις περιεχομένου για τα ακόλουθα",
+ "nowplaying": "τώραπαίζει",
+ "NowPlaying": "ΤώραΠαίζει"
}
diff --git a/translations/en.json b/translations/en.json
index 6b19ef3b2..c569f76f3 100644
--- a/translations/en.json
+++ b/translations/en.json
@@ -567,5 +567,7 @@
"SHOW MEDIA": "SHOW MEDIA",
"ActivityPub Specification": "ActivityPub Specification",
"Dogwhistle words": "Dogwhistle words",
- "Content warnings will be added for the following": "Content warnings will be added for the following"
+ "Content warnings will be added for the following": "Content warnings will be added for the following",
+ "nowplaying": "nowplaying",
+ "NowPlaying": "NowPlaying"
}
diff --git a/translations/es.json b/translations/es.json
index 2a0f58af5..2cef0c1ee 100644
--- a/translations/es.json
+++ b/translations/es.json
@@ -567,5 +567,7 @@
"SHOW MEDIA": "MOSTRAR MEDIOS",
"ActivityPub Specification": "Especificación de ActivityPub",
"Dogwhistle words": "Palabras de silbato para perros",
- "Content warnings will be added for the following": "Se agregarán advertencias de contenido para lo siguiente"
+ "Content warnings will be added for the following": "Se agregarán advertencias de contenido para lo siguiente",
+ "nowplaying": "jugandoahora",
+ "NowPlaying": "JugandoAhora"
}
diff --git a/translations/fr.json b/translations/fr.json
index 493cc8346..5c3b6c427 100644
--- a/translations/fr.json
+++ b/translations/fr.json
@@ -567,5 +567,7 @@
"SHOW MEDIA": "AFFICHER LES MÉDIAS",
"ActivityPub Specification": "Spécification ActivityPub",
"Dogwhistle words": "Mots de sifflet de chien",
- "Content warnings will be added for the following": "Des avertissements de contenu seront ajoutés pour les éléments suivants"
+ "Content warnings will be added for the following": "Des avertissements de contenu seront ajoutés pour les éléments suivants",
+ "nowplaying": "lectureencours",
+ "NowPlaying": "LectureEnCours"
}
diff --git a/translations/ga.json b/translations/ga.json
index d980c9432..2e2731714 100644
--- a/translations/ga.json
+++ b/translations/ga.json
@@ -567,5 +567,7 @@
"SHOW MEDIA": "Taispeáin MEÁIN",
"ActivityPub Specification": "Sonraíocht ActivityPub",
"Dogwhistle words": "Focail feadóg mhadra",
- "Content warnings will be added for the following": "Cuirfear rabhaidh ábhair leis maidir leis na nithe seo a leanas"
+ "Content warnings will be added for the following": "Cuirfear rabhaidh ábhair leis maidir leis na nithe seo a leanas",
+ "nowplaying": "anoisagimirt",
+ "NowPlaying": "AnoisAgImirt"
}
diff --git a/translations/hi.json b/translations/hi.json
index 95f4c8a66..30a8dc720 100644
--- a/translations/hi.json
+++ b/translations/hi.json
@@ -567,5 +567,7 @@
"SHOW MEDIA": "मीडिया दिखाएं",
"ActivityPub Specification": "गतिविधिपब विशिष्टता",
"Dogwhistle words": "कुत्ते की सीटी शब्द",
- "Content warnings will be added for the following": "निम्नलिखित के लिए सामग्री चेतावनियां जोड़ दी जाएंगी"
+ "Content warnings will be added for the following": "निम्नलिखित के लिए सामग्री चेतावनियां जोड़ दी जाएंगी",
+ "nowplaying": "अब खेल रहे हैं",
+ "NowPlaying": "अब खेल रहे हैं"
}
diff --git a/translations/it.json b/translations/it.json
index f5b7cb4e6..3827a9c06 100644
--- a/translations/it.json
+++ b/translations/it.json
@@ -567,5 +567,7 @@
"SHOW MEDIA": "MOSTRA MEDIA",
"ActivityPub Specification": "Specifica ActivityPub",
"Dogwhistle words": "Parole da fischietto",
- "Content warnings will be added for the following": "Verranno aggiunti avvisi sui contenuti per quanto segue"
+ "Content warnings will be added for the following": "Verranno aggiunti avvisi sui contenuti per quanto segue",
+ "nowplaying": "ora giocando",
+ "NowPlaying": "OraGiocando"
}
diff --git a/translations/ja.json b/translations/ja.json
index 5210d836c..c698debdf 100644
--- a/translations/ja.json
+++ b/translations/ja.json
@@ -567,5 +567,7 @@
"SHOW MEDIA": "メディアを表示",
"ActivityPub Specification": "ActivityPubの仕様",
"Dogwhistle words": "犬笛の言葉",
- "Content warnings will be added for the following": "以下のコンテンツ警告が追加されます"
+ "Content warnings will be added for the following": "以下のコンテンツ警告が追加されます",
+ "nowplaying": "再生中",
+ "NowPlaying": "再生中"
}
diff --git a/translations/ko.json b/translations/ko.json
index b0a9e2b55..bd212761f 100644
--- a/translations/ko.json
+++ b/translations/ko.json
@@ -567,5 +567,7 @@
"SHOW MEDIA": "미디어 표시",
"ActivityPub Specification": "ActivityPub 사양",
"Dogwhistle words": "개 휘파람 단어",
- "Content warnings will be added for the following": "다음에 대한 콘텐츠 경고가 추가됩니다."
+ "Content warnings will be added for the following": "다음에 대한 콘텐츠 경고가 추가됩니다.",
+ "nowplaying": "지금 재생",
+ "NowPlaying": "지금 재생"
}
diff --git a/translations/ku.json b/translations/ku.json
index 7df2289a8..c525bc6ad 100644
--- a/translations/ku.json
+++ b/translations/ku.json
@@ -567,5 +567,7 @@
"SHOW MEDIA": "MEDYA NÎŞAN DE",
"ActivityPub Specification": "Specification ActivityPub",
"Dogwhistle words": "Peyvên kûçikê",
- "Content warnings will be added for the following": "Hişyariyên naverokê dê ji bo jêrîn werin zêdekirin"
+ "Content warnings will be added for the following": "Hişyariyên naverokê dê ji bo jêrîn werin zêdekirin",
+ "nowplaying": "nihadilîze",
+ "NowPlaying": "NihaDilîze"
}
diff --git a/translations/nl.json b/translations/nl.json
index 8a94c779d..cda50afe5 100644
--- a/translations/nl.json
+++ b/translations/nl.json
@@ -567,5 +567,7 @@
"SHOW MEDIA": "TOON MEDIA",
"ActivityPub Specification": "ActivityPub-specificatie",
"Dogwhistle words": "Hondenfluitwoorden",
- "Content warnings will be added for the following": "Er worden inhoudswaarschuwingen toegevoegd voor het volgende:"
+ "Content warnings will be added for the following": "Er worden inhoudswaarschuwingen toegevoegd voor het volgende:",
+ "nowplaying": "nuaanhetspelen",
+ "NowPlaying": "NuAanHetSpelen"
}
diff --git a/translations/oc.json b/translations/oc.json
index 42e21d93b..230d0687a 100644
--- a/translations/oc.json
+++ b/translations/oc.json
@@ -563,5 +563,7 @@
"SHOW MEDIA": "SHOW MEDIA",
"ActivityPub Specification": "ActivityPub Specification",
"Dogwhistle words": "Dogwhistle words",
- "Content warnings will be added for the following": "Content warnings will be added for the following"
+ "Content warnings will be added for the following": "Content warnings will be added for the following",
+ "nowplaying": "nowplaying",
+ "NowPlaying": "NowPlaying"
}
diff --git a/translations/pl.json b/translations/pl.json
index 75da3fdba..be83884b3 100644
--- a/translations/pl.json
+++ b/translations/pl.json
@@ -567,5 +567,7 @@
"SHOW MEDIA": "POKAŻ MEDIA",
"ActivityPub Specification": "Specyfikacja ActivityPub",
"Dogwhistle words": "Słowa gwizdka na psa",
- "Content warnings will be added for the following": "Ostrzeżenia dotyczące treści zostaną dodane do następujących"
+ "Content warnings will be added for the following": "Ostrzeżenia dotyczące treści zostaną dodane do następujących",
+ "nowplaying": "terazgra",
+ "NowPlaying": "TerazGra"
}
diff --git a/translations/pt.json b/translations/pt.json
index 2adeebaa0..f016d3336 100644
--- a/translations/pt.json
+++ b/translations/pt.json
@@ -567,5 +567,7 @@
"SHOW MEDIA": "MOSTRAR MÍDIA",
"ActivityPub Specification": "Especificação do ActivityPub",
"Dogwhistle words": "Palavras de apito",
- "Content warnings will be added for the following": "Avisos de conteúdo serão adicionados para os seguintes"
+ "Content warnings will be added for the following": "Avisos de conteúdo serão adicionados para os seguintes",
+ "nowplaying": "agorajogando",
+ "NowPlaying": "AgoraJogando"
}
diff --git a/translations/ru.json b/translations/ru.json
index e12bb1799..3acc75209 100644
--- a/translations/ru.json
+++ b/translations/ru.json
@@ -567,5 +567,7 @@
"SHOW MEDIA": "ПОКАЗАТЬ МЕДИА",
"ActivityPub Specification": "Спецификация ActivityPub",
"Dogwhistle words": "Собачий свисток",
- "Content warnings will be added for the following": "Предупреждения о содержании будут добавлены для следующих"
+ "Content warnings will be added for the following": "Предупреждения о содержании будут добавлены для следующих",
+ "nowplaying": "сейчасиграет",
+ "NowPlaying": "СейчасИграет"
}
diff --git a/translations/sw.json b/translations/sw.json
index 02682a5b5..da1ca0dfe 100644
--- a/translations/sw.json
+++ b/translations/sw.json
@@ -567,5 +567,7 @@
"SHOW MEDIA": "ONESHA VYOMBO VYA HABARI",
"ActivityPub Specification": "Vipimo vya ActivityPub",
"Dogwhistle words": "Maneno ya mbwa",
- "Content warnings will be added for the following": "Maonyo ya maudhui yataongezwa kwa yafuatayo"
+ "Content warnings will be added for the following": "Maonyo ya maudhui yataongezwa kwa yafuatayo",
+ "nowplaying": "inachezasasa",
+ "NowPlaying": "InachezaSasa"
}
diff --git a/translations/tr.json b/translations/tr.json
index 2eadf668a..3f3794f12 100644
--- a/translations/tr.json
+++ b/translations/tr.json
@@ -567,5 +567,7 @@
"SHOW MEDIA": "MEDYA GÖSTER",
"ActivityPub Specification": "ActivityPub Spesifikasyonu",
"Dogwhistle words": "İtiraf sözleri",
- "Content warnings will be added for the following": "Aşağıdakiler için içerik uyarıları eklenecek"
+ "Content warnings will be added for the following": "Aşağıdakiler için içerik uyarıları eklenecek",
+ "nowplaying": "şimdioynuyor",
+ "NowPlaying": "ŞimdiOynuyor"
}
diff --git a/translations/uk.json b/translations/uk.json
index 58723e75a..51fa2a718 100644
--- a/translations/uk.json
+++ b/translations/uk.json
@@ -567,5 +567,7 @@
"SHOW MEDIA": "ПОКАЗАТИ ЗМІ",
"ActivityPub Specification": "Специфікація ActivityPub",
"Dogwhistle words": "Собачі слова",
- "Content warnings will be added for the following": "Попередження про вміст буде додано для наступних"
+ "Content warnings will be added for the following": "Попередження про вміст буде додано для наступних",
+ "nowplaying": "заразграє",
+ "NowPlaying": "ЗаразГрає"
}
diff --git a/translations/yi.json b/translations/yi.json
index 1a3f2fcf8..e21409988 100644
--- a/translations/yi.json
+++ b/translations/yi.json
@@ -567,5 +567,7 @@
"SHOW MEDIA": "ווייַז מעדיע",
"ActivityPub Specification": "ActivityPub באַשרייַבונג",
"Dogwhistle words": "דאָגווהיסטלע ווערטער",
- "Content warnings will be added for the following": "אינהאַלט וואָרנינגז וועט זיין מוסיף פֿאַר די פאלגענדע"
+ "Content warnings will be added for the following": "אינהאַלט וואָרנינגז וועט זיין מוסיף פֿאַר די פאלגענדע",
+ "nowplaying": "איצט פּלייַינג",
+ "NowPlaying": "איצט פּלייַינג"
}
diff --git a/translations/zh.json b/translations/zh.json
index e953072ec..05740f4df 100644
--- a/translations/zh.json
+++ b/translations/zh.json
@@ -567,5 +567,7 @@
"SHOW MEDIA": "展示媒体",
"ActivityPub Specification": "ActivityPub 规范",
"Dogwhistle words": "狗哨的话",
- "Content warnings will be added for the following": "将为以下内容添加内容警告"
+ "Content warnings will be added for the following": "将为以下内容添加内容警告",
+ "nowplaying": "现在玩",
+ "NowPlaying": "现在玩"
}
diff --git a/utils.py b/utils.py
index b3991cc09..1f95a9c5c 100644
--- a/utils.py
+++ b/utils.py
@@ -1070,6 +1070,32 @@ def _is_dangerous_string_simple(content: str, allow_local_network_access: bool,
return False
+def _html_tag_has_closing(tag_name: str, content: str) -> bool:
+ """Does the given tag have opening and closing labels?
+ """
+ content_lower = content.lower()
+ if '<' + tag_name not in content_lower:
+ return True
+ sections = content_lower.split('<' + tag_name)
+ ctr = 0
+ end_tag = '' + tag_name + '>'
+ for section in sections:
+ if ctr == 0:
+ ctr += 1
+ continue
+ # check that an ending tag exists
+ if end_tag not in section:
+ return False
+ if tag_name == 'code':
+ # check that lines are not too long
+ code_lines = section.split('\n')
+ for line in code_lines:
+ if len(line) >= 60:
+ return False
+ ctr += 1
+ return True
+
+
def dangerous_markup(content: str, allow_local_network_access: bool) -> bool:
"""Returns true if the given content contains dangerous html markup
"""
@@ -1080,8 +1106,10 @@ def dangerous_markup(content: str, allow_local_network_access: bool) -> bool:
if _is_dangerous_string_simple(content, allow_local_network_access,
separators, invalid_strings):
return True
+ if not _html_tag_has_closing('code', content):
+ return True
invalid_strings = [
- 'script', 'noscript', 'code', 'pre',
+ 'script', 'noscript', 'pre',
'canvas', 'style', 'abbr',
'frame', 'iframe', 'html', 'body',
'hr', 'allow-popups', 'allow-scripts',
diff --git a/webapp_likers.py b/webapp_likers.py
index 6ff5970f0..9650e19bd 100644
--- a/webapp_likers.py
+++ b/webapp_likers.py
@@ -142,7 +142,8 @@ def html_likers_of_post(base_dir: str, nickname: str,
add_emoji_to_display_name(session, base_dir,
http_prefix,
nickname, domain,
- liker_name, False)
+ liker_name, False,
+ translate)
else:
liker_name = get_nickname_from_actor(liker_actor)
if not liker_name:
diff --git a/webapp_post.py b/webapp_post.py
index dcfb5b7ef..081b22b38 100644
--- a/webapp_post.py
+++ b/webapp_post.py
@@ -1134,7 +1134,8 @@ def _get_post_title_announce_html(base_dir: str,
announce_display_name = \
add_emoji_to_display_name(None, base_dir, http_prefix,
nickname, domain,
- announce_display_name, False)
+ announce_display_name, False,
+ translate)
_log_post_timing(enable_timing_log, post_start_time, '13.3.1')
title_str += \
_announce_with_display_name_html(translate, post_json_object,
@@ -1341,7 +1342,7 @@ def _get_post_title_reply_html(base_dir: str,
reply_display_name = \
add_emoji_to_display_name(None, base_dir, http_prefix,
nickname, domain,
- reply_display_name, False)
+ reply_display_name, False, translate)
_log_post_timing(enable_timing_log, post_start_time, '13.6')
title_str += _get_reply_html(translate, in_reply_to, reply_display_name)
@@ -1739,7 +1740,7 @@ def individual_post_as_html(signing_priv_key_pem: str,
display_name = \
add_emoji_to_display_name(session, base_dir, http_prefix,
nickname, domain,
- display_name, False)
+ display_name, False, translate)
_log_post_timing(enable_timing_log, post_start_time, '7')
@@ -1872,7 +1873,7 @@ def individual_post_as_html(signing_priv_key_pem: str,
display_name = \
add_emoji_to_display_name(session, base_dir, http_prefix,
nickname, domain,
- display_name, False)
+ display_name, False, translate)
title_str += \
' ' + \
cw_str + '\n'
diff --git a/webapp_profile.py b/webapp_profile.py
index 9bf132225..348fbeebb 100644
--- a/webapp_profile.py
+++ b/webapp_profile.py
@@ -646,12 +646,12 @@ def html_profile(signing_priv_key_pem: str,
display_name = \
add_emoji_to_display_name(session, base_dir, http_prefix,
nickname, domain,
- profile_json['name'], True)
+ profile_json['name'], True, translate)
domain_full = get_full_domain(domain, port)
profile_description = \
add_emoji_to_display_name(session, base_dir, http_prefix,
nickname, domain,
- profile_json['summary'], False)
+ profile_json['summary'], False, translate)
if profile_description:
profile_description = standardize_text(profile_description)
posts_button = 'button'
@@ -2517,7 +2517,7 @@ def _individual_follow_as_html(signing_priv_key_pem: str,
display_name = \
add_emoji_to_display_name(None, base_dir, http_prefix,
actor_nickname, domain,
- display_name, False)
+ display_name, False, translate)
title_str = display_name
if dormant:
diff --git a/webapp_utils.py b/webapp_utils.py
index ff5a37761..e9effca61 100644
--- a/webapp_utils.py
+++ b/webapp_utils.py
@@ -1006,7 +1006,8 @@ def load_individual_post_as_html_from_cache(base_dir: str,
def add_emoji_to_display_name(session, base_dir: str, http_prefix: str,
nickname: str, domain: str,
- display_name: str, in_profile_name: bool) -> str:
+ display_name: str, in_profile_name: bool,
+ translate: {}) -> str:
"""Adds emoji icons to display names or CW on individual posts
"""
if ':' not in display_name:
@@ -1017,7 +1018,8 @@ def add_emoji_to_display_name(session, base_dir: str, http_prefix: str,
# print('TAG: display_name before tags: ' + display_name)
display_name = \
add_html_tags(base_dir, http_prefix,
- nickname, domain, display_name, [], emoji_tags)
+ nickname, domain, display_name, [],
+ emoji_tags, translate)
display_name = display_name.replace('