From 9d8f9b2004ee0cdecc767ff778eeaa576f76c20c Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 23 Jul 2021 15:47:25 +0200 Subject: [PATCH] sneed --- compilecss.py | 2 +- drama/routes/comments.py | 2 -- drama/routes/posts.py | 44 +++++++++++++++++++++------------------- drama/routes/users.py | 17 ++-------------- drama/routes/votes.py | 4 ++++ 5 files changed, 30 insertions(+), 39 deletions(-) diff --git a/compilecss.py b/compilecss.py index 9d973a25d..245dfabbd 100644 --- a/compilecss.py +++ b/compilecss.py @@ -2,6 +2,6 @@ for theme in ['dark', 'light', 'coffee', 'tron', '4chan']: with open(f"D:/#D/drama/assets/style/{theme}_ff66ac.css", encoding='utf-8') as t: text = t.read() for color in ['805ad5','62ca56','38a169','80ffff','2a96f3','62ca56','eb4963','ff0000','f39731','30409f','3e98a7','e4432d','7b9ae4','ec72de','7f8fa6', 'f8db58']: - newtext = text.replace("ff66ac", color).replace("ff4097", color).replace("ff1a83", color).replace("ff3390", color) + newtext = text.replace("ff66ac", color).replace("ff4097", color).replace("ff1a83", color).replace("ff3390", color).replace("rgba(255, 102, 172, 0.25)", color) with open(f"D:/#D/drama/assets/style/{theme}_{color}.css", encoding='utf-8', mode='w') as nt: nt.write(newtext) \ No newline at end of file diff --git a/drama/routes/comments.py b/drama/routes/comments.py index 0fa929ae3..91838063d 100644 --- a/drama/routes/comments.py +++ b/drama/routes/comments.py @@ -717,8 +717,6 @@ def edit_comment(cid, v): if ban.reason: reason += f" {ban.reason_text}" - - return jsonify({"error": reason}), 401 return {'html': lambda: render_template("comment_failed.html", action=f"/edit_comment/{c.base36id}", diff --git a/drama/routes/posts.py b/drama/routes/posts.py index fcb891a25..071ccfbe5 100644 --- a/drama/routes/posts.py +++ b/drama/routes/posts.py @@ -23,6 +23,23 @@ from PIL import Image as PILimage with open("snappy.txt", "r") as f: snappyquotes = f.read().split("{[para]}") +def resize(): + u = g.db.query(User).filter(User.profileurl != None, User.resized != True).first() + print(u.username) + print(f"1 {u.profileurl}") + x = requests.get(u.profileurl) + + with open("resizing", "wb") as file: + for chunk in x.iter_content(1024): + file.write(chunk) + + image = upload_from_file("resizing", "resizing", (100, 100)) + if image != None: + u.profileurl = image + u.resized = True + g.db.add(u) + print(f"2 {u.profileurl}") + @app.route("/banaward/post/", methods=["POST"]) @auth_required @@ -73,12 +90,7 @@ def publish(pid, v): def submit_get(v): if v and v.is_banned and not v.unban_utc: return render_template("seized.html") - board = request.args.get("guild", "general") - b = get_guild(board, graceful=True) - if not b: - - b = get_guild("general") - + b = get_guild("general") return render_template("submit.html", v=v, @@ -278,6 +290,8 @@ def edit_post(pid, v): for x in notify_users: send_notification(1046, x, f"@{v.username} has mentioned you: https://rdrama.net{p.permalink}") + resize() + return redirect(p.permalink) @app.route("/submit/title", methods=['GET']) @@ -1053,6 +1067,8 @@ def submit_post(v): g.db.commit() send_message(f"https://rdrama.net{new_post.permalink}") + resize() + return {"html": lambda: redirect(new_post.permalink), "api": lambda: jsonify(new_post.json) } @@ -1077,21 +1093,7 @@ def delete_post_pid(pid, v): cache.delete_memoized(frontlist) - u = g.db.query(User).filter(User.profileurl != None, User.resized != True).first() - print(u.username) - print(f"1 {u.profileurl}") - x = requests.get(u.profileurl) - - with open("resizing", "wb") as file: - for chunk in x.iter_content(1024): - file.write(chunk) - - image = upload_from_file("resizing", "resizing", (100, 100)) - if image != None: - u.profileurl = image - u.resized = True - g.db.add(u) - print(f"2 {u.profileurl}") + resize() return "", 204 diff --git a/drama/routes/users.py b/drama/routes/users.py index 62fa8f9d6..f1762f3a4 100644 --- a/drama/routes/users.py +++ b/drama/routes/users.py @@ -9,6 +9,7 @@ from drama.mail import * from flask import * from drama.__main__ import app, cache, limiter, db_session from pusher_push_notifications import PushNotifications +from .front import resize PUSHER_KEY = environ.get("PUSHER_KEY", "").strip() @@ -31,21 +32,7 @@ def leaderboard(v): if v and v.is_banned and not v.unban_utc:return render_template("seized.html") users1, users2 = leaderboard() - u = g.db.query(User).filter(User.profileurl != None, User.resized != True).first() - print(u.username) - print(f"1 {u.profileurl}") - x = requests.get(u.profileurl) - - with open("resizing", "wb") as file: - for chunk in x.iter_content(1024): - file.write(chunk) - - image = upload_from_file("resizing", "resizing", (100, 100)) - if image != None: - u.profileurl = image - u.resized = True - g.db.add(u) - print(f"2 {u.profileurl}") + resize() return render_template("leaderboard.html", v=v, users1=users1, users2=users2) diff --git a/drama/routes/votes.py b/drama/routes/votes.py index e5d296a14..6426ff074 100644 --- a/drama/routes/votes.py +++ b/drama/routes/votes.py @@ -3,7 +3,9 @@ from drama.helpers.get import * from drama.classes import * from flask import * from drama.__main__ import app +from .users import leaderboard +users1, users2 = leaderboard() @app.route("/api/v1/vote/post//", methods=["POST"]) @app.route("/api/vote/post//", methods=["POST"]) @@ -72,6 +74,8 @@ def api_vote_post(post_id, x, v): post.upvotes = post.ups post.downvotes = post.downs g.db.add(post) + + users1, users2 = leaderboard() return "", 204 @app.route("/api/v1/vote/comment//", methods=["POST"])