From b6a5d010cac09697f7a7e10cbafb214aec6434a7 Mon Sep 17 00:00:00 2001
From: Aevann1
Date: Wed, 29 Jun 2022 02:55:44 +0200
Subject: [PATCH] add "show more..." button
---
files/helpers/regex.py | 1 +
files/helpers/sanitize.py | 6 +++++-
files/templates/util/assetcache.html | 2 +-
3 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/files/helpers/regex.py b/files/helpers/regex.py
index 75c84a820..642c4fd41 100644
--- a/files/helpers/regex.py
+++ b/files/helpers/regex.py
@@ -94,6 +94,7 @@ reddit_domain_regex = re.compile("(^|\s)https:\/\/(reddit\.com|new\.reddit.com|w
color_regex = re.compile("[a-z0-9]{6}", flags=re.A)
+showmore_regex = re.compile("(.{3000,40000}?
)(.*)", flags=re.A)
def sub_matcher(match, upper=False):
if match.group(0).startswith('<'):
diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py
index 92b573468..d0e3748c5 100644
--- a/files/helpers/sanitize.py
+++ b/files/helpers/sanitize.py
@@ -335,10 +335,14 @@ def sanitize(sanitized, edit=False):
if bans: abort(403, description=f"Remove the banned domains {bans} and try again!")
+ sanitized = sanitized.replace('\n','')
+
+ if len(sanitized) > 5000:
+ sanitized = showmore_regex.sub(r'\1
SHOW MORE...
\2
', sanitized)
signal.alarm(0)
- return sanitized.replace('\n','')
+ return sanitized
diff --git a/files/templates/util/assetcache.html b/files/templates/util/assetcache.html
index c42ff7c9d..9f442348a 100644
--- a/files/templates/util/assetcache.html
+++ b/files/templates/util/assetcache.html
@@ -16,7 +16,7 @@ set CACHE_VER = {
'css/win98.css': 61,
'js/award_modal.js': 253,
- 'js/bootstrap.js': 268,
+ 'js/bootstrap.js': 269,
'js/comments+submission_listing.js': 261,
'js/submission_listing.js': 261,
'js/emoji_modal.js': 297,