From 4439f03ef517928e92c97c6afd7788b313c39654 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sat, 10 Dec 2022 21:12:14 +0200 Subject: [PATCH] resizable videos --- files/assets/css/main.css | 21 ++++++++++++++++++++- files/helpers/sanitize.py | 16 ++++------------ files/templates/formatting.html | 4 +++- files/templates/submission.html | 4 +++- files/templates/submission_listing.html | 4 +++- 5 files changed, 33 insertions(+), 16 deletions(-) diff --git a/files/assets/css/main.css b/files/assets/css/main.css index f196014d0..535488750 100644 --- a/files/assets/css/main.css +++ b/files/assets/css/main.css @@ -4925,7 +4925,7 @@ textarea { cursor: pointer; } video { - height: 50vh !important; + max-height: 50vh !important; max-width: 100% !important; margin-top: 0.5rem !important; margin-bottom: 0.5rem !important; @@ -6461,3 +6461,22 @@ div.markdown { font-size: 10px; } } + +.resizable { + resize:both; + display:inline-block; + overflow: auto; + scrollbar-width: none; + -ms-overflow-style: none; +} +.resizable::-webkit-scrollbar { + background: transparent; +} +.resizable > video { + height:100%!important; + max-height:100%!important; + margin:0!important; +} +.bigger { + height:50vh; +} diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index c6dd92956..03386de3d 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -58,14 +58,12 @@ def allowed_attributes(tag, name, value): try: value = int(value.replace('px', '')) except: return False if 0 < value <= 250: return True - return False if tag == 'a': if name == 'href' and '\\' not in value and 'xn--' not in value: return True if name == 'rel' and value == 'nofollow noopener': return True if name == 'target' and value == '_blank': return True - return False if tag == 'img': if name in {'src','data-src'}: return is_safe_url(value) @@ -73,38 +71,33 @@ def allowed_attributes(tag, name, value): if name == 'data-bs-toggle' and value == 'tooltip': return True if name in {'g','b','glow'} and not value: return True if name in {'alt','title'}: return True - return False if tag == 'lite-youtube': if name == 'params' and value.startswith('autoplay=1&modestbranding=1'): return True if name == 'videoid': return True - return False if tag == 'video': if name == 'controls' and value == '': return True if name == 'preload' and value == 'none': return True if name == 'src': return is_safe_url(value) - return False if tag == 'audio': if name == 'src': return is_safe_url(value) if name == 'controls' and value == '': return True if name == 'preload' and value == 'none': return True - return False if tag == 'p': - if name == 'class' and value == 'mb-0': return True - return False + if name == 'class' and value in ('mb-0','resizable'): return True if tag == 'span': if name == 'data-bs-toggle' and value == 'tooltip': return True if name == 'title': return True if name == 'alt': return True - return False if tag == 'table': if name == 'class' and value == 'table': return True - return False + + return False def build_url_re(tlds, protocols): """Builds the url regex used by linkifier @@ -370,7 +363,7 @@ def sanitize(sanitized, golden=True, limit_pings=0, showmore=True, count_marseys sanitized = sanitized.replace(i.group(0), htmlsource) - sanitized = video_sub_regex.sub(r'\1', sanitized) + sanitized = video_sub_regex.sub(r'\1

', sanitized) sanitized = audio_sub_regex.sub(r'\1', sanitized) if count_marseys: @@ -429,7 +422,6 @@ def allowed_attributes_emojis(tag, name, value): if name == 'data-bs-toggle' and value == 'tooltip': return True if name == 'title': return True if name == 'alt': return True - return False return False diff --git a/files/templates/formatting.html b/files/templates/formatting.html index 39584c9a1..b91701cb4 100644 --- a/files/templates/formatting.html +++ b/files/templates/formatting.html @@ -68,7 +68,9 @@ Text 2 Video Files https://files.catbox.moe/v4om92.mp4 - +

+ +

diff --git a/files/templates/submission.html b/files/templates/submission.html index 2f9da2e98..2abe0eea5 100644 --- a/files/templates/submission.html +++ b/files/templates/submission.html @@ -142,7 +142,9 @@ {% elif p.is_video %}
- +

+ +

{% elif p.is_audio %} diff --git a/files/templates/submission_listing.html b/files/templates/submission_listing.html index 2aac5366b..229468aec 100644 --- a/files/templates/submission_listing.html +++ b/files/templates/submission_listing.html @@ -247,7 +247,9 @@ {% elif p.is_video %}
- +

+ +

{% elif p.is_audio %}