feat(albums): show formatted editorial descriptions

This commit is contained in:
zarzet committed 2026-09-26 03:50:37 +07:00
1 parent 0e1881d837
commit 7d7716cd6f
13 files changed
+465 -25

No files matched your search

@@ -64,6 +64,11 @@ impl Backend {
],
);
info.insert("audio_traits".into(), value["audio_traits"].clone());
for key in ["editorial_notes", "description"] {
if let Some(notes) = value.get(key) {
info.insert(key.into(), notes.clone());
}
}
info.insert(
"total_tracks".into(),
json!(value["total_tracks"].as_i64().unwrap_or_default()),
@@ -386,6 +391,11 @@ fn album(value: &Value, full: bool) -> Value {
&["artist_id", "header_image", "header_video"],
));
result.insert("audio_traits".into(), json!(array(value, "audio_traits")));
for key in ["editorial_notes", "description"] {
if let Some(notes) = value.get(key) {
result.insert(key.into(), notes.clone());
}
}
}
result.into()
}
@@ -12,6 +12,8 @@ function collection(id) {
const count = Number(id);
return {id, name: "Album 音楽 🎵", artists: "Artist Café", provider_id: "supplied",
cover_url: "https://example.invalid/cover.jpg", total_tracks: count,
editorialNotes: {standard: "<p>A <i>new</i> direction &amp; sound.</p>", short: "A new direction."},
description: "Collection notes",
tracks: Array.from({length: count}, (_, i) => ({id: "track-" + i,
name: "歌 🎵 " + i, artists: "Artist Café", album_name: "Album 音楽 🎵",
provider_id: "supplied-track", duration_ms: 123456, track_number: i + 1,
@@ -24,7 +26,10 @@ function getArtist(id) {
url: "https://example.invalid/events/1", detailId: "event-1"}],
headerLogo: "https://example.invalid/logo.png", albumsNext: "artist-page-2", albums: []};
}
function handleUrl() { return {type: "artist", artist: getArtist("artist-1")}; }
function handleUrl(url) {
if (url.includes("/album/")) return {type: "album", album: collection("1"), tracks: collection("1").tracks};
return {type: "artist", artist: getArtist("artist-1")};
}
function getConcert(id) {
return {id, artistName: "Example Artist", title: "Example Show", venue: "Example Hall",
address: "123 Example Street", startAt: "2026-10-07T01:00:00Z",
@@ -86,6 +91,31 @@ fn concert_details_preserve_generic_actions_and_set_list() {
assert_eq!(detail["attribution"], "Example Events");
}
#[test]
fn album_editorial_notes_survive_metadata_and_url_routes() {
let (_root, backend) = fixture();
let direct: Value = serde_json::from_str(
&backend
.get_provider_metadata_json(ID, "album", "1", &|| Ok(()))
.unwrap(),
)
.unwrap();
let linked: Value = serde_json::from_str(
&backend
.handle_url_json("https://example.invalid/album/1")
.unwrap(),
)
.unwrap();
for album in [&direct["album_info"], &linked["album"]] {
assert_eq!(
album["editorial_notes"]["standard"],
"<p>A <i>new</i> direction &amp; sound.</p>"
);
assert_eq!(album["editorial_notes"]["short"], "A new direction.");
assert_eq!(album["description"], "Collection notes");
}
}
#[test]
fn response_envelopes_preserve_json_and_cancellation() {
let value = json!({
@@ -160,7 +160,8 @@
["cover_url","s","coverUrl","images"],["header_image","s","headerImage"],
["header_video","s","headerVideo"],["release_date","s","releaseDate"],
["total_tracks","i","totalTracks"],["album_type","s","albumType"],
["audio_traits","a","audioTraits"],["provider_id","s","providerId"]
["audio_traits","a","audioTraits"],["provider_id","s","providerId"],
["editorial_notes","M","editorialNotes"],["description","s"]
], ["id","name","artists","total_tracks","provider_id"]);
result.tracks = tracks;
if (!trim(result.artists)) {