Make the jukebox the home page, add seeking and redesign the site
Seeking: the progress bar is now a slider. Releasing it calls POST /api/player/seek, which restarts ffmpeg at that position and swaps the audio resource without going through Idle, so the track is neither finished nor requeued in loop mode. Structure: the jukebox is served at / and the old home page is gone. /jukebox/ redirects to / with its query string, and the Discord login callback now returns to /. Redesign: a login screen until the visitor is signed in, then an app layout with a top bar, the library on the left and the player and queue on the right (sticky, two columns from 1000 px). Small screens get a mini player while the main one is out of view. Icon buttons, a single play/pause button, a drop zone for uploads, toast messages and a refined violet palette with checked contrast. A refused password now returns to the login screen instead of leaving an empty page. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
d14cc414b5
commit
25f22dd363
13 changed files with 1615 additions and 1051 deletions
|
|
@ -99,7 +99,7 @@ test("a guild member logs in with Discord and uses the jukebox API", async () =>
|
|||
await withApp(async (base) => {
|
||||
const callback = await login(base, "member");
|
||||
assert.equal(callback.status, 303);
|
||||
assert.equal(callback.headers.get("location"), "/jukebox/");
|
||||
assert.equal(callback.headers.get("location"), "/");
|
||||
const session = cookieValue(callback, "palico_session");
|
||||
assert.ok(session);
|
||||
|
||||
|
|
@ -114,7 +114,7 @@ test("a guild member logs in with Discord and uses the jukebox API", async () =>
|
|||
test("someone outside the guild is turned away", async () => {
|
||||
await withApp(async (base) => {
|
||||
const callback = await login(base, "stranger");
|
||||
assert.equal(callback.headers.get("location"), "/jukebox/?login=not-member");
|
||||
assert.equal(callback.headers.get("location"), "/?login=not-member");
|
||||
assert.equal(cookieValue(callback, "palico_session"), null);
|
||||
});
|
||||
});
|
||||
|
|
@ -125,7 +125,7 @@ test("a callback without the matching state is refused", async () => {
|
|||
redirect: "manual",
|
||||
headers: { cookie: "palico_oauth_state=other" },
|
||||
});
|
||||
assert.equal(callback.headers.get("location"), "/jukebox/?login=state");
|
||||
assert.equal(callback.headers.get("location"), "/?login=state");
|
||||
assert.equal(calls.length, 0);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* @file Couvre la file du jukebox sans Discord : lecture, reconnexion, départ et retour du bot dans le
|
||||
* salon, reprise d'un morceau interrompu à sa position, mode boucle, mélange et reprise après
|
||||
* un redémarrage.
|
||||
* un redémarrage, déplacement dans le morceau en cours.
|
||||
*/
|
||||
|
||||
import test from "node:test";
|
||||
|
|
@ -234,6 +234,26 @@ test("an interrupted track resumes a little before where it stopped", () => {
|
|||
queue.shutdown();
|
||||
});
|
||||
|
||||
test("seeking restarts the current track at the chosen position", () => {
|
||||
const { client } = fakeClient();
|
||||
const { queue, played } = fakeQueue(client);
|
||||
assert.equal(queue.seek(30), null);
|
||||
|
||||
queue.currentTrack = { ...track("a"), duration: 200, resumeAt: 10, startedAt: "x" };
|
||||
setPlayed(queue, 0);
|
||||
assert.equal(queue.seek(95.7).position, 95_000);
|
||||
assert.equal(queue.currentTrack.resumeAt, 95);
|
||||
assert.equal(queue.currentTrack.startedAt, "x");
|
||||
assert.deepEqual(played, ["a"]);
|
||||
|
||||
// Au-delà de la fin : juste avant la fin. Au début : sans position de reprise.
|
||||
queue.seek(500);
|
||||
assert.equal(queue.currentTrack.resumeAt, 199);
|
||||
queue.seek(0);
|
||||
assert.equal("resumeAt" in queue.currentTrack, false);
|
||||
queue.shutdown();
|
||||
});
|
||||
|
||||
test("other bots do not count as listeners", () => {
|
||||
const { client, members } = fakeClient([BOT_ID, "otherbot-1"]);
|
||||
const { queue } = fakeQueue(client);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
/**
|
||||
* @file Couvre l'application web : route des messages privés (clé, limite, connexions locales),
|
||||
* /readyz et flux d'événements.
|
||||
* /readyz, ancienne adresse du jukebox, déplacement dans le morceau en cours et flux
|
||||
* d'événements.
|
||||
*/
|
||||
|
||||
import test from "node:test";
|
||||
|
|
@ -47,6 +48,8 @@ function fakeClient() {
|
|||
|
||||
const fakeQueue = {
|
||||
snapshot: () => ({ current: null, upcoming: [], status: "idle" }),
|
||||
// Aucun morceau en cours, sauf quand la position demandée vaut 42.
|
||||
seek: (seconds) => (seconds === 42 ? { position: 42_000 } : null),
|
||||
};
|
||||
|
||||
async function withServer(options, run) {
|
||||
|
|
@ -198,6 +201,35 @@ test("the events stream sends the queue state, then every update", async () => {
|
|||
}
|
||||
});
|
||||
|
||||
test("the old jukebox address redirects to the home page", async () => {
|
||||
await withServer({}, async ({ base }) => {
|
||||
const get = (path) => fetch(`${base}${path}`, { redirect: "manual" });
|
||||
const plain = await get("/jukebox/");
|
||||
assert.equal(plain.status, 301);
|
||||
assert.equal(plain.headers.get("location"), "/");
|
||||
assert.equal((await get("/jukebox?login=denied")).headers.get("location"), "/?login=denied");
|
||||
const home = await get("/");
|
||||
assert.equal(home.status, 200);
|
||||
assert.match(await home.text(), /<title>Palico Jukebox<\/title>/);
|
||||
});
|
||||
});
|
||||
|
||||
test("seeking needs a position in seconds and a track playing", async () => {
|
||||
await withServer({}, async ({ base }) => {
|
||||
const seek = (body) =>
|
||||
fetch(`${base}/api/player/seek`, {
|
||||
method: "POST",
|
||||
headers: { authorization: "Bearer web-key", "content-type": "application/json" },
|
||||
body: JSON.stringify(body),
|
||||
});
|
||||
assert.equal((await seek({ position: 42 })).status, 200);
|
||||
assert.equal((await seek({ position: 10 })).status, 409);
|
||||
assert.equal((await seek({ position: "42" })).status, 400);
|
||||
assert.equal((await seek({ position: -1 })).status, 400);
|
||||
assert.equal((await seek({})).status, 400);
|
||||
});
|
||||
});
|
||||
|
||||
test("the events stream requires the jukebox key", async () => {
|
||||
await withServer({}, async ({ base }) => {
|
||||
assert.equal((await fetch(`${base}/api/events`)).status, 401);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue