]> littlesong.place Git - littlesongplace.git/commitdiff
Add initial song player implementation
authorChris Fulljames <christianfulljames@gmail.com>
Sat, 11 Jan 2025 17:11:51 +0000 (12:11 -0500)
committerChris Fulljames <christianfulljames@gmail.com>
Sat, 11 Jan 2025 17:11:51 +0000 (12:11 -0500)
main.py
templates/base.html
templates/song-list.html
todo.txt

diff --git a/main.py b/main.py
index 6d78647a9a3b6450cc92a6cc4c9253bd053dc7d6..6643997cb5d1c087ae34889f0a4ffa94337bb5ad 100644 (file)
--- a/main.py
+++ b/main.py
@@ -257,7 +257,7 @@ def update_song():
     file = request.files["song"]
     title = request.form["title"]
     description = request.form["description"]
-    tags = [t.strip() for t in request.form["tags"].split(",")]
+    tags = [t.strip().lower() for t in request.form["tags"].split(",")]
     collaborators = [c.strip() for c in request.form["collabs"].split(",")]
 
     # Make sure song exists and the logged-in user owns it
index b3e144356a42a9d5f566f365d9e7dcd8d9201d67..753a8e8694f09a9363f5ed21d5cd3f9af3c2d3b6 100644 (file)
@@ -2,8 +2,11 @@
 <html>
     <head>
         <title>{% block title %} Base {% endblock %}</title>
+        <link rel="stylesheet" href="/static/styles.css">
+        <script src="/static/player.js"></script>
     </head>
     <body>
+        <!-- Navbar -->
         <div class="navbar">
             {% if "username" in session %}
             <p>Signed in as {{ session["username"] }}</p>
@@ -17,6 +20,7 @@
             <a href="/">Home</a>
         </div>
 
+        <!-- Stite Status Messages -->
         {% with messages = get_flashed_messages(with_categories=True) %}
         {% if messages %}
         <ul class="flashes">
         {% endif %}
         {% endwith %}
 
+        <!-- Page-Specific Content -->
         {% block body %}
         {% endblock %}
+
+        <!-- Song Player -->
+        <div class="player">
+            <a href="javascript:songPrevious()" class="player-button">&lt;&lt;</a>
+            <a href="javascript:songPlayPause()" class="player-button">&gt;</a>
+            <a href="javascript:songNext()" class="player-button">&gt;&gt;</a>
+            <div class="player-position">
+                <span id="player-position-bar"></span>
+                <span id="player-position-dot"></span>
+            </div>
+            <span class="player-time" id="player-current-time">0:00</span>
+            <span class="player-time-sep">/</span>
+            <span class="player-time" id="player-total-time">0:00</span>
+            <audio id="player-audio"></audio>
+            <!-- TODO: Show song title, artist -->
+            <!-- TODO: Volume control -->
+        </div>
     </body>
 </html>
 
index 5e4e98866b9ada5adaeedbb359c8f16be79cb6d7..c27f46c17812b0c2be8e58c0cf1a4fd240cc0910 100644 (file)
@@ -1,7 +1,7 @@
 {% for song in songs %}
 <div class="song">
     <!-- Song Title -->
-    <div class="song-title"><h3>{{ song.title }}</h3></div>
+    <div class="song-title">{{ song.title }}</div>
 
     <!-- Owner-Specific Buttons (Edit/Delete) -->
     {% if session["userid"] == song.userid %}
     {% endif %}
 
     <!-- Play Button -->
-    <audio src="/song/{{ song.userid }}/{{ song.songid }}" controls></audio>
+    <!-- <audio src="/song/{{ song.userid }}/{{ song.songid }}" controls></audio> -->
+    <div class="song-play-button">
+        <a href="javascript:play({{ song.userid }}, {{ song.songid }})">Play</a>
+    </div>
 
     <!-- Song Description -->
     <div class="song-description">{{ song.description }}</div>
index 4b3f033447425846efc81c6909f00f2969493a0d..6777e4444109013d037f143fd6742f75a4e9dc1b 100644 (file)
--- a/todo.txt
+++ b/todo.txt
@@ -1,10 +1,10 @@
-- delete user account
-- sort songs by upload timestamp
-
 - automated tests
 
-- javascript song player
+- javascript song player:
+    - scrubbing
+    - song queue
 
+- song search
 - admin account(s)
 - logging