add "show more..." button

master
Aevann1 2022-06-29 02:55:44 +02:00
parent 8f9d982104
commit b6a5d010ca
3 changed files with 7 additions and 2 deletions

View File

@ -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}?</p>)(<p>.*)", flags=re.A)
def sub_matcher(match, upper=False):
if match.group(0).startswith('<'):

View File

@ -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<p><a onclick="showmore()" role="button">SHOW MORE...</a></p><div class="d-none">\2</div>', sanitized)
signal.alarm(0)
return sanitized.replace('\n','')
return sanitized

View File

@ -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,