From 499781329f2992389902e763ba174a485407aff2 Mon Sep 17 00:00:00 2001
From: Aevann
Date: Mon, 3 Jul 2023 01:55:56 +0300
Subject: [PATCH] remove event_darkmode
---
files/assets/events/fistmas/js/darkmode.js | 20 --------------------
files/classes/user.py | 1 -
files/helpers/config/const.py | 1 +
files/routes/settings.py | 12 ------------
files/templates/post.html | 2 +-
files/templates/sidebar_WPD.html | 7 -------
files/templates/sidebar_rDrama.html | 7 -------
files/templates/util/html_head.html | 6 +++---
8 files changed, 5 insertions(+), 51 deletions(-)
delete mode 100644 files/assets/events/fistmas/js/darkmode.js
diff --git a/files/assets/events/fistmas/js/darkmode.js b/files/assets/events/fistmas/js/darkmode.js
deleted file mode 100644
index ea00206df..000000000
--- a/files/assets/events/fistmas/js/darkmode.js
+++ /dev/null
@@ -1,20 +0,0 @@
-function postToastRoastEventDarkmode(t, url) {
- const xhr = createXhrWithFormKey(url);
- xhr[0].onload = function() {
- postToastLoadEventDarkmode(xhr[0])
- };
- xhr[0].send(xhr[1]);
-}
-
-function postToastLoadEventDarkmode(xhr) {
- let data
- try {
- data = JSON.parse(xhr.response)
- }
- catch (e) {
- console.log(e)
- }
- success = xhr.status >= 200 && xhr.status < 300;
- showToast(success, getMessageFromJsonData(success, data));
- location.reload();
-}
diff --git a/files/classes/user.py b/files/classes/user.py
index 550d5088b..d059c2263 100644
--- a/files/classes/user.py
+++ b/files/classes/user.py
@@ -164,7 +164,6 @@ class User(Base):
if IS_FISTMAS():
#TODO: make event_music a cookie toggle instead
event_music = Column(Boolean, default=default_event_music, nullable=False)
- event_darkmode = Column(Boolean, default=default_darkmode, nullable=False)
badges = relationship("Badge", order_by="Badge.created_utc", back_populates="user")
subscriptions = relationship("Subscription", back_populates="user")
diff --git a/files/helpers/config/const.py b/files/helpers/config/const.py
index 1b1df1258..2f0601ef8 100644
--- a/files/helpers/config/const.py
+++ b/files/helpers/config/const.py
@@ -450,6 +450,7 @@ CHUD_MSG = """:marseypirate: : Avast, ye scurvy cur! Yer {type} be walkin' the p
PIN_AWARD_TEXT = " (pin award)"
THEMES = ["4chan","classic","classic_dark","coffee","dark","dramblr","light","midnight","tron","win98"]
+LIGHT_THEMES = ["4chan","classic","coffee","light","win98"]
BACKGROUND_CATEGORIES = ["glitter", "anime", "fantasy", "solarpunk", "pixelart"]
COMMENT_SORTS = ["hot", "new", "old", "top", "bottom", "controversial", "saves"]
SORTS = COMMENT_SORTS + ["bump", "comments", "views", "subscriptions", "saves"]
diff --git a/files/routes/settings.py b/files/routes/settings.py
index d1c9e1006..80ce75a85 100644
--- a/files/routes/settings.py
+++ b/files/routes/settings.py
@@ -970,15 +970,3 @@ def settings_checkmark_text(v):
v.verified = new_name
g.db.add(v)
return redirect("/settings/personal?msg=Checkmark Text successfully updated!")
-
-if IS_FISTMAS():
- @app.post("/events/fistmas2022/darkmode")
- @limiter.limit('1/second', scope=rpath)
- @limiter.limit('1/second', scope=rpath, key_func=get_ID)
- @limiter.limit(DEFAULT_RATELIMIT)
- @limiter.limit(DEFAULT_RATELIMIT, key_func=get_ID)
- @auth_required
- def event_darkmode(v):
- v.event_darkmode = not v.event_darkmode
- g.db.add(v)
- return {"message": "Dark mode toggled successfully!"}
diff --git a/files/templates/post.html b/files/templates/post.html
index cd805245e..04dc0594d 100644
--- a/files/templates/post.html
+++ b/files/templates/post.html
@@ -106,7 +106,7 @@
{% if p.embed %}
{% if p.domain == "twitter.com" %}
{{p.embed | safe}}
- {% if v and v.theme.split("_")[0] in ["light", "coffee", "4chan"] %}
+ {% if v and v.theme in LIGHT_THEMES %}
{% else %}
diff --git a/files/templates/sidebar_WPD.html b/files/templates/sidebar_WPD.html
index ac5a7732f..cd285de41 100644
--- a/files/templates/sidebar_WPD.html
+++ b/files/templates/sidebar_WPD.html
@@ -27,9 +27,6 @@
- {% if IS_FISTMAS() %}
-
- {% endif %}
-
-{% if IS_FISTMAS() %}
-
-{% endif %}
diff --git a/files/templates/sidebar_rDrama.html b/files/templates/sidebar_rDrama.html
index e9360bce6..d714e9eb7 100644
--- a/files/templates/sidebar_rDrama.html
+++ b/files/templates/sidebar_rDrama.html
@@ -34,9 +34,6 @@
- {% if IS_FISTMAS() %}
-
- {% endif %}
{% if sub and sub.sidebar_html %}
@@ -74,7 +71,3 @@
Live commit: {{git_head()[0]}}
-
-{% if IS_FISTMAS() %}
-
-{% endif %}
diff --git a/files/templates/util/html_head.html b/files/templates/util/html_head.html
index 322183fc0..9d444a789 100644
--- a/files/templates/util/html_head.html
+++ b/files/templates/util/html_head.html
@@ -130,10 +130,10 @@
{% if IS_FISTMAS() %}
- {% if v and v.event_darkmode %}
-
- {% else %}
+ {% if v and v.theme in LIGHT_THEMES %}
+ {% else %}
+
{% endif %}
{% endif %}