import json
import logging
import os
+import random
import shutil
import sqlite3
import subprocess
@app.route("/")
def index():
- users = [row["username"] for row in query_db("select username from users order by username asc")]
+ users = query_db("select * from users order by username asc")
+ users = [dict(row) for row in users]
+ for user in users:
+ user["has_pfp"] = user_has_pfp(user["userid"])
+ user["bgcolor"] = user["bgcolor"] or BGCOLOR
+ user["fgcolor"] = user["fgcolor"] or FGCOLOR
+ user["accolor"] = user["accolor"] or ACCOLOR
+
+ titles = [
+ ("Little Song Place", 2.0),
+ ("Lumpy Space Princess", 0.2),
+ ("Language Server Protocol", 0.1),
+ ("Liskov Substitution Principle", 0.1),
+ ("Louisiana State Police", 0.1),
+ ("Local Strategic Partnership", 0.1),
+ ("Light Switch Plate", 0.1),
+ ("Lightest Supersymmetric Particle", 0.1),
+ ]
+ titles, weights = zip(*titles)
+ title = random.choices(titles, weights)[0]
+
songs = Song.get_latest(50)
- return render_template("index.html", users=users, songs=songs)
+ return render_template("index.html", users=users, songs=songs, page_title=title)
@app.get("/signup")
def signup_get():
accolor=profile_data["accolor"] or ACCOLOR,
playlists=plist_data,
songs=songs,
- user_has_pfp=(get_user_images_path(profile_userid)/"pfp.jpg").exists(),
+ user_has_pfp=user_has_pfp(profile_userid),
is_profile_song_list=True)
@app.post("/edit-profile")
return plist_data
+def user_has_pfp(userid):
+ return (get_user_images_path(userid)/"pfp.jpg").exists()
+
@app.context_processor
def inject_global_vars():
return dict(
song_tags = [t["tag"] for t in tags[sd["songid"]] if t["tag"]]
song_collabs = [c["name"] for c in collabs[sd["songid"]] if c["name"]]
created = datetime.fromisoformat(sd["created"]).astimezone().strftime("%Y-%m-%d")
- user_has_pfp = (get_user_images_path(sd["userid"])/"pfp.jpg").exists()
- songs.append(cls(sd["songid"], sd["userid"], sd["username"], sd["title"], sanitize_user_text(sd["description"]), created, song_tags, song_collabs, user_has_pfp))
+ has_pfp = user_has_pfp(sd["userid"])
+ songs.append(cls(sd["songid"], sd["userid"], sd["username"], sd["title"], sanitize_user_text(sd["description"]), created, song_tags, song_collabs, has_pfp))
return songs
@classmethod
{% extends "base.html" %}
-{% block title %}Little Song Place{% endblock %}
+{% block title %}{{ page_title }}{% endblock %}
{% block body %}
<h2>Profiles</h2>
<p>Check out the music of the fine folks below!{% if not session["userid"] %} If you create an account, you'll show up here too.{% endif %}</p>
-{% for user in users %}
-<a href="/users/{{ user }}" class="profile-link user-list-entry">{{ user }}</a>
-
-{% endfor %}
+<div class="user-list">
+ {% for user in users %}
+ <a href="/users/{{ user['username'] }}" class="user-list-entry" style="--yellow:{{ user['bgcolor'] }};--black:{{ user['fgcolor'] }};--purple:{{ user['accolor'] }};">
+ {% if user['has_pfp'] -%}
+ <img class="small-pfp" src="/pfp/{{ user['userid'] }}" />
+ {%- endif %}
+ <span>{{ user['username'] }}</span>
+ </a>
+ {% endfor %}
+</div>
<h2>Recently Uploaded Songs</h2>
<p>Listen to all the newest tunes!</p>
<h1>Site News</h1>
-<h2>2025-02-22 - Continuous Playback</h2>
+<h2>2025-02-22 - Musical Continuity</h2>
The song player now persists between pages as you navigate around the site, so
the music isn't interrupted when you go to someone's profile or comment on a
-song. It will continue playing the songs from the original page until you
-click play on a new song.
+song! It will continue playing the songs from the original page until you
+click the play button on a new song.
+<ul>
+ <li>Persistent audio player</li>
+ <li>Profile links on the home page now use profile colors</li>
+ <li>General visual cleanup for song lists</li>
+ <li>You can now click the song title in the player to go to the song page</li>
+</ul>
<h2>2025-02-16 - Playlists</h2>
<p>