From d55610a3869167c8100ceec39f36334b5395de40 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Mon, 5 Apr 2021 16:03:13 -0300 Subject: reveal strings on info card art --- upd8.js | 84 ++++++++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 52 insertions(+), 32 deletions(-) (limited to 'upd8.js') diff --git a/upd8.js b/upd8.js index db6f04c..445ff8d 100755 --- a/upd8.js +++ b/upd8.js @@ -2126,6 +2126,23 @@ function serializeContribs(contribs) { })); } +function serializeCover(thing, pathFunction) { + const coverPath = pathFunction(thing, { + to: urls.from('media.root').to + }); + + const { artTags } = thing; + + const cwTags = artTags.filter(tag => tag.isCW); + const linkTags = artTags.filter(tag => !tag.isCW); + + return { + paths: serializeImagePaths(coverPath), + tags: linkTags.map(serializeLink), + warnings: cwTags.map(tag => tag.name) + }; +} + function validateWritePath(path, urlGroup) { if (!Array.isArray(path)) { return {error: `Expected array, got ${path}`}; @@ -2407,7 +2424,7 @@ writePage.html = (pageFn, {paths, strings, to}) => {
-
+
${img({ class: 'info-card-art', src: '', @@ -2415,6 +2432,15 @@ writePage.html = (pageFn, {paths, strings, to}) => { square: true })}
+
+ ${img({ + class: 'info-card-art', + src: '', + link: true, + square: true, + reveal: getRevealStringFromWarnings('', {strings}) + })} +

${strings('releaseInfo.from', {album: ''})}

@@ -2519,7 +2545,7 @@ function getGridHTML({ thumb: 'small', lazy: (typeof lazy === 'number' ? i >= lazy : lazy), square: true, - reveal: getRevealString(item.artTags, {strings}) + reveal: getRevealStringFromTags(item.artTags, {strings}) })} ${item.name} ${detailsFn && `${detailsFn(item)}`} @@ -2817,12 +2843,14 @@ function writeStaticPage(staticPage) { })); } -function getRevealString(tags, {strings}) { + +function getRevealStringFromWarnings(warnings, {strings}) { + return strings('misc.contentWarnings', {warnings}) + `
${strings('misc.contentWarnings.reveal')}` +} + +function getRevealStringFromTags(tags, {strings}) { return tags && tags.some(tag => tag.isCW) && ( - strings('misc.contentWarnings', { - warnings: tags.filter(tag => tag.isCW).map(tag => `${tag.name}`).join(', ') - }) + `
${strings('misc.contentWarnings.reveal')}` - ); + getRevealStringFromWarnings(tags.filter(tag => tag.isCW).map(tag => tag.name).join(', '), {strings})); } function generateCoverLink({ @@ -2840,7 +2868,7 @@ function generateCoverLink({ id: 'cover-art', link: true, square: true, - reveal: getRevealString(tags, {strings}) + reveal: getRevealStringFromTags(tags, {strings}) })} ${wikiInfo.features.artTagUI && tags.filter(tag => !tag.isCW).length && fixWS`

@@ -3105,30 +3133,22 @@ function writeTrackPage(track) { const data = { type: 'data', path: ['track', track.directory], - data: () => { - const coverPath = getTrackCover(track, { - to: urls.from('media.root').to - }); - - return { - name: track.name, - directory: track.directory, - date: track.date, - duration: track.duration, - color: track.color, - cover: { - paths: serializeImagePaths(coverPath) - }, - links: { - artists: serializeContribs(track.artists), - contributors: serializeContribs(track.contributors), - album: serializeLink(track.album), - groups: track.album.groups.map(serializeLink), - references: track.references.map(serializeLink), - referencedBy: track.referencedBy.map(serializeLink) - } - }; - } + data: () => ({ + name: track.name, + directory: track.directory, + date: track.date, + duration: track.duration, + color: track.color, + cover: serializeCover(track, getTrackCover), + links: { + artists: serializeContribs(track.artists), + contributors: serializeContribs(track.contributors), + album: serializeLink(track.album), + groups: track.album.groups.map(serializeLink), + references: track.references.map(serializeLink), + referencedBy: track.referencedBy.map(serializeLink) + } + }) }; // const page = ({strings, writePage}) => writePage('track', track.directory, ({to}) => ({ -- cgit 1.3.0-6-gf8a5