From 113157085c7bd6f23bd7c08ad6cd2d94673d7033 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 12 Sep 2023 14:47:15 -0300 Subject: content: artist..{TracksChunkedList,ChunkItem}: avoid double sanitize No further changes needed for artwork and flash chunked lists, where contributions consist of only one item (which might be null). --- .../generateArtistInfoPageChunkItem.js | 4 ++-- .../generateArtistInfoPageTracksChunkedList.js | 25 ++++++++++++++-------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/content/dependencies/generateArtistInfoPageChunkItem.js b/src/content/dependencies/generateArtistInfoPageChunkItem.js index 36f0ebcc..9f99513d 100644 --- a/src/content/dependencies/generateArtistInfoPageChunkItem.js +++ b/src/content/dependencies/generateArtistInfoPageChunkItem.js @@ -5,7 +5,7 @@ export default { content: {type: 'html'}, otherArtistLinks: {validate: v => v.strictArrayOf(v.isHTML)}, - contribution: {type: 'string'}, + contribution: {type: 'html'}, rerelease: {type: 'boolean'}, }, @@ -30,7 +30,7 @@ export default { options.artists = language.formatConjunctionList(slots.otherArtistLinks); } - if (slots.contribution) { + if (!html.isBlank(slots.contribution)) { parts.push('withContribution'); options.contribution = slots.contribution; } diff --git a/src/content/dependencies/generateArtistInfoPageTracksChunkedList.js b/src/content/dependencies/generateArtistInfoPageTracksChunkedList.js index 0566f713..654f759c 100644 --- a/src/content/dependencies/generateArtistInfoPageTracksChunkedList.js +++ b/src/content/dependencies/generateArtistInfoPageTracksChunkedList.js @@ -1,4 +1,4 @@ -import {accumulateSum, stitchArrays} from '#sugar'; +import {accumulateSum, empty, stitchArrays} from '#sugar'; import { chunkByProperties, @@ -16,7 +16,7 @@ export default { 'linkTrack', ], - extraDependencies: ['language'], + extraDependencies: ['html', 'language'], query(artist) { const tracksAsArtistAndContributor = @@ -122,11 +122,16 @@ export default { trackContributions: query.chunks.map(({chunk}) => - chunk.map(({contribs}) => - contribs - .filter(({who}) => who === artist) - .filter(({what}) => what) - .map(({what}) => what))), + chunk + .map(({contribs}) => + contribs + .filter(({who}) => who === artist) + .filter(({what}) => what) + .map(({what}) => what)) + .map(contributions => + (empty(contributions) + ? null + : contributions))), trackRereleases: query.chunks.map(({chunk}) => @@ -134,7 +139,7 @@ export default { }; }, - generate(data, relations, {language}) { + generate(data, relations, {html, language}) { return relations.chunkedList.slots({ chunks: stitchArrays({ @@ -192,7 +197,9 @@ export default { rerelease, contribution: - language.formatUnitList(contribution), + (contribution + ? language.formatUnitList(contribution) + : html.blank()), content: (duration -- cgit 1.3.0-6-gf8a5 From 0bb9482518badd10b6e2c3e8e2ba99367b6f6fd1 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 12 Sep 2023 15:14:13 -0300 Subject: thumbs: return correct function signature, yes, yes --- src/gen-thumbs.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gen-thumbs.js b/src/gen-thumbs.js index b7c192c3..18d1964d 100644 --- a/src/gen-thumbs.js +++ b/src/gen-thumbs.js @@ -673,7 +673,7 @@ export async function verifyImagePaths(mediaPath, {urls, wikiData}) { if (empty(missing) && empty(misplaced)) { logInfo`All image paths are good - nice! None are missing or misplaced.`; - return; + return {missing, misplaced}; } if (!empty(missing)) { -- cgit 1.3.0-6-gf8a5 From f3a855d772d51749c6f9d50632dc74792f902b29 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sat, 16 Sep 2023 21:42:55 -0300 Subject: client: fix sticky headings not working on pages w/o cover --- src/static/client2.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/static/client2.js b/src/static/client2.js index 78970410..d9afcb03 100644 --- a/src/static/client2.js +++ b/src/static/client2.js @@ -539,7 +539,7 @@ const stickyHeadingInfo = Array.from(document.querySelectorAll('.content-sticky- const contentHeadings = Array.from(contentContainer.querySelectorAll('.content-heading')); const contentCover = contentContainer.querySelector('#cover-art-container'); - if (stickyCover.querySelector('.image-text-area')) { + if (stickyCover?.querySelector('.image-text-area')) { stickyCoverContainer.remove(); stickyCoverContainer = null; stickyCover = null; -- cgit 1.3.0-6-gf8a5 From fdd8f355bfe0992fc340f800297df524276b1946 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Mon, 18 Sep 2023 16:05:05 -0300 Subject: data: Track.alwaysReferencedByDirectory flag & field --- src/data/things/track.js | 35 +++++++++++++++++++++++++++++++++++ src/data/yaml.js | 2 ++ src/find.js | 24 ++++++++++++------------ 3 files changed, 49 insertions(+), 12 deletions(-) diff --git a/src/data/things/track.js b/src/data/things/track.js index e176acb4..14510d96 100644 --- a/src/data/things/track.js +++ b/src/data/things/track.js @@ -36,6 +36,41 @@ export class Track extends Thing { urls: Thing.common.urls(), dateFirstReleased: Thing.common.simpleDate(), + // Controls how find.track works - it'll never be matched by a reference + // just to the track's name, which means you don't have to always reference + // some *other* (much more commonly referenced) track by directory instead + // of more naturally by name. + alwaysReferenceByDirectory: { + flags: {update: true, expose: true}, + + // Deliberately defaults to null - this will fall back to false in most + // cases. + update: {validate: isBoolean, default: null}, + + expose: { + dependencies: ['name', 'originalReleaseTrackByRef', 'trackData'], + + transform(value, { + name, + originalReleaseTrackByRef, + trackData, + [Track.instance]: thisTrack, + }) { + if (value !== null) return value; + + const original = + find.track( + originalReleaseTrackByRef, + trackData.filter(track => track !== thisTrack), + {quiet: true}); + + if (!original) return false; + + return name === original.name; + } + }, + }, + artistContribsByRef: Thing.common.contribsByRef(), contributorContribsByRef: Thing.common.contribsByRef(), coverArtistContribsByRef: Thing.common.contribsByRef(), diff --git a/src/data/yaml.js b/src/data/yaml.js index 35943199..07e0a3d2 100644 --- a/src/data/yaml.js +++ b/src/data/yaml.js @@ -338,6 +338,8 @@ export const processTrackDocument = makeProcessDocument(T.Track, { coverArtFileExtension: 'Cover Art File Extension', hasCoverArt: 'Has Cover Art', + alwaysReferenceByDirectory: 'Always Reference By Directory', + lyrics: 'Lyrics', commentary: 'Commentary', additionalFiles: 'Additional Files', diff --git a/src/find.js b/src/find.js index b8230800..966629e3 100644 --- a/src/find.js +++ b/src/find.js @@ -80,17 +80,19 @@ function matchDirectory(ref, data) { } function matchName(ref, data, mode) { - const matches = data.filter( - ({name}) => name.toLowerCase() === ref.toLowerCase() - ); + const matches = + data + .filter(({name}) => name.toLowerCase() === ref.toLowerCase()) + .filter(thing => + (Object.hasOwn(thing, 'alwaysReferenceByDirectory') + ? !thing.alwaysReferenceByDirectory + : true)); if (matches.length > 1) { - return warnOrThrow( - mode, + return warnOrThrow(mode, `Multiple matches for reference "${ref}". Please resolve:\n` + - matches.map((match) => `- ${inspect(match)}\n`).join('') + - `Returning null for this reference.` - ); + matches.map(match => `- ${inspect(match)}\n`).join('') + + `Returning null for this reference.`); } if (matches.length === 0) { @@ -100,10 +102,8 @@ function matchName(ref, data, mode) { const thing = matches[0]; if (ref !== thing.name) { - warnOrThrow( - mode, - `Bad capitalization: ${color.red(ref)} -> ${color.green(thing.name)}` - ); + warnOrThrow(mode, + `Bad capitalization: ${color.red(ref)} -> ${color.green(thing.name)}`); } return thing; -- cgit 1.3.0-6-gf8a5