tmufdsMerge branch 'frost' of https://github.com/Aevann1/Drama into frost

remotes/1693045480750635534/spooky-22
Aevann1 2022-03-17 17:42:33 +00:00
commit 9798a70fb9
13 changed files with 51 additions and 36 deletions

View File

@ -10,6 +10,8 @@ from json import loads, dump
from random import random, choice
import signal
import time
from urllib.parse import ParseResult, urlunparse, urlparse
allowed_tags = tags = ['b',
'blockquote',
@ -115,7 +117,13 @@ def sanitize(sanitized, noimages=False, alert=False, comment=False, edit=False):
sanitized = strikethrough_regex.sub(r'<del>\1</del>', sanitized)
sanitized = sanitized.replace("\ufeff", "").replace("𒐪","").replace("<script","").replace("script>","").replace('','')
sanitized = sanitized.replace("\ufeff", "").replace("𒐪","").replace("<script","").replace("script>","").replace('','').replace("https://youtu.be/", "https://youtube.com/watch?v=").replace("https://music.youtube.com/watch?v=", "https://youtube.com/watch?v=").replace("https://streamable.com/", "https://streamable.com/e/").replace("https://youtube.com/shorts/", "https://youtube.com/watch?v=").replace("https://mobile.twitter", "https://twitter").replace("https://m.facebook", "https://facebook").replace("m.wikipedia.org", "wikipedia.org").replace("https://m.youtube", "https://youtube").replace("https://www.youtube", "https://youtube").replace("old.reddit.com/gallery", "reddit.com/gallery")
if "https://youtube.com/watch?v=" in sanitized: sanitized = sanitized.replace("?t=", "&t=")
for rd in ["://reddit.com", "://new.reddit.com", "://www.reddit.com", "://redd.it", "://libredd.it"]:
sanitized = sanitized.replace(rd, "://old.reddit.com")
if alert:
captured = []
@ -195,6 +203,32 @@ def sanitize(sanitized, noimages=False, alert=False, comment=False, edit=False):
except: tag.string = ""
parsed_url = urlparse(tag.get("href"))
domain = parsed_url.netloc
if domain == 'old.reddit.com':
new_url = ParseResult(scheme="https",
netloc=parsed_url.netloc,
path=parsed_url.path,
params=parsed_url.params,
query=None,
fragment=parsed_url.fragment)
else:
qd = parse_qs(parsed_url.query)
filtered = {k: val for k, val in qd.items() if not k.startswith('utm_') and not k.startswith('ref_')}
new_url = ParseResult(scheme="https",
netloc=parsed_url.netloc,
path=parsed_url.path,
params=parsed_url.params,
query=urlencode(filtered, doseq=True),
fragment=parsed_url.fragment)
new_url = urlunparse(new_url)
if tag.string == tag["href"]: tag.string = new_url
tag["href"] = new_url
sanitized = str(soup)
@ -276,10 +310,6 @@ def sanitize(sanitized, noimages=False, alert=False, comment=False, edit=False):
sanitized = re.sub(f'(?<!"):{i.group(1).lower()}:', f'<img loading="lazy" data-bs-toggle="tooltip" alt=":{old}:" title=":{old}:" class="{classes}" src="/e/{emoji}.webp">', sanitized, flags=re.I|re.A)
if comment: marseys_used.add(emoji)
sanitized = sanitized.replace("https://youtu.be/", "https://youtube.com/watch?v=").replace("https://music.youtube.com/watch?v=", "https://youtube.com/watch?v=").replace("https://streamable.com/", "https://streamable.com/e/").replace("https://youtube.com/shorts/", "https://youtube.com/watch?v=").replace("https://mobile.twitter", "https://twitter").replace("https://m.facebook", "https://facebook").replace("m.wikipedia.org", "wikipedia.org").replace("https://m.youtube", "https://youtube").replace("https://www.youtube", "https://youtube")
if "https://youtube.com/watch?v=" in sanitized: sanitized = sanitized.replace("?t=", "&t=")
captured = []
for i in youtube_regex.finditer(sanitized):
if i.group(0) in captured: continue
@ -299,11 +329,6 @@ def sanitize(sanitized, noimages=False, alert=False, comment=False, edit=False):
sanitized = sanitized.replace(replacing, htmlsource)
for rd in ["://reddit.com", "://new.reddit.com", "://www.reddit.com", "://redd.it", "://libredd.it"]:
sanitized = sanitized.replace(rd, "://old.reddit.com")
sanitized = sanitized.replace("old.reddit.com/gallery", "reddit.com/gallery")
sanitized = unlinked_regex.sub(r'\1<a href="\2" rel="nofollow noopener noreferrer" target="_blank">\2</a>', sanitized)

View File

@ -23,16 +23,6 @@ GUMROAD_TOKEN = environ.get("GUMROAD_TOKEN", "").strip()
month = datetime.now().strftime('%B')
@app.get('/admin/default')
@admin_level_required(3)
def default(v):
for u in g.db.query(User).filter(User.profileurl == None).all():
u.profileurl = '/e/' + random.choice(marseys_const) + '.webp'
g.db.add(u)
print(u.username, flush=True)
g.db.commit()
return 'done'
@app.get('/admin/merge/<id1>/<id2>')
@admin_level_required(3)
def merge(v, id1, id2):

View File

@ -15,7 +15,7 @@
{% if v %}
<style>:root{--primary:#{{v.themecolor}}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?v=176"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?v=28">
<link rel="stylesheet" href="/static/assets/css/main.css?v=178"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?v=28">
{% if v.agendaposter %}
<style>
html {
@ -39,7 +39,7 @@
{% endif %}
{% else %}
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?v=176"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=28">
<link rel="stylesheet" href="/static/assets/css/main.css?v=178"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=28">
{% endif %}
</head>

View File

@ -7,7 +7,7 @@
<script src="/static/assets/js/bootstrap.js?v=245"></script>
{% if v %}
<style>:root{--primary:#{{v.themecolor}}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?v=176">
<link rel="stylesheet" href="/static/assets/css/main.css?v=178">
<link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?v=28">
{% if v.agendaposter %}
<style>
@ -32,7 +32,7 @@
{% endif %}
{% else %}
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?v=176">
<link rel="stylesheet" href="/static/assets/css/main.css?v=178">
<link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=28">
{% endif %}

View File

@ -1,5 +1,5 @@
<div class="modal fade" id="gifModal" tabindex="-1" role="dialog" aria-labelledby="gifModalTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-scrollable modal-dialog-centered p-5" style="max-width:100% !important" role="document">
<div class="modal-dialog modal-dialog-scrollable modal-dialog-centered p-4" style="max-width:100% !important" role="document">
<div class="modal-content">
<div class="modal-header border-bottom-0 shadow-md p-3">
<div class="form-group d-flex align-items-center w-100 mb-0">

View File

@ -6,7 +6,7 @@
{% block content %}
{% if v %}
<style>:root{--primary:#{{v.themecolor}}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?v=176"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?v=28">
<link rel="stylesheet" href="/static/assets/css/main.css?v=178"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?v=28">
{% if v.agendaposter %}
<style>
html {
@ -30,7 +30,7 @@
{% endif %}
{% else %}
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?v=176"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=28">
<link rel="stylesheet" href="/static/assets/css/main.css?v=178"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=28">
{% endif %}
<div class="row justify-content-around">

View File

@ -18,7 +18,7 @@
{% endblock %}
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?v=176">
<link rel="stylesheet" href="/static/assets/css/main.css?v=178">
<link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=28">
</head>

View File

@ -14,7 +14,7 @@
<title>2-Step Login - {{SITE_NAME}}</title>
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?v=176"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=28">
<link rel="stylesheet" href="/static/assets/css/main.css?v=178"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=28">
</head>

View File

@ -34,7 +34,7 @@
<style>:root{--primary:#{{v.themecolor}}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?v=176"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?v=28">
<link rel="stylesheet" href="/static/assets/css/main.css?v=178"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?v=28">
{% if v.agendaposter %}
<style>
html {

View File

@ -39,10 +39,10 @@
{% if v %}
<style>:root{--primary:#{{v.themecolor}}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?v=176"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?v=28">
<link rel="stylesheet" href="/static/assets/css/main.css?v=178"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?v=28">
{% else %}
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?v=176"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=28">
<link rel="stylesheet" href="/static/assets/css/main.css?v=178"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=28">
{% endif %}
</head>

View File

@ -31,7 +31,7 @@
<title>{% if ref_user %}{{ref_user.username}} invites you to {{SITE_NAME}}{% else %}Sign up - {{SITE_NAME}}{% endif %}</title>
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?v=176"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=28">
<link rel="stylesheet" href="/static/assets/css/main.css?v=178"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=28">
</head>

View File

@ -32,7 +32,7 @@
<title>{% if ref_user %}{{ref_user.username}} invites you to {{SITE_NAME}}{% else %}{{SITE_NAME}}{% endif %}</title>
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?v=176"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=28">
<link rel="stylesheet" href="/static/assets/css/main.css?v=178"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=28">
</head>

View File

@ -26,7 +26,7 @@
{% block stylesheets %}
{% if v %}
<style>:root{--primary:#{{v.themecolor}}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?v=176"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?v=28">
<link rel="stylesheet" href="/static/assets/css/main.css?v=178"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?v=28">
{% if v.agendaposter %}
<style>
html {
@ -50,7 +50,7 @@
{% endif %}
{% else %}
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?v=176">
<link rel="stylesheet" href="/static/assets/css/main.css?v=178">
<link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=28">
{% endif %}
{% endblock %}