forked from rDrama/rDrama
Merge branch 'master' of https://github.com/Aevann1/Drama into snow
commit
4b8d712a00
|
@ -16,7 +16,7 @@ import gevent
|
||||||
from werkzeug.middleware.proxy_fix import ProxyFix
|
from werkzeug.middleware.proxy_fix import ProxyFix
|
||||||
import redis
|
import redis
|
||||||
|
|
||||||
app = Flask(__name__, template_folder='./templates')
|
app = Flask(__name__, template_folder='templates')
|
||||||
app.wsgi_app = ProxyFix(app.wsgi_app, x_for=3)
|
app.wsgi_app = ProxyFix(app.wsgi_app, x_for=3)
|
||||||
app.url_map.strict_slashes = False
|
app.url_map.strict_slashes = False
|
||||||
app.jinja_env.cache = {}
|
app.jinja_env.cache = {}
|
||||||
|
|
|
@ -182,7 +182,7 @@ def sanitize(sanitized, noimages=False):
|
||||||
classes = 'height=60 class="emoji" '
|
classes = 'height=60 class="emoji" '
|
||||||
remoji = emoji
|
remoji = emoji
|
||||||
|
|
||||||
if path.isfile(f'./files/assets/images/emojis/{remoji}.webp'):
|
if path.isfile(f'files/assets/images/emojis/{remoji}.webp'):
|
||||||
new = re.sub(f'(?<!"):{emoji}:', f'<img loading="lazy" data-bs-toggle="tooltip" alt=":{emoji}: emoji" title=":{emoji}:" delay="0" {classes}src="/assets/images/emojis/{remoji}.webp" >', new, flags=re.I)
|
new = re.sub(f'(?<!"):{emoji}:', f'<img loading="lazy" data-bs-toggle="tooltip" alt=":{emoji}: emoji" title=":{emoji}:" delay="0" {classes}src="/assets/images/emojis/{remoji}.webp" >', new, flags=re.I)
|
||||||
|
|
||||||
sanitized = sanitized.replace(old, new)
|
sanitized = sanitized.replace(old, new)
|
||||||
|
@ -192,10 +192,10 @@ def sanitize(sanitized, noimages=False):
|
||||||
emoji = i.group(1).lower()
|
emoji = i.group(1).lower()
|
||||||
if emoji.startswith("!"):
|
if emoji.startswith("!"):
|
||||||
emoji = emoji[1:]
|
emoji = emoji[1:]
|
||||||
if path.isfile(f'./files/assets/images/emojis/{emoji}.webp'):
|
if path.isfile(f'files/assets/images/emojis/{emoji}.webp'):
|
||||||
sanitized = re.sub(f'(?<!"):!{emoji}:', f'<img loading="lazy" data-bs-toggle="tooltip" alt=":!{emoji}: emoji" title=":!{emoji}:" delay="0" height=30 class="emoji mirrored" src="/assets/images/emojis/{emoji}.webp">', sanitized, flags=re.I)
|
sanitized = re.sub(f'(?<!"):!{emoji}:', f'<img loading="lazy" data-bs-toggle="tooltip" alt=":!{emoji}: emoji" title=":!{emoji}:" delay="0" height=30 class="emoji mirrored" src="/assets/images/emojis/{emoji}.webp">', sanitized, flags=re.I)
|
||||||
|
|
||||||
elif path.isfile(f'./files/assets/images/emojis/{emoji}.webp'):
|
elif path.isfile(f'files/assets/images/emojis/{emoji}.webp'):
|
||||||
sanitized = re.sub(f'(?<!"):{emoji}:', f'<img loading="lazy" data-bs-toggle="tooltip" alt=":{emoji}: emoji" title=":{emoji}:" delay="0" height=30 class="emoji" src="/assets/images/emojis/{emoji}.webp">', sanitized, flags=re.I)
|
sanitized = re.sub(f'(?<!"):{emoji}:', f'<img loading="lazy" data-bs-toggle="tooltip" alt=":{emoji}: emoji" title=":{emoji}:" delay="0" height=30 class="emoji" src="/assets/images/emojis/{emoji}.webp">', sanitized, flags=re.I)
|
||||||
|
|
||||||
sanitized = sanitized.replace("https://www.", "https://").replace("https://youtu.be/", "https://youtube.com/watch?v=").replace("https://music.youtube.com/watch?v=", "https://youtube.com/watch?v=").replace("https://open.spotify.com/", "https://open.spotify.com/embed/").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("https://m.wikipedia", "https://wikipedia").replace("https://m.youtube", "https://youtube")
|
sanitized = sanitized.replace("https://www.", "https://").replace("https://youtu.be/", "https://youtube.com/watch?v=").replace("https://music.youtube.com/watch?v=", "https://youtube.com/watch?v=").replace("https://open.spotify.com/", "https://open.spotify.com/embed/").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("https://m.wikipedia", "https://wikipedia").replace("https://m.youtube", "https://youtube")
|
||||||
|
@ -239,10 +239,10 @@ def filter_emojis_only(title):
|
||||||
|
|
||||||
if emoji.startswith("!"):
|
if emoji.startswith("!"):
|
||||||
emoji = emoji[1:]
|
emoji = emoji[1:]
|
||||||
if path.isfile(f'./files/assets/images/emojis/{emoji}.webp'):
|
if path.isfile(f'files/assets/images/emojis/{emoji}.webp'):
|
||||||
title = re.sub(f'(?<!"):!{emoji}:', f'<img loading="lazy" data-bs-toggle="tooltip" alt=":!{emoji}: emoji" title=":!{emoji}:" delay="0" height=30 src="/assets/images/emojis/{emoji}.webp" class="emoji mirrored">', title, flags=re.I)
|
title = re.sub(f'(?<!"):!{emoji}:', f'<img loading="lazy" data-bs-toggle="tooltip" alt=":!{emoji}: emoji" title=":!{emoji}:" delay="0" height=30 src="/assets/images/emojis/{emoji}.webp" class="emoji mirrored">', title, flags=re.I)
|
||||||
|
|
||||||
elif path.isfile(f'./files/assets/images/emojis/{emoji}.webp'):
|
elif path.isfile(f'files/assets/images/emojis/{emoji}.webp'):
|
||||||
title = re.sub(f'(?<!"):{emoji}:', f'<img loading="lazy" data-bs-toggle="tooltip" alt=":{emoji}: emoji" title=":{emoji}:" delay="0" height=30 class="emoji" src="/assets/images/emojis/{emoji}.webp">', title, flags=re.I)
|
title = re.sub(f'(?<!"):{emoji}:', f'<img loading="lazy" data-bs-toggle="tooltip" alt=":{emoji}: emoji" title=":{emoji}:" delay="0" height=30 class="emoji" src="/assets/images/emojis/{emoji}.webp">', title, flags=re.I)
|
||||||
|
|
||||||
if len(title) > 1500: abort(400)
|
if len(title) > 1500: abort(400)
|
||||||
|
|
|
@ -204,7 +204,7 @@ def monthly(v):
|
||||||
def get_rules(v):
|
def get_rules(v):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open(f'./rules_{SITE_NAME}.html', 'r') as f: rules = f.read()
|
with open(f'rules_{SITE_NAME}.html', 'r') as f: rules = f.read()
|
||||||
except Exception:
|
except Exception:
|
||||||
rules = None
|
rules = None
|
||||||
|
|
||||||
|
@ -219,9 +219,9 @@ def post_rules(v):
|
||||||
|
|
||||||
text = request.values.get('rules', '').strip()
|
text = request.values.get('rules', '').strip()
|
||||||
|
|
||||||
with open(f'./rules_{SITE_NAME}.html', 'w+') as f: f.write(text)
|
with open(f'rules_{SITE_NAME}.html', 'w+') as f: f.write(text)
|
||||||
|
|
||||||
with open(f'./rules_{SITE_NAME}.html', 'r') as f: rules = f.read()
|
with open(f'rules_{SITE_NAME}.html', 'r') as f: rules = f.read()
|
||||||
|
|
||||||
ma = ModAction(
|
ma = ModAction(
|
||||||
kind="change_rules",
|
kind="change_rules",
|
||||||
|
@ -317,7 +317,7 @@ def reported_comments(v):
|
||||||
@app.get("/admin")
|
@app.get("/admin")
|
||||||
@admin_level_required(2)
|
@admin_level_required(2)
|
||||||
def admin_home(v):
|
def admin_home(v):
|
||||||
with open('./disablesignups', 'r') as f:
|
with open('disablesignups', 'r') as f:
|
||||||
x = f.read()
|
x = f.read()
|
||||||
return render_template("admin/admin_home.html", v=v, x=x)
|
return render_template("admin/admin_home.html", v=v, x=x)
|
||||||
|
|
||||||
|
@ -325,9 +325,9 @@ def admin_home(v):
|
||||||
@admin_level_required(2)
|
@admin_level_required(2)
|
||||||
@validate_formkey
|
@validate_formkey
|
||||||
def disablesignups(v):
|
def disablesignups(v):
|
||||||
with open('./disablesignups', 'r') as f: content = f.read()
|
with open('disablesignups', 'r') as f: content = f.read()
|
||||||
|
|
||||||
with open('./disablesignups', 'w') as f:
|
with open('disablesignups', 'w') as f:
|
||||||
if content == "yes":
|
if content == "yes":
|
||||||
f.write("no")
|
f.write("no")
|
||||||
return {"message": "Signups enabed!"}
|
return {"message": "Signups enabed!"}
|
||||||
|
|
|
@ -169,7 +169,7 @@ def logout(v):
|
||||||
@app.get("/signup")
|
@app.get("/signup")
|
||||||
@auth_desired
|
@auth_desired
|
||||||
def sign_up_get(v):
|
def sign_up_get(v):
|
||||||
with open('./disablesignups', 'r') as f:
|
with open('disablesignups', 'r') as f:
|
||||||
if f.read() == "yes": return "New account registration is currently closed. Please come back later.", 403
|
if f.read() == "yes": return "New account registration is currently closed. Please come back later.", 403
|
||||||
|
|
||||||
if v: return redirect("/")
|
if v: return redirect("/")
|
||||||
|
@ -217,7 +217,7 @@ def sign_up_get(v):
|
||||||
@limiter.limit("5/day")
|
@limiter.limit("5/day")
|
||||||
@auth_desired
|
@auth_desired
|
||||||
def sign_up_post(v):
|
def sign_up_post(v):
|
||||||
with open('./disablesignups', 'r') as f:
|
with open('disablesignups', 'r') as f:
|
||||||
if f.read() == "yes": return "New account registration is currently closed. Please come back later.", 403
|
if f.read() == "yes": return "New account registration is currently closed. Please come back later.", 403
|
||||||
|
|
||||||
if v: abort(403)
|
if v: abort(403)
|
||||||
|
|
|
@ -12,17 +12,23 @@ from files.classes.mod_logs import ACTIONTYPES, ACTIONTYPES2
|
||||||
site = environ.get("DOMAIN").strip()
|
site = environ.get("DOMAIN").strip()
|
||||||
site_name = environ.get("SITE_NAME").strip()
|
site_name = environ.get("SITE_NAME").strip()
|
||||||
|
|
||||||
|
@app.get("/emojis")
|
||||||
|
@auth_desired
|
||||||
|
def emojis(v):
|
||||||
|
emojis = (x.replace('.webp','') for x in os.listdir("files/assets/images/emojis"))
|
||||||
|
return render_template("emojis.html", v=v, emojis=emojis)
|
||||||
|
|
||||||
@app.get('/rules')
|
@app.get('/rules')
|
||||||
@auth_desired
|
@auth_desired
|
||||||
def static_rules(v):
|
def static_rules(v):
|
||||||
|
|
||||||
if not path.exists(f'./rules_{site_name}.html'):
|
if not path.exists(f'rules_{site_name}.html'):
|
||||||
if v and v.admin_level > 1:
|
if v and v.admin_level > 1:
|
||||||
return render_template('norules.html', v=v)
|
return render_template('norules.html', v=v)
|
||||||
else:
|
else:
|
||||||
abort(404)
|
abort(404)
|
||||||
|
|
||||||
with open(f'./rules_{site_name}.html', 'r') as f:
|
with open(f'rules_{site_name}.html', 'r') as f:
|
||||||
rules = f.read()
|
rules = f.read()
|
||||||
|
|
||||||
return render_template('rules.html', rules=rules, v=v)
|
return render_template('rules.html', rules=rules, v=v)
|
||||||
|
@ -69,7 +75,7 @@ def participation_stats(v):
|
||||||
@auth_required
|
@auth_required
|
||||||
def chart(v):
|
def chart(v):
|
||||||
file = cached_chart()
|
file = cached_chart()
|
||||||
return send_file(f"../{file}")
|
return send_file(f".{file}")
|
||||||
|
|
||||||
|
|
||||||
@cache.memoize(timeout=86400)
|
@cache.memoize(timeout=86400)
|
||||||
|
@ -264,7 +270,7 @@ def static_service2(path):
|
||||||
@app.get('/assets/<path:path>')
|
@app.get('/assets/<path:path>')
|
||||||
@limiter.exempt
|
@limiter.exempt
|
||||||
def static_service(path):
|
def static_service(path):
|
||||||
resp = make_response(send_from_directory('./assets', path))
|
resp = make_response(send_from_directory('assets', path))
|
||||||
if request.path.endswith('.webp') or request.path.endswith('.gif') or request.path.endswith('.ttf') or request.path.endswith('.woff') or request.path.endswith('.woff2'):
|
if request.path.endswith('.webp') or request.path.endswith('.gif') or request.path.endswith('.ttf') or request.path.endswith('.woff') or request.path.endswith('.woff2'):
|
||||||
resp.headers.remove("Cache-Control")
|
resp.headers.remove("Cache-Control")
|
||||||
resp.headers.add("Cache-Control", "public, max-age=2628000")
|
resp.headers.add("Cache-Control", "public, max-age=2628000")
|
||||||
|
@ -289,7 +295,7 @@ def images(path):
|
||||||
|
|
||||||
@app.get("/robots.txt")
|
@app.get("/robots.txt")
|
||||||
def robots_txt():
|
def robots_txt():
|
||||||
return send_file("./assets/robots.txt")
|
return send_file("assets/robots.txt")
|
||||||
|
|
||||||
@app.get("/settings")
|
@app.get("/settings")
|
||||||
@auth_required
|
@auth_required
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
{% extends "default.html" %}
|
|
||||||
{% block content %}
|
|
||||||
<pre>
|
|
||||||
|
|
||||||
|
|
||||||
</pre>
|
|
||||||
<table class="table table-striped mb-5">
|
|
||||||
<thead class="bg-primary text-white">
|
|
||||||
<tr>
|
|
||||||
<th style="font-weight: bold">#</th>
|
|
||||||
<th style="font-weight: bold">Name</th>
|
|
||||||
<th style="font-weight: bold">Marsey</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody id="followers-table">
|
|
||||||
{% for marsey in marseys %}
|
|
||||||
<tr>
|
|
||||||
<td style="font-weight: bold">{{loop.index}}</td>
|
|
||||||
<td style="font-weight: bold">{{marsey}}</td>
|
|
||||||
<td><img loading="lazy" data-bs-toggle="tooltip" alt=":{{marsey}}:" title=":{{marsey}}:" delay="0" src="/assets/images/emojis/{{marsey}}.webp" ></td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
{% endblock %}
|
|
Loading…
Reference in New Issue