From a41622d6acab4386ed76d84090fd395b4be03346 Mon Sep 17 00:00:00 2001 From: DrTransmisia Date: Wed, 4 May 2022 20:39:48 +0200 Subject: [PATCH 2/8] removed error in DDL --- seed-db.sql | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/seed-db.sql b/seed-db.sql index b7107ccd8..37d4ac31f 100644 --- a/seed-db.sql +++ b/seed-db.sql @@ -1,39 +1,39 @@ INSERT INTO public.users (username, passhash, created_utc, admin_level, over_18, is_activated, bio, bio_html, login_nonce, is_private, unban_utc, original_username, customtitle, defaultsorting, defaultsortingcomments, defaulttime, namecolor, titlecolor, customtitleplain, theme, themecolor, changelogsub, reddit, css, profilecss, coins, agendaposter, - post_count, comment_count, background, verified, truecoins, cardview, subs + post_count, comment_count, background, verified, truecoins, cardview ) VALUES ('System', '', 0, 0, true, true, '', '', 0, false, 0, 'System', '', 'hot', 'top', 'day', 'ff66ac', 'ff66ac', '', 'dark', 'ff66ac', false, 'old.reddit.com', '', '', 0, 0, - 0, 0, '', 'Verified', 0, false, 2), + 0, 0, '', 'Verified', 0, false), ('AutoJanny', '', 0, 0, true, true, '', '', 0, false, 0, 'AutoJanny', '', 'hot', 'top', 'day', 'ff66ac', 'ff66ac', '', 'dark', 'ff66ac', false, 'old.reddit.com', '', '', 0, 0, - 0, 0, '', 'Verified', 0, false, 2), + 0, 0, '', 'Verified', 0, false), ('Snappy', '', 0, 0, true, true, '', '', 0, false, 0, 'Snappy', '', 'hot', 'top', 'day', '62ca56', 'e4432d', '', 'dark', '30409f', false, 'old.reddit.com', '', '', 0, 0, - 0, 0, '', 'Verified', 0, false, 2), + 0, 0, '', 'Verified', 0, false), ('longpostbot', '', 0, 0, true, true, '', '', 0, false, 0, 'longpostbot', '', 'hot', 'top', 'day', '62ca56', 'e4432d', '', 'dark', '30409f', false, 'old.reddit.com', '', '', 0, 0, - 0, 0, '', 'Verified', 0, false, 2), + 0, 0, '', 'Verified', 0, false), ('zozbot', '', 0, 0, true, true, '', '', 0, false, 0, 'zozbot', '', 'hot', 'top', 'day', '62ca56', 'e4432d', '', 'dark', '30409f', false, 'old.reddit.com', '', '', 0, 0, - 0, 0, '', 'Verified', 0, false, 2), + 0, 0, '', 'Verified', 0, false), ('AutoPoller', '', 0, 0, true, true, '', '', 0, false, 0, 'AutoPoller', '', 'hot', 'top', 'day', '62ca56', 'e4432d', '', 'dark', '30409f', false, 'old.reddit.com', '', '', 0, 0, - 0, 0, '', 'Verified', 0, false, 2), + 0, 0, '', 'Verified', 0, false), ('AutoBetter', '', 0, 0, true, true, '', '', 0, false, 0, 'AutoBetter', '', 'hot', 'top', 'day', '62ca56', 'e4432d', '', 'dark', '30409f', false, 'old.reddit.com', '', '', 0, 0, - 0, 0, '', 'Verified', 0, false, 2), + 0, 0, '', 'Verified', 0, false), ('AutoChoice', '', 0, 0, true, true, '', '', 0, false, 0, 'AutoChoice', '', 'hot', 'top', 'day', '62ca56', 'e4432d', '', 'dark', '30409f', false, 'old.reddit.com', '', '', 0, 0, - 0, 0, '', 'Verified', 0, false, 2); + 0, 0, '', 'Verified', 0, false); INSERT INTO public.badge_defs VALUES (1,'Alpha User','Joined during open alpha'), From e526a4fd1cb44ec80f2f225ca94c856b63bbbc84 Mon Sep 17 00:00:00 2001 From: DrTransmisia Date: Thu, 5 May 2022 15:47:47 +0200 Subject: [PATCH 3/8] re-factoring emoji system\n\nnow should be less CPU intesive although most of the load seems to come from the img loading itself and it is not address in this commit --- files/routes/static.py | 28 ++++-- files/templates/emoji_modal.html | 151 ++++++++++++++----------------- 2 files changed, 91 insertions(+), 88 deletions(-) diff --git a/files/routes/static.py b/files/routes/static.py index 72226400d..dbc30c8f2 100644 --- a/files/routes/static.py +++ b/files/routes/static.py @@ -47,15 +47,31 @@ def marseys(v): marseys = g.db.query(Marsey).order_by(Marsey.count.desc()) return render_template("marseys.html", v=v, marseys=marseys) -@app.get("/marsey_list") +@app.get("/marsey_list.json") @cache.memoize(timeout=600) def marsey_list(): - if SITE_NAME == 'rDrama': - marseys = [f"{x.name} : {y} {x.tags}" for x, y in g.db.query(Marsey, User.username).join(User, User.id==Marsey.author_id).order_by(Marsey.count.desc())] - else: - marseys = [f"{x.name} : {x.tags}" for x in g.db.query(Marsey).order_by(Marsey.count.desc())] + # From database + emojis = [{ + "name": emoij.name, + "author": author if SITE_NAME == 'rDrama' else "rDrama's chads", + # yikes, I don't really like this DB schema. Next time be better + "tags": emoij.tags.split(" ") + [emoij.name[len("marsey"):] if emoij.name.startswith("marsey") else emoij.name] + ([author] if SITE_NAME == 'rDrama' else []), + "count": emoij.count, + "class": "Marsey" + } for emoij, author in g.db.query(Marsey, User.username).join(User, User.id==Marsey.author_id).order_by(Marsey.count.desc())] - return str(marseys).replace("'",'"') + # Stastic shit + shit = open("files/assets/shit emojis.json", "r", encoding="utf-8") + emojis = emojis + json.load(shit) + shit.close() + + if SITE_NAME == 'Cringetopia': + shit = open("files/assets/shit emojis.cringetopia.json", "r", encoding="utf-8") + emojis = emojis + json.load(shit) + shit.close() + + # return str(marseys).replace("'",'"') + return jsonify(emojis) @app.get('/rules') @app.get('/sidebar') diff --git a/files/templates/emoji_modal.html b/files/templates/emoji_modal.html index 0ccee1646..f307c6e82 100644 --- a/files/templates/emoji_modal.html +++ b/files/templates/emoji_modal.html @@ -1,49 +1,19 @@