From 212c5fe9972dad3c53826c0364376a98b6c5a3c3 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sun, 26 Feb 2023 17:43:15 -0400 Subject: new 'Sheet Music Files' & 'MIDI Project Files' fields --- src/page/album.js | 53 ++++++++++++++++++++++++++++++--------- src/page/track.js | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 115 insertions(+), 12 deletions(-) (limited to 'src/page') diff --git a/src/page/album.js b/src/page/album.js index 897e5110..f4578ace 100644 --- a/src/page/album.js +++ b/src/page/album.js @@ -50,6 +50,8 @@ export function write(album, {wikiData}) { }; const hasAdditionalFiles = !empty(album.additionalFiles); + const numAdditionalFiles = album.additionalFiles.flatMap((g) => g.files).length; + const albumDuration = getTotalDuration(album.tracks); const displayTrackSections = @@ -336,18 +338,22 @@ export function write(album, {wikiData}) { ]), ...html.fragment( - hasAdditionalFiles && - generateAdditionalFilesList(album.additionalFiles, { - // TODO: Kinda near the metal here... - getFileSize: (file) => - getSizeOfAdditionalFile( - urls.from('media.root').to( - 'media.albumAdditionalFile', - album.directory, - file)), - linkFile: (file) => - link.albumAdditionalFile({album, file}), - })), + hasAdditionalFiles && [ + html.tag('p', + {id: 'additional-files', class: ['content-heading']}, + language.$('releaseInfo.additionalFiles.heading', { + additionalFiles: language.countAdditionalFiles(numAdditionalFiles, { + unit: true, + }), + })), + + generateAlbumAdditionalFilesList(album, album.additionalFiles, { + generateAdditionalFilesList, + getSizeOfAdditionalFile, + link, + urls, + }), + ]), ...html.fragment( album.commentary && [ @@ -834,3 +840,26 @@ export function generateAlbumChronologyLinks(album, currentTrack, { })), ]); } + +export function generateAlbumAdditionalFilesList(album, additionalFiles, { + fileSize = true, + + generateAdditionalFilesList, + getSizeOfAdditionalFile, + link, + urls, +}) { + return generateAdditionalFilesList(additionalFiles, { + getFileSize: + (fileSize + ? (file) => + // TODO: Kinda near the metal here... + getSizeOfAdditionalFile( + urls + .from('media.root') + .to('media.albumAdditionalFile', album.directory, file)) + : () => null), + linkFile: (file) => + link.albumAdditionalFile({album, file}), + }); +} diff --git a/src/page/track.js b/src/page/track.js index caba3668..b9038bac 100644 --- a/src/page/track.js +++ b/src/page/track.js @@ -5,6 +5,7 @@ import { generateAlbumNavLinks, generateAlbumSecondaryNav, generateAlbumSidebar, + generateAlbumAdditionalFilesList as unbound_generateAlbumAdditionalFilesList, } from './album.js'; import { @@ -73,6 +74,11 @@ export function write(track, {wikiData}) { const hasCommentary = track.commentary || otherReleases.some((t) => t.commentary); + const hasAdditionalFiles = !empty(track.additionalFiles); + const hasSheetMusicFiles = !empty(track.sheetMusicFiles); + const hasMidiProjectFiles = !empty(track.midiProjectFiles); + const numAdditionalFiles = album.additionalFiles.flatMap((g) => g.files).length; + const generateCommentary = ({language, link, transformMultiline}) => transformMultiline([ track.commentary, @@ -161,12 +167,15 @@ export function write(track, {wikiData}) { page: ({ absoluteTo, fancifyURL, + generateAdditionalFilesList, + generateAdditionalFilesShortcut, generateChronologyLinks, generateNavigationLinks, generateTrackListDividedByGroups, getAlbumStylesheet, getArtistString, getLinkThemeString, + getSizeOfAdditionalFile, getThemeString, getTrackCover, html, @@ -184,6 +193,14 @@ export function write(track, {wikiData}) { link, }); + const generateAlbumAdditionalFilesList = bindOpts(unbound_generateAlbumAdditionalFilesList, { + [bindOpts.bindIndex]: 2, + generateAdditionalFilesList, + getSizeOfAdditionalFile, + link, + urls, + }); + return { title: language.$('trackPage.title', {track: track.name}), stylesheet: getAlbumStylesheet(album, {to}), @@ -273,6 +290,30 @@ export function write(track, {wikiData}) { }), ]), + html.tag('p', + { + [html.onlyIfContent]: true, + [html.joinChildren]: '
', + }, + [ + hasSheetMusicFiles && + language.$('releaseInfo.sheetMusicFiles.shortcut', { + link: html.tag('a', + {href: '#sheet-music-files'}, + language.$('releaseInfo.sheetMusicFiles.shortcut.link')), + }), + + hasMidiProjectFiles && + language.$('releaseInfo.midiProjectFiles.shortcut', { + link: html.tag('a', + {href: '#midi-project-files'}, + language.$('releaseInfo.midiProjectFiles.shortcut.link')), + }), + + hasAdditionalFiles && + generateAdditionalFilesShortcut(track.additionalFiles), + ]), + html.tag('p', (empty(track.urls) ? language.$('releaseInfo.listenOn.noLinks') @@ -377,6 +418,39 @@ export function write(track, {wikiData}) { html.tag('blockquote', transformLyrics(track.lyrics)), ]), + ...html.fragment( + hasSheetMusicFiles && [ + html.tag('p', + {id: 'sheet-music-files', class: ['content-heading']}, + language.$('releaseInfo.sheetMusicFiles.heading')), + + generateAlbumAdditionalFilesList(album, track.sheetMusicFiles, { + fileSize: false, + }), + ]), + + ...html.fragment( + hasMidiProjectFiles && [ + html.tag('p', + {id: 'midi-project-files', class: ['content-heading']}, + language.$('releaseInfo.midiProjectFiles.heading')), + + generateAlbumAdditionalFilesList(album, track.midiProjectFiles), + ]), + + ...html.fragment( + hasAdditionalFiles && [ + html.tag('p', + {id: 'additional-files', class: ['content-heading']}, + language.$('releaseInfo.additionalFiles.heading', { + additionalFiles: language.countAdditionalFiles(numAdditionalFiles, { + unit: true, + }), + })), + + generateAlbumAdditionalFilesList(album, track.additionalFiles), + ]), + ...html.fragment( hasCommentary && [ html.tag('p', {class: ['content-heading']}, -- cgit 1.3.0-6-gf8a5