Merge branch 'master' of https://github.com/Aevann1/Drama into snow

remotes/1693045480750635534/spooky-22
Aevann1 2021-12-14 23:34:36 +02:00
commit 4b8d712a00
6 changed files with 25 additions and 45 deletions

View File

@ -16,7 +16,7 @@ import gevent
from werkzeug.middleware.proxy_fix import ProxyFix
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.url_map.strict_slashes = False
app.jinja_env.cache = {}

View File

@ -182,7 +182,7 @@ def sanitize(sanitized, noimages=False):
classes = 'height=60 class="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)
sanitized = sanitized.replace(old, new)
@ -192,10 +192,10 @@ def sanitize(sanitized, noimages=False):
emoji = i.group(1).lower()
if emoji.startswith("!"):
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)
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 = 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("!"):
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)
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)
if len(title) > 1500: abort(400)

View File

@ -204,7 +204,7 @@ def monthly(v):
def get_rules(v):
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:
rules = None
@ -219,9 +219,9 @@ def post_rules(v):
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(
kind="change_rules",
@ -317,7 +317,7 @@ def reported_comments(v):
@app.get("/admin")
@admin_level_required(2)
def admin_home(v):
with open('./disablesignups', 'r') as f:
with open('disablesignups', 'r') as f:
x = f.read()
return render_template("admin/admin_home.html", v=v, x=x)
@ -325,9 +325,9 @@ def admin_home(v):
@admin_level_required(2)
@validate_formkey
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":
f.write("no")
return {"message": "Signups enabed!"}

View File

@ -169,7 +169,7 @@ def logout(v):
@app.get("/signup")
@auth_desired
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 v: return redirect("/")
@ -217,7 +217,7 @@ def sign_up_get(v):
@limiter.limit("5/day")
@auth_desired
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 v: abort(403)

View File

@ -12,17 +12,23 @@ from files.classes.mod_logs import ACTIONTYPES, ACTIONTYPES2
site = environ.get("DOMAIN").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')
@auth_desired
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:
return render_template('norules.html', v=v)
else:
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()
return render_template('rules.html', rules=rules, v=v)
@ -69,7 +75,7 @@ def participation_stats(v):
@auth_required
def chart(v):
file = cached_chart()
return send_file(f"../{file}")
return send_file(f".{file}")
@cache.memoize(timeout=86400)
@ -264,7 +270,7 @@ def static_service2(path):
@app.get('/assets/<path:path>')
@limiter.exempt
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'):
resp.headers.remove("Cache-Control")
resp.headers.add("Cache-Control", "public, max-age=2628000")
@ -289,7 +295,7 @@ def images(path):
@app.get("/robots.txt")
def robots_txt():
return send_file("./assets/robots.txt")
return send_file("assets/robots.txt")
@app.get("/settings")
@auth_required

View File

@ -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 %}