From 029210cc329a015a939472a688209d3f3423242b Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 30 May 2023 09:51:26 -0300 Subject: thumbs, content: integrate cached thumb sizes into content --- src/content/dependencies/image.js | 85 ++++++++++++++++++++++++++++----------- 1 file changed, 61 insertions(+), 24 deletions(-) (limited to 'src/content') diff --git a/src/content/dependencies/image.js b/src/content/dependencies/image.js index 71b905f7..905b3c2e 100644 --- a/src/content/dependencies/image.js +++ b/src/content/dependencies/image.js @@ -2,10 +2,12 @@ import {empty} from '#sugar'; export default { extraDependencies: [ - 'getSizeOfImageFile', + 'getDimensionsOfImagePath', + 'getSizeOfImagePath', + 'getThumbnailEqualOrSmaller', + 'getThumbnailsAvailableForDimensions', 'html', 'language', - 'thumb', 'to', ], @@ -52,10 +54,12 @@ export default { }, generate(data, slots, { - getSizeOfImageFile, + getDimensionsOfImagePath, + getSizeOfImagePath, + getThumbnailEqualOrSmaller, + getThumbnailsAvailableForDimensions, html, language, - thumb, to, }) { let originalSrc; @@ -68,12 +72,6 @@ export default { originalSrc = ''; } - const thumbSrc = - originalSrc && - (slots.thumb - ? thumb[slots.thumb](originalSrc) - : originalSrc); - const willLink = typeof slots.link === 'string' || slots.link; const customLink = typeof slots.link === 'string'; @@ -95,18 +93,6 @@ export default { slots.missingSourceContent)); } - let fileSize = null; - if (willLink) { - const mediaRoot = to('media.root'); - if (originalSrc.startsWith(mediaRoot)) { - fileSize = - getSizeOfImageFile( - originalSrc - .slice(mediaRoot.length) - .replace(/^\//, '')); - } - } - let reveal = null; if (willReveal) { reveal = [ @@ -119,16 +105,67 @@ export default { ]; } + let mediaSrc = null; + if (originalSrc.startsWith(to('media.root'))) { + mediaSrc = + originalSrc + .slice(to('media.root').length) + .replace(/^\//, ''); + } + + let thumbSrc = null; + if (mediaSrc) { + // Note: This provides mediaSrc to getThumbnailEqualOrSmaller, since + // it's the identifier which thumbnail utilities use to query from the + // thumbnail cache. But we use the result to operate on originalSrc, + // which is the HTML output-appropriate path including `../../` or + // another alternate base path. + const selectedSize = getThumbnailEqualOrSmaller(slots.thumb, mediaSrc); + thumbSrc = originalSrc.replace(/\.(jpg|png)$/, `.${selectedSize}.jpg`); + } + + let originalWidth = null; + let originalHeight = null; + let availableThumbs = null; + if (mediaSrc) { + [originalWidth, originalHeight] = + getDimensionsOfImagePath(mediaSrc); + availableThumbs = + getThumbnailsAvailableForDimensions([originalWidth, originalHeight]); + } + + let fileSize = null; + if (willLink && mediaSrc) { + fileSize = getSizeOfImagePath(mediaSrc); + } + const imgAttributes = { id: idOnImg, class: classOnImg, alt: slots.alt, width: slots.width, height: slots.height, - 'data-original-size': fileSize, - 'data-no-image-preview': customLink, }; + if (customLink) { + imgAttributes['data-no-image-preview'] = true; + } + + if (fileSize) { + imgAttributes['data-original-size'] = fileSize; + } + + if (originalWidth && originalHeight) { + imgAttributes['data-original-length'] = Math.max(originalWidth, originalHeight); + } + + if (!empty(availableThumbs)) { + imgAttributes['data-thumbs'] = + availableThumbs + .map(([name, size]) => `${name}:${size}`) + .join(' '); + } + const nonlazyHTML = originalSrc && prepare( -- cgit 1.3.0-6-gf8a5 From 669f435f2b86133a8e096b22371ff9fbb1b703b7 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Mon, 4 Sep 2023 20:51:49 -0300 Subject: content: image: defend against unavailable thumbnail info --- src/content/dependencies/image.js | 68 ++++++++++++++++++++++++++------------- 1 file changed, 45 insertions(+), 23 deletions(-) (limited to 'src/content') diff --git a/src/content/dependencies/image.js b/src/content/dependencies/image.js index 905b3c2e..b5591e6d 100644 --- a/src/content/dependencies/image.js +++ b/src/content/dependencies/image.js @@ -1,7 +1,9 @@ +import {logWarn} from '#cli'; import {empty} from '#sugar'; export default { extraDependencies: [ + 'checkIfImagePathHasCachedThumbnails', 'getDimensionsOfImagePath', 'getSizeOfImagePath', 'getThumbnailEqualOrSmaller', @@ -54,6 +56,7 @@ export default { }, generate(data, slots, { + checkIfImagePathHasCachedThumbnails, getDimensionsOfImagePath, getSizeOfImagePath, getThumbnailEqualOrSmaller, @@ -113,8 +116,27 @@ export default { .replace(/^\//, ''); } + const hasThumbnails = + mediaSrc && + checkIfImagePathHasCachedThumbnails(mediaSrc); + + // Warn for images that *should* have cached thumbnail information but are + // missing from the thumbs cache. + if ( + slots.thumb && + !hasThumbnails && + !mediaSrc.endsWith('.gif') + ) { + logWarn`No thumbnail info cached: ${mediaSrc} - displaying original image here (instead of ${slots.thumb})`; + } + + // Important to note that these might not be set at all, even if + // slots.thumb was provided. let thumbSrc = null; - if (mediaSrc) { + let availableThumbs = null; + let originalLength = null; + + if (hasThumbnails && slots.thumb) { // Note: This provides mediaSrc to getThumbnailEqualOrSmaller, since // it's the identifier which thumbnail utilities use to query from the // thumbnail cache. But we use the result to operate on originalSrc, @@ -122,16 +144,12 @@ export default { // another alternate base path. const selectedSize = getThumbnailEqualOrSmaller(slots.thumb, mediaSrc); thumbSrc = originalSrc.replace(/\.(jpg|png)$/, `.${selectedSize}.jpg`); - } - let originalWidth = null; - let originalHeight = null; - let availableThumbs = null; - if (mediaSrc) { - [originalWidth, originalHeight] = - getDimensionsOfImagePath(mediaSrc); - availableThumbs = - getThumbnailsAvailableForDimensions([originalWidth, originalHeight]); + const dimensions = getDimensionsOfImagePath(mediaSrc); + availableThumbs = getThumbnailsAvailableForDimensions(dimensions); + + const [width, height] = dimensions; + originalLength = Math.max(width, height) } let fileSize = null; @@ -151,19 +169,23 @@ export default { imgAttributes['data-no-image-preview'] = true; } - if (fileSize) { - imgAttributes['data-original-size'] = fileSize; - } + // These attributes are only relevant when a thumbnail are available *and* + // being used. + if (hasThumbnails && slots.thumb) { + if (fileSize) { + imgAttributes['data-original-size'] = fileSize; + } - if (originalWidth && originalHeight) { - imgAttributes['data-original-length'] = Math.max(originalWidth, originalHeight); - } + if (originalLength) { + imgAttributes['data-original-length'] = originalLength; + } - if (!empty(availableThumbs)) { - imgAttributes['data-thumbs'] = - availableThumbs - .map(([name, size]) => `${name}:${size}`) - .join(' '); + if (!empty(availableThumbs)) { + imgAttributes['data-thumbs'] = + availableThumbs + .map(([name, size]) => `${name}:${size}`) + .join(' '); + } } const nonlazyHTML = @@ -171,7 +193,7 @@ export default { prepare( html.tag('img', { ...imgAttributes, - src: thumbSrc, + src: thumbSrc ?? originalSrc, })); if (slots.lazy) { @@ -182,7 +204,7 @@ export default { { ...imgAttributes, class: 'lazy', - 'data-original': thumbSrc, + 'data-original': thumbSrc ?? originalSrc, }), true), ]); -- cgit 1.3.0-6-gf8a5 From 0ff743b1350b1d42ba23d9701a0b7acfb7501254 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 5 Sep 2023 20:32:13 -0300 Subject: content: linkTemplate: handle null href w/ hash cleanly --- src/content/dependencies/linkTemplate.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/content') diff --git a/src/content/dependencies/linkTemplate.js b/src/content/dependencies/linkTemplate.js index 1cf64c59..ba7c7cda 100644 --- a/src/content/dependencies/linkTemplate.js +++ b/src/content/dependencies/linkTemplate.js @@ -29,14 +29,16 @@ export default { language, to, }) { - let href = slots.href; + let href; let style; let title; - if (href) { - href = encodeURI(href); + if (slots.href) { + href = encodeURI(slots.href); } else if (!empty(slots.path)) { href = to(...slots.path); + } else { + href = ''; } if (appendIndexHTML) { -- cgit 1.3.0-6-gf8a5 From 9e23a5a9eff30af0d7c8e356520dec791aebd38f Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Mon, 21 Aug 2023 21:15:42 -0300 Subject: content, data: be more guarded about track contribs arrays --- src/content/dependencies/generateAlbumInfoPage.js | 2 +- src/content/dependencies/generateAlbumTrackListItem.js | 4 +++- src/content/dependencies/generateTrackInfoPage.js | 7 +++++-- 3 files changed, 9 insertions(+), 4 deletions(-) (limited to 'src/content') diff --git a/src/content/dependencies/generateAlbumInfoPage.js b/src/content/dependencies/generateAlbumInfoPage.js index ce17ab21..51ea5927 100644 --- a/src/content/dependencies/generateAlbumInfoPage.js +++ b/src/content/dependencies/generateAlbumInfoPage.js @@ -44,7 +44,7 @@ export default { relations.coverArtistChronologyContributions = getChronologyRelations(album, { - contributions: album.coverArtistContribs, + contributions: album.coverArtistContribs ?? [], linkArtist: artist => relation('linkArtist', artist), diff --git a/src/content/dependencies/generateAlbumTrackListItem.js b/src/content/dependencies/generateAlbumTrackListItem.js index f65b47c9..8b443baf 100644 --- a/src/content/dependencies/generateAlbumTrackListItem.js +++ b/src/content/dependencies/generateAlbumTrackListItem.js @@ -1,4 +1,4 @@ -import {compareArrays} from '#sugar'; +import {compareArrays, empty} from '#sugar'; export default { contentDependencies: [ @@ -31,6 +31,8 @@ export default { } data.showArtists = + empty(track.artistContribs) || + empty(album.artistContribs) || !compareArrays( track.artistContribs.map(c => c.who), album.artistContribs.map(c => c.who), diff --git a/src/content/dependencies/generateTrackInfoPage.js b/src/content/dependencies/generateTrackInfoPage.js index 334c5422..7002204c 100644 --- a/src/content/dependencies/generateTrackInfoPage.js +++ b/src/content/dependencies/generateTrackInfoPage.js @@ -51,7 +51,10 @@ export default { relations.artistChronologyContributions = getChronologyRelations(track, { - contributions: [...track.artistContribs, ...track.contributorContribs], + contributions: [ + ...track.artistContribs ?? [], + ...track.contributorContribs ?? [], + ], linkArtist: artist => relation('linkArtist', artist), linkThing: track => relation('linkTrack', track), @@ -65,7 +68,7 @@ export default { relations.coverArtistChronologyContributions = getChronologyRelations(track, { - contributions: track.coverArtistContribs, + contributions: track.coverArtistContribs ?? [], linkArtist: artist => relation('linkArtist', artist), -- cgit 1.3.0-6-gf8a5 From 93448ef747b681d3b87b050b555311c0172b83cc Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Mon, 21 Aug 2023 22:12:24 -0300 Subject: content, data: be even more guarded about contrib arrays --- .../dependencies/generateAlbumTrackListItem.js | 20 ++++---- src/content/dependencies/generateTrackList.js | 59 +++++++++++++--------- 2 files changed, 45 insertions(+), 34 deletions(-) (limited to 'src/content') diff --git a/src/content/dependencies/generateAlbumTrackListItem.js b/src/content/dependencies/generateAlbumTrackListItem.js index 8b443baf..f92712f9 100644 --- a/src/content/dependencies/generateAlbumTrackListItem.js +++ b/src/content/dependencies/generateAlbumTrackListItem.js @@ -11,9 +11,11 @@ export default { relations(relation, track) { const relations = {}; - relations.contributionLinks = - track.artistContribs - .map(contrib => relation('linkContribution', contrib)); + if (!empty(track.artistContribs)) { + relations.contributionLinks = + track.artistContribs + .map(contrib => relation('linkContribution', contrib)); + } relations.trackLink = relation('linkTrack', track); @@ -31,12 +33,12 @@ export default { } data.showArtists = - empty(track.artistContribs) || - empty(album.artistContribs) || - !compareArrays( - track.artistContribs.map(c => c.who), - album.artistContribs.map(c => c.who), - {checkOrder: false}); + !empty(track.artistContribs) && + (empty(album.artistContribs) || + !compareArrays( + track.artistContribs.map(c => c.who), + album.artistContribs.map(c => c.who), + {checkOrder: false})); return data; }, diff --git a/src/content/dependencies/generateTrackList.js b/src/content/dependencies/generateTrackList.js index f001c3b3..65f5552b 100644 --- a/src/content/dependencies/generateTrackList.js +++ b/src/content/dependencies/generateTrackList.js @@ -1,4 +1,4 @@ -import {empty} from '#sugar'; +import {empty, stitchArrays} from '#sugar'; export default { contentDependencies: ['linkTrack', 'linkContribution'], @@ -11,14 +11,17 @@ export default { } return { - items: tracks.map(track => ({ - trackLink: - relation('linkTrack', track), + trackLinks: + tracks + .map(track => relation('linkTrack', track)), - contributionLinks: - track.artistContribs - .map(contrib => relation('linkContribution', contrib)), - })), + contributionLinks: + tracks + .map(track => + (empty(track.artistContribs) + ? null + : track.artistContribs + .map(contrib => relation('linkContribution', contrib)))), }; }, @@ -28,22 +31,28 @@ export default { }, generate(relations, slots, {html, language}) { - return html.tag('ul', - relations.items.map(({trackLink, contributionLinks}) => - html.tag('li', - language.$('trackList.item.withArtists', { - track: trackLink, - by: - html.tag('span', {class: 'by'}, - language.$('trackList.item.withArtists.by', { - artists: - language.formatConjunctionList( - contributionLinks.map(link => - link.slots({ - showContribution: slots.showContribution, - showIcons: slots.showIcons, - }))), - })), - })))); + return ( + html.tag('ul', + stitchArrays({ + trackLink: relations.trackLinks, + contributionLinks: relations.contributionLinks, + }).map(({trackLink, contributionLinks}) => + html.tag('li', + (empty(contributionLinks) + ? trackLink + : language.$('trackList.item.withArtists', { + track: trackLink, + by: + html.tag('span', {class: 'by'}, + language.$('trackList.item.withArtists.by', { + artists: + language.formatConjunctionList( + contributionLinks.map(link => + link.slots({ + showContribution: slots.showContribution, + showIcons: slots.showIcons, + }))), + })), + })))))); }, }; -- cgit 1.3.0-6-gf8a5 From eb00f2993a1aaaba171ad6c918656552f80bb748 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Thu, 7 Sep 2023 12:38:34 -0300 Subject: data: import Thing.common utilities directly Also rename 'color' (from #cli) to 'colors'. --- src/content/dependencies/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/content') diff --git a/src/content/dependencies/index.js b/src/content/dependencies/index.js index 3bc34845..57025a5d 100644 --- a/src/content/dependencies/index.js +++ b/src/content/dependencies/index.js @@ -6,7 +6,7 @@ import {fileURLToPath} from 'node:url'; import chokidar from 'chokidar'; import {ESLint} from 'eslint'; -import {color, logWarn} from '#cli'; +import {colors, logWarn} from '#cli'; import contentFunction, {ContentFunctionSpecError} from '#content-function'; import {annotateFunction} from '#sugar'; @@ -192,7 +192,7 @@ export function watchContentDependencies({ if (logging && emittedReady) { const timestamp = new Date().toLocaleString('en-US', {timeStyle: 'medium'}); - console.log(color.green(`[${timestamp}] Updated ${functionName}`)); + console.log(colors.green(`[${timestamp}] Updated ${functionName}`)); } contentDependencies[functionName] = fn; @@ -219,9 +219,9 @@ export function watchContentDependencies({ } if (typeof error === 'string') { - console.error(color.yellow(error)); + console.error(colors.yellow(error)); } else if (error instanceof ContentFunctionSpecError) { - console.error(color.yellow(error.message)); + console.error(colors.yellow(error.message)); } else { console.error(error); } -- cgit 1.3.0-6-gf8a5 From bbccaf51222cb4bed73466164496f5bc1030292c Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Thu, 7 Sep 2023 17:30:54 -0300 Subject: data: roll paired "byRef" and "dynamic" properties into one --- src/content/dependencies/generateWikiHomeAlbumsRow.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/content') diff --git a/src/content/dependencies/generateWikiHomeAlbumsRow.js b/src/content/dependencies/generateWikiHomeAlbumsRow.js index 99c1be55..cb0860f5 100644 --- a/src/content/dependencies/generateWikiHomeAlbumsRow.js +++ b/src/content/dependencies/generateWikiHomeAlbumsRow.js @@ -16,7 +16,7 @@ export default { sprawl({albumData}, row) { const sprawl = {}; - switch (row.sourceGroupByRef) { + switch (row.sourceGroup) { case 'new-releases': sprawl.albums = getNewReleases(row.countAlbumsFromGroup, {albumData}); break; -- cgit 1.3.0-6-gf8a5 From 40729920984ca1362f1672b1307bf7aa32687107 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Fri, 8 Sep 2023 08:49:54 -0300 Subject: infra, content: use watchPath variable where appropriate --- src/content/dependencies/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/content') diff --git a/src/content/dependencies/index.js b/src/content/dependencies/index.js index 57025a5d..65241faa 100644 --- a/src/content/dependencies/index.js +++ b/src/content/dependencies/index.js @@ -77,12 +77,12 @@ export function watchContentDependencies({ // prematurely find out there aren't any nulls - before the nulls have // been entered at all!). - readdir(metaDirname).then(files => { + readdir(watchPath).then(files => { if (closed) { return; } - const filePaths = files.map(file => path.join(metaDirname, file)); + const filePaths = files.map(file => path.join(watchPath, file)); for (const filePath of filePaths) { if (filePath === metaPath) continue; const functionName = getFunctionName(filePath); @@ -91,7 +91,7 @@ export function watchContentDependencies({ } } - const watcher = chokidar.watch(metaDirname); + const watcher = chokidar.watch(watchPath); watcher.on('all', (event, filePath) => { if (!['add', 'change'].includes(event)) return; -- cgit 1.3.0-6-gf8a5 From 21a270ca6efa561cad3e87048cf8deb8a166d55f Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Fri, 8 Sep 2023 08:51:20 -0300 Subject: fix miscellaneous eslint errors --- src/content/dependencies/index.js | 1 - 1 file changed, 1 deletion(-) (limited to 'src/content') diff --git a/src/content/dependencies/index.js b/src/content/dependencies/index.js index 65241faa..71802050 100644 --- a/src/content/dependencies/index.js +++ b/src/content/dependencies/index.js @@ -30,7 +30,6 @@ export function watchContentDependencies({ const contentDependencies = {}; let emittedReady = false; - let allDependenciesFulfilled = false; let closed = false; let _close = () => {}; -- cgit 1.3.0-6-gf8a5 From 3eb82ab2e3f9d921095af05cf0bc284f335aaa35 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Mon, 11 Sep 2023 10:11:44 -0300 Subject: content: misc. changes to handle HTML sanitization --- src/content/dependencies/generateCoverGrid.js | 12 ++++++++---- src/content/dependencies/generateFooterLocalizationLinks.js | 2 +- src/content/dependencies/generatePageLayout.js | 6 +++--- src/content/dependencies/linkTemplate.js | 2 +- src/content/dependencies/linkThing.js | 2 +- 5 files changed, 14 insertions(+), 10 deletions(-) (limited to 'src/content') diff --git a/src/content/dependencies/generateCoverGrid.js b/src/content/dependencies/generateCoverGrid.js index 9822e1ae..5636e4f3 100644 --- a/src/content/dependencies/generateCoverGrid.js +++ b/src/content/dependencies/generateCoverGrid.js @@ -2,7 +2,7 @@ import {stitchArrays} from '#sugar'; export default { contentDependencies: ['generateGridActionLinks'], - extraDependencies: ['html'], + extraDependencies: ['html', 'language'], relations(relation) { return { @@ -20,7 +20,7 @@ export default { actionLinks: {validate: v => v.sparseArrayOf(v.isHTML)}, }, - generate(relations, slots, {html}) { + generate(relations, slots, {html, language}) { return ( html.tag('div', {class: 'grid-listing'}, [ stitchArrays({ @@ -42,8 +42,12 @@ export default { ? slots.lazy : false), }), - html.tag('span', {[html.onlyIfContent]: true}, name), - html.tag('span', {[html.onlyIfContent]: true}, info), + + html.tag('span', {[html.onlyIfContent]: true}, + language.sanitize(name)), + + html.tag('span', {[html.onlyIfContent]: true}, + language.sanitize(info)), ], })), diff --git a/src/content/dependencies/generateFooterLocalizationLinks.js b/src/content/dependencies/generateFooterLocalizationLinks.js index b4970b17..5df83566 100644 --- a/src/content/dependencies/generateFooterLocalizationLinks.js +++ b/src/content/dependencies/generateFooterLocalizationLinks.js @@ -38,7 +38,7 @@ export default { return html.tag('div', {class: 'footer-localization-links'}, language.$('misc.uiLanguage', { - languages: links.join('\n'), + languages: language.formatListWithoutSeparator(links), })); }, }; diff --git a/src/content/dependencies/generatePageLayout.js b/src/content/dependencies/generatePageLayout.js index 95a5dbec..5377f80d 100644 --- a/src/content/dependencies/generatePageLayout.js +++ b/src/content/dependencies/generatePageLayout.js @@ -105,7 +105,7 @@ export default { color: {validate: v => v.isColor}, styleRules: { - validate: v => v.sparseArrayOf(v.isString), + validate: v => v.sparseArrayOf(v.isHTML), default: [], }, @@ -183,7 +183,7 @@ export default { } else { aggregate.call(v.validateProperties({ path: v.strictArrayOf(v.isString), - title: v.isString, + title: v.isHTML, }), { path: object.path, title: object.title, @@ -521,7 +521,7 @@ export default { ]), slots.bannerPosition === 'bottom' && slots.banner, footerHTML, - ].filter(Boolean).join('\n'); + ]; const pageHTML = html.tags([ ``, diff --git a/src/content/dependencies/linkTemplate.js b/src/content/dependencies/linkTemplate.js index ba7c7cda..7206e960 100644 --- a/src/content/dependencies/linkTemplate.js +++ b/src/content/dependencies/linkTemplate.js @@ -16,7 +16,7 @@ export default { path: {validate: v => v.validateArrayItems(v.isString)}, hash: {type: 'string'}, - tooltip: {validate: v => v.isString}, + tooltip: {type: 'string'}, attributes: {validate: v => v.isAttributes}, color: {validate: v => v.isColor}, content: {type: 'html'}, diff --git a/src/content/dependencies/linkThing.js b/src/content/dependencies/linkThing.js index e3e2608f..643bf4b1 100644 --- a/src/content/dependencies/linkThing.js +++ b/src/content/dependencies/linkThing.js @@ -26,7 +26,7 @@ export default { preferShortName: {type: 'boolean', default: false}, tooltip: { - validate: v => v.oneOf(v.isBoolean, v.isString), + validate: v => v.oneOf(v.isBoolean, v.isHTML), default: false, }, -- cgit 1.3.0-6-gf8a5 From 4ac038fce1f99ca12a9bca578fb9d0ffd8482ecd Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Mon, 11 Sep 2023 14:33:47 -0300 Subject: content: generateAlbumSidebarTrackSection: don't pre-encode endash --- src/content/dependencies/generateAlbumSidebarTrackSection.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/content') diff --git a/src/content/dependencies/generateAlbumSidebarTrackSection.js b/src/content/dependencies/generateAlbumSidebarTrackSection.js index 2aca6da1..d71b0bdb 100644 --- a/src/content/dependencies/generateAlbumSidebarTrackSection.js +++ b/src/content/dependencies/generateAlbumSidebarTrackSection.js @@ -82,7 +82,7 @@ export default { (data.hasTrackNumbers ? language.$('albumSidebar.trackList.group.withRange', { group: sectionName, - range: `${data.firstTrackNumber}–${data.lastTrackNumber}` + range: `${data.firstTrackNumber}–${data.lastTrackNumber}` }) : language.$('albumSidebar.trackList.group', { group: sectionName, -- cgit 1.3.0-6-gf8a5 From a88d346f9e7c2c9b01795c10761a5ec698e88f94 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Mon, 11 Sep 2023 15:11:24 -0300 Subject: content: image: custom-handle images assessed to be missing --- src/content/dependencies/image.js | 42 +++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 13 deletions(-) (limited to 'src/content') diff --git a/src/content/dependencies/image.js b/src/content/dependencies/image.js index b5591e6d..64fe8533 100644 --- a/src/content/dependencies/image.js +++ b/src/content/dependencies/image.js @@ -1,4 +1,4 @@ -import {logWarn} from '#cli'; +import {logInfo, logWarn} from '#cli'; import {empty} from '#sugar'; export default { @@ -10,6 +10,7 @@ export default { 'getThumbnailsAvailableForDimensions', 'html', 'language', + 'missingImagePaths', 'to', ], @@ -63,6 +64,7 @@ export default { getThumbnailsAvailableForDimensions, html, language, + missingImagePaths, to, }) { let originalSrc; @@ -75,8 +77,27 @@ export default { originalSrc = ''; } - const willLink = typeof slots.link === 'string' || slots.link; - const customLink = typeof slots.link === 'string'; + let mediaSrc = null; + if (originalSrc.startsWith(to('media.root'))) { + mediaSrc = + originalSrc + .slice(to('media.root').length) + .replace(/^\//, ''); + } + + const isMissingImageFile = + missingImagePaths.includes(mediaSrc); + + if (isMissingImageFile) { + logInfo`No image file for ${mediaSrc} - build again for list of missing images.`; + } + + const willLink = + !isMissingImageFile && + (typeof slots.link === 'string' || slots.link); + + const customLink = + typeof slots.link === 'string'; const willReveal = slots.reveal && @@ -87,13 +108,16 @@ export default { const idOnImg = willLink ? null : slots.id; const idOnLink = willLink ? slots.id : null; + const classOnImg = willLink ? null : slots.class; const classOnLink = willLink ? slots.class : null; - if (!originalSrc) { + if (!originalSrc || isMissingImageFile) { return prepare( html.tag('div', {class: 'image-text-area'}, - slots.missingSourceContent)); + (html.isBlank(slots.missingSourceContent) + ? language.$(`misc.missingImage`) + : slots.missingSourceContent))); } let reveal = null; @@ -108,14 +132,6 @@ export default { ]; } - let mediaSrc = null; - if (originalSrc.startsWith(to('media.root'))) { - mediaSrc = - originalSrc - .slice(to('media.root').length) - .replace(/^\//, ''); - } - const hasThumbnails = mediaSrc && checkIfImagePathHasCachedThumbnails(mediaSrc); -- cgit 1.3.0-6-gf8a5 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(-) (limited to 'src/content') 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 b85404e0b438a0c014b26b9cbfd12475cea6cb33 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 19 Sep 2023 10:36:25 -0300 Subject: content: linkThing: sanitize name before passing to linkTemplate --- src/content/dependencies/linkThing.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/content') diff --git a/src/content/dependencies/linkThing.js b/src/content/dependencies/linkThing.js index 643bf4b1..e661ca7c 100644 --- a/src/content/dependencies/linkThing.js +++ b/src/content/dependencies/linkThing.js @@ -1,6 +1,6 @@ export default { contentDependencies: ['linkTemplate'], - extraDependencies: ['html'], + extraDependencies: ['html', 'language'], relations(relation) { return { @@ -41,7 +41,7 @@ export default { hash: {type: 'string'}, }, - generate(data, relations, slots, {html}) { + generate(data, relations, slots, {html, language}) { const path = [data.pathKey, data.directory]; const name = @@ -51,7 +51,7 @@ export default { const content = (html.isBlank(slots.content) - ? name + ? language.sanitize(name) : slots.content); let color = null; -- cgit 1.3.0-6-gf8a5 From 2099c258fc1833ac459c8a43ca0cae9ae6150ad0 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 19 Sep 2023 12:41:20 -0300 Subject: content: listTracksWithExtra: handle dateless albums cleanly --- src/content/dependencies/listTracksWithExtra.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/content') diff --git a/src/content/dependencies/listTracksWithExtra.js b/src/content/dependencies/listTracksWithExtra.js index 73d25e3d..c9f80f35 100644 --- a/src/content/dependencies/listTracksWithExtra.js +++ b/src/content/dependencies/listTracksWithExtra.js @@ -65,10 +65,14 @@ export default { stitchArrays({ albumLink: relations.albumLinks, date: data.dates, - }).map(({albumLink, date}) => ({ - album: albumLink, - date: language.formatDate(date), - })), + }).map(({albumLink, date}) => + (date + ? { + stringsKey: 'withDate', + album: albumLink, + date: language.formatDate(date), + } + : {album: albumLink})), chunkRows: relations.trackLinks -- cgit 1.3.0-6-gf8a5 From 424cb392d3a4fc2f7b47b68de30378fc5abf1321 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sun, 24 Sep 2023 15:40:20 -0300 Subject: content: generateAlbumStyleRules: provide album & track directory --- .../dependencies/generateAlbumCommentaryPage.js | 2 +- .../dependencies/generateAlbumGalleryPage.js | 2 +- src/content/dependencies/generateAlbumInfoPage.js | 2 +- .../dependencies/generateAlbumStyleRules.js | 72 +++++++++++++--------- src/content/dependencies/generateTrackInfoPage.js | 2 +- 5 files changed, 46 insertions(+), 34 deletions(-) (limited to 'src/content') diff --git a/src/content/dependencies/generateAlbumCommentaryPage.js b/src/content/dependencies/generateAlbumCommentaryPage.js index de619251..5979ed3f 100644 --- a/src/content/dependencies/generateAlbumCommentaryPage.js +++ b/src/content/dependencies/generateAlbumCommentaryPage.js @@ -21,7 +21,7 @@ export default { relation('generatePageLayout'); relations.albumStyleRules = - relation('generateAlbumStyleRules', album); + relation('generateAlbumStyleRules', album, null); relations.albumLink = relation('linkAlbum', album); diff --git a/src/content/dependencies/generateAlbumGalleryPage.js b/src/content/dependencies/generateAlbumGalleryPage.js index 68b56bd9..b98abc46 100644 --- a/src/content/dependencies/generateAlbumGalleryPage.js +++ b/src/content/dependencies/generateAlbumGalleryPage.js @@ -51,7 +51,7 @@ export default { relation('generatePageLayout'); relations.albumStyleRules = - relation('generateAlbumStyleRules', album); + relation('generateAlbumStyleRules', album, null); relations.albumLink = relation('linkAlbum', album); diff --git a/src/content/dependencies/generateAlbumInfoPage.js b/src/content/dependencies/generateAlbumInfoPage.js index ce17ab21..5c4344b0 100644 --- a/src/content/dependencies/generateAlbumInfoPage.js +++ b/src/content/dependencies/generateAlbumInfoPage.js @@ -37,7 +37,7 @@ export default { relation('generatePageLayout'); relations.albumStyleRules = - relation('generateAlbumStyleRules', album); + relation('generateAlbumStyleRules', album, null); relations.socialEmbed = relation('generateAlbumSocialEmbed', album); diff --git a/src/content/dependencies/generateAlbumStyleRules.js b/src/content/dependencies/generateAlbumStyleRules.js index 1acaea17..9269ae83 100644 --- a/src/content/dependencies/generateAlbumStyleRules.js +++ b/src/content/dependencies/generateAlbumStyleRules.js @@ -3,14 +3,13 @@ import {empty} from '#sugar'; export default { extraDependencies: ['to'], - data(album) { + data(album, track) { const data = {}; data.hasWallpaper = !empty(album.wallpaperArtistContribs); data.hasBanner = !empty(album.bannerArtistContribs); if (data.hasWallpaper) { - data.hasWallpaperStyle = !!album.wallpaperStyle; data.wallpaperPath = ['media.albumWallpaper', album.directory, album.wallpaperFileExtension]; data.wallpaperStyle = album.wallpaperStyle; } @@ -20,40 +19,53 @@ export default { data.bannerStyle = album.bannerStyle; } + data.albumDirectory = album.directory; + + if (track) { + data.trackDirectory = track.directory; + } + return data; }, generate(data, {to}) { - const wallpaperPart = - (data.hasWallpaper - ? [ - `body::before {`, - ` background-image: url("${to(...data.wallpaperPath)}");`, - ...(data.hasWallpaperStyle - ? data.wallpaperStyle - .split('\n') - .map(line => ` ${line}`) - : []), - `}`, - ] - : []); + const indent = parts => + (parts ?? []) + .filter(Boolean) + .join('\n') + .split('\n') + .map(line => ' '.repeat(4) + line) + .join('\n'); - const bannerPart = - (data.hasBannerStyle - ? [ - `#banner img {`, - ...data.bannerStyle - .split('\n') - .map(line => ` ${line}`), - `}`, - ] + const rule = (selector, parts) => + (!empty(parts.filter(Boolean)) + ? [`${selector} {`, indent(parts), `}`] : []); - return [ - ...wallpaperPart, - ...bannerPart, - ] - .filter(Boolean) - .join('\n'); + const wallpaperRule = + data.hasWallpaper && + rule(`body::before`, [ + `background-image: url("${to(...data.wallpaperPath)}");`, + data.wallpaperStyle, + ]); + + const bannerRule = + data.hasBanner && + rule(`#banner img`, [ + data.bannerStyle, + ]); + + const dataRule = + rule(`:root`, [ + data.albumDirectory && + `--album-directory: ${data.albumDirectory};`, + data.trackDirectory && + `--track-directory: ${data.trackDirectory};`, + ]); + + return ( + [...wallpaperRule, ...bannerRule, ...dataRule] + .filter(Boolean) + .join('\n')); }, }; diff --git a/src/content/dependencies/generateTrackInfoPage.js b/src/content/dependencies/generateTrackInfoPage.js index 334c5422..c20c0d08 100644 --- a/src/content/dependencies/generateTrackInfoPage.js +++ b/src/content/dependencies/generateTrackInfoPage.js @@ -44,7 +44,7 @@ export default { relation('generatePageLayout'); relations.albumStyleRules = - relation('generateAlbumStyleRules', track.album); + relation('generateAlbumStyleRules', track.album, track); relations.socialEmbed = relation('generateTrackSocialEmbed', track); -- cgit 1.3.0-6-gf8a5 From 84686df07e1029bcad91b9fda47b6f3bd280ee56 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 6 Jun 2023 20:07:03 -0300 Subject: content: generateCoverArtwork: mode commentary --- src/content/dependencies/generateCoverArtwork.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/content') diff --git a/src/content/dependencies/generateCoverArtwork.js b/src/content/dependencies/generateCoverArtwork.js index 4060c6b0..385385e3 100644 --- a/src/content/dependencies/generateCoverArtwork.js +++ b/src/content/dependencies/generateCoverArtwork.js @@ -32,7 +32,7 @@ export default { }, mode: { - validate: v => v.is('primary', 'thumbnail'), + validate: v => v.is('primary', 'thumbnail', 'commentary'), default: 'primary', }, }, @@ -73,6 +73,18 @@ export default { square: true, }); + case 'commentary': + return relations.image + .slots({ + path: slots.path, + alt: slots.alt, + thumb: 'medium', + class: 'commentary-art', + reveal: true, + link: true, + square: true, + }); + default: return html.blank(); } -- cgit 1.3.0-6-gf8a5 From 1c3d50b059b3848f685ff6655242f5cb6815ddd6 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 6 Jun 2023 20:17:22 -0300 Subject: content: generateAlbumSidebarTrackSection: be mildly more versatile --- .../generateAlbumSidebarTrackSection.js | 24 ++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'src/content') diff --git a/src/content/dependencies/generateAlbumSidebarTrackSection.js b/src/content/dependencies/generateAlbumSidebarTrackSection.js index d71b0bdb..e8c0377d 100644 --- a/src/content/dependencies/generateAlbumSidebarTrackSection.js +++ b/src/content/dependencies/generateAlbumSidebarTrackSection.js @@ -33,10 +33,19 @@ export default { } } + data.trackDirectories = + trackSection.tracks + .map(track => track.directory); + return data; }, - generate(data, relations, {getColors, html, language}) { + slots: { + anchor: {type: 'boolean'}, + open: {type: 'boolean'}, + }, + + generate(slots, data, relations, {getColors, html, language}) { const sectionName = html.tag('span', {class: 'group-name'}, (data.isDefaultTrackSection @@ -59,7 +68,13 @@ export default { 'current', }, language.$('albumSidebar.trackList.item', { - track: trackLink, + track: + (slots.anchor + ? trackLink.slots({ + anchor: true, + hash: data.trackDirectories[index], + }) + : trackLink), }))); return html.tag('details', @@ -67,6 +82,11 @@ export default { class: data.includesCurrentTrack && 'current', open: ( + // Allow forcing open via a template slot. + // This isn't exactly janky, but the rest of this function + // kind of is when you contextualize it in a template... + slots.open || + // Leave sidebar track sections collapsed on album info page, // since there's already a view of the full track listing // in the main content area. -- cgit 1.3.0-6-gf8a5 From 1b81e54834d5f447b5b6e52eb7dfb875673a44f1 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 6 Jun 2023 20:17:35 -0300 Subject: content: generateAlbumCommentaryPage: add sidebar, artworks --- .../dependencies/generateAlbumCommentaryPage.js | 41 +++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) (limited to 'src/content') diff --git a/src/content/dependencies/generateAlbumCommentaryPage.js b/src/content/dependencies/generateAlbumCommentaryPage.js index 5979ed3f..85a2108c 100644 --- a/src/content/dependencies/generateAlbumCommentaryPage.js +++ b/src/content/dependencies/generateAlbumCommentaryPage.js @@ -2,10 +2,13 @@ import {stitchArrays} from '#sugar'; export default { contentDependencies: [ + 'generateAlbumCoverArtwork', 'generateAlbumNavAccent', + 'generateAlbumSidebarTrackSection', 'generateAlbumStyleRules', 'generateColorStyleVariables', 'generateContentHeading', + 'generateTrackCoverArtwork', 'generatePageLayout', 'linkAlbum', 'linkTrack', @@ -30,6 +33,9 @@ export default { relation('generateAlbumNavAccent', album, null); if (album.commentary) { + relations.albumCommentaryCover = + relation('generateAlbumCoverArtwork', album); + relations.albumCommentaryContent = relation('transformContent', album.commentary); } @@ -46,6 +52,13 @@ export default { tracksWithCommentary .map(track => relation('linkTrack', track)); + relations.trackCommentaryCovers = + tracksWithCommentary + .map(track => + (track.hasUniqueCoverArt + ? relation('generateTrackCoverArtwork', track) + : null)); + relations.trackCommentaryContent = tracksWithCommentary .map(track => relation('transformContent', track.commentary)); @@ -57,6 +70,13 @@ export default { ? null : relation('generateColorStyleVariables'))); + relations.sidebarAlbumLink = + relation('linkAlbum', album); + + relations.sidebarTrackSections = + album.trackSections.map(trackSection => + relation('generateAlbumSidebarTrackSection', album, null, trackSection)); + return relations; }, @@ -129,6 +149,11 @@ export default { {class: ['content-heading']}, language.$('albumCommentaryPage.entry.title.albumCommentary')), + relations.albumCommentaryCover + ?.slots({ + displayMode: 'commentary', + }), + html.tag('blockquote', relations.albumCommentaryContent), ], @@ -137,15 +162,19 @@ export default { heading: relations.trackCommentaryHeadings, link: relations.trackCommentaryLinks, directory: data.trackCommentaryDirectories, + cover: relations.trackCommentaryCovers, content: relations.trackCommentaryContent, colorVariables: relations.trackCommentaryColorVariables, color: data.trackCommentaryColors, - }).map(({heading, link, directory, content, colorVariables, color}) => [ + }).map(({heading, link, directory, cover, content, colorVariables, color}) => [ heading.slots({ tag: 'h3', id: directory, title: link, }), + + cover?.slots({mode: 'commentary'}), + html.tag('blockquote', (color ? {style: colorVariables.slot('color', color).content} @@ -170,6 +199,16 @@ export default { }), }, ], + + leftSidebarStickyMode: 'column', + leftSidebarContent: [ + html.tag('h1', relations.sidebarAlbumLink), + relations.sidebarTrackSections.map(section => + section.slots({ + anchor: true, + open: true, + })), + ], }); }, }; -- cgit 1.3.0-6-gf8a5 From 528d909f4eeec9d7f6b54031752a94a6c9dca5ab Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sun, 24 Sep 2023 10:29:09 -0300 Subject: content: generateAlbum{CommentaryPage,SidebarTrackSection}: merge fixes --- src/content/dependencies/generateAlbumCommentaryPage.js | 4 +--- src/content/dependencies/generateAlbumSidebarTrackSection.js | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) (limited to 'src/content') diff --git a/src/content/dependencies/generateAlbumCommentaryPage.js b/src/content/dependencies/generateAlbumCommentaryPage.js index 85a2108c..5c057b80 100644 --- a/src/content/dependencies/generateAlbumCommentaryPage.js +++ b/src/content/dependencies/generateAlbumCommentaryPage.js @@ -150,9 +150,7 @@ export default { language.$('albumCommentaryPage.entry.title.albumCommentary')), relations.albumCommentaryCover - ?.slots({ - displayMode: 'commentary', - }), + ?.slots({mode: 'commentary'}), html.tag('blockquote', relations.albumCommentaryContent), diff --git a/src/content/dependencies/generateAlbumSidebarTrackSection.js b/src/content/dependencies/generateAlbumSidebarTrackSection.js index e8c0377d..00e9b621 100644 --- a/src/content/dependencies/generateAlbumSidebarTrackSection.js +++ b/src/content/dependencies/generateAlbumSidebarTrackSection.js @@ -45,7 +45,7 @@ export default { open: {type: 'boolean'}, }, - generate(slots, data, relations, {getColors, html, language}) { + generate(data, relations, slots, {getColors, html, language}) { const sectionName = html.tag('span', {class: 'group-name'}, (data.isDefaultTrackSection -- cgit 1.3.0-6-gf8a5 From b695bf0c8d0c904ef5b26c76361b804a7ebdc335 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sun, 24 Sep 2023 10:29:25 -0300 Subject: content: generateCoverArtwork: lazy commentary covers --- src/content/dependencies/generateCoverArtwork.js | 1 + 1 file changed, 1 insertion(+) (limited to 'src/content') diff --git a/src/content/dependencies/generateCoverArtwork.js b/src/content/dependencies/generateCoverArtwork.js index 385385e3..aeba97de 100644 --- a/src/content/dependencies/generateCoverArtwork.js +++ b/src/content/dependencies/generateCoverArtwork.js @@ -83,6 +83,7 @@ export default { reveal: true, link: true, square: true, + lazy: true, }); default: -- cgit 1.3.0-6-gf8a5 From 8ed9240b56d61be97a5cc1da7c9fcb179bb58a93 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 26 Sep 2023 11:32:12 -0300 Subject: content: generateAlbumStyleRules: oops --- src/content/dependencies/generateAlbumStyleRules.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/content') diff --git a/src/content/dependencies/generateAlbumStyleRules.js b/src/content/dependencies/generateAlbumStyleRules.js index 9269ae83..c5acf374 100644 --- a/src/content/dependencies/generateAlbumStyleRules.js +++ b/src/content/dependencies/generateAlbumStyleRules.js @@ -64,8 +64,9 @@ export default { ]); return ( - [...wallpaperRule, ...bannerRule, ...dataRule] + [wallpaperRule, bannerRule, dataRule] .filter(Boolean) + .flat() .join('\n')); }, }; -- cgit 1.3.0-6-gf8a5 From 26a147bff746dea09ec68df184fe0ea0e2920608 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sun, 1 Oct 2023 17:59:54 -0300 Subject: content: image: fix CW-decorating images which are missing --- src/content/dependencies/image.js | 1 + 1 file changed, 1 insertion(+) (limited to 'src/content') diff --git a/src/content/dependencies/image.js b/src/content/dependencies/image.js index 64fe8533..6c0aeecd 100644 --- a/src/content/dependencies/image.js +++ b/src/content/dependencies/image.js @@ -102,6 +102,7 @@ export default { const willReveal = slots.reveal && originalSrc && + !isMissingImageFile && !empty(data.contentWarnings); const willSquare = slots.square; -- cgit 1.3.0-6-gf8a5 From 08238e0673cc12f642bed0ad0a8f78d784a064df Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Fri, 6 Oct 2023 18:35:19 -0300 Subject: content: generateAlbumGalleryPage: stub album galleries --- .../generateAlbumGalleryNoTrackArtworksLine.js | 7 +++++++ src/content/dependencies/generateAlbumGalleryPage.js | 7 +++++++ src/content/dependencies/generateAlbumNavAccent.js | 16 ++++++++-------- 3 files changed, 22 insertions(+), 8 deletions(-) create mode 100644 src/content/dependencies/generateAlbumGalleryNoTrackArtworksLine.js (limited to 'src/content') diff --git a/src/content/dependencies/generateAlbumGalleryNoTrackArtworksLine.js b/src/content/dependencies/generateAlbumGalleryNoTrackArtworksLine.js new file mode 100644 index 00000000..ad99cb87 --- /dev/null +++ b/src/content/dependencies/generateAlbumGalleryNoTrackArtworksLine.js @@ -0,0 +1,7 @@ +export default { + extraDependencies: ['html', 'language'], + + generate: ({html, language}) => + html.tag('p', {class: 'quick-info'}, + language.$('albumGalleryPage.noTrackArtworksLine')), +}; diff --git a/src/content/dependencies/generateAlbumGalleryPage.js b/src/content/dependencies/generateAlbumGalleryPage.js index b98abc46..9551eb98 100644 --- a/src/content/dependencies/generateAlbumGalleryPage.js +++ b/src/content/dependencies/generateAlbumGalleryPage.js @@ -3,6 +3,7 @@ import {compareArrays, stitchArrays} from '#sugar'; export default { contentDependencies: [ 'generateAlbumGalleryCoverArtistsLine', + 'generateAlbumGalleryNoTrackArtworksLine', 'generateAlbumGalleryStatsLine', 'generateAlbumNavAccent', 'generateAlbumStyleRules', @@ -62,6 +63,11 @@ export default { relations.statsLine = relation('generateAlbumGalleryStatsLine', album); + if (album.tracks.every(track => !track.hasUniqueCoverArt)) { + relations.noTrackArtworksLine = + relation('generateAlbumGalleryNoTrackArtworksLine'); + } + if (query.coverArtistsForAllTracks) { relations.coverArtistsLine = relation('generateAlbumGalleryCoverArtistsLine', query.coverArtistsForAllTracks); @@ -131,6 +137,7 @@ export default { mainContent: [ relations.statsLine, relations.coverArtistsLine, + relations.noTrackArtworksLine, relations.coverGrid .slots({ diff --git a/src/content/dependencies/generateAlbumNavAccent.js b/src/content/dependencies/generateAlbumNavAccent.js index c79219bb..7eb1dac0 100644 --- a/src/content/dependencies/generateAlbumNavAccent.js +++ b/src/content/dependencies/generateAlbumNavAccent.js @@ -33,10 +33,8 @@ export default { } } - if (album.tracks.some(t => t.hasUniqueCoverArt)) { - relations.albumGalleryLink = - relation('linkAlbumGallery', album); - } + relations.albumGalleryLink = + relation('linkAlbumGallery', album); if (album.commentary || album.tracks.some(t => t.commentary)) { relations.albumCommentaryLink = @@ -49,6 +47,7 @@ export default { data(album, track) { return { hasMultipleTracks: album.tracks.length > 1, + galleryIsStub: album.tracks.every(t => !t.hasUniqueCoverArt), isTrackPage: !!track, }; }, @@ -66,10 +65,11 @@ export default { const {content: extraLinks = []} = slots.showExtraLinks && {content: [ - relations.albumGalleryLink?.slots({ - attributes: {class: slots.currentExtra === 'gallery' && 'current'}, - content: language.$('albumPage.nav.gallery'), - }), + (!data.galleryIsStub || slots.currentExtra === 'gallery') && + relations.albumGalleryLink?.slots({ + attributes: {class: slots.currentExtra === 'gallery' && 'current'}, + content: language.$('albumPage.nav.gallery'), + }), relations.albumCommentaryLink?.slots({ attributes: {class: slots.currentExtra === 'commentary' && 'current'}, -- cgit 1.3.0-6-gf8a5 From d7dcbbfe67ab7e8728da3f0503a6b1a20e9e2664 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Fri, 6 Oct 2023 18:37:08 -0300 Subject: content, css: supporting changes for better secondary nav dynamics --- src/content/dependencies/generatePageLayout.js | 47 +++++++++++++++----------- 1 file changed, 28 insertions(+), 19 deletions(-) (limited to 'src/content') diff --git a/src/content/dependencies/generatePageLayout.js b/src/content/dependencies/generatePageLayout.js index 5377f80d..cd831ba7 100644 --- a/src/content/dependencies/generatePageLayout.js +++ b/src/content/dependencies/generatePageLayout.js @@ -394,6 +394,10 @@ export default { const sidebarLeftHTML = generateSidebarHTML('leftSidebar', 'sidebar-left'); const sidebarRightHTML = generateSidebarHTML('rightSidebar', 'sidebar-right'); + + const hasSidebarLeft = !html.isBlank(sidebarLeftHTML); + const hasSidebarRight = !html.isBlank(sidebarRightHTML); + const collapseSidebars = slots.leftSidebarCollapse && slots.rightSidebarCollapse; const hasID = (() => { @@ -422,20 +426,20 @@ export default { processSkippers([ {condition: true, id: 'content', string: 'content'}, { - condition: !html.isBlank(sidebarLeftHTML), + condition: hasSidebarLeft, id: 'sidebar-left', string: - (html.isBlank(sidebarRightHTML) - ? 'sidebar' - : 'sidebar.left'), + (hasSidebarRight + ? 'sidebar.left' + : 'sidebar'), }, { - condition: !html.isBlank(sidebarRightHTML), + condition: hasSidebarRight, id: 'sidebar-right', string: - (html.isBlank(sidebarLeftHTML) - ? 'sidebar' - : 'sidebar.right'), + (hasSidebarLeft + ? 'sidebar.right' + : 'sidebar'), }, {condition: navHTML, id: 'header', string: 'header'}, {condition: footerHTML, id: 'footer', string: 'footer'}, @@ -507,11 +511,6 @@ export default { class: [ 'layout-columns', !collapseSidebars && 'vertical-when-thin', - (sidebarLeftHTML || sidebarRightHTML) && 'has-one-sidebar', - (sidebarLeftHTML && sidebarRightHTML) && 'has-two-sidebars', - !(sidebarLeftHTML || sidebarRightHTML) && 'has-zero-sidebars', - sidebarLeftHTML && 'has-sidebar-left', - sidebarRightHTML && 'has-sidebar-right', ], }, [ @@ -609,7 +608,7 @@ export default { html.tag('link', { rel: 'stylesheet', - href: to('shared.staticFile', 'site4.css', cachebust), + href: to('shared.staticFile', 'site5.css', cachebust), }), html.tag('style', [ @@ -624,12 +623,22 @@ export default { ]), html.tag('body', - // {style: body.style || ''}, [ - html.tag('div', {id: 'page-container'}, [ - skippersHTML, - layoutHTML, - ]), + html.tag('div', + { + id: 'page-container', + class: [ + (hasSidebarLeft || hasSidebarRight) && 'has-one-sidebar', + (hasSidebarLeft && hasSidebarRight) && 'has-two-sidebars', + !(hasSidebarLeft || hasSidebarRight) && 'has-zero-sidebars', + hasSidebarLeft && 'has-sidebar-left', + hasSidebarRight && 'has-sidebar-right', + ], + }, + [ + skippersHTML, + layoutHTML, + ]), // infoCardHTML, imageOverlayHTML, -- cgit 1.3.0-6-gf8a5 From 7cca97b865b7d9e299a7e1e6be9947a0fc0fb9c4 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Fri, 6 Oct 2023 18:38:31 -0300 Subject: content: generateAlbumGalleryPage: secondary nav on gallery page --- src/content/dependencies/generateAlbumGalleryPage.js | 6 ++++++ src/content/dependencies/generateAlbumSecondaryNav.js | 6 +++--- src/content/dependencies/linkAlbumDynamically.js | 14 ++++++++++++++ 3 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 src/content/dependencies/linkAlbumDynamically.js (limited to 'src/content') diff --git a/src/content/dependencies/generateAlbumGalleryPage.js b/src/content/dependencies/generateAlbumGalleryPage.js index 9551eb98..34581a16 100644 --- a/src/content/dependencies/generateAlbumGalleryPage.js +++ b/src/content/dependencies/generateAlbumGalleryPage.js @@ -6,6 +6,7 @@ export default { 'generateAlbumGalleryNoTrackArtworksLine', 'generateAlbumGalleryStatsLine', 'generateAlbumNavAccent', + 'generateAlbumSecondaryNav', 'generateAlbumStyleRules', 'generateCoverGrid', 'generatePageLayout', @@ -60,6 +61,9 @@ export default { relations.albumNavAccent = relation('generateAlbumNavAccent', album, null); + relations.secondaryNav = + relation('generateAlbumSecondaryNav', album); + relations.statsLine = relation('generateAlbumGalleryStatsLine', album); @@ -179,6 +183,8 @@ export default { }), }, ], + + secondaryNav: relations.secondaryNav, }); }, }; diff --git a/src/content/dependencies/generateAlbumSecondaryNav.js b/src/content/dependencies/generateAlbumSecondaryNav.js index 705dec51..8cf36fa4 100644 --- a/src/content/dependencies/generateAlbumSecondaryNav.js +++ b/src/content/dependencies/generateAlbumSecondaryNav.js @@ -5,7 +5,7 @@ export default { 'generateColorStyleVariables', 'generatePreviousNextLinks', 'generateSecondaryNav', - 'linkAlbum', + 'linkAlbumDynamically', 'linkGroup', 'linkTrack', ], @@ -64,14 +64,14 @@ export default { query.adjacentGroupInfo .map(({previousAlbum}) => (previousAlbum - ? relation('linkAlbum', previousAlbum) + ? relation('linkAlbumDynamically', previousAlbum) : null)); relations.nextAlbumLinks = query.adjacentGroupInfo .map(({nextAlbum}) => (nextAlbum - ? relation('linkAlbum', nextAlbum) + ? relation('linkAlbumDynamically', nextAlbum) : null)); } diff --git a/src/content/dependencies/linkAlbumDynamically.js b/src/content/dependencies/linkAlbumDynamically.js new file mode 100644 index 00000000..3adc64df --- /dev/null +++ b/src/content/dependencies/linkAlbumDynamically.js @@ -0,0 +1,14 @@ +export default { + contentDependencies: ['linkAlbumGallery', 'linkAlbum'], + extraDependencies: ['pagePath'], + + relations: (relation, album) => ({ + galleryLink: relation('linkAlbumGallery', album), + infoLink: relation('linkAlbum', album), + }), + + generate: (relations, {pagePath}) => + (pagePath[0] === 'albumGallery' + ? relations.galleryLink + : relations.infoLink), +}; -- cgit 1.3.0-6-gf8a5 From 388b3d381833edc40bbcabee0611b96a3e8f2879 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sat, 7 Oct 2023 09:17:30 -0300 Subject: content: generateGroupSecondaryNav --- .../dependencies/generateGroupGalleryPage.js | 7 ++ src/content/dependencies/generateGroupInfoPage.js | 6 ++ .../dependencies/generateGroupSecondaryNav.js | 99 ++++++++++++++++++++++ src/content/dependencies/linkGroupDynamically.js | 14 +++ 4 files changed, 126 insertions(+) create mode 100644 src/content/dependencies/generateGroupSecondaryNav.js create mode 100644 src/content/dependencies/linkGroupDynamically.js (limited to 'src/content') diff --git a/src/content/dependencies/generateGroupGalleryPage.js b/src/content/dependencies/generateGroupGalleryPage.js index 47239f55..71b9f508 100644 --- a/src/content/dependencies/generateGroupGalleryPage.js +++ b/src/content/dependencies/generateGroupGalleryPage.js @@ -11,6 +11,7 @@ export default { 'generateCoverCarousel', 'generateCoverGrid', 'generateGroupNavLinks', + 'generateGroupSecondaryNav', 'generateGroupSidebar', 'generatePageLayout', 'image', @@ -46,6 +47,9 @@ export default { relation('generateGroupNavLinks', group); if (sprawl.enableGroupUI) { + relations.secondaryNav = + relation('generateGroupSecondaryNav', group); + relations.sidebar = relation('generateGroupSidebar', group); } @@ -208,6 +212,9 @@ export default { relations.navLinks .slot('currentExtra', 'gallery') .content, + + secondaryNav: + relations.secondaryNav ?? null, }); }, }; diff --git a/src/content/dependencies/generateGroupInfoPage.js b/src/content/dependencies/generateGroupInfoPage.js index e162a26a..0583755e 100644 --- a/src/content/dependencies/generateGroupInfoPage.js +++ b/src/content/dependencies/generateGroupInfoPage.js @@ -4,6 +4,7 @@ export default { contentDependencies: [ 'generateContentHeading', 'generateGroupNavLinks', + 'generateGroupSecondaryNav', 'generateGroupSidebar', 'generatePageLayout', 'linkAlbum', @@ -32,6 +33,9 @@ export default { relation('generateGroupNavLinks', group); if (sprawl.enableGroupUI) { + relations.secondaryNav = + relation('generateGroupSecondaryNav', group); + relations.sidebar = relation('generateGroupSidebar', group); } @@ -161,6 +165,8 @@ export default { navLinkStyle: 'hierarchical', navLinks: relations.navLinks.content, + + secondaryNav: relations.secondaryNav ?? null, }); }, }; diff --git a/src/content/dependencies/generateGroupSecondaryNav.js b/src/content/dependencies/generateGroupSecondaryNav.js new file mode 100644 index 00000000..e3b28099 --- /dev/null +++ b/src/content/dependencies/generateGroupSecondaryNav.js @@ -0,0 +1,99 @@ +export default { + contentDependencies: [ + 'generateColorStyleVariables', + 'generatePreviousNextLinks', + 'generateSecondaryNav', + 'linkGroupDynamically', + 'linkListing', + ], + + extraDependencies: ['html', 'language', 'wikiData'], + + sprawl: ({listingSpec, wikiInfo}) => ({ + groupsByCategoryListing: + (wikiInfo.enableListings + ? listingSpec + .find(l => l.directory === 'groups/by-category') + : null), + }), + + query(sprawl, group) { + const groups = group.category.groups; + const index = groups.indexOf(group); + + return { + previousGroup: + (index > 0 + ? groups[index - 1] + : null), + + nextGroup: + (index < groups.length - 1 + ? groups[index + 1] + : null), + }; + }, + + relations(relation, query, sprawl, _group) { + const relations = {}; + + relations.secondaryNav = + relation('generateSecondaryNav'); + + if (sprawl.groupsByCategoryListing) { + relations.categoryLink = + relation('linkListing', sprawl.groupsByCategoryListing); + } + + relations.colorVariables = + relation('generateColorStyleVariables'); + + if (query.previousGroup || query.nextGroup) { + relations.previousNextLinks = + relation('generatePreviousNextLinks'); + } + + relations.previousGroupLink = + (query.previousGroup + ? relation('linkGroupDynamically', query.previousGroup) + : null); + + relations.nextGroupLink = + (query.nextGroup + ? relation('linkGroupDynamically', query.nextGroup) + : null); + + return relations; + }, + + data: (query, sprawl, group) => ({ + categoryName: group.category.name, + categoryColor: group.category.color, + }), + + generate(data, relations, {html, language}) { + const {content: previousNextPart} = + relations.previousNextLinks.slots({ + previousLink: relations.previousGroupLink, + nextLink: relations.nextGroupLink, + id: true, + }); + + const {categoryLink} = relations; + + categoryLink?.setSlot('content', data.categoryName); + + return relations.secondaryNav.slots({ + class: 'nav-links-groups', + content: + (!relations.previousGroupLink && !relations.nextGroupLink + ? categoryLink + : html.tag('span', + {style: relations.colorVariables.slot('color', data.categoryColor).content}, + [ + categoryLink.slot('color', false), + `(${language.formatUnitList(previousNextPart)})`, + ])), + }); + }, +}; diff --git a/src/content/dependencies/linkGroupDynamically.js b/src/content/dependencies/linkGroupDynamically.js new file mode 100644 index 00000000..90303ed1 --- /dev/null +++ b/src/content/dependencies/linkGroupDynamically.js @@ -0,0 +1,14 @@ +export default { + contentDependencies: ['linkGroupGallery', 'linkGroup'], + extraDependencies: ['pagePath'], + + relations: (relation, group) => ({ + galleryLink: relation('linkGroupGallery', group), + infoLink: relation('linkGroup', group), + }), + + generate: (relations, {pagePath}) => + (pagePath[0] === 'groupGallery' + ? relations.galleryLink + : relations.infoLink), +}; -- cgit 1.3.0-6-gf8a5 From 849bfa93f880a8611597e87f13eeb168795c6452 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sat, 7 Oct 2023 09:20:46 -0300 Subject: content: generateGroupGalleryPage: remove "another group" content link --- .../dependencies/generateGroupGalleryPage.js | 28 ++-------------------- 1 file changed, 2 insertions(+), 26 deletions(-) (limited to 'src/content') diff --git a/src/content/dependencies/generateGroupGalleryPage.js b/src/content/dependencies/generateGroupGalleryPage.js index 71b9f508..259f5dce 100644 --- a/src/content/dependencies/generateGroupGalleryPage.js +++ b/src/content/dependencies/generateGroupGalleryPage.js @@ -21,18 +21,8 @@ export default { extraDependencies: ['html', 'language', 'wikiData'], - sprawl({listingSpec, wikiInfo}) { - const sprawl = {}; - sprawl.enableGroupUI = wikiInfo.enableGroupUI; - - if (wikiInfo.enableListings && wikiInfo.enableGroupUI) { - sprawl.groupsByCategoryListing = - listingSpec - .find(l => l.directory === 'groups/by-category'); - } - - return sprawl; - }, + sprawl: ({wikiInfo}) => + ({enableGroupUI: wikiInfo.enableGroupUI}), relations(relation, sprawl, group) { const relations = {}; @@ -54,11 +44,6 @@ export default { relation('generateGroupSidebar', group); } - if (sprawl.groupsByCategoryListing) { - relations.groupListingLink = - relation('linkListing', sprawl.groupsByCategoryListing); - } - const carouselAlbums = filterItemsForCarousel(group.featuredAlbums); if (!empty(carouselAlbums)) { @@ -164,15 +149,6 @@ export default { })), })), - relations.groupListingLink && - html.tag('p', - {class: 'quick-info'}, - language.$('groupGalleryPage.anotherGroupLine', { - link: - relations.groupListingLink - .slot('content', language.$('groupGalleryPage.anotherGroupLine.link')), - })), - relations.coverGrid .slots({ links: relations.gridLinks, -- cgit 1.3.0-6-gf8a5 From 680cc3acdcabfe8d765275a7f78c4b254670fe2e Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Fri, 6 Oct 2023 09:13:35 -0300 Subject: content: generateAlbumCommentaryPage: don't break for coverless album --- src/content/dependencies/generateAlbumCommentaryPage.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/content') diff --git a/src/content/dependencies/generateAlbumCommentaryPage.js b/src/content/dependencies/generateAlbumCommentaryPage.js index 5c057b80..2982b037 100644 --- a/src/content/dependencies/generateAlbumCommentaryPage.js +++ b/src/content/dependencies/generateAlbumCommentaryPage.js @@ -33,8 +33,10 @@ export default { relation('generateAlbumNavAccent', album, null); if (album.commentary) { - relations.albumCommentaryCover = - relation('generateAlbumCoverArtwork', album); + if (album.hasCoverArt) { + relations.albumCommentaryCover = + relation('generateAlbumCoverArtwork', album); + } relations.albumCommentaryContent = relation('transformContent', album.commentary); -- cgit 1.3.0-6-gf8a5 From 822d0ad890cbdb2a780a2fdf7d1c1aa053fc1d77 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sun, 8 Oct 2023 12:43:00 -0300 Subject: infra: tweak how empty content function modules are handled --- src/content/dependencies/index.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/content') diff --git a/src/content/dependencies/index.js b/src/content/dependencies/index.js index 71802050..58bac0d2 100644 --- a/src/content/dependencies/index.js +++ b/src/content/dependencies/index.js @@ -177,7 +177,14 @@ export function watchContentDependencies({ // Just skip newly created files. They'll be processed again when // written. if (spec === undefined) { - contentDependencies[functionName] = null; + // For practical purposes the file is treated as though it doesn't + // even exist (undefined), rather than not being ready yet (null). + // Apart from if existing contents of the file were erased (but not + // the file itself), this value might already be set (to null!) by + // the readdir performed at the beginning to evaluate which files + // should be read and processed at least once before reporting all + // dependencies as ready. + delete contentDependencies[functionName]; return; } -- cgit 1.3.0-6-gf8a5 From eb7b9f1a7af122e8dc9282f14cc1e211ef068417 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 10 Oct 2023 09:19:11 -0300 Subject: content: generateAlbumGalleryPage: show album cover at start --- .../dependencies/generateAlbumGalleryPage.js | 76 ++++++++++++++-------- 1 file changed, 50 insertions(+), 26 deletions(-) (limited to 'src/content') diff --git a/src/content/dependencies/generateAlbumGalleryPage.js b/src/content/dependencies/generateAlbumGalleryPage.js index 34581a16..f61b1983 100644 --- a/src/content/dependencies/generateAlbumGalleryPage.js +++ b/src/content/dependencies/generateAlbumGalleryPage.js @@ -80,15 +80,25 @@ export default { relations.coverGrid = relation('generateCoverGrid'); - relations.links = - album.tracks.map(track => - relation('linkTrack', track)); - - relations.images = - album.tracks.map(track => - (track.hasUniqueCoverArt - ? relation('image', track.artTags) - : relation('image'))); + relations.links = [ + relation('linkAlbum', album), + + ... + album.tracks + .map(track => relation('linkTrack', track)), + ]; + + relations.images = [ + (album.hasCoverArt + ? relation('image', album.artTags) + : relation('image')), + + ... + album.tracks.map(track => + (track.hasUniqueCoverArt + ? relation('image', track.artTags) + : relation('image'))), + ]; return relations; }, @@ -99,27 +109,41 @@ export default { data.name = album.name; data.color = album.color; - data.names = - album.tracks.map(track => track.name); + data.names = [ + album.name, + ...album.tracks.map(track => track.name), + ]; - data.coverArtists = - album.tracks.map(track => { - if (query.coverArtistsForAllTracks) { - return null; - } + data.coverArtists = [ + (album.hasCoverArt + ? album.coverArtistContribs.map(({who: artist}) => artist.name) + : null), - if (track.hasUniqueCoverArt) { - return track.coverArtistContribs.map(({who: artist}) => artist.name); - } + ... + album.tracks.map(track => { + if (query.coverArtistsForAllTracks) { + return null; + } - return null; - }); + if (track.hasUniqueCoverArt) { + return track.coverArtistContribs.map(({who: artist}) => artist.name); + } - data.paths = - album.tracks.map(track => - (track.hasUniqueCoverArt - ? ['media.trackCover', track.album.directory, track.directory, track.coverArtFileExtension] - : null)); + return null; + }), + ]; + + data.paths = [ + (album.hasCoverArt + ? ['media.albumCover', album.directory, album.coverArtFileExtension] + : null), + + ... + album.tracks.map(track => + (track.hasUniqueCoverArt + ? ['media.trackCover', track.album.directory, track.directory, track.coverArtFileExtension] + : null)), + ]; return data; }, -- cgit 1.3.0-6-gf8a5 From 962e6d1777feb69711e33b16d11d322edd1744cd Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 10 Oct 2023 09:37:14 -0300 Subject: content: generateGroupNavLinks: remove previous/next --- src/content/dependencies/generateGroupNavLinks.js | 44 ++--------------------- 1 file changed, 3 insertions(+), 41 deletions(-) (limited to 'src/content') diff --git a/src/content/dependencies/generateGroupNavLinks.js b/src/content/dependencies/generateGroupNavLinks.js index 68341e0a..5cde2ab4 100644 --- a/src/content/dependencies/generateGroupNavLinks.js +++ b/src/content/dependencies/generateGroupNavLinks.js @@ -2,10 +2,8 @@ import {empty} from '#sugar'; export default { contentDependencies: [ - 'generatePreviousNextLinks', 'linkGroup', 'linkGroupGallery', - 'linkGroupExtra', ], extraDependencies: ['html', 'language', 'wikiData'], @@ -28,24 +26,6 @@ export default { relations.mainLink = relation('linkGroup', group); - relations.previousNextLinks = - relation('generatePreviousNextLinks'); - - const groups = sprawl.groupCategoryData - .flatMap(category => category.groups); - - const index = groups.indexOf(group); - - if (index > 0) { - relations.previousLink = - relation('linkGroupExtra', groups[index - 1]); - } - - if (index < groups.length - 1) { - relations.nextLink = - relation('linkGroupExtra', groups[index + 1]); - } - relations.infoLink = relation('linkGroup', group); @@ -80,26 +60,6 @@ export default { ]; } - const previousNextLinks = - (relations.previousLink || relations.nextLink) && - relations.previousNextLinks.slots({ - previousLink: - relations.previousLink - ?.slot('extra', slots.currentExtra) - ?.content - ?? null, - nextLink: - relations.nextLink - ?.slot('extra', slots.currentExtra) - ?.content - ?? null, - }); - - const previousNextPart = - previousNextLinks && - language.formatUnitList( - previousNextLinks.content.filter(Boolean)); - const infoLink = relations.infoLink.slots({ attributes: {class: slots.currentExtra === null && 'current'}, @@ -119,7 +79,9 @@ export default { : language.formatUnitList([infoLink, ...extraLinks])); const accent = - `(${[extrasPart, previousNextPart].filter(Boolean).join('; ')})`; + (extrasPart + ? `(${extrasPart})` + : null); return [ {auto: 'home'}, -- cgit 1.3.0-6-gf8a5 From 3a871cf43a11b87392d26320c736b516925da684 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Wed, 11 Oct 2023 14:32:28 -0300 Subject: implement flash act pages, rework flash sidebar layout --- .../dependencies/generateFlashActGalleryPage.js | 91 ++++++++ .../dependencies/generateFlashActNavAccent.js | 74 +++++++ .../dependencies/generateFlashActSidebar.js | 209 ++++++++++++++++++ src/content/dependencies/generateFlashIndexPage.js | 21 +- src/content/dependencies/generateFlashInfoPage.js | 17 +- src/content/dependencies/generateFlashNavAccent.js | 7 +- src/content/dependencies/generateFlashSidebar.js | 236 --------------------- src/content/dependencies/linkFlashAct.js | 14 ++ src/content/dependencies/listArtTagNetwork.js | 1 + 9 files changed, 405 insertions(+), 265 deletions(-) create mode 100644 src/content/dependencies/generateFlashActGalleryPage.js create mode 100644 src/content/dependencies/generateFlashActNavAccent.js create mode 100644 src/content/dependencies/generateFlashActSidebar.js delete mode 100644 src/content/dependencies/generateFlashSidebar.js create mode 100644 src/content/dependencies/linkFlashAct.js create mode 100644 src/content/dependencies/listArtTagNetwork.js (limited to 'src/content') diff --git a/src/content/dependencies/generateFlashActGalleryPage.js b/src/content/dependencies/generateFlashActGalleryPage.js new file mode 100644 index 00000000..8eea58bb --- /dev/null +++ b/src/content/dependencies/generateFlashActGalleryPage.js @@ -0,0 +1,91 @@ +import {stitchArrays} from '#sugar'; + +export default { + contentDependencies: [ + 'generateCoverGrid', + 'generateFlashActNavAccent', + 'generateFlashActSidebar', + 'generatePageLayout', + 'image', + 'linkFlash', + 'linkFlashIndex', + ], + + extraDependencies: ['html', 'language'], + + relations: (relation, act) => ({ + layout: + relation('generatePageLayout'), + + flashIndexLink: + relation('linkFlashIndex'), + + flashActNavAccent: + relation('generateFlashActNavAccent', act), + + sidebar: + relation('generateFlashActSidebar', act, null), + + coverGrid: + relation('generateCoverGrid'), + + coverGridImages: + act.flashes + .map(_flash => relation('image')), + + flashLinks: + act.flashes + .map(flash => relation('linkFlash', flash)), + }), + + data: (act) => ({ + name: act.name, + color: act.color, + + flashNames: + act.flashes.map(flash => flash.name), + + flashCoverPaths: + act.flashes.map(flash => + ['media.flashArt', flash.directory, flash.coverArtFileExtension]) + }), + + generate(data, relations, {html, language}) { + return relations.layout.slots({ + title: + language.$('flashPage.title', { + flash: new html.Tag(null, null, data.name), + }), + + color: data.color, + headingMode: 'static', + + mainClasses: ['flash-index'], + mainContent: [ + relations.coverGrid.slots({ + links: relations.flashLinks, + names: data.flashNames, + lazy: 6, + + images: + stitchArrays({ + image: relations.coverGridImages, + path: data.flashCoverPaths, + }).map(({image, path}) => + image.slot('path', path)), + }), + ], + + navLinkStyle: 'hierarchical', + navLinks: [ + {auto: 'home'}, + {html: relations.flashIndexLink}, + {auto: 'current'}, + ], + + navBottomRowContent: relations.flashActNavAccent, + + ...relations.sidebar, + }); + }, +}; diff --git a/src/content/dependencies/generateFlashActNavAccent.js b/src/content/dependencies/generateFlashActNavAccent.js new file mode 100644 index 00000000..98504385 --- /dev/null +++ b/src/content/dependencies/generateFlashActNavAccent.js @@ -0,0 +1,74 @@ +import {empty} from '#sugar'; + +export default { + contentDependencies: [ + 'generatePreviousNextLinks', + 'linkFlashAct', + ], + + extraDependencies: ['html', 'language', 'wikiData'], + + sprawl({flashActData}) { + return {flashActData}; + }, + + query(sprawl, flashAct) { + // Like with generateFlashNavAccent, don't sort chronologically here. + const flashActs = + sprawl.flashActData; + + const index = flashActs.indexOf(flashAct); + + const previousFlashAct = + (index > 0 + ? flashActs[index - 1] + : null); + + const nextFlashAct = + (index < flashActs.length - 1 + ? flashActs[index + 1] + : null); + + return {previousFlashAct, nextFlashAct}; + }, + + relations(relation, query) { + const relations = {}; + + if (query.previousFlashAct || query.nextFlashAct) { + relations.previousNextLinks = + relation('generatePreviousNextLinks'); + + relations.previousFlashActLink = + (query.previousFlashAct + ? relation('linkFlashAct', query.previousFlashAct) + : null); + + relations.nextFlashActLink = + (query.nextFlashAct + ? relation('linkFlashAct', query.nextFlashAct) + : null); + } + + return relations; + }, + + generate(relations, {html, language}) { + const {content: previousNextLinks = []} = + relations.previousNextLinks && + relations.previousNextLinks.slots({ + previousLink: relations.previousFlashActLink, + nextLink: relations.nextFlashActLink, + }); + + const allLinks = [ + ...previousNextLinks, + ].filter(Boolean); + + if (empty(allLinks)) { + return html.blank(); + } + + return `(${language.formatUnitList(allLinks)})`; + }, +}; diff --git a/src/content/dependencies/generateFlashActSidebar.js b/src/content/dependencies/generateFlashActSidebar.js new file mode 100644 index 00000000..ff5dc049 --- /dev/null +++ b/src/content/dependencies/generateFlashActSidebar.js @@ -0,0 +1,209 @@ +import find from '#find'; +import {stitchArrays} from '#sugar'; + +export default { + contentDependencies: ['linkFlash', 'linkFlashAct', 'linkFlashIndex'], + extraDependencies: ['getColors', 'html', 'language', 'wikiData'], + + // So help me Gog, the flash sidebar is heavily hard-coded. + + sprawl: ({flashActData}) => ({flashActData}), + + query(sprawl, act, flash) { + const findFlashAct = directory => + find.flashAct(directory, sprawl.flashActData, {mode: 'error'}); + + const sideFirstActs = [ + findFlashAct('flash-act:a1'), + findFlashAct('flash-act:a6a1'), + findFlashAct('flash-act:hiveswap'), + findFlashAct('flash-act:cool-and-new-web-comic'), + findFlashAct('flash-act:psycholonials'), + ]; + + const sideNames = [ + `Side 1 (Acts 1-5)`, + `Side 2 (Acts 6-7)`, + `Additional Canon`, + `Fan Adventures`, + `More Flashes & Games`, + ]; + + const sideColors = [ + '#4ac925', + '#3796c6', + '#f2a400', + '#c466ff', + '#32c7fe', + ]; + + const sideFirstActIndexes = + sideFirstActs + .map(act => sprawl.flashActData.indexOf(act)); + + const actSideIndexes = + sprawl.flashActData + .map((act, actIndex) => actIndex) + .map(actIndex => + sideFirstActIndexes + .findIndex((firstActIndex, i) => + i === sideFirstActs.length - 1 || + firstActIndex <= actIndex && + sideFirstActIndexes[i + 1] > actIndex)); + + const sideActs = + sideNames + .map((name, sideIndex) => + stitchArrays({ + act: sprawl.flashActData, + actSideIndex: actSideIndexes, + }).filter(({actSideIndex}) => actSideIndex === sideIndex) + .map(({act}) => act)); + + const currentActFlashes = + act.flashes; + + const currentFlashIndex = + currentActFlashes.indexOf(flash); + + const currentSideIndex = + actSideIndexes[sprawl.flashActData.indexOf(act)]; + + const currentSideActs = + sideActs[currentSideIndex]; + + const currentActIndex = + currentSideActs.indexOf(act); + + const visualNovelActs = [ + findFlashAct('flash-act:friendsim'), + findFlashAct('flash-act:pesterquest'), + findFlashAct('flash-act:psycholonials'), + ]; + + const gameSeriesActs = [ + findFlashAct('flash-act:hiveswap'), + ]; + + const listTerminology = + (visualNovelActs.includes(act) + ? 'volumesInThisGame' + : gameSeriesActs.includes(act) + ? 'gamesInThisSeries' + : act === findFlashAct('flash-act:other-fan-adventures') + ? 'flashesInThisSection' + : currentSideIndex <= 1 + ? 'flashesInThisAct' + : currentSideIndex === 3 + ? 'flashesInThisStory' + : 'entriesInThisSection'); + + return { + sideNames, + sideColors, + sideActs, + + currentSideIndex, + currentSideActs, + currentActIndex, + currentActFlashes, + currentFlashIndex, + + listTerminology, + }; + }, + + relations: (relation, query, sprawl, act, _flash) => ({ + currentActLink: + relation('linkFlashAct', act), + + flashIndexLink: + relation('linkFlashIndex'), + + sideActLinks: + query.sideActs + .map(acts => acts + .map(act => relation('linkFlashAct', act))), + + currentActFlashLinks: + act.flashes + .map(flash => relation('linkFlash', flash)), + }), + + data: (query, sprawl, act, flash) => ({ + isFlashActPage: !flash, + + sideColors: query.sideColors, + sideNames: query.sideNames, + + currentSideIndex: query.currentSideIndex, + currentActIndex: query.currentActIndex, + currentFlashIndex: query.currentFlashIndex, + + listTerminology: query.listTerminology, + }), + + generate(data, relations, {getColors, html, language}) { + const currentActBox = html.tags([ + html.tag('h1', relations.currentActLink), + + html.tag('details', + (data.isFlashActPage + ? {} + : {class: 'current', open: true}), + [ + html.tag('summary', + html.tag('span', {class: 'group-name'}, + language.$('flashSidebar.flashList', data.listTerminology))), + + html.tag('ul', + relations.currentActFlashLinks + .map((flashLink, index) => + html.tag('li', + {class: index === data.currentFlashIndex && 'current'}, + flashLink))), + ]), + ]); + + const sideMapBox = html.tags([ + html.tag('h1', relations.flashIndexLink), + + stitchArrays({ + sideName: data.sideNames, + sideColor: data.sideColors, + actLinks: relations.sideActLinks, + }).map(({sideName, sideColor, actLinks}, sideIndex) => + html.tag('details', { + class: sideIndex === data.currentSideIndex && 'current', + open: data.isFlashActPage && sideIndex === data.currentSideIndex, + style: sideColor && `--primary-color: ${getColors(sideColor).primary}` + }, [ + html.tag('summary', + html.tag('span', {class: 'group-name'}, + sideName)), + + html.tag('ul', + actLinks.map((actLink, actIndex) => + html.tag('li', + {class: + sideIndex === data.currentSideIndex && + actIndex === data.currentActIndex && + 'current'}, + actLink))), + ])), + ]); + + return { + leftSidebarMultiple: + (data.isFlashActPage + ? [ + {content: sideMapBox}, + {content: currentActBox}, + ] + : [ + {content: currentActBox}, + {content: sideMapBox}, + ]), + }; + }, +}; diff --git a/src/content/dependencies/generateFlashIndexPage.js b/src/content/dependencies/generateFlashIndexPage.js index 66588fdb..ad1dab94 100644 --- a/src/content/dependencies/generateFlashIndexPage.js +++ b/src/content/dependencies/generateFlashIndexPage.js @@ -7,6 +7,7 @@ export default { 'generatePageLayout', 'image', 'linkFlash', + 'linkFlashAct', ], extraDependencies: ['html', 'language', 'wikiData'], @@ -36,9 +37,9 @@ export default { query.flashActs .map(() => relation('generateColorStyleVariables')), - actFirstFlashLinks: + actLinks: query.flashActs - .map(act => relation('linkFlash', act.flashes[0])), + .map(act => relation('linkFlashAct', act)), actCoverGrids: query.flashActs @@ -58,7 +59,7 @@ export default { data: (query) => ({ jumpLinkAnchors: query.jumpActs - .map(act => act.anchor), + .map(act => act.directory), jumpLinkColors: query.jumpActs @@ -70,16 +71,12 @@ export default { actAnchors: query.flashActs - .map(act => act.anchor), + .map(act => act.directory), actColors: query.flashActs .map(act => act.color), - actNames: - query.flashActs - .map(act => act.name), - actCoverGridNames: query.flashActs .map(act => act.flashes @@ -118,10 +115,9 @@ export default { stitchArrays({ colorVariables: relations.actColorVariables, - firstFlashLink: relations.actFirstFlashLinks, + actLink: relations.actLinks, anchor: data.actAnchors, color: data.actColors, - name: data.actNames, coverGrid: relations.actCoverGrids, coverGridImages: relations.actCoverGridImages, @@ -132,8 +128,7 @@ export default { colorVariables, anchor, color, - name, - firstFlashLink, + actLink, coverGrid, coverGridImages, @@ -146,7 +141,7 @@ export default { id: anchor, style: colorVariables.slot('color', color).content, }, - firstFlashLink.slot('content', name)), + actLink), coverGrid.slots({ links: coverGridLinks, diff --git a/src/content/dependencies/generateFlashInfoPage.js b/src/content/dependencies/generateFlashInfoPage.js index 553d2f54..09c6b37c 100644 --- a/src/content/dependencies/generateFlashInfoPage.js +++ b/src/content/dependencies/generateFlashInfoPage.js @@ -4,13 +4,13 @@ export default { contentDependencies: [ 'generateContentHeading', 'generateContributionList', + 'generateFlashActSidebar', 'generateFlashCoverArtwork', 'generateFlashNavAccent', - 'generateFlashSidebar', 'generatePageLayout', 'generateTrackList', 'linkExternal', - 'linkFlashIndex', + 'linkFlashAct', ], extraDependencies: ['html', 'language'], @@ -41,7 +41,7 @@ export default { relation('generatePageLayout'); relations.sidebar = - relation('generateFlashSidebar', flash); + relation('generateFlashActSidebar', flash.act, flash); if (query.urls) { relations.externalLinks = @@ -59,8 +59,8 @@ export default { const nav = sections.nav = {}; - nav.flashIndexLink = - relation('linkFlashIndex'); + nav.flashActLink = + relation('linkFlashAct', flash.act); nav.flashNavAccent = relation('generateFlashNavAccent', flash); @@ -163,14 +163,11 @@ export default { navLinkStyle: 'hierarchical', navLinks: [ {auto: 'home'}, - {html: sec.nav.flashIndexLink}, + {html: sec.nav.flashActLink.slot('color', false)}, {auto: 'current'}, ], - navBottomRowContent: - sec.nav.flashNavAccent.slots({ - showFlashNavigation: true, - }), + navBottomRowContent: sec.nav.flashNavAccent, ...relations.sidebar, }); diff --git a/src/content/dependencies/generateFlashNavAccent.js b/src/content/dependencies/generateFlashNavAccent.js index 2c8205d3..57196d06 100644 --- a/src/content/dependencies/generateFlashNavAccent.js +++ b/src/content/dependencies/generateFlashNavAccent.js @@ -55,13 +55,8 @@ export default { return relations; }, - slots: { - showFlashNavigation: {type: 'boolean', default: false}, - }, - - generate(relations, slots, {html, language}) { + generate(relations, {html, language}) { const {content: previousNextLinks = []} = - slots.showFlashNavigation && relations.previousNextLinks && relations.previousNextLinks.slots({ previousLink: relations.previousFlashLink, diff --git a/src/content/dependencies/generateFlashSidebar.js b/src/content/dependencies/generateFlashSidebar.js deleted file mode 100644 index ba761922..00000000 --- a/src/content/dependencies/generateFlashSidebar.js +++ /dev/null @@ -1,236 +0,0 @@ -import {stitchArrays} from '#sugar'; - -export default { - contentDependencies: ['linkFlash', 'linkFlashIndex'], - extraDependencies: ['html', 'wikiData'], - - // So help me Gog, the flash sidebar is heavily hard-coded. - - sprawl: ({flashActData}) => ({flashActData}), - - query(sprawl, flash) { - const flashActs = - sprawl.flashActData.slice(); - - const act6 = - flashActs - .findIndex(act => act.name.startsWith('Act 6')); - - const postCanon = - flashActs - .findIndex(act => act.name.includes('Post Canon')); - - const outsideCanon = - postCanon + - flashActs - .slice(postCanon) - .findIndex(act => !act.name.includes('Post Canon')); - - const currentAct = flash.act; - - const actIndex = - flashActs - .indexOf(currentAct); - - const side = - (actIndex < 0 - ? 0 - : actIndex < act6 - ? 1 - : actIndex < outsideCanon - ? 2 - : 3); - - const sideActs = - flashActs - .filter((act, index) => - act.name.startsWith('Act 1') || - act.name.startsWith('Act 6 Act 1') || - act.name.startsWith('Hiveswap') || - index >= outsideCanon); - - const currentSideIndex = - sideActs - .findIndex(act => { - if (act.name.startsWith('Act 1')) { - return side === 1; - } else if (act.name.startsWith('Act 6 Act 1')) { - return side === 2; - } else if (act.name.startsWith('Hiveswap Act 1')) { - return side === 3; - } else { - return act === currentAct; - } - }) - - const sideNames = - sideActs - .map(act => { - if (act.name.startsWith('Act 1')) { - return `Side 1 (Acts 1-5)`; - } else if (act.name.startsWith('Act 6 Act 1')) { - return `Side 2 (Acts 6-7)`; - } else if (act.name.startsWith('Hiveswap Act 1')) { - return `Outside Canon (Misc. Games)`; - } else { - return act.name; - } - }); - - const sideColors = - sideActs - .map(act => { - if (act.name.startsWith('Act 1')) { - return '#4ac925'; - } else if (act.name.startsWith('Act 6 Act 1')) { - return '#1076a2'; - } else if (act.name.startsWith('Hiveswap Act 1')) { - return '#008282'; - } else { - return act.color; - } - }); - - const sideFirstFlashes = - sideActs - .map(act => act.flashes[0]); - - const scopeActs = - flashActs - .filter((act, index) => { - if (index < act6) { - return side === 1; - } else if (index < outsideCanon) { - return side === 2; - } else { - return false; - } - }); - - const currentScopeActIndex = - scopeActs.indexOf(currentAct); - - const scopeActNames = - scopeActs - .map(act => act.name); - - const scopeActFirstFlashes = - scopeActs - .map(act => act.flashes[0]); - - const currentActFlashes = - currentAct.flashes; - - const currentFlashIndex = - currentActFlashes - .indexOf(flash); - - return { - currentSideIndex, - sideNames, - sideColors, - sideFirstFlashes, - - currentScopeActIndex, - scopeActNames, - scopeActFirstFlashes, - - currentActFlashes, - currentFlashIndex, - }; - }, - - relations: (relation, query) => ({ - flashIndexLink: - relation('linkFlashIndex'), - - sideFirstFlashLinks: - query.sideFirstFlashes - .map(flash => relation('linkFlash', flash)), - - scopeActFirstFlashLinks: - query.scopeActFirstFlashes - .map(flash => relation('linkFlash', flash)), - - currentActFlashLinks: - query.currentActFlashes - .map(flash => relation('linkFlash', flash)), - }), - - data: (query) => ({ - currentSideIndex: query.currentSideIndex, - sideColors: query.sideColors, - sideNames: query.sideNames, - - currentScopeActIndex: query.currentScopeActIndex, - scopeActNames: query.scopeActNames, - - currentFlashIndex: query.currentFlashIndex, - }), - - generate(data, relations, {html}) { - const currentActFlashList = - html.tag('ul', - relations.currentActFlashLinks - .map((flashLink, index) => - html.tag('li', - {class: index === data.currentFlashIndex && 'current'}, - flashLink))); - - return { - leftSidebarContent: html.tags([ - html.tag('h1', relations.flashIndexLink), - - html.tag('dl', - stitchArrays({ - sideFirstFlashLink: relations.sideFirstFlashLinks, - sideColor: data.sideColors, - sideName: data.sideNames, - }).map(({sideFirstFlashLink, sideColor, sideName}, index) => [ - // Side acts are displayed whether part of Homestuck proper or - // not, and they're always the same regardless the current flash - // page. Scope acts, if applicable, and the list of flashes - // belonging to the current act, will be inserted after the - // heading of the current side. - html.tag('dt', - {class: [ - 'side', - index === data.currentSideIndex && 'current', - ]}, - sideFirstFlashLink.slots({ - color: sideColor, - content: sideName, - })), - - // Scope acts are only applicable when inside Homestuck proper. - // Hiveswap and all acts beyond are each considered to be its - // own "side". - index === data.currentSideIndex && - data.currentScopeActIndex !== -1 && - stitchArrays({ - scopeActFirstFlashLink: relations.scopeActFirstFlashLinks, - scopeActName: data.scopeActNames, - }).map(({scopeActFirstFlashLink, scopeActName}, index) => [ - html.tag('dt', - {class: index === data.currentScopeActIndex && 'current'}, - scopeActFirstFlashLink.slot('content', scopeActName)), - - // Inside Homestuck proper, the flash list of the current - // act should show after the heading for the relevant - // scope act. - index === data.currentScopeActIndex && - html.tag('dd', currentActFlashList), - ]), - - // Outside of Homestuck proper, the current act is represented - // by a side instead of a scope act, so place its flash list - // after the heading for the relevant side. - index === data.currentSideIndex && - data.currentScopeActIndex === -1 && - html.tag('dd', currentActFlashList), - ])), - - ]), - }; - }, -}; diff --git a/src/content/dependencies/linkFlashAct.js b/src/content/dependencies/linkFlashAct.js new file mode 100644 index 00000000..fbb819ed --- /dev/null +++ b/src/content/dependencies/linkFlashAct.js @@ -0,0 +1,14 @@ +export default { + contentDependencies: ['linkThing'], + extraDependencies: ['html'], + + relations: (relation, flashAct) => + ({link: relation('linkThing', 'localized.flashActGallery', flashAct)}), + + data: (flashAct) => + ({name: flashAct.name}), + + generate: (data, relations, {html}) => + relations.link + .slot('content', new html.Tag(null, null, data.name)), +}; diff --git a/src/content/dependencies/listArtTagNetwork.js b/src/content/dependencies/listArtTagNetwork.js new file mode 100644 index 00000000..b3a54747 --- /dev/null +++ b/src/content/dependencies/listArtTagNetwork.js @@ -0,0 +1 @@ +export default {generate() {}}; -- cgit 1.3.0-6-gf8a5 From 428e14394209f55215168b9acbe680a982f9beb6 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Wed, 11 Oct 2023 15:11:42 -0300 Subject: content: transformContent: add [[flash-act]] tag --- src/content/dependencies/transformContent.js | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/content') diff --git a/src/content/dependencies/transformContent.js b/src/content/dependencies/transformContent.js index 9a5ac456..3c2c3521 100644 --- a/src/content/dependencies/transformContent.js +++ b/src/content/dependencies/transformContent.js @@ -53,6 +53,10 @@ export const replacerSpec = { } }, }, + 'flash-act': { + find: 'flashAct', + link: 'flashAct', + }, group: { find: 'group', link: 'groupInfo', @@ -119,6 +123,7 @@ const linkThingRelationMap = { artist: 'linkArtist', artistGallery: 'linkArtistGallery', flash: 'linkFlash', + flashAct: 'linkFlashAct', groupInfo: 'linkGroup', groupGallery: 'linkGroupGallery', listing: 'linkListing', -- cgit 1.3.0-6-gf8a5 From 63075c650bf990407e9eefe3e9f135b2425a2ded Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Mon, 23 Oct 2023 13:48:47 -0300 Subject: content, css: linkTemplate: new linkless slot --- src/content/dependencies/linkTemplate.js | 35 ++++++++++++++++++-------------- src/content/dependencies/linkThing.js | 2 ++ 2 files changed, 22 insertions(+), 15 deletions(-) (limited to 'src/content') diff --git a/src/content/dependencies/linkTemplate.js b/src/content/dependencies/linkTemplate.js index 7206e960..d9af726c 100644 --- a/src/content/dependencies/linkTemplate.js +++ b/src/content/dependencies/linkTemplate.js @@ -15,6 +15,7 @@ export default { href: {type: 'string'}, path: {validate: v => v.validateArrayItems(v.isString)}, hash: {type: 'string'}, + linkless: {type: 'boolean', default: false}, tooltip: {type: 'string'}, attributes: {validate: v => v.isAttributes}, @@ -33,25 +34,29 @@ export default { let style; let title; - if (slots.href) { - href = encodeURI(slots.href); - } else if (!empty(slots.path)) { - href = to(...slots.path); + if (slots.linkless) { + href = null; } else { - href = ''; - } + if (slots.href) { + href = encodeURI(slots.href); + } else if (!empty(slots.path)) { + href = to(...slots.path); + } else { + href = ''; + } - if (appendIndexHTML) { - if ( - /^(?!https?:\/\/).+\/$/.test(href) && - href.endsWith('/') - ) { - href += 'index.html'; + if (appendIndexHTML) { + if ( + /^(?!https?:\/\/).+\/$/.test(href) && + href.endsWith('/') + ) { + href += 'index.html'; + } } - } - if (slots.hash) { - href += (slots.hash.startsWith('#') ? '' : '#') + slots.hash; + if (slots.hash) { + href += (slots.hash.startsWith('#') ? '' : '#') + slots.hash; + } } if (slots.color) { diff --git a/src/content/dependencies/linkThing.js b/src/content/dependencies/linkThing.js index e661ca7c..b20b132b 100644 --- a/src/content/dependencies/linkThing.js +++ b/src/content/dependencies/linkThing.js @@ -36,6 +36,7 @@ export default { }, anchor: {type: 'boolean', default: false}, + linkless: {type: 'boolean', default: false}, attributes: {validate: v => v.isAttributes}, hash: {type: 'string'}, @@ -78,6 +79,7 @@ export default { attributes: slots.attributes, hash: slots.hash, + linkless: slots.linkless, }); }, } -- cgit 1.3.0-6-gf8a5 From 22b1823dd82bf4fd2063d121c743d02e452fe7f3 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Mon, 23 Oct 2023 13:49:20 -0300 Subject: content: generateAlbimSidebarTrackSection: handle commentary-less tracks --- .../dependencies/generateAlbumCommentaryPage.js | 1 + .../generateAlbumSidebarTrackSection.js | 24 +++++++++++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) (limited to 'src/content') diff --git a/src/content/dependencies/generateAlbumCommentaryPage.js b/src/content/dependencies/generateAlbumCommentaryPage.js index 2982b037..3ad1549e 100644 --- a/src/content/dependencies/generateAlbumCommentaryPage.js +++ b/src/content/dependencies/generateAlbumCommentaryPage.js @@ -207,6 +207,7 @@ export default { section.slots({ anchor: true, open: true, + mode: 'commentary', })), ], }); diff --git a/src/content/dependencies/generateAlbumSidebarTrackSection.js b/src/content/dependencies/generateAlbumSidebarTrackSection.js index 00e9b621..d3cd37f0 100644 --- a/src/content/dependencies/generateAlbumSidebarTrackSection.js +++ b/src/content/dependencies/generateAlbumSidebarTrackSection.js @@ -37,12 +37,21 @@ export default { trackSection.tracks .map(track => track.directory); + data.tracksAreMissingCommentary = + trackSection.tracks + .map(track => !track.commentary); + return data; }, slots: { anchor: {type: 'boolean'}, open: {type: 'boolean'}, + + mode: { + validate: v => v.is('info', 'commentary'), + default: 'info', + }, }, generate(data, relations, slots, {getColors, html, language}) { @@ -62,14 +71,23 @@ export default { relations.trackLinks.map((trackLink, index) => html.tag('li', { - class: + class: [ data.includesCurrentTrack && index === data.currentTrackIndex && - 'current', + 'current', + + slots.mode === 'commentary' && + data.tracksAreMissingCommentary[index] && + 'no-commentary', + ], }, language.$('albumSidebar.trackList.item', { track: - (slots.anchor + (slots.mode === 'commentary' && data.tracksAreMissingCommentary[index] + ? trackLink.slots({ + linkless: true, + }) + : slots.anchor ? trackLink.slots({ anchor: true, hash: data.trackDirectories[index], -- cgit 1.3.0-6-gf8a5 From f64118417ea45178cfa50c181c9c102e5c8ff1b5 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 24 Oct 2023 10:48:10 -0300 Subject: content: generateFlashActSidebar: use flash act listTermonology --- .../dependencies/generateFlashActSidebar.js | 31 ++++++---------------- 1 file changed, 8 insertions(+), 23 deletions(-) (limited to 'src/content') diff --git a/src/content/dependencies/generateFlashActSidebar.js b/src/content/dependencies/generateFlashActSidebar.js index ff5dc049..f8ad33db 100644 --- a/src/content/dependencies/generateFlashActSidebar.js +++ b/src/content/dependencies/generateFlashActSidebar.js @@ -75,27 +75,9 @@ export default { const currentActIndex = currentSideActs.indexOf(act); - const visualNovelActs = [ - findFlashAct('flash-act:friendsim'), - findFlashAct('flash-act:pesterquest'), - findFlashAct('flash-act:psycholonials'), - ]; - - const gameSeriesActs = [ - findFlashAct('flash-act:hiveswap'), - ]; - - const listTerminology = - (visualNovelActs.includes(act) - ? 'volumesInThisGame' - : gameSeriesActs.includes(act) - ? 'gamesInThisSeries' - : act === findFlashAct('flash-act:other-fan-adventures') - ? 'flashesInThisSection' - : currentSideIndex <= 1 + const fallbackListTerminology = + (currentSideIndex <= 1 ? 'flashesInThisAct' - : currentSideIndex === 3 - ? 'flashesInThisStory' : 'entriesInThisSection'); return { @@ -109,7 +91,7 @@ export default { currentActFlashes, currentFlashIndex, - listTerminology, + fallbackListTerminology, }; }, @@ -140,7 +122,8 @@ export default { currentActIndex: query.currentActIndex, currentFlashIndex: query.currentFlashIndex, - listTerminology: query.listTerminology, + customListTerminology: act.listTerminology, + fallbackListTerminology: query.fallbackListTerminology, }), generate(data, relations, {getColors, html, language}) { @@ -154,7 +137,9 @@ export default { [ html.tag('summary', html.tag('span', {class: 'group-name'}, - language.$('flashSidebar.flashList', data.listTerminology))), + (data.customListTerminology + ? language.sanitize(data.customListTerminology) + : language.$('flashSidebar.flashList', data.fallbackListTerminology)))), html.tag('ul', relations.currentActFlashLinks -- cgit 1.3.0-6-gf8a5 From 0df06e2f5d7bb3aeaccfd6b2187eec6e8f40755f Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 24 Oct 2023 11:33:12 -0300 Subject: content: generateFlashActSidebar: rearrange some sides --- src/content/dependencies/generateFlashActSidebar.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/content') diff --git a/src/content/dependencies/generateFlashActSidebar.js b/src/content/dependencies/generateFlashActSidebar.js index f8ad33db..bd6063c9 100644 --- a/src/content/dependencies/generateFlashActSidebar.js +++ b/src/content/dependencies/generateFlashActSidebar.js @@ -18,7 +18,7 @@ export default { findFlashAct('flash-act:a6a1'), findFlashAct('flash-act:hiveswap'), findFlashAct('flash-act:cool-and-new-web-comic'), - findFlashAct('flash-act:psycholonials'), + findFlashAct('flash-act:sunday-night-strifin'), ]; const sideNames = [ @@ -26,7 +26,7 @@ export default { `Side 2 (Acts 6-7)`, `Additional Canon`, `Fan Adventures`, - `More Flashes & Games`, + `Fan Games & More`, ]; const sideColors = [ -- cgit 1.3.0-6-gf8a5