master
Aevann1 2022-02-06 12:54:05 +02:00
parent e4b1dde431
commit 022e300d2f
9 changed files with 15 additions and 15 deletions

View File

@ -19,7 +19,7 @@ from json import loads
f = 'files/templates/sidebar_' + environ.get("SITE_NAME").strip() + '.html' f = 'files/templates/sidebar_' + environ.get("SITE_NAME").strip() + '.html'
if not path.exists(f): if not path.exists(f):
with open(f, 'w'): pass with open(f, 'w', encoding="utf-8"): pass
app = Flask(__name__, template_folder='templates') app = Flask(__name__, template_folder='templates')
app.url_map.strict_slashes = False app.url_map.strict_slashes = False

View File

@ -41,7 +41,7 @@ def get_hand_value(hand):
def format_cards(hand): def format_cards(hand):
return map(lambda x: "".join(x), hand) return map("".join(x), hand)
def format_all(player_hand, dealer_hand, deck, status, wager): def format_all(player_hand, dealer_hand, deck, status, wager):

View File

@ -159,7 +159,7 @@ def sanitize(sanitized, noimages=False, alert=False, comment=False, edit=False):
tag["data-src"] = tag["src"] tag["data-src"] = tag["src"]
tag["src"] = "/static/assets/images/loading.webp" tag["src"] = "/static/assets/images/loading.webp"
tag['alt'] = f'![]({tag["data-src"]})' tag['alt'] = f'![]({tag["data-src"]})'
tag["onclick"] = f"expandDesktopImage(this.src);" tag["onclick"] = "expandDesktopImage(this.src);"
tag["data-bs-toggle"] = "modal" tag["data-bs-toggle"] = "modal"
tag["data-bs-target"] = "#expandImageModal" tag["data-bs-target"] = "#expandImageModal"

View File

@ -314,7 +314,7 @@ def monthly(v):
def get_sidebar(v): def get_sidebar(v):
try: try:
with open(f'files/templates/sidebar_{SITE_NAME}.html', 'r') as f: sidebar = f.read() with open(f'files/templates/sidebar_{SITE_NAME}.html', 'r', encoding="utf-8") as f: sidebar = f.read()
except: except:
sidebar = None sidebar = None
@ -328,9 +328,9 @@ def post_sidebar(v):
text = request.values.get('sidebar', '').strip() text = request.values.get('sidebar', '').strip()
with open(f'files/templates/sidebar_{SITE_NAME}.html', 'w+') as f: f.write(text) with open(f'files/templates/sidebar_{SITE_NAME}.html', 'w+', encoding="utf-8") as f: f.write(text)
with open(f'files/templates/sidebar_{SITE_NAME}.html', 'r') as f: sidebar = f.read() with open(f'files/templates/sidebar_{SITE_NAME}.html', 'r', encoding="utf-8") as f: sidebar = f.read()
ma = ModAction( ma = ModAction(
kind="change_sidebar", kind="change_sidebar",

View File

@ -165,7 +165,7 @@ def api_comment(v):
body = request.values.get("body", "").strip()[:10000] body = request.values.get("body", "").strip()[:10000]
if v.admin_level == 3 and parent_post.id == 37749: if v.admin_level == 3 and parent_post.id == 37749:
with open(f"snappy_{SITE_NAME}.txt", "a") as f: with open(f"snappy_{SITE_NAME}.txt", "a", encoding="utf-8") as f:
f.write('\n{[para]}\n' + body) f.write('\n{[para]}\n' + body)
if v.marseyawarded and parent_post.id not in (37696,37697,37749,37833,37838): if v.marseyawarded and parent_post.id not in (37696,37697,37749,37833,37838):

View File

@ -24,7 +24,7 @@ marseys = tuple(f':#{x[0]}:' for x in db.query(Marsey.name).all())
db.close() db.close()
if path.exists(f'snappy_{SITE_NAME}.txt'): if path.exists(f'snappy_{SITE_NAME}.txt'):
with open(f'snappy_{SITE_NAME}.txt', "r") as f: with open(f'snappy_{SITE_NAME}.txt', "r", encoding="utf-8") as f:
if SITE == 'pcmemes.net': snappyquotes = tuple(f.read().split("{[para]}")) if SITE == 'pcmemes.net': snappyquotes = tuple(f.read().split("{[para]}"))
else: snappyquotes = tuple(f.read().split("{[para]}")) + marseys else: snappyquotes = tuple(f.read().split("{[para]}")) + marseys
else: snappyquotes = marseys else: snappyquotes = marseys

View File

@ -66,7 +66,7 @@ def searchposts(v):
if 'author' in criteria: if 'author' in criteria:
posts = posts.filter(Submission.ghost == None) posts = posts.filter(Submission.ghost == None)
author = get_user(criteria['author']) author = get_user(criteria['author'])
if not author: return {"error": f"User not found"} if not author: return {"error": "User not found"}
if author.is_private and author.id != v.id and v.admin_level < 2 and not v.eye: if author.is_private and author.id != v.id and v.admin_level < 2 and not v.eye:
if request.headers.get("Authorization"): if request.headers.get("Authorization"):
return {"error": f"@{author.username}'s profile is private; You can't use the 'author' syntax on them"} return {"error": f"@{author.username}'s profile is private; You can't use the 'author' syntax on them"}
@ -213,7 +213,7 @@ def searchcomments(v):
if 'author' in criteria: if 'author' in criteria:
comments = comments.filter(Comment.ghost == None) comments = comments.filter(Comment.ghost == None)
author = get_user(criteria['author']) author = get_user(criteria['author'])
if not author: return {"error": f"User not found"} if not author: return {"error": "User not found"}
if author.is_private and author.id != v.id and v.admin_level < 2 and not v.eye: if author.is_private and author.id != v.id and v.admin_level < 2 and not v.eye:
if request.headers.get("Authorization"): if request.headers.get("Authorization"):
return {"error": f"@{author.username}'s profile is private; You can't use the 'author' syntax on them"} return {"error": f"@{author.username}'s profile is private; You can't use the 'author' syntax on them"}

View File

@ -384,7 +384,7 @@ def formatting(v):
@app.get("/service-worker.js") @app.get("/service-worker.js")
def serviceworker(): def serviceworker():
with open("files/assets/js/service-worker.js", "r") as f: return Response(f.read(), mimetype='application/javascript') with open("files/assets/js/service-worker.js", "r", encoding="utf-8") as f: return Response(f.read(), mimetype='application/javascript')
@app.get("/settings/security") @app.get("/settings/security")
@auth_required @auth_required

View File

@ -256,9 +256,9 @@ def transfer_coins(v, username):
amount = request.values.get("amount", "").strip() amount = request.values.get("amount", "").strip()
amount = int(amount) if amount.isdigit() else None amount = int(amount) if amount.isdigit() else None
if amount is None or amount <= 0: return {"error": f"Invalid amount of coins."}, 400 if amount is None or amount <= 0: return {"error": "Invalid amount of coins."}, 400
if v.coins < amount: return {"error": f"You don't have enough coins."}, 400 if v.coins < amount: return {"error": "You don't have enough coins."}, 400
if amount < 100: return {"error": f"You have to gift at least 100 coins."}, 400 if amount < 100: return {"error": "You have to gift at least 100 coins."}, 400
if not v.patron and not receiver.patron and not v.alts_patron and not receiver.alts_patron: tax = math.ceil(amount*0.03) if not v.patron and not receiver.patron and not v.alts_patron and not receiver.alts_patron: tax = math.ceil(amount*0.03)
else: tax = 0 else: tax = 0
@ -275,7 +275,7 @@ def transfer_coins(v, username):
g.db.commit() g.db.commit()
return {"message": f"{amount-tax} coins transferred!"}, 200 return {"message": f"{amount-tax} coins transferred!"}, 200
return {"message": f"You can't transfer coins to yourself!"}, 400 return {"message": "You can't transfer coins to yourself!"}, 400
@app.post("/@<username>/transfer_bux") @app.post("/@<username>/transfer_bux")