diff --git a/README.md b/README.md
index be49736..34b5a45 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,9 @@
# Sonda
+**This repository has moved.** Development continues at
+[git.kmalloc.org/squid/sonda](https://git.kmalloc.org/squid/sonda); this
+Codeberg mirror is archived and read-only.
+
Sonda is a privacy-first, self-hosted music server written in Go. It streams the music you already own, from your own disks, and keeps everything it knows about you on your own machine.
It is a single executable, one database (SQLite by default, PostgreSQL if you prefer) and the folders that hold your music. There is no Redis, no message broker and no cloud account.
@@ -390,7 +394,7 @@ Back up the database and `sonda.toml`. Your music stays wherever you keep it.
## Web app
-A web client lives in `web/` (React, Vite and shadcn/ui). It talks only to the Sonda server: no CDN, no external fonts, no analytics. With the app built into the binary (`make build`, or the Docker image) `sondad` serves it: open the address of the server, for example `http://127.0.0.1:8080`, and sign in. The page carries a strict Content-Security-Policy (only resources of the server itself, no inline scripts), cannot be framed and sends no referrer, and a link inside the app (`/admin/users`) works when you reload it. The player draws a live picture of what is playing, in the browser, from the sound itself (Web Audio). Settings has a choice for it, kept on the device: a spectrogram (the last seconds, low notes at the bottom, the default), the classic bars with falling caps, an oscilloscope, Milkdrop, or nothing. The bars, the oscilloscope and the spectrogram take the colour of this server or, for a friend's song, the colour of the friend. Milkdrop fills the background of the full-screen player with the pictures Winamp made famous, drawn on the device with [butterchurn](https://github.com/jberg/butterchurn) (MIT) and its presets, which are part of the app: nothing is fetched from outside. It is loaded only when chosen, and anyone who asked the system for less motion gets the spectrogram instead, because the pictures flash. The player listens to the sound and changes nothing of it, and draws only while something plays.
+A web client lives in `web/` (React, Vite and shadcn/ui). It talks only to the Sonda server: no CDN, no external fonts, no analytics. With the app built into the binary (`make build`, or the Docker image) `sondad` serves it: open the address of the server, for example `http://127.0.0.1:8080`, and sign in. The page carries a strict Content-Security-Policy (only resources of the server itself, no inline scripts), cannot be framed and sends no referrer, and a link inside the app (`/admin/users`) works when you reload it. The player draws a live picture of what is playing, in the browser, from the sound itself (Web Audio). Settings has a choice for it, kept on the device: a spectrogram (the last seconds, low notes at the bottom, the default), the classic bars with falling caps, an oscilloscope, Milkdrop, or nothing. The bars, the oscilloscope and the spectrogram take the colour of this server or, for a friend's song, the colour of the friend. Milkdrop fills the background of the full-screen player with the pictures Winamp made famous, drawn on the device with [butterchurn](https://github.com/jberg/butterchurn) (MIT) and its presets, which are part of the app: nothing is fetched from outside. It is loaded only when chosen, and anyone who asked the system for less motion gets the spectrogram instead, because the pictures flash. The player listens to the sound and changes nothing of it, and draws only while something plays. On a phone the player is one row at the foot of the page (and is not there while nothing plays); a tap or a swipe up opens the full-screen player, a swipe down or the Back gesture closes it, and the lock screen shows the song with its seek bar and follows play and pause. The queue is kept in the browser, so a page that is reloaded, or a tab that Android throws away, comes back paused on the same song at the same second.
To work on the interface itself, run the Vite dev server next to a running `sondad` (set `SONDA_URL` to where it listens: the default is `http://127.0.0.1:8080`):
diff --git a/web/index.html b/web/index.html
index b6c7099..243714a 100644
--- a/web/index.html
+++ b/web/index.html
@@ -9,7 +9,7 @@
-
+
Sonda
diff --git a/web/src/auth/AuthGate.tsx b/web/src/auth/AuthGate.tsx
index 7f5fe51..7b24792 100644
--- a/web/src/auth/AuthGate.tsx
+++ b/web/src/auth/AuthGate.tsx
@@ -9,7 +9,7 @@ export default function AuthGate({ children }: { children: ReactNode }) {
const { t } = useTranslation()
if (status === 'loading') {
- return
+ return
}
if (status === 'anonymous') return
return <>{children}>
diff --git a/web/src/auth/LoginPage.tsx b/web/src/auth/LoginPage.tsx
index 3f225b9..1ad513e 100644
--- a/web/src/auth/LoginPage.tsx
+++ b/web/src/auth/LoginPage.tsx
@@ -31,7 +31,7 @@ export default function LoginPage() {
}
return (
-
+
diff --git a/web/src/components/Cover.test.tsx b/web/src/components/Cover.test.tsx
index 7b610e0..207f55a 100644
--- a/web/src/components/Cover.test.tsx
+++ b/web/src/components/Cover.test.tsx
@@ -16,7 +16,7 @@ function placeholder(container: HTMLElement) {
test('a cover asks for the album cover of the API', () => {
const { container } = render()
const img = container.querySelector('img')!
- expect(img.getAttribute('src')).toBe('/api/v1/albums/12/cover')
+ expect(img.getAttribute('src')).toBe('/api/v1/albums/12/cover?size=small')
expect(img).toHaveAttribute('loading', 'lazy')
expect(img).toHaveAttribute('alt', '')
expect(placeholder(container)).toBeNull()
@@ -25,9 +25,9 @@ test('a cover asks for the album cover of the API', () => {
test('the cover URL carries the access token and follows it when it changes', () => {
sessionStore.setState({ accessToken: 'tok1' })
const { container } = render()
- expect(container.querySelector('img')!.getAttribute('src')).toBe('/api/v1/albums/12/cover?access_token=tok1')
+ expect(container.querySelector('img')!.getAttribute('src')).toBe('/api/v1/albums/12/cover?size=small&access_token=tok1')
act(() => sessionStore.setState({ accessToken: 'tok2' }))
- expect(container.querySelector('img')!.getAttribute('src')).toBe('/api/v1/albums/12/cover?access_token=tok2')
+ expect(container.querySelector('img')!.getAttribute('src')).toBe('/api/v1/albums/12/cover?size=small&access_token=tok2')
})
test('a cover that fails to load is replaced by the placeholder', () => {
@@ -116,3 +116,10 @@ test('a cover that cannot be loaded falls back to the rings, and the picture hid
expect(placeholder(container)).not.toBeNull()
expect(container.querySelector('img')).toBeNull()
})
+
+test('a big cover asks for the full picture, a friend’s cover for the only one the friend has', () => {
+ const big = render()
+ expect(big.container.querySelector('img')!.getAttribute('src')).toBe('/api/v1/albums/12/cover')
+ const friend = render()
+ expect(friend.container.querySelector('img')!.getAttribute('src')).toBe('/api/v1/friends/3/albums/12/cover')
+})
diff --git a/web/src/components/Cover.tsx b/web/src/components/Cover.tsx
index 1ce7bca..92e1d1c 100644
--- a/web/src/components/Cover.tsx
+++ b/web/src/components/Cover.tsx
@@ -19,10 +19,14 @@ const RINGS = [
{ size: '68%', opacity: 0.3 },
] as const
+/** Up to this size (CSS pixels) a cover is drawn from the small picture. */
+const SMALL_UP_TO = 150
+
/** The cover of an album, or the rings of Sonda when there is none (or it cannot be loaded). */
export default function Cover({ albumId, friend, size, fluid = false }: CoverProps) {
useAccessToken() // the URL carries the token, so it has to follow a renewal
- const src = albumId === null ? null : mediaUrl(coverPath(friend, albumId))
+ // A thumbnail asks for the small picture: a phone does not need to fetch 1000 pixels to draw 56.
+ const src = albumId === null ? null : mediaUrl(coverPath(friend, albumId, size <= SMALL_UP_TO))
// A failure is remembered for this URL only: a renewed token makes a new URL, which is tried again.
const [failed, setFailed] = useState(null)
const showImage = src !== null && failed !== src
@@ -36,7 +40,16 @@ export default function Cover({ albumId, friend, size, fluid = false }: CoverPro
className="relative shrink-0 overflow-hidden rounded-sm bg-muted"
>
{showImage ? (
- setFailed(src)} />
+ window.matchMedia?.('(pointer: coarse)').matches && e.preventDefault()}
+ className="size-full object-cover"
+ onError={() => setFailed(src)}
+ />
) : (
{RINGS.map((r) => (
diff --git a/web/src/components/PageTitle.test.tsx b/web/src/components/PageTitle.test.tsx
index 2ccf523..ac8fccd 100644
--- a/web/src/components/PageTitle.test.tsx
+++ b/web/src/components/PageTitle.test.tsx
@@ -11,5 +11,5 @@ test('it is the heading of the page, the largest text on it', () => {
test('a greeting is larger still', () => {
render(Good evening)
- expect(screen.getByRole('heading', { level: 1 }).className).toContain('text-5xl')
+ expect(screen.getByRole('heading', { level: 1 }).className).toContain('text-[2.5rem]')
})
diff --git a/web/src/components/PageTitle.tsx b/web/src/components/PageTitle.tsx
index 3310f37..a1a86c9 100644
--- a/web/src/components/PageTitle.tsx
+++ b/web/src/components/PageTitle.tsx
@@ -4,7 +4,7 @@ import { cn } from '@/lib/utils'
/** The title of a page: the largest text on it. A greeting (`large`) is larger still. */
export default function PageTitle({ children, large = false, className }: { children: ReactNode; large?: boolean; className?: string }) {
return (
-
+
{children}
)
diff --git a/web/src/components/RouteLoading.tsx b/web/src/components/RouteLoading.tsx
index 39ba75c..68b6f31 100644
--- a/web/src/components/RouteLoading.tsx
+++ b/web/src/components/RouteLoading.tsx
@@ -3,5 +3,5 @@ import { useTranslation } from 'react-i18next'
/** What is on screen while the first page of a lazy route is being fetched. */
export default function RouteLoading() {
const { t } = useTranslation()
- return
+ return
}
diff --git a/web/src/components/TrackRow.tsx b/web/src/components/TrackRow.tsx
index ac5478f..9e5b0b4 100644
--- a/web/src/components/TrackRow.tsx
+++ b/web/src/components/TrackRow.tsx
@@ -29,11 +29,12 @@ export default function TrackRow({ track, index, onPlay, active = false, disable
disabled={disabled}
aria-current={active ? 'true' : undefined}
className={cn(
- 'grid min-h-13 min-w-0 flex-1 grid-cols-[2.5rem_minmax(0,1fr)_4.5rem] items-center gap-3 rounded-lg px-4 text-left',
+ 'grid min-h-13 min-w-0 flex-1 grid-cols-[minmax(0,1fr)_3rem] items-center gap-2 rounded-lg px-3 text-left sm:grid-cols-[2.5rem_minmax(0,1fr)_4.5rem] sm:gap-3 sm:px-4',
disabled && 'opacity-60',
)}
>
-
+ {/* On a phone the number goes: two buttons and the length follow the title, and it needs the room. */}
+
{track.track_no > 0 ? track.track_no : index + 1}
diff --git a/web/src/components/layout/NowPlaying.tsx b/web/src/components/layout/NowPlaying.tsx
index 99348f3..9dc7f98 100644
--- a/web/src/components/layout/NowPlaying.tsx
+++ b/web/src/components/layout/NowPlaying.tsx
@@ -16,6 +16,7 @@ import VolumeControl from '@/components/VolumeControl'
import { Button } from '@/components/ui/button'
import { Dialog, DialogContent, DialogDescription, DialogTitle } from '@/components/ui/dialog'
import { formatTime } from '@/lib/time'
+import { useSwipe } from '@/lib/useSwipe'
import { albumHref, artistHref, type QueuedTrack } from '@/player/media'
import { useMilkdrop } from '@/player/milkdrop'
import { useVisualizerPref } from '@/player/prefs'
@@ -23,7 +24,9 @@ import { currentTrack, usePlayer } from '@/player/store'
import { useNowPlayingUi } from '@/player/ui'
import PlayerControls from './PlayerControls'
+/** How many of the next tracks a wide screen lists; a phone lists them all, up to MAX_UP_NEXT. */
const UP_NEXT = 3
+const MAX_UP_NEXT = 100
/** The big seek bar and the times. The part of this screen that follows the playback every moment. */
function NowPlayingSeek({ track }: { track: QueuedTrack }) {
@@ -69,11 +72,15 @@ export default function NowPlaying() {
if (open && !track) setOpen(false)
}, [open, track, setOpen])
- const upNext = queue.slice(index + 1, index + 1 + UP_NEXT)
+ // A swipe down from the top of the page closes the player, as the arrow does.
+ const swipe = useSwipe({ onDown: () => setOpen(false), allow: (e) => e.currentTarget.scrollTop === 0 })
+
+ const upNext = queue.slice(index + 1, index + 1 + MAX_UP_NEXT)
return (