From: Chris Fulljames Date: Sun, 19 Jan 2025 02:40:22 +0000 (-0500) Subject: Home page update and minor tweaks X-Git-Url: https://littlesong.place/gitweb/gitweb.cgi?a=commitdiff_plain;h=837cbfeaf78fec5fdfdcdfcc3c2a72d2d2e0e973;p=littlesongplace.git Home page update and minor tweaks --- diff --git a/main.py b/main.py index f9d6375..5bdf722 100644 --- a/main.py +++ b/main.py @@ -45,7 +45,9 @@ app.logger.addHandler(handler) @app.route("/") def index(): users = [row["username"] for row in query_db("select username from users")] - return render_template("index.html", users=users) + songs = Song.get_latest(50) + song_list = render_template("song-list.html", songs=songs) + return render_template("index.html", users=users, song_list=song_list) @app.get("/signup") def signup_get(): @@ -529,6 +531,10 @@ class Song: def get_all_for_tag(cls, tag): return cls._from_db(f"select * from song_tags inner join songs on song_tags.songid = songs.songid inner join users on songs.userid = users.userid where (tag = ?)", [tag]) + @classmethod + def get_latest(cls, count): + return cls._from_db("select * from songs inner join users on songs.userid = users.userid order by songs.created desc limit ?", [count]) + @classmethod def _from_db(cls, query, args=()): songs_data = query_db(query, args) diff --git a/templates/base.html b/templates/base.html index ac7708b..0a99afc 100644 --- a/templates/base.html +++ b/templates/base.html @@ -1,7 +1,7 @@ - {% block title %} Base {% endblock %} + {% block title %}{% endblock %} diff --git a/templates/index.html b/templates/index.html index 2e802c7..7800dbd 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,14 +1,37 @@ {% extends "base.html" %} +{% block title %}Little Song Place{% endblock %} + {% block body %} +

A Brief Introduction

+

Hello, and welcome!

-

Check out the music of the fine folks below! If you create an account, you'll show up here too. :)

+

+I created this website because I wanted a little place where a few friends can +share songs with each other. There are lots of big places for this +already of course, but they all feel too cold and impersonal to me. I figure +maybe some of you also feel the same way, so I made this little song place just +for us. +

+ +

+At present it's very basic - you can listen to the newest songs here on the +home page, or go to someone's profile to listen to all of their music. There +are no likes, comments, followers, or play counts. Maybe someday there will +be, or maybe we'll discover we don't need them. I'm open to any thoughts or +feedback you might have! Just send me (cfull) a message on Discord. :) +

-

Lovely Humans:

+

Check out the music of the fine folks below! If you create an account, you'll show up here too.

+ +

Profiles

{% for user in users %} {{ user }}
{% endfor %} +

Recently Uploaded Songs

+{{ song_list|safe }} + {% endblock %} diff --git a/templates/login.html b/templates/login.html index 40d095e..a44e65b 100644 --- a/templates/login.html +++ b/templates/login.html @@ -1,6 +1,6 @@ {% extends "base.html" %} -{% block title %}Login{% endblock %} +{% block title %}Sign In{% endblock %} {% block body %} diff --git a/templates/profile.html b/templates/profile.html index f605ff6..9662de4 100644 --- a/templates/profile.html +++ b/templates/profile.html @@ -1,6 +1,6 @@ {% extends "base.html" %} -{% block title %}{{ name }}'s Profile{% endblock %} +{% block title %}{{ name }}'s profile{% endblock %} {% block body %}