Add section images, larger covers and track tags
Section images:
- A section gets an optional image, set from its new "Modifier" dialog
(name and image), which replaces "Renommer". It goes through the same
conversion as track covers and is deleted with its section.
- Track and section uploads share routes/coverUpload.js. The cover
folder is created again if it went missing, instead of failing.
Larger images: 72 px for tracks (was 48), 96 px for section headers,
160 px in the player and the edit dialog (was 96); smaller on phones.
Tags:
- Library tracks take free tags, edited in the "Modifier" dialog, which
suggests the tags already in use. Case is ignored ("Épique" and
"épique" are one tag); at most 15 tags of 30 characters.
- A tag bar above the library filters it, and the "Tout ajouter"
buttons (global and per section) then only queue its tracks
(enqueue-all takes a tag). The search also matches tags.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
793765fb79
commit
bda95ca946
13 changed files with 601 additions and 165 deletions
42
src/features/tags.js
Normal file
42
src/features/tags.js
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
/**
|
||||
* @file Étiquettes des morceaux de la bibliothèque : nettoyage de la liste envoyée par la page et
|
||||
* comparaison sans tenir compte des majuscules.
|
||||
*
|
||||
* Utilisé par : web/routes/library.js (modification d'un morceau, ajout à la file par étiquette).
|
||||
* Attention : la virgule sépare les étiquettes dans la page ; elle est donc retirée d'une étiquette.
|
||||
* « Calme » et « calme » sont la même étiquette : la première écriture reçue est gardée.
|
||||
*/
|
||||
|
||||
const MAX_TAGS = 15;
|
||||
const MAX_TAG_LENGTH = 30;
|
||||
|
||||
// Clé de comparaison d'une étiquette.
|
||||
function tagKey(tag) {
|
||||
return String(tag).toLocaleLowerCase("fr");
|
||||
}
|
||||
|
||||
// Liste d'étiquettes propre (sans doublon, ni vide, ni caractère de contrôle), ou null si
|
||||
// `value` n'est pas un tableau.
|
||||
function cleanTags(value) {
|
||||
if (!Array.isArray(value)) return null;
|
||||
const tags = new Map();
|
||||
for (const raw of value) {
|
||||
const tag = String(raw ?? "")
|
||||
.replace(/[\u0000-\u001f,]/g, " ")
|
||||
.replace(/\s+/g, " ")
|
||||
.trim()
|
||||
.slice(0, MAX_TAG_LENGTH)
|
||||
.trim();
|
||||
if (tag && !tags.has(tagKey(tag))) {
|
||||
tags.set(tagKey(tag), tag);
|
||||
}
|
||||
}
|
||||
return [...tags.values()].slice(0, MAX_TAGS);
|
||||
}
|
||||
|
||||
function hasTag(entry, tag) {
|
||||
const key = tagKey(tag);
|
||||
return (entry.tags ?? []).some((item) => tagKey(item) === key);
|
||||
}
|
||||
|
||||
export { cleanTags, hasTag };
|
||||
Loading…
Add table
Add a link
Reference in a new issue