forked from rDrama/rDrama
fds
parent
d91cb91e07
commit
8214e2c6f9
|
@ -478,7 +478,7 @@ class Submission(Base):
|
||||||
@property
|
@property
|
||||||
@lazy
|
@lazy
|
||||||
def is_image(self):
|
def is_image(self):
|
||||||
if self.url and (self.url.lower().endswith('.webp') or self.url.lower().endswith('.jpg') or self.url.lower().endswith('.png') or self.url.lower().endswith('.gif') or self.url.lower().endswith('.jpeg') or self.url.lower().endswith('?maxwidth=9999') or self.url.lower().endswith('&fidelity=high')) and (self.url.startswith('/') or self.url.startswith(f'{SITE_FULL}/') or embed_check_regex.fullmatch(self.url)):
|
if self.url and (self.url.lower().endswith('.webp') or self.url.lower().endswith('.jpg') or self.url.lower().endswith('.png') or self.url.lower().endswith('.gif') or self.url.lower().endswith('.jpeg') or self.url.lower().endswith('?maxwidth=9999') or self.url.lower().endswith('&fidelity=high')) and embed_check_regex.fullmatch(self.url):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
|
@ -804,13 +804,14 @@ approved_embed_hosts = [
|
||||||
'amazonaws.com',
|
'amazonaws.com',
|
||||||
'githubusercontent.com',
|
'githubusercontent.com',
|
||||||
'unilad.co.uk',
|
'unilad.co.uk',
|
||||||
'grrrgraphics.com'
|
'grrrgraphics.com',
|
||||||
|
'redditmedia.com'
|
||||||
]
|
]
|
||||||
|
|
||||||
hosts = "|".join(approved_embed_hosts).replace('.','\.')
|
hosts = "|".join(approved_embed_hosts).replace('.','\.')
|
||||||
|
|
||||||
image_check_regex = re.compile(f'!\[\]\(((?!https:\/\/([a-z0-9-]\.)*({hosts})\/).*?)\)', flags=re.A)
|
image_check_regex = re.compile(f'!\[\]\(((?!(https:\/\/([a-z0-9-]\.)*({hosts}))?\/).*?)\)', flags=re.A)
|
||||||
|
|
||||||
embed_check_regex = regex.compile(f'(?<!<(code|pre|a)>)https:\/\/([a-z0-9-]\.)*({hosts})\/[\w:~,()\-.#&\/=?@%;+]*', flags=regex.A)
|
embed_check_regex = regex.compile(f'(?<!<(code|pre|a)>)(https:\/\/([a-z0-9-]\.)*({hosts}))?\/[\w:~,()\-.#&\/=?@%;+]*', flags=regex.A)
|
||||||
|
|
||||||
video_regex = regex.compile(f'((?<!<(code|pre|a)>)https:\/\/([a-z0-9-]\.)*({hosts})\/[\w:~,()\-.#&\/=?@%;+]*?\.(mp4|webm|mov))', flags=regex.A)
|
video_regex = regex.compile(f'((?<!<(code|pre|a)>)(https:\/\/([a-z0-9-]\.)*({hosts}))?\/[\w:~,()\-.#&\/=?@%;+]*?\.(mp4|webm|mov))', flags=regex.A)
|
|
@ -37,7 +37,7 @@ def allowed_attributes(tag, name, value):
|
||||||
|
|
||||||
if tag == 'img':
|
if tag == 'img':
|
||||||
if name in ['src','data-src']:
|
if name in ['src','data-src']:
|
||||||
if value.startswith('/') or value.startswith(f'{SITE_FULL}/') or embed_check_regex.fullmatch(value): return True
|
if embed_check_regex.fullmatch(value): return True
|
||||||
else: return False
|
else: return False
|
||||||
|
|
||||||
if name == 'loading' and value == 'lazy': return True
|
if name == 'loading' and value == 'lazy': return True
|
||||||
|
|
|
@ -490,12 +490,25 @@ def changeloglist(v=None, sort="new", page=1 ,t="all"):
|
||||||
@auth_required
|
@auth_required
|
||||||
def random_post(v):
|
def random_post(v):
|
||||||
|
|
||||||
x = g.db.query(Submission).filter(Submission.deleted_utc == 0, Submission.is_banned == False, Submission.private == False)
|
p = g.db.query(Submission.id).filter(Submission.deleted_utc == 0, Submission.is_banned == False, Submission.private == False).order_by(func.random()).first()
|
||||||
total = x.count()
|
|
||||||
n = random.randint(1, total - 2)
|
if p: p = p[0]
|
||||||
|
else: abort(404)
|
||||||
|
|
||||||
|
return redirect(f"/post/{p.id}")
|
||||||
|
|
||||||
|
|
||||||
|
@app.get("/random_user")
|
||||||
|
@auth_required
|
||||||
|
def random_user(v):
|
||||||
|
|
||||||
|
u = g.db.query(User.username).filter(User.song != None).order_by(func.random()).first()
|
||||||
|
|
||||||
|
if u: u = u[0]
|
||||||
|
else: abort(404)
|
||||||
|
|
||||||
|
return redirect(f"/@{x}")
|
||||||
|
|
||||||
post = x.offset(n).limit(1).one_or_none()
|
|
||||||
return redirect(f"/post/{post.id}")
|
|
||||||
|
|
||||||
@app.get("/comments")
|
@app.get("/comments")
|
||||||
@auth_required
|
@auth_required
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
{% if v %}
|
{% if v %}
|
||||||
<style>:root{--primary:#{{v.themecolor}}}</style>
|
<style>:root{--primary:#{{v.themecolor}}}</style>
|
||||||
<link rel="stylesheet" href="/assets/css/main.css?v=237"><link rel="stylesheet" href="/assets/css/{{v.theme}}.css?v=55">
|
<link rel="stylesheet" href="/assets/css/main.css?v=238"><link rel="stylesheet" href="/assets/css/{{v.theme}}.css?v=55">
|
||||||
{% if v.agendaposter %}
|
{% if v.agendaposter %}
|
||||||
<style>
|
<style>
|
||||||
html {
|
html {
|
||||||
|
@ -39,7 +39,7 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
|
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
|
||||||
<link rel="stylesheet" href="/assets/css/main.css?v=237"><link rel="stylesheet" href="/assets/css/{{config('DEFAULT_THEME')}}.css?v=55">
|
<link rel="stylesheet" href="/assets/css/main.css?v=238"><link rel="stylesheet" href="/assets/css/{{config('DEFAULT_THEME')}}.css?v=55">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
<title>Chat</title>
|
<title>Chat</title>
|
||||||
|
|
||||||
<style>:root{--primary:#{{v.themecolor}}}</style>
|
<style>:root{--primary:#{{v.themecolor}}}</style>
|
||||||
<link rel="stylesheet" href="/assets/css/main.css?v=237">
|
<link rel="stylesheet" href="/assets/css/main.css?v=238">
|
||||||
<link rel="stylesheet" href="/assets/css/{{v.theme}}.css?v=55">
|
<link rel="stylesheet" href="/assets/css/{{v.theme}}.css?v=55">
|
||||||
{% if v.css %}
|
{% if v.css %}
|
||||||
<link rel="stylesheet" href="/@{{v.username}}/css">
|
<link rel="stylesheet" href="/@{{v.username}}/css">
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<script src="/assets/js/bootstrap.js?v=245"></script>
|
<script src="/assets/js/bootstrap.js?v=245"></script>
|
||||||
{% if v %}
|
{% if v %}
|
||||||
<style>:root{--primary:#{{v.themecolor}}}</style>
|
<style>:root{--primary:#{{v.themecolor}}}</style>
|
||||||
<link rel="stylesheet" href="/assets/css/main.css?v=237">
|
<link rel="stylesheet" href="/assets/css/main.css?v=238">
|
||||||
<link rel="stylesheet" href="/assets/css/{{v.theme}}.css?v=55">
|
<link rel="stylesheet" href="/assets/css/{{v.theme}}.css?v=55">
|
||||||
{% if v.agendaposter %}
|
{% if v.agendaposter %}
|
||||||
<style>
|
<style>
|
||||||
|
@ -32,7 +32,7 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
|
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
|
||||||
<link rel="stylesheet" href="/assets/css/main.css?v=237">
|
<link rel="stylesheet" href="/assets/css/main.css?v=238">
|
||||||
<link rel="stylesheet" href="/assets/css/{{config('DEFAULT_THEME')}}.css?v=55">
|
<link rel="stylesheet" href="/assets/css/{{config('DEFAULT_THEME')}}.css?v=55">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|
|
@ -83,14 +83,19 @@
|
||||||
|
|
||||||
<div class="collapse navbar-collapse" id="navbarResponsive">
|
<div class="collapse navbar-collapse" id="navbarResponsive">
|
||||||
<ul class="navbar-nav ml-auto d-none d-md-flex {% if not v %}pad{% endif %}">
|
<ul class="navbar-nav ml-auto d-none d-md-flex {% if not v %}pad{% endif %}">
|
||||||
|
|
||||||
<li class="nav-item d-flex align-items-center justify-content-center text-center mx-1">
|
<li class="nav-item d-flex align-items-center justify-content-center text-center mx-1">
|
||||||
<a class="nav-link" href="/chat/" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Chat"><i class="fas fa-messages"></i></a>
|
<a class="nav-link" href="/random_user/" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Random user"><i class="fas fa-music"></i></a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li class="nav-item d-flex align-items-center justify-content-center text-center mx-1">
|
<li class="nav-item d-flex align-items-center justify-content-center text-center mx-1">
|
||||||
<a class="nav-link" href="/random/" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Random post"><i class="fas fa-random"></i></a>
|
<a class="nav-link" href="/random/" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Random post"><i class="fas fa-random"></i></a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
<li class="nav-item d-flex align-items-center justify-content-center text-center mx-1">
|
||||||
|
<a class="nav-link" href="/chat/" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Chat"><i class="fas fa-messages"></i></a>
|
||||||
|
</li>
|
||||||
|
|
||||||
{% if v and v.admin_level > 1 %}
|
{% if v and v.admin_level > 1 %}
|
||||||
<li class="nav-item d-flex align-items-center justify-content-center text-center mx-1">
|
<li class="nav-item d-flex align-items-center justify-content-center text-center mx-1">
|
||||||
<a class="nav-link" href="/admin/" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Admin tools"><i class="fas fa-crown{% if v.has_report_queue %} text-success{% endif %}"></i></a>
|
<a class="nav-link" href="/admin/" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Admin tools"><i class="fas fa-crown{% if v.has_report_queue %} text-success{% endif %}"></i></a>
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{% if v %}
|
{% if v %}
|
||||||
<style>:root{--primary:#{{v.themecolor}}}</style>
|
<style>:root{--primary:#{{v.themecolor}}}</style>
|
||||||
<link rel="stylesheet" href="/assets/css/main.css?v=237"><link rel="stylesheet" href="/assets/css/{{v.theme}}.css?v=55">
|
<link rel="stylesheet" href="/assets/css/main.css?v=238"><link rel="stylesheet" href="/assets/css/{{v.theme}}.css?v=55">
|
||||||
{% if v.agendaposter %}
|
{% if v.agendaposter %}
|
||||||
<style>
|
<style>
|
||||||
html {
|
html {
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
|
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
|
||||||
<link rel="stylesheet" href="/assets/css/main.css?v=237"><link rel="stylesheet" href="/assets/css/{{config('DEFAULT_THEME')}}.css?v=55">
|
<link rel="stylesheet" href="/assets/css/main.css?v=238"><link rel="stylesheet" href="/assets/css/{{config('DEFAULT_THEME')}}.css?v=55">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<div class="row justify-content-around">
|
<div class="row justify-content-around">
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
|
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
|
||||||
<link rel="stylesheet" href="/assets/css/main.css?v=237">
|
<link rel="stylesheet" href="/assets/css/main.css?v=238">
|
||||||
<link rel="stylesheet" href="/assets/css/{{config('DEFAULT_THEME')}}.css?v=55">
|
<link rel="stylesheet" href="/assets/css/{{config('DEFAULT_THEME')}}.css?v=55">
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
<title>2-Step Login - {{SITE_NAME}}</title>
|
<title>2-Step Login - {{SITE_NAME}}</title>
|
||||||
|
|
||||||
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
|
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
|
||||||
<link rel="stylesheet" href="/assets/css/main.css?v=237"><link rel="stylesheet" href="/assets/css/{{config('DEFAULT_THEME')}}.css?v=55">
|
<link rel="stylesheet" href="/assets/css/main.css?v=238"><link rel="stylesheet" href="/assets/css/{{config('DEFAULT_THEME')}}.css?v=55">
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
|
|
||||||
|
|
||||||
<style>:root{--primary:#{{v.themecolor}}}</style>
|
<style>:root{--primary:#{{v.themecolor}}}</style>
|
||||||
<link rel="stylesheet" href="/assets/css/main.css?v=237"><link rel="stylesheet" href="/assets/css/{{v.theme}}.css?v=55">
|
<link rel="stylesheet" href="/assets/css/main.css?v=238"><link rel="stylesheet" href="/assets/css/{{v.theme}}.css?v=55">
|
||||||
{% if v.agendaposter %}
|
{% if v.agendaposter %}
|
||||||
<style>
|
<style>
|
||||||
html {
|
html {
|
||||||
|
|
|
@ -39,10 +39,10 @@
|
||||||
|
|
||||||
{% if v %}
|
{% if v %}
|
||||||
<style>:root{--primary:#{{v.themecolor}}}</style>
|
<style>:root{--primary:#{{v.themecolor}}}</style>
|
||||||
<link rel="stylesheet" href="/assets/css/main.css?v=237"><link rel="stylesheet" href="/assets/css/{{v.theme}}.css?v=55">
|
<link rel="stylesheet" href="/assets/css/main.css?v=238"><link rel="stylesheet" href="/assets/css/{{v.theme}}.css?v=55">
|
||||||
{% else %}
|
{% else %}
|
||||||
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
|
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
|
||||||
<link rel="stylesheet" href="/assets/css/main.css?v=237"><link rel="stylesheet" href="/assets/css/{{config('DEFAULT_THEME')}}.css?v=55">
|
<link rel="stylesheet" href="/assets/css/main.css?v=238"><link rel="stylesheet" href="/assets/css/{{config('DEFAULT_THEME')}}.css?v=55">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
<title>{% if ref_user %}{{ref_user.username}} invites you to {{SITE_NAME}}{% else %}Sign up - {{SITE_NAME}}{% endif %}</title>
|
<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>
|
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
|
||||||
<link rel="stylesheet" href="/assets/css/main.css?v=237"><link rel="stylesheet" href="/assets/css/{{config('DEFAULT_THEME')}}.css?v=55">
|
<link rel="stylesheet" href="/assets/css/main.css?v=238"><link rel="stylesheet" href="/assets/css/{{config('DEFAULT_THEME')}}.css?v=55">
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
<title>{% if ref_user %}{{ref_user.username}} invites you to {{SITE_NAME}}{% else %}{{SITE_NAME}}{% endif %}</title>
|
<title>{% if ref_user %}{{ref_user.username}} invites you to {{SITE_NAME}}{% else %}{{SITE_NAME}}{% endif %}</title>
|
||||||
|
|
||||||
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
|
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
|
||||||
<link rel="stylesheet" href="/assets/css/main.css?v=237"><link rel="stylesheet" href="/assets/css/{{config('DEFAULT_THEME')}}.css?v=55">
|
<link rel="stylesheet" href="/assets/css/main.css?v=238"><link rel="stylesheet" href="/assets/css/{{config('DEFAULT_THEME')}}.css?v=55">
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue