From 329c23eaba10cc0c33c133769c7c61c15f26f87c Mon Sep 17 00:00:00 2001 From: bashrc Date: Tue, 14 Apr 2026 13:43:28 +0100 Subject: [PATCH] Truncate content warning if it is too long --- webapp_post.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/webapp_post.py b/webapp_post.py index 191f202f5..50cfe72f7 100644 --- a/webapp_post.py +++ b/webapp_post.py @@ -2359,6 +2359,8 @@ def individual_post_as_html(signing_priv_key_pem: str, block_nostr: {}) -> str: """ Shows a single post as html """ + max_content_warning_length: int = 120 + if not post_json_object: return '' @@ -3238,6 +3240,10 @@ def individual_post_as_html(signing_priv_key_pem: str, cw_content_str, post_json_object, page_number) cw_content_str = \ switch_words(base_dir, nickname, domain, cw_content_str) + # truncate content warning if it is too long + if len(cw_content_str) > max_content_warning_length: + cw_content_str = \ + remove_html(cw_content_str[:max_content_warning_length]) if not is_blog_post(post_json_object): # get the content warning button content_str += \