diff --git a/files/__main__.py b/files/__main__.py index 169873a4e..6aa668154 100644 --- a/files/__main__.py +++ b/files/__main__.py @@ -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 = {} diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index 59cdfed8c..dd391d48c 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -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'(?', 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'(?', 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'(?', 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'(?', 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'(?', title, flags=re.I) if len(title) > 1500: abort(400) diff --git a/files/routes/admin.py b/files/routes/admin.py index df5b5e4a0..0cdb2e6cb 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -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!"} diff --git a/files/routes/login.py b/files/routes/login.py index 547381366..3a7bdf41a 100644 --- a/files/routes/login.py +++ b/files/routes/login.py @@ -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) diff --git a/files/routes/static.py b/files/routes/static.py index 97594e119..dd7a38409 100644 --- a/files/routes/static.py +++ b/files/routes/static.py @@ -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/') @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 diff --git a/files/templates/marseys.html b/files/templates/marseys.html deleted file mode 100644 index 0cecf8967..000000000 --- a/files/templates/marseys.html +++ /dev/null @@ -1,26 +0,0 @@ -{% extends "default.html" %} -{% block content %} -
-
-	
-
- - - - - - - - - -{% for marsey in marseys %} - - - - - -{% endfor %} - -
#NameMarsey
{{loop.index}}{{marsey}}:{{marsey}}:
- -{% endblock %} \ No newline at end of file