css solution to the height spam question

pull/134/head
Aevann 2023-02-26 13:08:52 +02:00
parent 08dbc35f34
commit 686f88e9cf
6 changed files with 10 additions and 8 deletions

View File

@ -7151,9 +7151,9 @@ sub, sup {
}
@media (max-width: 768px) {
.comment-text > p {
.comment-text:not(.has_show_more) {
max-height: 100vh;
overflow: auto;
overflow: auto !important;
}
}

View File

@ -264,6 +264,7 @@ function showmore(t) {
while (!(div.id && (div.id.startsWith('comment-text-') || div.id == 'post-text'))){
div = div.parentElement
}
div = div.parentElement
let text = div.getElementsByTagName('d')[0]
if (!text) text = div.getElementsByClassName('showmore-text')[0]

View File

@ -1042,3 +1042,5 @@ AUDIO_FORMATS = ('mp3','wav','ogg','aac','m4a','flac')
if not IS_LOCALHOST and SECRET_KEY == DEFAULT_CONFIG_VALUE:
from warnings import warn
warn("Secret key is the default value! Please change it to a secure random number. Thanks <3", RuntimeWarning)
SHOW_MORE = '<p><button class="showmore">SHOW MORE</button></p></div><div class="d-none">'

View File

@ -559,9 +559,7 @@ def sanitize(sanitized, golden=True, limit_pings=0, showmore=True, count_marseys
if (pos < 0 and len(sanitized) > CHARLIMIT) or pos > CHARLIMIT:
pos = CHARLIMIT - 500
if pos >= 0:
sanitized = (sanitized[:pos] +
showmore_regex.sub(r'\1<p><button class="showmore">SHOW MORE</button></p><d class="d-none">\2</d>',
sanitized[pos:], count=1))
sanitized = (sanitized[:pos] + showmore_regex.sub(rf'\1{SHOW_MORE}\2', sanitized[pos:], count=1))
return sanitized.strip()

View File

@ -118,5 +118,5 @@ def inject_constants():
"HOUSE_JOIN_COST":HOUSE_JOIN_COST, "HOUSE_SWITCH_COST":HOUSE_SWITCH_COST, "IMAGE_FORMATS":','.join(IMAGE_FORMATS),
"PAGE_SIZES":PAGE_SIZES, "THEMES":THEMES, "COMMENT_SORTS":COMMENT_SORTS, "SORTS":SORTS,
"TIME_FILTERS":TIME_FILTERS, "HOUSES":HOUSES, "TIERS_ID_TO_NAME":TIERS_ID_TO_NAME,
"DEFAULT_CONFIG_VALUE":DEFAULT_CONFIG_VALUE, "IS_LOCALHOST":IS_LOCALHOST, "BACKGROUND_CATEGORIES":BACKGROUND_CATEGORIES, "PAGE_SIZE":PAGE_SIZE, "TAGLINES":TAGLINES, "IS_FISTMAS":IS_FISTMAS, "get_alt_graph":get_alt_graph, "current_registered_users":current_registered_users, "gitref":git_head()
"DEFAULT_CONFIG_VALUE":DEFAULT_CONFIG_VALUE, "IS_LOCALHOST":IS_LOCALHOST, "BACKGROUND_CATEGORIES":BACKGROUND_CATEGORIES, "PAGE_SIZE":PAGE_SIZE, "TAGLINES":TAGLINES, "IS_FISTMAS":IS_FISTMAS, "get_alt_graph":get_alt_graph, "current_registered_users":current_registered_users, "gitref":git_head(), "SHOW_MORE": SHOW_MORE,
}

View File

@ -251,8 +251,9 @@
<div id="comment-banned-warning" class="comment-text text-removed mb-0">removed by @{{c.ban_reason}} (Admin)</div>
{% endif %}
<div id="comment-text-{{c.id}}" class="comment-text mb-0 {% if c.author.agendaposter and not (c.parent_submission and c.post.sub == 'chudrama') %}agendaposter{% endif %} {% if c.author.rainbow %}rainbow-text{% endif %}">
{{c.realbody(v) | safe}}
{% set realbody = c.realbody(v) %}
<div id="comment-text-{{c.id}}" class="comment-text {% if SHOW_MORE in realbody %}has_show_more{% endif %} mb-0 {% if c.author.agendaposter and not (c.parent_submission and c.post.sub == 'chudrama') %}agendaposter{% endif %} {% if c.author.rainbow %}rainbow-text{% endif %}">
{{realbody | safe}}
</div>
{% if c.parent_submission or c.wall_user_id %}