From 656466b176e1a2f228d5274fa8ff6c65193ceb0c Mon Sep 17 00:00:00 2001 From: AB Date: Tue, 24 Nov 2026 03:15:58 +0200 Subject: [PATCH] Filter playlists, group artist tracks and improve playback and cache controls --- CHANGELOG.md | 17 + Cargo.lock | 2 +- Cargo.toml | 2 +- src/i18n/phrases.rs | 33 +- src/player/artist_tests.rs | 23 + src/player/mod.rs | 56 +- src/player/offline-catalog.js | 107 ++- src/podcasts/tests.rs | 14 +- templates/player.html | 2 + templates/player/account_actions.html | 13 +- .../player/artist_popular_track_row.html | 50 ++ templates/player/artist_popular_tracks.html | 31 + templates/player/collection_scripts.html | 6 +- templates/player/collection_styles.html | 10 + templates/player/modals.html | 34 +- templates/player/offline_cache_manager.html | 162 ++++ templates/player/offline_cache_styles.css | 127 +++ templates/player/offline_manager_scripts.html | 161 ++++ templates/player/offline_scripts.html | 32 +- templates/player/offline_settings.html | 21 +- templates/player/offline_styles.css | 23 +- templates/player/pin_undo.html | 7 +- templates/player/playlist_filter_scripts.html | 89 ++ templates/player/playlist_filter_styles.css | 57 ++ templates/player/playlist_track_row.html | 89 ++ templates/player/scripts.html | 68 +- templates/player/search_group_scripts.html | 210 +++-- templates/player/shell.html | 295 ++----- templates/player/sidebar_styles.html | 1 + templates/player/styles.html | 797 ++++-------------- templates/player/track_version_toggle.html | 7 + tests/browser-offline-catalog.cjs | 44 +- tests/browser-offline-player.cjs | 5 +- tests/browser-player-layout.cjs | 122 ++- tests/browser-playlist-filter.cjs | 165 ++++ tests/browser-playlist-header.cjs | 14 +- tests/browser-search-groups.cjs | 79 +- tests/browser-sidebar.cjs | 48 +- tests/offline-cache-manager.cjs | 174 ++++ tests/playlist_filter.test.cjs | 54 ++ tests/search_groups.test.cjs | 35 +- 41 files changed, 2156 insertions(+), 1130 deletions(-) create mode 100644 templates/player/artist_popular_track_row.html create mode 100644 templates/player/artist_popular_tracks.html create mode 100644 templates/player/offline_cache_manager.html create mode 100644 templates/player/offline_cache_styles.css create mode 100644 templates/player/offline_manager_scripts.html create mode 100644 templates/player/playlist_filter_scripts.html create mode 100644 templates/player/playlist_filter_styles.css create mode 100644 templates/player/playlist_track_row.html create mode 100644 templates/player/track_version_toggle.html create mode 100644 tests/browser-playlist-filter.cjs create mode 100644 tests/offline-cache-manager.cjs create mode 100644 tests/playlist_filter.test.cjs diff --git a/CHANGELOG.md b/CHANGELOG.md index 977b9ea..e4e5314 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,23 @@ - Desktop/mobile lyrics view following playback, individual track previews, availability icons, and local version editing in the admin track editor. +## v0.16.1 — 2026-11-24 + +- Artist pages show five distinct popular titles at first. Matching titles are + grouped regardless of capitalization, with each recording available from its + branch button. A slim control below the list quickly expands or collapses + the top 50 and respects reduced-motion settings. +- The bottom player uses a shorter, responsive grid for playback, seeking and + track actions on desktop and mobile. +- Saved music in account settings opens a searchable, sortable, paginated cache + manager. It shows download and last-played dates, play counts, audio details + and sizes. Cleanup by date previews the number of recordings and the space + that removing them would free, including shared audio and artwork. +- The account menu shows cache usage against the configured limit and stays + open when interacting with its controls. Unpin notifications can be dismissed early. +- Playlists and Liked songs have an in-list search by track title or artist. + Matching rows animate into place and retain their original playback and edit positions. + ## v0.16.0 — 2026-11-24 - Added opt-in offline listening to the web player. Starting a music track saves diff --git a/Cargo.lock b/Cargo.lock index 8cfd6ec..e12d157 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2062,7 +2062,7 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "furumusic" -version = "0.16.0" +version = "0.16.1" dependencies = [ "anyhow", "async-stream", diff --git a/Cargo.toml b/Cargo.toml index b003258..4ba49c4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "furumusic" -version = "0.16.0" +version = "0.16.1" edition = "2024" description = "Reusable web-app boilerplate: auth, OIDC/SSO, admin panel, user management, i18n, PostgreSQL" diff --git a/src/i18n/phrases.rs b/src/i18n/phrases.rs index db30550..5af1206 100644 --- a/src/i18n/phrases.rs +++ b/src/i18n/phrases.rs @@ -303,6 +303,30 @@ translations! { player_offline_used: "Audio and artwork" , "Аудио и обложки"; player_offline_limit: "Cache limit" , "Лимит кеша"; player_offline_saved: "Saved music" , "Сохранённая музыка"; + player_offline_open_cache: "Open cache" , "Открыть кеш"; + player_offline_back_settings: "Back to settings" , "Назад к настройкам"; + player_offline_cache_search: "Search titles and artists" , "Поиск по трекам и артистам"; + player_offline_sort: "Sort by" , "Сортировка"; + player_offline_download_date: "Download date" , "Дата загрузки"; + player_offline_last_played: "Last played" , "Последнее прослушивание"; + player_offline_play_count: "Plays" , "Прослушивания"; + player_offline_bitrate: "Bitrate" , "Битрейт"; + player_offline_ascending: "Ascending order" , "По возрастанию"; + player_offline_descending: "Descending order" , "По убыванию"; + player_offline_manage_storage: "Manage storage" , "Освободить место"; + player_offline_cleanup_scope: "Date filters apply to all saved music, including tracks outside the search results." , "Очистка по дате охватывает все сохранённые треки, включая те, которые не попали в результаты поиска."; + player_offline_remove_by: "Removal criterion" , "Критерий удаления"; + player_offline_downloaded_before: "Downloaded before" , "Загружены до"; + player_offline_played_before: "Last played before" , "Последнее прослушивание до"; + player_offline_never_cleanup: "For tracks with no plays, the download date is used." , "Для треков без прослушиваний используется дата загрузки."; + player_offline_cutoff: "Cutoff date" , "Дата отсечения"; + player_offline_preview_removal: "Preview removal" , "Проверить перед удалением"; + player_offline_will_free: "Space to free" , "Освободится"; + player_offline_remove_confirm: "Remove saved music?" , "Удалить сохранённую музыку?"; + player_offline_saved_all: "All saved tracks on this device" , "Все сохранённые треки на этом устройстве"; + player_offline_pages: "Saved music pages" , "Страницы сохранённой музыки"; + player_offline_previous_page: "Previous page" , "Предыдущая страница"; + player_offline_next_page: "Next page" , "Следующая страница"; player_offline_empty: "No music saved on this device yet." , "На этом устройстве пока нет сохранённой музыки."; player_offline_empty_uploads: "None of your uploads are saved on this device." , "На этом устройстве пока нет треков из ваших загрузок."; player_offline_empty_followed: "No music by your followed artists is saved on this device." , "На этом устройстве пока нет музыки артистов, на которых вы подписаны."; @@ -310,8 +334,6 @@ translations! { player_offline_page_missing: "This page is unavailable offline." , "Эта страница недоступна в офлайн-режиме."; player_offline_open_catalog: "Open saved catalog" , "Открыть сохранённый каталог"; player_offline_clear: "Clear cache" , "Очистить кеш"; - player_offline_show_more: "Show more tracks" , "Показать ещё треки"; - player_offline_confirm_clear: "Remove all saved music from this device?" , "Удалить всю сохранённую музыку с этого устройства?"; player_offline_remove: "Remove from this device" , "Удалить с устройства"; player_offline_save: "Save for offline listening" , "Сохранить для офлайна"; player_offline_available: "Saved on this device" , "Сохранено на устройстве"; @@ -348,6 +370,9 @@ translations! { player_likes_playlist: "Liked songs" , "Мне нравится"; player_listened: "listened" , "прослушано"; player_search_placeholder: "Search artists, releases, tracks, podcasts..." , "Поиск артистов, релизов, треков, подкастов..."; + player_playlist_search: "Search this playlist" , "Поиск по плейлисту"; + player_clear_playlist_search: "Clear playlist search" , "Очистить поиск по плейлисту"; + player_playlist_no_matches: "No matching tracks" , "Подходящих треков нет"; player_search_similar_to: "Search similar to:" , "Поиск похожих на:"; player_find_similar: "Find similar tracks" , "Найти похожие треки"; player_similarity_failed: "Similarity search failed" , "Не удалось найти похожие треки"; @@ -446,6 +471,10 @@ translations! { player_queue_empty: "Queue is empty" , "Очередь пуста"; player_shuffle: "Shuffle" , "Перемешать"; player_repeat: "Repeat" , "Повтор"; + player_pause: "Pause" , "Пауза"; + player_seek: "Playback position" , "Позиция воспроизведения"; + player_mute: "Mute" , "Выключить звук"; + player_unmute: "Unmute" , "Включить звук"; player_volume: "Volume" , "Громкость"; player_appears_on: "Appears on" , "Участвует в"; player_top_tracks: "Popular tracks" , "Популярные треки"; diff --git a/src/player/artist_tests.rs b/src/player/artist_tests.rs index 9fd2fbd..3b08def 100644 --- a/src/player/artist_tests.rs +++ b/src/player/artist_tests.rs @@ -8,6 +8,13 @@ async fn artist_credits_include_visible_features_and_count_each_track_once() -> .max_connections(1) .connect(&std::env::var("FURU_ARTIST_TEST_DATABASE_URL")?) .await?; + let schema = format!("artist_{}", uuid::Uuid::new_v4().simple()); + sqlx::raw_sql(&format!( + "BEGIN; CREATE SCHEMA {schema}; SET LOCAL search_path TO {schema}, public; + CREATE COLLATION furumusic_unicode (provider=icu, locale='und', deterministic=true);" + )) + .execute(&pool) + .await?; sqlx::raw_sql( r#" CREATE TEMP TABLE furumusic__artist ( @@ -82,5 +89,21 @@ async fn artist_credits_include_visible_features_and_count_each_track_once() -> let cards = helpers::artist_cards(&pool, rows.into(), "medium").await?; assert_eq!((cards[0].release_count, cards[0].track_count), (0, 1)); assert_eq!((cards[1].release_count, cards[1].track_count), (1, 3)); + + // Rank titles by their best recording, retaining every version even below the 50-title cutoff. + sqlx::raw_sql( + r#"UPDATE furumusic__track SET title = 'За дверью' WHERE id = 20; + INSERT INTO furumusic__track (id,title,release_id,lastfm_rating,lastfm_playcount) VALUES + (100,'ЗА ДВЕРЬЮ',10,90,100), (101,' за Дверью ',10,90,120); + INSERT INTO furumusic__track (id,title,release_id,lastfm_rating) + SELECT id, 'Song ' || id, 10, 10 FROM generate_series(1000,1049) id;"#, + ) + .execute(&pool) + .await?; + let popular = load_artist_detail(&pool, 2).await?.unwrap().top_tracks; + let ids: Vec<_> = popular.iter().map(|track| track.id).collect(); + let expected: Vec<_> = [101, 100, 20].into_iter().chain(1000..1049).collect(); + assert_eq!(ids, expected); + sqlx::query("ROLLBACK").execute(&pool).await?; Ok(()) } diff --git a/src/player/mod.rs b/src/player/mod.rs index a525fc6..5f3806d 100644 --- a/src/player/mod.rs +++ b/src/player/mod.rs @@ -4087,28 +4087,18 @@ async fn load_artist_detail( let featured_tracks = build_track_items(featured_rows, pool).await?; let top_tracks = sqlx::query_as::<_, PlaylistTrackRow>( - r#"SELECT * FROM ( - SELECT DISTINCT ON (lower(t.title::text)) - NULL::bigint AS playlist_track_id, - t.id, t.title::text as title, t.track_number, t.disc_number, - t.duration_seconds, t.cover_file_id, - r.cover_file_id as release_cover_file_id, - r.id as release_id, - r.title::text as release_title, - r.year as release_year, - COALESCE(mf.uploader_name, 'UFO')::text AS uploader_name, - mf.audio_format, - mf.audio_bitrate, - mf.audio_sample_rate, - mf.audio_bit_depth, - mf.file_size_bytes, - t.lastfm_listeners, - t.lastfm_playcount, - t.lastfm_rating, - t.lastfm_updated_at + r#"WITH ranked AS ( + SELECT t.id, + lower(trim(regexp_replace(normalize(t.title::text, NFKC) COLLATE furumusic_unicode, + '[[:space:]]+', ' ', 'g'))) AS title_key, + row_number() OVER ( + ORDER BY COALESCE(t.lastfm_rating, 0) DESC, + COALESCE(t.lastfm_playcount, 0) DESC, + COALESCE(t.lastfm_listeners, 0) DESC, + r.year DESC NULLS LAST, t.track_number NULLS LAST, t.id + ) AS rank FROM furumusic__track t JOIN furumusic__release r ON r.id = t.release_id - LEFT JOIN furumusic__media_file mf ON mf.id = t.audio_file_id WHERE t.is_hidden = false AND r.is_hidden = false AND t.id IN ( @@ -4119,15 +4109,23 @@ async fn load_artist_detail( JOIN furumusic__track rt ON rt.release_id = ra.release_id WHERE ra.artist_id = $1 ) - ORDER BY lower(t.title::text), COALESCE(t.lastfm_rating, 0) DESC - ) deduped - ORDER BY COALESCE(lastfm_rating, 0) DESC, - COALESCE(lastfm_playcount, 0) DESC, - COALESCE(lastfm_listeners, 0) DESC, - release_year DESC NULLS LAST, - track_number NULLS LAST, - id - LIMIT 50"#, + ), top_titles AS ( + SELECT title_key, min(rank) AS first_rank + FROM ranked GROUP BY title_key ORDER BY first_rank LIMIT 50 + ) + SELECT NULL::bigint AS playlist_track_id, + t.id, t.title::text AS title, t.track_number, t.disc_number, + t.duration_seconds, t.cover_file_id, r.cover_file_id AS release_cover_file_id, + r.id AS release_id, r.title::text AS release_title, r.year AS release_year, + COALESCE(mf.uploader_name, 'UFO')::text AS uploader_name, + mf.audio_format, mf.audio_bitrate, mf.audio_sample_rate, mf.audio_bit_depth, mf.file_size_bytes, + t.lastfm_listeners, t.lastfm_playcount, t.lastfm_rating, t.lastfm_updated_at + FROM top_titles + JOIN ranked USING (title_key) + JOIN furumusic__track t ON t.id = ranked.id + JOIN furumusic__release r ON r.id = t.release_id + LEFT JOIN furumusic__media_file mf ON mf.id = t.audio_file_id + ORDER BY top_titles.first_rank, ranked.rank"#, ) .bind(artist_id) .fetch_all(pool) diff --git a/src/player/offline-catalog.js b/src/player/offline-catalog.js index 2e7d5e8..949c5d9 100644 --- a/src/player/offline-catalog.js +++ b/src/player/offline-catalog.js @@ -53,6 +53,8 @@ return {id, content_id:t.content_id, title:t.title, artists, featured_artists:featured, release_id:releaseId, release_title:releaseTitle, release_year:year, track_number:t.track_number ?? null, disc_number:t.disc_number ?? null, duration_seconds:t.duration_seconds || 0, cover_url:coverKey(t.cover_url), + audio_format:t.audio_format ?? metadata.audio_format, audio_bitrate:t.audio_bitrate ?? metadata.audio_bitrate, + audio_sample_rate:t.audio_sample_rate ?? metadata.audio_sample_rate, audio_bit_depth:t.audio_bit_depth ?? metadata.audio_bit_depth, uploader_name:'Federation', offline_remote:true, has_lyrics:false, stream_url:BASE + 'stream/' + id, offline_release:{artists:releaseArtists,release_type:key.release_type || ''}}; } @@ -175,9 +177,15 @@ return {tracks, bytes:bytes || 0}; } async list() { - const [rows, plays] = await Promise.all([this.all('tracks'), this.all('plays')]); + const tx = (await this.db()).transaction(['tracks','plays','files']); + const files = tx.objectStore('files'); + const [rows, plays, fileKeys, fileInfo] = await Promise.all([ + requests(tx.objectStore('tracks').getAll()), requests(tx.objectStore('plays').getAll()), + requests(files.getAllKeys()), requests(files.getAll()), + ]); + const mime = new Map(fileKeys.map((key,i) => [key, fileInfo[i].mime])); const counts = new Map(plays.map(p => [p.id, p])); - return rows.map(r => ({...r.track, bytes:r.bytes, downloaded_at:r.downloaded_at, + return rows.map(r => ({...r.track, bytes:r.bytes, audio_mime:mime.get(r.file), downloaded_at:r.downloaded_at, last_played_at:counts.get(r.id)?.last_played_at || null, play_count:counts.get(r.id)?.play_count || 0})); } async has(value) { @@ -406,16 +414,93 @@ if (!activeNames.has(name)) await dir.removeEntry(name); } } - async remove(trackId) { - const id = OfflineCatalog.trackId(trackId); - if (!id) return; - await navigator.locks.request(this.name, async () => { - await this.write(['tracks','plays','pending','lyrics','meta'], get => { - get('tracks').delete(id); get('plays').delete(id); get('pending').delete(id); get('lyrics').delete(id); - get('meta').put(crypto.randomUUID(),'revision'); - }); - await this.prune(await this.directory()); + previewCleanup(criteria = {}) { + return this._cleanup(criteria, null); + } + removeMany(ids, criteria = {}) { + if (!Array.isArray(ids)) throw new TypeError('Expected selected track IDs'); + const selected = new Set(ids.map(trackId).filter(Boolean)); + return navigator.locks.request(this.name, () => this._cleanup(criteria, selected)); + } + async remove(value) { + const id = trackId(value); + if (id) await navigator.locks.request(this.name, () => this._cleanup({}, new Set([id]), true)); + } + async _cleanup(criteria, selected, cancelUnstored = false) { + for (const [field, cutoff] of Object.entries(criteria)) { + if (!['downloadedBefore','lastPlayedBefore'].includes(field) || !Number.isFinite(cutoff)) + throw new TypeError('Invalid offline cleanup cutoff'); + } + const deleting = selected !== null; + const db = await this.db(); + const tx = db.transaction(deleting ? stores : ['tracks','plays','files','assets'], deleting ? 'readwrite' : 'readonly'); + const get = name => tx.objectStore(name); + const finished = new Promise((resolve,reject) => { + tx.oncomplete = resolve; + tx.onabort = () => reject(tx.error || new DOMException('Cleanup aborted','AbortError')); }); + let ids, bytes, discardedFiles; + try { + const [rows, activity, used] = await Promise.all([ + requests(get('tracks').getAll()), requests(get('plays').getAll()), + deleting ? requests(get('meta').get('bytes')) : 0, + ]); + const lastPlay = new Map(activity.map(p => [p.id, p.last_played_at])); + const retainedFiles = new Set(), retainedAssets = new Set(), retainedReleases = new Set(); + const files = new Set(), assets = new Set(), releases = new Set(); + ids = []; + for (const row of rows) { + const lastUsed = lastPlay.get(row.id) ?? row.downloaded_at; + const matches = (!deleting || selected.has(row.id)) + && (criteria.downloadedBefore === undefined || row.downloaded_at < criteria.downloadedBefore) + && (criteria.lastPlayedBefore === undefined || lastUsed < criteria.lastPlayedBefore); + if (matches) ids.push(row.id); + (matches ? files : retainedFiles).add(row.file); + (matches ? releases : retainedReleases).add(row.track.release_id); + for (const key of row.assets) (matches ? assets : retainedAssets).add(key); + } + const fileKeys = [...files].filter(key => !retainedFiles.has(key)); + const assetKeys = [...assets].filter(key => !retainedAssets.has(key)); + // OPFS holds the audio. These reads access file descriptors and Blob sizes only. + const [fileInfo, artwork] = await Promise.all([ + Promise.all(fileKeys.map(key => requests(get('files').get(key)))), + Promise.all(assetKeys.map(key => requests(get('assets').get(key)))), + ]); + discardedFiles = fileInfo.filter(Boolean); + bytes = discardedFiles.reduce((n,f) => n + f.bytes, 0) + artwork.reduce((n,a) => n + (a?.size || 0), 0); + if (deleting) { + // Reading plays and checking cutoffs in this same write transaction protects a newly played track. + for (const id of cancelUnstored ? selected : ids) { + for (const name of ['tracks','plays','pending','lyrics']) get(name).delete(id); + } + for (const key of fileKeys) get('files').delete(key); + for (const key of assetKeys) get('assets').delete(key); + for (const id of releases) if (!retainedReleases.has(id)) get('meta').delete('release/'+id); + if (ids.length) { + get('meta').put(Math.max(0,(used || 0) - bytes),'bytes'); + get('meta').put(crypto.randomUUID(),'revision'); + } + } + await finished; + } catch (error) { + try { tx.abort(); } catch { /* already completed or aborted */ } + await finished.catch(() => {}); + throw error; + } + // Commit the index first so an interrupted removal can only leave an unreferenced file. + if (deleting && discardedFiles.length) { + try { + const dir = await this.directory(); + for (const file of discardedFiles) { + try { await dir.removeEntry(file.name); } + catch (error) { if (error.name !== 'NotFoundError') throw error; } + } + } catch (error) { + this._reconciled = false; + throw error; + } + } + return {ids, count:ids.length, bytes}; } async clear() { await navigator.locks.request(this.name, async () => { diff --git a/src/podcasts/tests.rs b/src/podcasts/tests.rs index cb01fcc..e5eac31 100644 --- a/src/podcasts/tests.rs +++ b/src/podcasts/tests.rs @@ -18,7 +18,7 @@ fn episode_routes_accept_encoded_colons_and_reject_invalid_ids() { #[test] fn renders_podcast_navigation_and_views() { - let html = crate::player::PlayerPageTemplate { + let player = crate::player::PlayerPageTemplate { t: crate::i18n::Translations::for_lang(crate::i18n::Lang::En), guest: false, account_id: 1, @@ -26,9 +26,8 @@ fn renders_podcast_navigation_and_views() { downloads_enabled: true, torrent_downloads_enabled: true, youtube_downloads_enabled: true, - } - .render() - .unwrap(); + }; + let html = player.render().unwrap(); assert_eq!( html.matches("href=\"#podcasts\" class=\"podcast-nav\"").count(), 2 @@ -41,6 +40,13 @@ fn renders_podcast_navigation_and_views() { ); if std::env::var_os("FURU_PODCAST_RENDER_FIXTURE").is_some() { std::fs::write("target/podcast-player-fixture.html", html).unwrap(); + let shared = crate::player::PlayerPageTemplate { + guest: true, + account_id: 0, + share_token: "playlist-filter-test".into(), + ..player + }; + std::fs::write("target/shared-player-fixture.html", shared.render().unwrap()).unwrap(); } } diff --git a/templates/player.html b/templates/player.html index e05f0a2..2baf732 100644 --- a/templates/player.html +++ b/templates/player.html @@ -30,6 +30,7 @@ if ('serviceWorker' in navigator) { {% include "player/modals.html" %} {% include "player/lyrics_modal.html" %} {% include "player/offline_scripts.html" %} +{% include "player/offline_manager_scripts.html" %} {% include "player/podcast_scripts.html" %} {% include "player/lyrics_scripts.html" %} {% include "player/lyrics_search_scripts.html" %} @@ -38,6 +39,7 @@ if ('serviceWorker' in navigator) { {% include "player/listening_scripts.html" %} {% include "player/track_actions_scripts.html" %} {% include "player/playlist_header_scripts.html" %} +{% include "player/playlist_filter_scripts.html" %} {% include "player/scripts.html" %} {% endblock body %} diff --git a/templates/player/account_actions.html b/templates/player/account_actions.html index 43c5dc4..8d10ace 100644 --- a/templates/player/account_actions.html +++ b/templates/player/account_actions.html @@ -3,25 +3,26 @@
- +
+ {% endif %} -
- + - +

{{ t.player_offline_empty }}

- - diff --git a/templates/player/offline_styles.css b/templates/player/offline_styles.css index fa11ff7..e43161d 100644 --- a/templates/player/offline_styles.css +++ b/templates/player/offline_styles.css @@ -1,16 +1,20 @@ html:not(.offline-active) [data-offline-only], html.offline-active [data-online-only], .offline-active :is(.device-popover,.user-settings-devices) > :not([data-offline-only]) {display:none !important} .offline-account {padding:8px 8px 9px; border-bottom:1px solid var(--border-color); margin-bottom:3px} +.offline-account-meter {display:block; width:100%; height:3px; margin:7px 0 3px; appearance:none; border:0; border-radius:4px; overflow:hidden; color:var(--accent); background:var(--bg-active)} +.offline-account-meter::-webkit-progress-bar {background:var(--bg-active)} +.offline-account-meter::-webkit-progress-value {background:var(--accent); border-radius:4px} +.offline-account-meter::-moz-progress-bar {background:var(--accent); border-radius:4px} .offline-account-summary,.offline-limit-label,.offline-saved-summary {display:flex; justify-content:space-between; align-items:center; gap:8px} -.offline-account-summary > div,.offline-saved-summary > div,.offline-saved-list li > div {min-width:0} +.offline-account-summary > div,.offline-saved-summary > div {min-width:0} .offline-account strong,.offline-saved-summary strong {display:block; font-size:13px; font-weight:600; line-height:1.3} -.offline-account small,.offline-saved small,.offline-track-size {display:block; color:var(--text-subdued); font-size:12px; font-variant-numeric:tabular-nums} -.offline-manage,.offline-switch-row,.offline-saved-list button {border:0; border-radius:6px; color:var(--text-secondary); background:transparent; font:inherit; cursor:pointer} +.offline-account small,.offline-saved small {display:block; color:var(--text-subdued); font-size:12px; font-variant-numeric:tabular-nums} +.offline-manage,.offline-switch-row {border:0; border-radius:6px; color:var(--text-secondary); background:transparent; font:inherit; cursor:pointer} .offline-manage {flex:none; padding:6px; font-size:12px; text-decoration:underline; text-underline-offset:3px} -.offline-manage:is(:hover,:focus-visible),.offline-saved-list button:is(:hover,:focus-visible) {background:var(--bg-active); color:var(--text-primary)} +.offline-manage:is(:hover,:focus-visible) {background:var(--bg-active); color:var(--text-primary)} .offline-switch-row {display:flex; align-items:center; justify-content:space-between; gap:8px; min-height:30px; padding:0; text-align:left} .offline-account .offline-switch-row {width:100%; margin-top:3px; font-size:12px} -.offline-switch-row:focus-visible,.offline-manage:focus-visible,.offline-saved-list button:focus-visible,.offline-scale input:focus-visible {outline:2px solid var(--accent); outline-offset:2px} +.offline-switch-row:focus-visible,.offline-manage:focus-visible,.offline-scale input:focus-visible {outline:2px solid var(--accent); outline-offset:2px} .offline-switch-row:disabled,.offline-saved button:disabled {opacity:.5; cursor:default} .offline-switch {position:relative; display:block; flex:none; width:32px; height:18px; border-radius:99px; background:var(--bg-active); border:1px solid var(--text-subdued)} .offline-switch::before {content:""; position:absolute; top:2px; left:2px; width:12px; height:12px; border-radius:50%; background:var(--text-secondary); transition:transform .12s} @@ -33,17 +37,12 @@ html:not(.offline-active) [data-offline-only], html.offline-active [data-online- .offline-scale-marks span:last-of-type {transform:translateX(-100%)} .offline-scale input {display:block; width:100%; height:20px; margin:0; accent-color:var(--accent)} .offline-saved {margin-top:16px} -.offline-saved-list {list-style:none; margin:8px 0 0; padding:0; max-height:min(28dvh,220px); overflow:auto; overscroll-behavior:contain; scrollbar-width:thin} -.offline-saved-list li {display:grid; grid-template-columns:minmax(0,1fr) auto auto; align-items:center; gap:8px; min-height:40px; border-top:1px solid var(--border-color)} -.offline-saved-list strong,.offline-saved-list small {display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap} -.offline-saved-list strong {font-size:13px; font-weight:500} -.offline-saved-list button {display:grid; place-items:center; width:36px; height:36px} -.offline-saved-list svg,.offline-topbar-state svg {width:17px; height:17px; flex:none} +.offline-topbar-state svg {width:17px; height:17px; flex:none} .offline-settings .offline-error {color:var(--error, #edadaa)} .offline-topbar-state {display:inline-flex; align-items:center; gap:5px; flex:none; color:var(--text-secondary); font-size:12px; font-weight:600} .offline-devices-note {padding:9px; color:var(--text-secondary); font-size:13px} @media(max-width:600px) { - .offline-account .offline-switch-row,.offline-manage,.offline-saved-list button {min-height:40px} + .offline-account .offline-switch-row,.offline-manage {min-height:40px} .offline-topbar-state span {position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%)} } @media(max-width:360px) { diff --git a/templates/player/pin_undo.html b/templates/player/pin_undo.html index 004d93b..9ed96f2 100644 --- a/templates/player/pin_undo.html +++ b/templates/player/pin_undo.html @@ -1,8 +1,13 @@
diff --git a/templates/player/playlist_filter_scripts.html b/templates/player/playlist_filter_scripts.html new file mode 100644 index 0000000..0bb4559 --- /dev/null +++ b/templates/player/playlist_filter_scripts.html @@ -0,0 +1,89 @@ + diff --git a/templates/player/playlist_filter_styles.css b/templates/player/playlist_filter_styles.css new file mode 100644 index 0000000..3dcb373 --- /dev/null +++ b/templates/player/playlist_filter_styles.css @@ -0,0 +1,57 @@ +.playlist-search-toolbar { + display: flex; + align-items: center; + justify-content: flex-end; + gap: 10px; + margin: 0 0 8px; +} +.playlist-match-count { font-size: 12px; color: var(--text-secondary); font-variant-numeric: tabular-nums; } +.playlist-search-field { + width: min(100%, 228px); + min-width: 0; + position: relative; + border: 1px solid var(--border-color); + border-radius: 7px; + background: var(--bg-elevated); + color: var(--text-secondary); +} +.playlist-search-field:focus-within { border-color: var(--accent); } +.playlist-search-field input { + box-sizing: border-box; width: 100%; min-width: 0; height: 32px; + border: 0; border-radius: inherit; background: transparent; + padding: 0 32px; color: var(--text-primary); outline: none; + font: inherit; font-size: 13px; +} +.playlist-search-field input:placeholder-shown { padding-right: 9px; } +.playlist-search-field input::-webkit-search-cancel-button { display: none; } +.playlist-search-field svg { + width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.6; + stroke-linecap: round; stroke-linejoin: round; +} +.playlist-search-field > svg { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); pointer-events: none; } +.playlist-search-clear { + position: absolute; inset: 0 0 0 auto; width: 32px; padding: 0; + display: grid; place-items: center; border: 0; border-radius: 6px; + color: var(--text-secondary); background: transparent; cursor: pointer; +} +.playlist-search-clear:is(:hover, :focus-visible) { color: var(--text-primary); background: var(--bg-active); } +.playlist-search-clear:focus-visible, .playlist-filter-row .track-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; } +.playlist-filter-row { + display: grid; grid-template-rows: 1fr; opacity: 1; + transition: grid-template-rows 145ms ease-out, opacity 120ms ease-out; +} +.playlist-filter-row.is-leaving { grid-template-rows: 0fr; opacity: 0; pointer-events: none; } +@starting-style { + .playlist-filter-row.is-entering { grid-template-rows: 0fr; opacity: 0; } +} +.playlist-filter-clip { min-height: 0; overflow: hidden; } +.playlist-search-empty { padding: 16px; color: var(--text-secondary); font-size: 13px; text-align: center; } +@media (max-width: 600px) { + .playlist-search-toolbar { gap: 7px; margin-bottom: 6px; } + .playlist-search-field { width: min(68%, 208px); } + .playlist-search-field input { height: 36px; font-size: 16px; } + .playlist-search-clear { width: 36px; } +} +@media (prefers-reduced-motion: reduce) { + .playlist-filter-row { transition: none; } +} diff --git a/templates/player/playlist_track_row.html b/templates/player/playlist_track_row.html new file mode 100644 index 0000000..5e2a82e --- /dev/null +++ b/templates/player/playlist_track_row.html @@ -0,0 +1,89 @@ +
+ + + + + + + +
+ +
+
+
+ {% include "player/track_artist_links.html" %} +
+
+
+ +
+ {% include "player/track_row_badges.html" %} + + + {% include "player/track_actions_button.html" %} +
+ +
diff --git a/templates/player/scripts.html b/templates/player/scripts.html index eca6179..627b4e4 100644 --- a/templates/player/scripts.html +++ b/templates/player/scripts.html @@ -578,6 +578,9 @@ document.addEventListener('alpine:init', () => { return; } this.cleanLastfmQuery(); + document.addEventListener('click', event => { + if (this.menuOpen && !event.target.closest?.('[data-account-menu]')) this.menuOpen = false; + }, true); this.load(); this.loadLastfm(); }, @@ -1040,37 +1043,6 @@ document.addEventListener('alpine:init', () => { this.seek(Math.max(0, Math.min(max, current + delta))); }, - seekFromClick(event) { - const bar = event.currentTarget; - this._setProgressFromClientX(event.clientX, bar); - }, - - _setProgressFromClientX(clientX, bar) { - const rect = bar.getBoundingClientRect(); - const pct = rect.width > 0 ? Math.max(0, Math.min(1, (clientX - rect.left) / rect.width)) : 0; - if (this.duration > 0) { - this.seek(pct * this.duration); - } - }, - - startProgressDrag(event) { - const bar = event.currentTarget; - this._setProgressFromClientX(event.clientX, bar); - bar.setPointerCapture?.(event.pointerId); - - const move = (e) => { - this._setProgressFromClientX(e.clientX, bar); - }; - const stop = () => { - window.removeEventListener('pointermove', move); - window.removeEventListener('pointerup', stop); - window.removeEventListener('pointercancel', stop); - }; - window.addEventListener('pointermove', move); - window.addEventListener('pointerup', stop); - window.addEventListener('pointercancel', stop); - }, - next() { if (this._shouldSendRemote()) { this._sendRemote('next', { @@ -1154,34 +1126,6 @@ document.addEventListener('alpine:init', () => { return Math.pow(pct, this._volumeCurve); }, - _setVolumeFromClientX(clientX, bar) { - const rect = bar.getBoundingClientRect(); - const pct = rect.width > 0 ? (clientX - rect.left) / rect.width : 0; - this.setVolume(this._volumeFromSliderPosition(pct)); - }, - - setVolumeFromClick(event) { - this._setVolumeFromClientX(event.clientX, event.currentTarget); - }, - - startVolumeDrag(event) { - const bar = event.currentTarget; - this._setVolumeFromClientX(event.clientX, bar); - bar.setPointerCapture?.(event.pointerId); - - const move = (e) => { - this._setVolumeFromClientX(e.clientX, bar); - }; - const stop = () => { - window.removeEventListener('pointermove', move); - window.removeEventListener('pointerup', stop); - window.removeEventListener('pointercancel', stop); - }; - window.addEventListener('pointermove', move); - window.addEventListener('pointerup', stop); - window.addEventListener('pointercancel', stop); - }, - toggleMute() { if (this.volume > 0) { this._prevVolume = this.volume; @@ -4648,10 +4592,8 @@ document.addEventListener('alpine:init', () => { playSearchTrack(idx) { const tracks = this.displaySearchResults.tracks; - const visible = Alpine.store('searchGroups').rows(tracks, 'search') - .filter(row => !row._searchGroupHidden); - const position = visible.findIndex(row => row._searchSourceIndex === idx); - if (position >= 0) Alpine.store('queue').playRelease(visible.map(row => tracks[row._searchSourceIndex]), position); + const groups = Alpine.store('searchGroups'); + groups.playRows(groups.rows(tracks, 'search'), tracks, idx); }, _setupScroll() { diff --git a/templates/player/search_group_scripts.html b/templates/player/search_group_scripts.html index e60f023..f3a0443 100644 --- a/templates/player/search_group_scripts.html +++ b/templates/player/search_group_scripts.html @@ -1,85 +1,145 @@ diff --git a/templates/player/shell.html b/templates/player/shell.html index bdc619b..3e34a23 100644 --- a/templates/player/shell.html +++ b/templates/player/shell.html @@ -10,9 +10,7 @@ {% if !guest %}