From d39b155df38c8fd0a0c6cdba2dcb7ccd1cd7d123 Mon Sep 17 00:00:00 2001 From: Glenn Thompson Date: Sun, 7 Dec 2025 10:17:44 +0300 Subject: [PATCH] Fix profile page and Now Playing in frameset mode Profile page fixes: - Use session:field with string 'user-id' instead of symbol - Use find-user-by-id to get user object - Use dm:field to access user data (username, role) - Add missing template parameters (top-artist-4, top-artist-5) - Add error handling with detailed logging Player-content fixes: - Remove broken player.js that was causing ReferenceError - Add simple inline Now Playing updater script - Fetches /api/asteroid/partial/now-playing every 10 seconds - Updates after 200ms initial delay All fixes tested and working in frameset mode: - Profile page loads correctly with user data - Now Playing panel updates on player page - Stream continues playing during navigation - Spectrum analyzer MUTED indicator working - Login/logout without halting stream Known issue: - ParenScript player.lisp has compilation issue (extra paren on line 242) - Only 15/36 functions compile - Non-frameset mode still halts stream on navigation (expected) --- asteroid.lisp | 76 ++++++++++++++++++++++-------------- template/player-content.ctml | 27 ++++++++++++- 2 files changed, 73 insertions(+), 30 deletions(-) diff --git a/asteroid.lisp b/asteroid.lisp index 33c61d8..fa5763a 100644 --- a/asteroid.lisp +++ b/asteroid.lisp @@ -577,35 +577,53 @@ (define-page profile-content #@"/profile-content" () "User profile content (displayed in content frame)" (require-authentication) - (clip:process-to-string - (load-template "profile-content") - :title "🎧 admin - Profile | Asteroid Radio" - :username "admin" - :user-role "admin" - :join-date "Unknown" - :last-active "Unknown" - :total-listen-time "0h 0m" - :tracks-played "0" - :session-count "0" - :favorite-genre "Unknown" - :recent-track-1-title "" - :recent-track-1-artist "" - :recent-track-1-duration "" - :recent-track-1-played-at "" - :recent-track-2-title "" - :recent-track-2-artist "" - :recent-track-2-duration "" - :recent-track-2-played-at "" - :recent-track-3-title "" - :recent-track-3-artist "" - :recent-track-3-duration "" - :recent-track-3-played-at "" - :top-artist-1 "" - :top-artist-1-plays "" - :top-artist-2 "" - :top-artist-2-plays "" - :top-artist-3 "" - :top-artist-3-plays "")) + (handler-case + (let* ((user-id (session:field "user-id")) + (current-user (when user-id (find-user-by-id user-id))) + (username (if current-user + (let ((uname (dm:field current-user "username"))) + (format nil "~a" (or uname "Unknown"))) + "Unknown")) + (user-role (if current-user + (let ((role (dm:field current-user "role"))) + (format nil "~a" (or role "user"))) + "user"))) + (clip:process-to-string + (load-template "profile-content") + :title (format nil "🎧 ~a - Profile | Asteroid Radio" username) + :username username + :user-role user-role + :join-date "Unknown" + :last-active "Unknown" + :total-listen-time "0h 0m" + :tracks-played "0" + :session-count "0" + :favorite-genre "Unknown" + :recent-track-1-title "" + :recent-track-1-artist "" + :recent-track-1-duration "" + :recent-track-1-played-at "" + :recent-track-2-title "" + :recent-track-2-artist "" + :recent-track-2-duration "" + :recent-track-2-played-at "" + :recent-track-3-title "" + :recent-track-3-artist "" + :recent-track-3-duration "" + :recent-track-3-played-at "" + :top-artist-1 "" + :top-artist-1-plays "" + :top-artist-2 "" + :top-artist-2-plays "" + :top-artist-3 "" + :top-artist-3-plays "" + :top-artist-4 "" + :top-artist-4-plays "" + :top-artist-5 "" + :top-artist-5-plays "")) + (error (e) + (format t "ERROR in profile-content: ~a~%" e) + (format nil "

Error loading profile

~a
" e)))) ;; Status content frame (for frameset mode) (define-page status-content #@"/status-content" () diff --git a/template/player-content.ctml b/template/player-content.ctml index 7a00bc0..425040f 100644 --- a/template/player-content.ctml +++ b/template/player-content.ctml @@ -6,8 +6,33 @@ - +