Commit Graph

19 Commits

Author SHA1 Message Date
Glenn Thompson 68a83390c9 Use local-time:now for last-login update (database agnostic)
Replace raw PostgreSQL SQL with data-model approach using local-time:now
as suggested by easilok. This keeps the code database backend agnostic
instead of being tied to PostgreSQL-specific syntax.
2025-12-10 11:11:32 -05:00
Glenn Thompson 46d57e2775 Fix timestamp consistency across all tables
- Update USERS table schema to use TIMESTAMP instead of integer
- Add migration 003 to convert existing integer timestamps to TIMESTAMP
- Remove timestamp-to-unix calls in playlist-management.lisp (use DB default)
- Update user-management.lisp to use postmodern:execute for last-login update
- All timestamp columns now consistently use PostgreSQL TIMESTAMP type
2025-12-10 11:11:32 -05:00
Brian O'Reilly 8fd0b06b69 dump users in db to csv, and restore them from same
this is (hopefully) a write once run once utility, but we're moving
from sqlite to postgres, and I don't want to lose the users that have
already signed up for the site.
2025-12-07 19:44:04 -05:00
Glenn Thompson b6be0ebab1 feat: Convert JavaScript to Parenscript with stream fixes and UX improvements
Major Changes:
- Convert all JavaScript files to Parenscript for better maintainability
- Move spectrum-analyzer to parenscript/ directory structure
- Add parenscript-utils.lisp for shared utilities
- Convert admin.js, player.js, front-page.js, auth-ui.js to Parenscript
- Convert profile.js, users.js, recently-played.js to Parenscript

Stream Reconnect Fixes (from merged PR):
- Add reset-spectrum-analyzer function to properly clean up Web Audio API
- Implement reconnect logic for pauses longer than 10 seconds
- Detect stale audio in 'playing' event and force stream reconnection
- Prevent 'Now Playing' updates while stream is paused
- Reduce reconnect delay to 200ms for faster response
- Add proper spectrum analyzer reset/reinit during reconnection

UX Improvements:
- Change live indicator from blink to smooth pulse (2s ease-in-out)
- Pulse animation like old PowerBook/MacBook sleep indicator
- Add MUTED indicator to spectrum analyzer when audio is muted
- Spectrum continues to flow even when muted (data still streaming)
- Red 'MUTED' text displayed in top-right corner of canvas

Technical Details:
- Parenscript files generate JavaScript via API endpoints
- All player modes updated: main player, front page, popout, frame player
- Improved audio context handling to only create once per element
- Added comprehensive error handling and logging
- Updated asteroid.asd to include parenscript module structure

Documentation:
- Updated all documentation dates to 2025-12-06
- Added PARENSCRIPT-EXPERIMENT.org documenting the conversion
- Updated PROJECT-HISTORY.org with Phase 9 (Visual Audio Features)
- Added comprehensive project statistics (408 commits, 9,300 LOC)

This conversion improves code maintainability by using Lisp throughout
the stack and makes it easier to share code between frontend and backend.
2025-12-06 11:55:24 -05:00
Luis Pereira ded376d971 feat: add user activate and deactivate routes 2025-11-21 18:06:49 -05:00
Luis Pereira 8245917b28 fix: add data-model-save wrapper
This tries to bypass a weird error where native "dm:save" fails with lambdalite.
2025-11-16 09:38:04 -05:00
Luis Pereira c5804641b8 fix: move user database methods to data-model 2025-11-16 09:38:04 -05:00
Glenn Thompson 8b0e494da9 fix: Replace undefined uri-path with radiance:path
The previous commit used uri-path() which doesn't exist in Radiance.
This caused 'The function ASTEROID::URI-PATH is undefined' errors
when trying to authenticate.

Changed to use radiance:path() which is the correct Radiance API
function for extracting the path component from a URI object.

Fixes authentication in both require-authentication and require-role.
2025-11-14 06:57:42 -05:00
Brian O'Reilly 11c3e1df77 slight error computing the external/internal url from the uri object. 2025-11-10 08:10:53 -05:00
glenneth 4c99ded7f0 feat: Add password management and fix listener count
- Add user password change functionality in profile page
- Add admin password reset functionality in admin dashboard
- Fix listener count to show total from Icecast root tag
- Replace concatenate with format
- Add with-error-handling to API endpoints
- Make Icecast port binding configurable via ICECAST_BIND env var
- Add comprehensive docstrings to public functions

Note: Password reset has known issue with LambdaLite db:update
not updating password-hash field. Issue reported as an issue.
2025-11-04 16:26:29 -05:00
Luis Pereira 0930fc2c1c fix: retry user initialization 2025-10-30 19:08:46 -04:00
glenneth 4b8a3a064c feat: Implement role-based page flow and user management APIs
Core Features:
- Login redirects based on user role (admin -> /admin, users -> /profile)
- User registration redirects to /profile page
- Convert user management APIs to use define-api (Radiance standard)
- Add user statistics API endpoint
- Add create user API endpoint
- Add list users API endpoint

Authentication & Authorization:
- Update require-role to return proper JSON for API requests
- Fix password verification with debug logging
- Add reset-user-password function for admin use

API Endpoints (using define-api):
- /api/asteroid/users - Get all users (admin only)
- /api/asteroid/user-stats - Get user statistics (admin only)
- /api/asteroid/users/create - Create new user (admin only)

Bug Fixes:
- Fix JavaScript API path for user-stats endpoint
- Remove dependency on non-existent radiance:api-output
- Use api-output for proper JSON responses

Testing:
- Admin login redirects to /asteroid/admin ✓
- Regular user login redirects to /asteroid/profile ✓
- User creation working (testuser created successfully) ✓
- User statistics loading correctly ✓

Known Issues (non-blocking):
- User table display needs UI fixes
- Profile page needs additional API endpoints
- Session persistence on navigation needs investigation
2025-10-12 09:47:38 -04:00
glenneth dde8027b5c WORKING: API-aware authentication returns JSON for API routes
 Solution:
- require-authentication returns T on success, api-output value on failure
- Endpoints check result: if T, execute body; else return api-output value
- api-output sets response data which gets returned to client

 Results:
- API routes return JSON errors (not HTML redirects)
- Page routes still redirect to login
- Player page handles auth errors gracefully
- Shows 'Error loading tracks' instead of crashing

 Pattern:
  (let ((auth-result (require-authentication)))
    (if (eq auth-result t)
        ;; authenticated - execute endpoint
        ...
        ;; not authenticated - return api-output value
        auth-result))

Thanks to easilokx for the guidance on Radiance patterns!
2025-10-07 18:39:49 -04:00
glenneth dff299923e Fix api-output usage: pass structured data with :status and :message
- Remove handler-case that was catching api-output's condition
- Pass alist data structure instead of JSON string
- Use :status and :message keyword arguments as per Radiance docs
- Detection and formatting work correctly
- Issue: api-output doesn't stop execution from helper function
- Need Radiance-specific pattern (redirect works, api-output doesn't)
2025-10-07 18:39:49 -04:00
glenneth 9ec7848b47 Add API-aware authentication with auto-detection (needs execution flow fix)
 Working:
- Auto-detects API requests from /api/ in URI
- Optional :api keyword parameter for explicit control
- Returns JSON for API requests, redirects for pages
- Page redirects work perfectly (admin page redirects to login)
- API detection logs show correct behavior

 Issue:
- API endpoints still execute after require-authentication returns JSON
- radiance:api-output doesn't stop execution like redirect does
- Need proper Radiance mechanism to halt request processing

Question for easilokx:
What's the correct way to stop execution and return JSON from a helper
function like require-authentication? We tried api-output but execution
continues. How does redirect actually stop execution?
2025-10-07 18:39:49 -04:00
glenneth 707e7aba96 WIP: Add API-aware authentication (detection works, need to fix execution flow)
- Add api-auth-error condition for API authentication failures
- Update require-authentication and require-role to detect /api/ routes
- Add :api keyword parameter for explicit API/page mode
- Auto-detects API requests from URI path
- Returns JSON for API requests, redirects for page requests
- Issue: Execution continues after returning JSON, need Radiance-specific solution
2025-10-07 18:39:49 -04:00
Glenn Thompson e61a5a51df Complete Docker streaming infrastructure and user management fixes
## Docker Infrastructure Improvements
- **Liquidsoap Upgrade**: Updated to latest savonet/liquidsoap:792d8bf tag
- **Port Configuration**: Resolved port conflicts, standardized on port 8000 for streaming
- **Service Integration**: Docker Icecast (8000) + Asteroid web app (8080) architecture
- **Script Updates**: Fixed docker-compose commands for legacy compatibility
- **Documentation**: Comprehensive updates to setup-complete.org with correct URLs

## User Management System Fixes
- **Database Field Handling**: Fixed list vs string format inconsistencies in RADIANCE i-lambdalite
- **Authentication Flow**: Resolved "string designator" errors in user initialization
- **Admin Creation**: Fixed default admin user detection and creation logic
- **Session Management**: Proper handling of user ID storage and retrieval

## Web Interface Improvements
- **Navigation Routes**: Fixed /player/ → /player route mismatch
- **Link Consistency**: All navigation links now match defined routes
- **Template Integration**: Proper CLIP template processing with corrected data types

## Configuration Management
- **RADIANCE Config**: Fixed r-simple-wsessions typo in startup modules
- **Domain Setup**: Added "asteroid" domain to RADIANCE configuration
- **Service Dependencies**: Proper module loading order and error handling

## System Integration
- **Dual-Port Architecture**: Streaming (8000) + Web Interface (8080) separation
- **Service Status**: Integration points for Docker service monitoring
- **Audio Pipeline**: Liquidsoap → Icecast → Web Player workflow established

## Testing & Validation
- **Stream Verification**: Confirmed http://localhost:8000/asteroid.mp3 streaming
- **Web Access**: Validated http://localhost:8080/asteroid/ interface
- **User Authentication**: Tested login/logout and admin panel access
- **Database Operations**: Verified track metadata and user management

This commit establishes a fully functional internet radio streaming platform
with containerized audio services and integrated web management interface.
2025-10-02 16:50:06 +03:00
Glenn Thompson b1a61fae00 Fix user management API authentication and data formatting
- Fixed find-user-by-id to handle BIT type database IDs
- Updated user-has-role-p to extract role from list format
- Enhanced API endpoint to return properly formatted JSON data
- Added comprehensive debugging for authentication flow
- Created login.chtml template with CLIP data binding
- Resolved 'Error loading users' issue in admin panel
2025-09-30 14:11:46 -04:00
Glenn Thompson 84d0bc4ce4 Fix Asteroid Radio authentication system
- Fix database query syntax for RADIANCE hash table returns
- Handle RADIANCE field storage format (lists instead of strings)
- Configure r-simple-sessions module for session management
- Update login page styling to match main site theme
- Implement working authentication with admin/asteroid123
- Add proper error handling and debug logging
- Ensure session persistence and redirects work correctly
2025-09-30 14:11:46 -04:00