modified: app.py

new file:   static/css/theme-dark.css
	new file:   static/css/theme-light.css
	modified:   templates/index.html
	modified:   templates/login.html
	modified:   templates/settings.html
This commit is contained in:
SimolZimol
2024-09-03 11:18:01 +02:00
parent 911ecfa9ca
commit 00c958c34d
6 changed files with 33 additions and 2 deletions

9
app.py
View File

@@ -71,7 +71,7 @@ def get_db_connection():
@app.route("/")
def index():
if "username" in session:
return render_template("index.html", bot_running=bot_status())
return render_template("index.html", bot_running=bot_status(), theme=session.get('theme', 'light'))
return redirect(url_for("login"))
@app.route("/login", methods=["GET", "POST"])
@@ -111,20 +111,25 @@ def settings():
if request.method == "POST":
introduction = request.form.get("introduction")
asknotes_introduction = request.form.get("asknotes_introduction")
theme = request.form.get("theme")
# Speichern der Intros
save_text_file(INTRO_FILE, introduction)
save_text_file(ASKNOTES_INTRO_FILE, asknotes_introduction)
# Speichern des ausgewählten Themes in der Session
session['theme'] = theme
return redirect(url_for("settings"))
# Laden der aktuellen Inhalte aus den Textdateien
introduction = load_text_file(INTRO_FILE)
asknotes_introduction = load_text_file(ASKNOTES_INTRO_FILE)
return render_template("settings.html", introduction=introduction, asknotes_introduction=asknotes_introduction)
return render_template("settings.html", introduction=introduction, asknotes_introduction=asknotes_introduction, theme=session.get('theme', 'light'))
return redirect(url_for("login"))
@app.route("/users")
def users():
"""Zeigt eine Liste aller Benutzer aus der Datenbank an."""

View File

@@ -0,0 +1,8 @@
body {
background-color: #343a40;
color: #ffffff;
}
.navbar, .card {
background-color: #495057;
}

View File

@@ -0,0 +1,8 @@
body {
background-color: #ffffff;
color: #000000;
}
.navbar, .card {
background-color: #f8f9fa;
}

View File

@@ -3,6 +3,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="{{ url_for('static', filename='css/theme-' + theme + '.css') }}" rel="stylesheet">
<title>Admin Panel</title>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
</head>

View File

@@ -4,6 +4,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="{{ url_for('static', filename='css/theme-' + theme + '.css') }}" rel="stylesheet">
<title>Login</title>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
</head>

View File

@@ -3,6 +3,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="{{ url_for('static', filename='css/theme-' + theme + '.css') }}" rel="stylesheet">
<title>Settings</title>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
</head>
@@ -20,6 +21,13 @@
<label for="asknotes_introduction">Asknotes Introduction Text</label>
<textarea id="asknotes_introduction" name="asknotes_introduction" class="form-control" rows="5">{{ asknotes_introduction }}</textarea>
</div>
<div class="form-group">
<label for="theme">Select Theme</label>
<select id="theme" name="theme" class="form-control">
<option value="light" {% if theme == 'light' %}selected{% endif %}>Light Theme</option>
<option value="dark" {% if theme == 'dark' %}selected{% endif %}>Dark Theme</option>
</select>
</div>
<button type="submit" class="btn btn-primary btn-block">Save Settings</button>
</form>
<a href="{{ url_for('index') }}" class="btn btn-secondary btn-block mt-3">Back to Dashboard</a>