diff --git a/app.py b/app.py index 7a51455..c775f64 100644 --- a/app.py +++ b/app.py @@ -87,10 +87,16 @@ def index(): return render_template("index.html") -@app.route("/chat/") -def chat(room): - return render_template("chat.html", room=room) +@app.route("/chat/") +def chat(room_name): + # Query all rooms so that newest is first. + rooms = Room.query.order_by(Room.id.desc()).all() + # Get username from query parameters + username = request.args.get("username", "guest") + + # Pass username and rooms into the template + return render_template("chat.html", room_name=room_name, rooms=rooms, username=username) @socketio.on("join") def on_join(data): diff --git a/templates/chat.html b/templates/chat.html index 300373d..353a6e1 100644 --- a/templates/chat.html +++ b/templates/chat.html @@ -71,9 +71,53 @@ margin-bottom: 8px; } + .main-container { + display: grid; + grid-template-columns: 20% 80%; /* Adjust the 20% as needed */ + width: 100%; + height: 90vh; + } + + #rooms-list { + border-right: 1px solid #e1e1e1; + overflow-y: auto; + } + + +#rooms-list ul { + list-style: none; /* Removes default list styling */ + padding: 0; /* Resets default padding */ + margin: 0; /* Resets default margin */ +} + +#rooms-list li { + margin-bottom: 10px; /* Adds space between items */ + padding: 5px; /* Adds padding inside each item */ + border: 1px solid #e1e1e1; /* Adds a border around each item */ + border-radius: 5px; /* Optional: Rounds the corners of the border */ +} + +#rooms-list a { + text-decoration: none; /* Optional: Removes underline from links */ + color: inherit; /* Optional: Ensures link color matches the text color */ +} + +
+
+ +
+
@@ -81,13 +125,15 @@
+
+