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)
This commit is contained in:
parent
b54af08eeb
commit
d39b155df3
|
|
@ -577,11 +577,22 @@
|
||||||
(define-page profile-content #@"/profile-content" ()
|
(define-page profile-content #@"/profile-content" ()
|
||||||
"User profile content (displayed in content frame)"
|
"User profile content (displayed in content frame)"
|
||||||
(require-authentication)
|
(require-authentication)
|
||||||
|
(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
|
(clip:process-to-string
|
||||||
(load-template "profile-content")
|
(load-template "profile-content")
|
||||||
:title "🎧 admin - Profile | Asteroid Radio"
|
:title (format nil "🎧 ~a - Profile | Asteroid Radio" username)
|
||||||
:username "admin"
|
:username username
|
||||||
:user-role "admin"
|
:user-role user-role
|
||||||
:join-date "Unknown"
|
:join-date "Unknown"
|
||||||
:last-active "Unknown"
|
:last-active "Unknown"
|
||||||
:total-listen-time "0h 0m"
|
:total-listen-time "0h 0m"
|
||||||
|
|
@ -605,7 +616,14 @@
|
||||||
:top-artist-2 ""
|
:top-artist-2 ""
|
||||||
:top-artist-2-plays ""
|
:top-artist-2-plays ""
|
||||||
:top-artist-3 ""
|
:top-artist-3 ""
|
||||||
:top-artist-3-plays ""))
|
: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 "<html><body><h1>Error loading profile</h1><pre>~a</pre></body></html>" e))))
|
||||||
|
|
||||||
;; Status content frame (for frameset mode)
|
;; Status content frame (for frameset mode)
|
||||||
(define-page status-content #@"/status-content" ()
|
(define-page status-content #@"/status-content" ()
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,33 @@
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<link rel="stylesheet" type="text/css" href="/asteroid/static/asteroid.css">
|
<link rel="stylesheet" type="text/css" href="/asteroid/static/asteroid.css">
|
||||||
<script src="/asteroid/static/js/auth-ui.js"></script>
|
<script src="/asteroid/static/js/auth-ui.js"></script>
|
||||||
<script src="/asteroid/static/js/player.js"></script>
|
|
||||||
<script src="/api/asteroid/spectrum-analyzer.js"></script>
|
<script src="/api/asteroid/spectrum-analyzer.js"></script>
|
||||||
|
<script>
|
||||||
|
// Simple Now Playing updater
|
||||||
|
function updateNowPlaying() {
|
||||||
|
fetch('/api/asteroid/partial/now-playing')
|
||||||
|
.then(response => {
|
||||||
|
const contentType = response.headers.get('content-type');
|
||||||
|
if (contentType && contentType.includes('text/html')) {
|
||||||
|
return response.text();
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
})
|
||||||
|
.then(data => {
|
||||||
|
const nowPlayingDiv = document.getElementById('now-playing');
|
||||||
|
if (nowPlayingDiv) {
|
||||||
|
nowPlayingDiv.innerHTML = data;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(error => console.log('Could not fetch now playing:', error));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update on load and every 10 seconds
|
||||||
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
setTimeout(updateNowPlaying, 200);
|
||||||
|
setInterval(updateNowPlaying, 10000);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
<script>
|
<script>
|
||||||
// Handle logout without navigation
|
// Handle logout without navigation
|
||||||
function handleLogout() {
|
function handleLogout() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue