From 589273c5e1d63e5f68ecedd68c9d4b49c36b25f4 Mon Sep 17 00:00:00 2001
From: "(quasar) nebula" ${language.$('releaseInfo.additionalFiles.heading', {fileCount})}
+ ${additionalFiles.map(({ title, description, files }) => fixWS`
+
+ `;
+}
+
// Artist strings
export function getArtistString(artists, {
diff --git a/src/page/album.js b/src/page/album.js
index 5ea7c5a0..8df8a678 100644
--- a/src/page/album.js
+++ b/src/page/album.js
@@ -53,7 +53,8 @@ export function write(album, {wikiData}) {
}`;
};
- const commentaryEntries = [album, ...album.tracks].filter(x => x.commentary).length;
+ const hasCommentaryEntries = ([album, ...album.tracks].filter(x => x.commentary).length > 0);
+ const hasAdditionalFiles = (album.additionalFiles?.length > 0);
const albumDuration = getTotalDuration(album.tracks);
const listTag = getAlbumListTag(album);
@@ -100,6 +101,8 @@ export function write(album, {wikiData}) {
path: ['album', album.directory],
page: ({
fancifyURL,
+ generateAdditionalFilesShortcut,
+ generateAdditionalFilesList,
generateChronologyLinks,
generateCoverLink,
getAlbumCover,
@@ -181,12 +184,15 @@ export function write(album, {wikiData}) {
})
].filter(Boolean).join('
+ ${files.map(file => `
\n')}
${ - language.$('releaseInfo.viewCommentary', { - link: link.albumCommentary(album, { - text: language.$('releaseInfo.viewCommentary.link') + ${(hasAdditionalFiles || hasCommentaryEntries) && fixWS`
+ ${[
+ hasAdditionalFiles && generateAdditionalFilesShortcut(album.additionalFiles, {language}),
+ hasCommentaryEntries && language.$('releaseInfo.viewCommentary', {
+ link: link.albumCommentary(album, {
+ text: language.$('releaseInfo.viewCommentary.link')
+ })
})
- })
+ ].filter(Boolean).join('
\n')
}
${ language.$('releaseInfo.listenOn', { @@ -212,6 +218,9 @@ export function write(album, {wikiData}) { ${album.tracks.map(trackToListItem).join('\n')} ${listTag}> `} + ${hasAdditionalFiles && generateAdditionalFilesList(album.additionalFiles, { + linkFile: file => link.albumAdditionalFile({album, file}) + })} ${album.dateAddedToWiki && fixWS`
${[ diff --git a/src/strings-default.json b/src/strings-default.json index 1c5fbc68..78de7a89 100644 --- a/src/strings-default.json +++ b/src/strings-default.json @@ -98,6 +98,12 @@ "releaseInfo.artistCommentary": "Artist commentary:", "releaseInfo.artistCommentary.seeOriginalRelease": "See {ORIGINAL}!", "releaseInfo.artTags": "Tags:", + "releaseInfo.additionalFiles.shortcut": "{ANCHOR_LINK} {TITLES}", + "releaseInfo.additionalFiles.shortcut.anchorLink": "Additional files:", + "releaseInfo.additionalFiles.heading": "Has {FILE_COUNT} additional files:", + "releaseInfo.additionalFiles.entry": "{TITLE}", + "releaseInfo.additionalFiles.entry.withDescription": "{TITLE}: {DESCRIPTION}", + "releaseInfo.additionalFiles.file": "{FILE} ({SIZE})", "releaseInfo.note": "Note:", "trackList.group": "{GROUP} ({DURATION}):", "trackList.item.withDuration": "({DURATION}) {TRACK}", diff --git a/src/upd8.js b/src/upd8.js index bca6a0d0..b55ddda9 100755 --- a/src/upd8.js +++ b/src/upd8.js @@ -85,6 +85,8 @@ import { import { fancifyFlashURL, fancifyURL, + generateAdditionalFilesShortcut, + generateAdditionalFilesList, generateChronologyLinks, generateCoverLink, generateInfoGalleryLinks, @@ -1944,6 +1946,14 @@ async function main() { to }); + bound.generateAdditionalFilesShortcut = bindOpts(generateAdditionalFilesShortcut, { + language + }); + + bound.generateAdditionalFilesList = bindOpts(generateAdditionalFilesList, { + language + }); + bound.generateChronologyLinks = bindOpts(generateChronologyLinks, { link: bound.link, linkAnythingMan: bound.linkAnythingMan, diff --git a/src/url-spec.js b/src/url-spec.js index b9366b0d..c1ed1eba 100644 --- a/src/url-spec.js +++ b/src/url-spec.js @@ -76,6 +76,7 @@ const urlSpec = { trackCover: 'album-art/<>/<>.<>', artistAvatar: 'artist-avatar/<>.<>', flashArt: 'flash-art/<>.<>', + albumAdditionalFile: 'album-additional/<>/<>', } } }; diff --git a/src/util/link.js b/src/util/link.js index 4e611df5..68539621 100644 --- a/src/util/link.js +++ b/src/util/link.js @@ -94,6 +94,19 @@ const link = { tag: linkDirectory('tag'), track: linkDirectory('track', {expose: 'data-track'}), + // TODO: This is a bit hacky. Files are just strings (not objects), so we + // have to manually provide the album alongside the file. They also don't + // follow the usual {name: whatever} type shape, so we have to provide that + // ourselves. + _albumAdditionalFileHelper: linkHelper( + ((fakeFileObject, { to }) => + to('media.albumAdditionalFile', fakeFileObject.album.directory, fakeFileObject.name)), + {color: false}), + albumAdditionalFile: ({ file, album }, { to }) => link._albumAdditionalFileHelper({ + name: file, + album + }, {to}), + media: linkPathname('media.path', {color: false}), root: linkPathname('shared.path', {color: false}), data: linkPathname('data.path', {color: false}), -- cgit 1.3.0-6-gf8a5