diff options
Diffstat (limited to 'src/page')
-rw-r--r-- | src/page/album-commentary.js | 87 | ||||
-rw-r--r-- | src/page/album.js | 223 | ||||
-rw-r--r-- | src/page/artist-alias.js | 16 | ||||
-rw-r--r-- | src/page/artist.js | 258 | ||||
-rw-r--r-- | src/page/flash.js | 160 | ||||
-rw-r--r-- | src/page/group.js | 128 | ||||
-rw-r--r-- | src/page/homepage.js | 70 | ||||
-rw-r--r-- | src/page/index.js | 28 | ||||
-rw-r--r-- | src/page/listing.js | 104 | ||||
-rw-r--r-- | src/page/news.js | 60 | ||||
-rw-r--r-- | src/page/static.js | 18 | ||||
-rw-r--r-- | src/page/tag.js | 46 | ||||
-rw-r--r-- | src/page/track.js | 157 |
13 files changed, 669 insertions, 686 deletions
diff --git a/src/page/album-commentary.js b/src/page/album-commentary.js index b469838d..719bd65a 100644 --- a/src/page/album-commentary.js +++ b/src/page/album-commentary.js @@ -1,34 +1,34 @@ -// @format -// +/** @format */ + // Album commentary page and index specifications. // Imports -import fixWS from "fix-whitespace"; +import fixWS from 'fix-whitespace'; -import { filterAlbumsByCommentary } from "../util/wiki-data.js"; +import {filterAlbumsByCommentary} from '../util/wiki-data.js'; // Page exports -export function condition({ wikiData }) { +export function condition({wikiData}) { return filterAlbumsByCommentary(wikiData.albumData).length; } -export function targets({ wikiData }) { +export function targets({wikiData}) { return filterAlbumsByCommentary(wikiData.albumData); } -export function write(album, { wikiData }) { - const { wikiInfo } = wikiData; +export function write(album, {wikiData}) { + const {wikiInfo} = wikiData; const entries = [album, ...album.tracks] .filter((x) => x.commentary) .map((x) => x.commentary); - const words = entries.join(" ").split(" ").length; + const words = entries.join(' ').split(' ').length; const page = { - type: "page", - path: ["albumCommentary", album.directory], + type: 'page', + path: ['albumCommentary', album.directory], page: ({ getAlbumStylesheet, getLinkThemeString, @@ -38,30 +38,30 @@ export function write(album, { wikiData }) { to, transformMultiline, }) => ({ - title: language.$("albumCommentaryPage.title", { album: album.name }), + title: language.$('albumCommentaryPage.title', {album: album.name}), stylesheet: getAlbumStylesheet(album), theme: getThemeString(album.color), main: { content: fixWS` <div class="long-content"> - <h1>${language.$("albumCommentaryPage.title", { + <h1>${language.$('albumCommentaryPage.title', { album: link.album(album), })}</h1> - <p>${language.$("albumCommentaryPage.infoLine", { + <p>${language.$('albumCommentaryPage.infoLine', { words: `<b>${language.formatWordCount(words, { unit: true, })}</b>`, entries: `<b>${language.countCommentaryEntries( entries.length, - { unit: true } + {unit: true} )}</b>`, })}</p> ${ album.commentary && fixWS` <h3>${language.$( - "albumCommentaryPage.entry.title.albumCommentary" + 'albumCommentaryPage.entry.title.albumCommentary' )}</h3> <blockquote> ${transformMultiline(album.commentary)} @@ -73,7 +73,7 @@ export function write(album, { wikiData }) { .map( (track) => fixWS` <h3 id="${track.directory}">${language.$( - "albumCommentaryPage.entry.title.trackCommentary", + 'albumCommentaryPage.entry.title.trackCommentary', { track: link.track(track), } @@ -85,22 +85,22 @@ export function write(album, { wikiData }) { </blockquote> ` ) - .join("\n")} + .join('\n')} </div> `, }, nav: { - linkContainerClasses: ["nav-links-hierarchy"], + linkContainerClasses: ['nav-links-hierarchy'], links: [ - { toHome: true }, + {toHome: true}, { - path: ["localized.commentaryIndex"], - title: language.$("commentaryIndex.title"), + path: ['localized.commentaryIndex'], + title: language.$('commentaryIndex.title'), }, { - html: language.$("albumCommentaryPage.nav.album", { - album: link.albumCommentary(album, { class: "current" }), + html: language.$('albumCommentaryPage.nav.album', { + album: link.albumCommentary(album, {class: 'current'}), }), }, ], @@ -111,7 +111,7 @@ export function write(album, { wikiData }) { return [page]; } -export function writeTargetless({ wikiData }) { +export function writeTargetless({wikiData}) { const data = filterAlbumsByCommentary(wikiData.albumData) .map((album) => ({ album, @@ -119,44 +119,41 @@ export function writeTargetless({ wikiData }) { .filter((x) => x.commentary) .map((x) => x.commentary), })) - .map(({ album, entries }) => ({ + .map(({album, entries}) => ({ album, entries, - words: entries.join(" ").split(" ").length, + words: entries.join(' ').split(' ').length, })); - const totalEntries = data.reduce( - (acc, { entries }) => acc + entries.length, - 0 - ); - const totalWords = data.reduce((acc, { words }) => acc + words, 0); + const totalEntries = data.reduce((acc, {entries}) => acc + entries.length, 0); + const totalWords = data.reduce((acc, {words}) => acc + words, 0); const page = { - type: "page", - path: ["commentaryIndex"], - page: ({ link, language }) => ({ - title: language.$("commentaryIndex.title"), + type: 'page', + path: ['commentaryIndex'], + page: ({link, language}) => ({ + title: language.$('commentaryIndex.title'), main: { content: fixWS` <div class="long-content"> - <h1>${language.$("commentaryIndex.title")}</h1> - <p>${language.$("commentaryIndex.infoLine", { + <h1>${language.$('commentaryIndex.title')}</h1> + <p>${language.$('commentaryIndex.infoLine', { words: `<b>${language.formatWordCount(totalWords, { unit: true, })}</b>`, entries: `<b>${language.countCommentaryEntries( totalEntries, - { unit: true } + {unit: true} )}</b>`, })}</p> - <p>${language.$("commentaryIndex.albumList.title")}</p> + <p>${language.$('commentaryIndex.albumList.title')}</p> <ul> ${data .map( - ({ album, entries, words }) => fixWS` + ({album, entries, words}) => fixWS` <li>${language.$( - "commentaryIndex.albumList.item", + 'commentaryIndex.albumList.item', { album: link.albumCommentary(album), words: language.formatWordCount(words, { @@ -165,19 +162,19 @@ export function writeTargetless({ wikiData }) { entries: language.countCommentaryEntries( entries.length, - { unit: true } + {unit: true} ), } )}</li> ` ) - .join("\n")} + .join('\n')} </ul> </div> `, }, - nav: { simple: true }, + nav: {simple: true}, }), }; diff --git a/src/page/album.js b/src/page/album.js index f015976f..6c8bb844 100644 --- a/src/page/album.js +++ b/src/page/album.js @@ -1,33 +1,33 @@ -// @format -// +/** @format */ + // Album page specification. // Imports -import fixWS from "fix-whitespace"; +import fixWS from 'fix-whitespace'; -import * as html from "../util/html.js"; +import * as html from '../util/html.js'; -import { bindOpts, compareArrays } from "../util/sugar.js"; +import {bindOpts, compareArrays} from '../util/sugar.js'; import { getAlbumCover, getAlbumListTag, getTotalDuration, -} from "../util/wiki-data.js"; +} from '../util/wiki-data.js'; // Page exports -export function targets({ wikiData }) { +export function targets({wikiData}) { return wikiData.albumData; } -export function write(album, { wikiData }) { - const { wikiInfo } = wikiData; +export function write(album, {wikiData}) { + const {wikiInfo} = wikiData; const unbound_trackToListItem = ( track, - { getArtistString, getLinkThemeString, link, language } + {getArtistString, getLinkThemeString, link, language} ) => { const itemOpts = { duration: language.formatDuration(track.duration ?? 0), @@ -37,13 +37,13 @@ export function write(album, { wikiData }) { compareArrays( track.artistContribs.map((c) => c.who), album.artistContribs.map((c) => c.who), - { checkOrder: false } + {checkOrder: false} ) - ? language.$("trackList.item.withDuration", itemOpts) - : language.$("trackList.item.withDuration.withArtists", { + ? language.$('trackList.item.withDuration', itemOpts) + : language.$('trackList.item.withDuration.withArtists', { ...itemOpts, by: `<span class="by">${language.$( - "trackList.item.withArtists.by", + 'trackList.item.withArtists.by', { artists: getArtistString(track.artistContribs), } @@ -60,8 +60,8 @@ export function write(album, { wikiData }) { const listTag = getAlbumListTag(album); const data = { - type: "data", - path: ["album", album.directory], + type: 'data', + path: ['album', album.directory], data: ({ serializeContribs, serializeCover, @@ -97,8 +97,8 @@ export function write(album, { wikiData }) { }; const page = { - type: "page", - path: ["album", album.directory], + type: 'page', + path: ['album', album.directory], page: ({ fancifyURL, generateAdditionalFilesShortcut, @@ -126,7 +126,7 @@ export function write(album, { wikiData }) { const cover = getAlbumCover(album); return { - title: language.$("albumPage.title", { album: album.name }), + title: language.$('albumPage.title', {album: album.name}), stylesheet: getAlbumStylesheet(album), theme: getThemeString(album.color, [ `--album-directory: ${album.directory}`, @@ -135,12 +135,12 @@ export function write(album, { wikiData }) { banner: album.bannerArtistContribs.length && { dimensions: album.bannerDimensions, path: [ - "media.albumBanner", + 'media.albumBanner', album.directory, album.bannerFileExtension, ], - alt: language.$("misc.alt.albumBanner"), - position: "top", + alt: language.$('misc.alt.albumBanner'), + position: 'top', }, main: { @@ -149,17 +149,17 @@ export function write(album, { wikiData }) { cover && generateCoverLink({ src: cover, - alt: language.$("misc.alt.albumCover"), + alt: language.$('misc.alt.albumCover'), tags: album.artTags, }) } - <h1>${language.$("albumPage.title", { + <h1>${language.$('albumPage.title', { album: album.name, })}</h1> <p> ${[ album.artistContribs.length && - language.$("releaseInfo.by", { + language.$('releaseInfo.by', { artists: getArtistString( album.artistContribs, { @@ -169,7 +169,7 @@ export function write(album, { wikiData }) { ), }), album.coverArtistContribs.length && - language.$("releaseInfo.coverArtBy", { + language.$('releaseInfo.coverArtBy', { artists: getArtistString( album.coverArtistContribs, { @@ -179,7 +179,7 @@ export function write(album, { wikiData }) { ), }), album.wallpaperArtistContribs.length && - language.$("releaseInfo.wallpaperArtBy", { + language.$('releaseInfo.wallpaperArtBy', { artists: getArtistString( album.wallpaperArtistContribs, { @@ -189,7 +189,7 @@ export function write(album, { wikiData }) { ), }), album.bannerArtistContribs.length && - language.$("releaseInfo.bannerArtBy", { + language.$('releaseInfo.bannerArtBy', { artists: getArtistString( album.bannerArtistContribs, { @@ -199,23 +199,23 @@ export function write(album, { wikiData }) { ), }), album.date && - language.$("releaseInfo.released", { + language.$('releaseInfo.released', { date: language.formatDate(album.date), }), album.coverArtDate && +album.coverArtDate !== +album.date && - language.$("releaseInfo.artReleased", { + language.$('releaseInfo.artReleased', { date: language.formatDate(album.coverArtDate), }), - language.$("releaseInfo.duration", { + language.$('releaseInfo.duration', { duration: language.formatDuration( albumDuration, - { approximate: album.tracks.length > 1 } + {approximate: album.tracks.length > 1} ), }), ] .filter(Boolean) - .join("<br>\n")} + .join('<br>\n')} </p> ${ (hasAdditionalFiles || hasCommentaryEntries) && @@ -224,26 +224,26 @@ export function write(album, { wikiData }) { hasAdditionalFiles && generateAdditionalFilesShortcut( album.additionalFiles, - { language } + {language} ), hasCommentaryEntries && - language.$("releaseInfo.viewCommentary", { + language.$('releaseInfo.viewCommentary', { link: link.albumCommentary(album, { text: language.$( - "releaseInfo.viewCommentary.link" + 'releaseInfo.viewCommentary.link' ), }), }), ] .filter(Boolean) - .join("<br>\n")}</p>` + .join('<br>\n')}</p>` } ${ album.urls?.length && - `<p>${language.$("releaseInfo.listenOn", { + `<p>${language.$('releaseInfo.listenOn', { links: language.formatDisjunctionList( album.urls.map((url) => - fancifyURL(url, { album: true }) + fancifyURL(url, {album: true}) ) ), })}</p>` @@ -263,32 +263,32 @@ export function write(album, { wikiData }) { tracks, }) => fixWS` <dt>${language.$( - "trackList.section.withDuration", + 'trackList.section.withDuration', { duration: language.formatDuration( getTotalDuration(tracks), - { approximate: tracks.length > 1 } + {approximate: tracks.length > 1} ), section: name, } )}</dt> <dd><${ - listTag === "ol" + listTag === 'ol' ? `ol start="${startIndex + 1}"` : listTag }> ${tracks .map(trackToListItem) - .join("\n")} + .join('\n')} </${listTag}></dd> ` ) - .join("\n")} + .join('\n')} </dl> ` : fixWS` <${listTag}> - ${album.tracks.map(trackToListItem).join("\n")} + ${album.tracks.map(trackToListItem).join('\n')} </${listTag}> ` } @@ -297,14 +297,14 @@ export function write(album, { wikiData }) { fixWS` <p> ${[ - language.$("releaseInfo.addedToWiki", { + language.$('releaseInfo.addedToWiki', { date: language.formatDate( album.dateAddedToWiki ), }), ] .filter(Boolean) - .join("<br>\n")} + .join('<br>\n')} </p> ` } @@ -315,21 +315,21 @@ export function write(album, { wikiData }) { getFileSize: (file) => getSizeOfAdditionalFile( urls - .from("media.root") + .from('media.root') .to( - "media.albumAdditionalFile", + 'media.albumAdditionalFile', album.directory, file ) ), linkFile: (file) => - link.albumAdditionalFile({ album, file }), + link.albumAdditionalFile({album, file}), }) } ${ album.commentary && fixWS` - <p>${language.$("releaseInfo.artistCommentary")}</p> + <p>${language.$('releaseInfo.artistCommentary')}</p> <blockquote> ${transformMultiline(album.commentary)} </blockquote> @@ -348,16 +348,16 @@ export function write(album, { wikiData }) { }), nav: { - linkContainerClasses: ["nav-links-hierarchy"], + linkContainerClasses: ['nav-links-hierarchy'], links: [ - { toHome: true }, + {toHome: true}, { - html: language.$("albumPage.nav.album", { - album: link.album(album, { class: "current" }), + html: language.$('albumPage.nav.album', { + album: link.album(album, {class: 'current'}), }), }, ], - bottomRowContent: generateAlbumNavLinks(album, null, { language }), + bottomRowContent: generateAlbumNavLinks(album, null, {language}), content: generateAlbumChronologyLinks(album, null, { generateChronologyLinks, }), @@ -380,14 +380,7 @@ export function write(album, { wikiData }) { export function generateAlbumSidebar( album, currentTrack, - { - fancifyURL, - getLinkThemeString, - link, - language, - transformMultiline, - wikiData, - } + {fancifyURL, getLinkThemeString, link, language, transformMultiline, wikiData} ) { const listTag = getAlbumListTag(album); @@ -400,41 +393,41 @@ export function generateAlbumSidebar( }]; */ - const { trackGroups } = album; + const {trackGroups} = album; const trackToListItem = (track) => html.tag( - "li", - { class: track === currentTrack && "current" }, - language.$("albumSidebar.trackList.item", { + 'li', + {class: track === currentTrack && 'current'}, + language.$('albumSidebar.trackList.item', { track: link.track(track), }) ); const nameOrDefault = (isDefaultTrackGroup, name) => isDefaultTrackGroup - ? language.$("albumSidebar.trackList.fallbackGroupName") + ? language.$('albumSidebar.trackList.fallbackGroupName') : name; const trackListPart = fixWS` <h1>${link.album(album)}</h1> ${trackGroups - .map(({ name, color, startIndex, tracks, isDefaultTrackGroup }) => + .map(({name, color, startIndex, tracks, isDefaultTrackGroup}) => html.tag( - "details", + 'details', { // Leave side8ar track groups collapsed on al8um homepage, // since there's already a view of all the groups expanded // in the main content area. open: currentTrack && tracks.includes(currentTrack), - class: tracks.includes(currentTrack) && "current", + class: tracks.includes(currentTrack) && 'current', }, [ html.tag( - "summary", - { style: getLinkThemeString(color) }, - listTag === "ol" - ? language.$("albumSidebar.trackList.group.withRange", { + 'summary', + {style: getLinkThemeString(color)}, + listTag === 'ol' + ? language.$('albumSidebar.trackList.group.withRange', { group: `<span class="group-name">${nameOrDefault( isDefaultTrackGroup, name @@ -443,7 +436,7 @@ export function generateAlbumSidebar( startIndex + tracks.length }`, }) - : language.$("albumSidebar.trackList.group", { + : language.$('albumSidebar.trackList.group', { group: `<span class="group-name">${nameOrDefault( isDefaultTrackGroup, name @@ -452,20 +445,20 @@ export function generateAlbumSidebar( ), fixWS` <${ - listTag === "ol" + listTag === 'ol' ? `ol start="${startIndex + 1}"` : listTag }> - ${tracks.map(trackToListItem).join("\n")} + ${tracks.map(trackToListItem).join('\n')} </${listTag}> `, ] ) ) - .join("\n")} + .join('\n')} `; - const { groups } = album; + const {groups} = album; const groupParts = groups .map((group) => { @@ -473,17 +466,17 @@ export function generateAlbumSidebar( const index = albums.indexOf(album); const next = index >= 0 && albums[index + 1]; const previous = index > 0 && albums[index - 1]; - return { group, next, previous }; + return {group, next, previous}; }) .map( - ({ group, next, previous }) => fixWS` - <h1>${language.$("albumSidebar.groupBox.title", { + ({group, next, previous}) => fixWS` + <h1>${language.$('albumSidebar.groupBox.title', { group: link.groupInfo(group), })}</h1> ${!currentTrack && transformMultiline(group.descriptionShort)} ${ group.urls?.length && - `<p>${language.$("releaseInfo.visitOn", { + `<p>${language.$('releaseInfo.visitOn', { links: language.formatDisjunctionList( group.urls.map((url) => fancifyURL(url)) ), @@ -495,7 +488,7 @@ export function generateAlbumSidebar( ${ next && `<p class="group-chronology-link">${language.$( - "albumSidebar.groupBox.next", + 'albumSidebar.groupBox.next', { album: link.album(next), } @@ -504,7 +497,7 @@ export function generateAlbumSidebar( ${ previous && `<p class="group-chronology-link">${language.$( - "albumSidebar.groupBox.previous", + 'albumSidebar.groupBox.previous', { album: link.album(previous), } @@ -517,7 +510,7 @@ export function generateAlbumSidebar( if (groupParts.length) { if (currentTrack) { - const combinedGroupPart = groupParts.join("\n<hr>\n"); + const combinedGroupPart = groupParts.join('\n<hr>\n'); return { multiple: [trackListPart, combinedGroupPart], }; @@ -536,9 +529,9 @@ export function generateAlbumSidebar( export function generateAlbumSecondaryNav( album, currentTrack, - { link, language, getLinkThemeString } + {link, language, getLinkThemeString} ) { - const { groups } = album; + const {groups} = album; if (!groups.length) { return null; @@ -550,56 +543,56 @@ export function generateAlbumSecondaryNav( const index = albums.indexOf(album); const next = index >= 0 && albums[index + 1]; const previous = index > 0 && albums[index - 1]; - return { group, next, previous }; + return {group, next, previous}; }) - .map(({ group, next, previous }) => { + .map(({group, next, previous}) => { const previousNext = !currentTrack && [ previous && link.album(previous, { color: false, - text: language.$("misc.nav.previous"), + text: language.$('misc.nav.previous'), }), next && link.album(next, { color: false, - text: language.$("misc.nav.next"), + text: language.$('misc.nav.next'), }), ].filter(Boolean); - return html.tag("span", { style: getLinkThemeString(group.color) }, [ - language.$("albumSidebar.groupBox.title", { + return html.tag('span', {style: getLinkThemeString(group.color)}, [ + language.$('albumSidebar.groupBox.title', { group: link.groupInfo(group), }), - previousNext?.length && `(${previousNext.join(",\n")})`, + previousNext?.length && `(${previousNext.join(',\n')})`, ]); }); return { - classes: ["dot-between-spans"], - content: groupParts.join("\n"), + classes: ['dot-between-spans'], + content: groupParts.join('\n'), }; } export function generateAlbumNavLinks( album, currentTrack, - { generatePreviousNextLinks, language } + {generatePreviousNextLinks, language} ) { if (album.tracks.length <= 1) { - return ""; + return ''; } const previousNextLinks = currentTrack && generatePreviousNextLinks(currentTrack, { data: album.tracks, - linkKey: "track", + linkKey: 'track', }); const randomLink = `<a href="#" data-random="track-in-album" id="random-button">${ currentTrack - ? language.$("trackPage.nav.random") - : language.$("albumPage.nav.randomTrack") + ? language.$('trackPage.nav.random') + : language.$('albumPage.nav.randomTrack') }</a>`; return previousNextLinks @@ -610,44 +603,44 @@ export function generateAlbumNavLinks( export function generateAlbumChronologyLinks( album, currentTrack, - { generateChronologyLinks } + {generateChronologyLinks} ) { return html.tag( - "div", + 'div', { [html.onlyIfContent]: true, - class: "nav-chronology-links", + class: 'nav-chronology-links', }, [ currentTrack && generateChronologyLinks(currentTrack, { - contribKey: "artistContribs", + contribKey: 'artistContribs', getThings: (artist) => [ ...artist.tracksAsArtist, ...artist.tracksAsContributor, ], - headingString: "misc.chronology.heading.track", + headingString: 'misc.chronology.heading.track', }), currentTrack && generateChronologyLinks(currentTrack, { - contribKey: "contributorContribs", + contribKey: 'contributorContribs', getThings: (artist) => [ ...artist.tracksAsArtist, ...artist.tracksAsContributor, ], - headingString: "misc.chronology.heading.track", + headingString: 'misc.chronology.heading.track', }), generateChronologyLinks(currentTrack || album, { - contribKey: "coverArtistContribs", - dateKey: "coverArtDate", + contribKey: 'coverArtistContribs', + dateKey: 'coverArtDate', getThings: (artist) => [ ...artist.albumsAsCoverArtist, ...artist.tracksAsCoverArtist, ], - headingString: "misc.chronology.heading.coverArt", + headingString: 'misc.chronology.heading.coverArt', }), ] .filter(Boolean) - .join("\n") + .join('\n') ); } diff --git a/src/page/artist-alias.js b/src/page/artist-alias.js index 8a45503d..46ad1a34 100644 --- a/src/page/artist-alias.js +++ b/src/page/artist-alias.js @@ -1,21 +1,21 @@ -// @format -// +/** @format */ + // Artist alias redirect pages. // (Makes old permalinks bring visitors to the up-to-date page.) -export function targets({ wikiData }) { +export function targets({wikiData}) { return wikiData.artistAliasData; } -export function write(aliasArtist, { wikiData }) { +export function write(aliasArtist, {wikiData}) { // This function doesn't actually use wikiData, 8ut, um, consistency? - const { aliasedArtist } = aliasArtist; + const {aliasedArtist} = aliasArtist; const redirect = { - type: "redirect", - fromPath: ["artist", aliasArtist.directory], - toPath: ["artist", aliasedArtist.directory], + type: 'redirect', + fromPath: ['artist', aliasArtist.directory], + toPath: ['artist', aliasedArtist.directory], title: () => aliasedArtist.name, }; diff --git a/src/page/artist.js b/src/page/artist.js index 314d2aa2..6b26b0f9 100644 --- a/src/page/artist.js +++ b/src/page/artist.js @@ -1,16 +1,16 @@ -// @format -// +/** @format */ + // Artist page specification. // // NB: See artist-alias.js for artist alias redirect pages. // Imports -import fixWS from "fix-whitespace"; +import fixWS from 'fix-whitespace'; -import * as html from "../util/html.js"; +import * as html from '../util/html.js'; -import { bindOpts, unique } from "../util/sugar.js"; +import {bindOpts, unique} from '../util/sugar.js'; import { chunkByProperties, @@ -19,18 +19,18 @@ import { sortByDate, sortByDirectory, sortChronologically, -} from "../util/wiki-data.js"; +} from '../util/wiki-data.js'; // Page exports -export function targets({ wikiData }) { +export function targets({wikiData}) { return wikiData.artistData; } -export function write(artist, { wikiData }) { - const { groupData, wikiInfo } = wikiData; +export function write(artist, {wikiData}) { + const {groupData, wikiInfo} = wikiData; - const { name, urls, contextNotes } = artist; + const {name, urls, contextNotes} = artist; const artThingsAll = sortAlbumsTracksChronologically( unique([ @@ -39,7 +39,7 @@ export function write(artist, { wikiData }) { ...(artist.albumsAsBannerArtist ?? []), ...(artist.tracksAsCoverArtist ?? []), ]), - { getDate: (o) => o.coverArtDate } + {getDate: (o) => o.coverArtDate} ); const artThingsGallery = sortAlbumsTracksChronologically( @@ -47,7 +47,7 @@ export function write(artist, { wikiData }) { ...(artist.albumsAsCoverArtist ?? []), ...(artist.tracksAsCoverArtist ?? []), ], - { getDate: (o) => o.coverArtDate } + {getDate: (o) => o.coverArtDate} ); const commentaryThings = sortAlbumsTracksChronologically([ @@ -58,17 +58,17 @@ export function write(artist, { wikiData }) { const hasGallery = artThingsGallery.length > 0; const getArtistsAndContrib = (thing, key) => ({ - artists: thing[key]?.filter(({ who }) => who !== artist), - contrib: thing[key]?.find(({ who }) => who === artist), + artists: thing[key]?.filter(({who}) => who !== artist), + contrib: thing[key]?.find(({who}) => who === artist), thing, key, }); const artListChunks = chunkByProperties( artThingsAll.flatMap((thing) => - ["coverArtistContribs", "wallpaperArtistContribs", "bannerArtistContribs"] + ['coverArtistContribs', 'wallpaperArtistContribs', 'bannerArtistContribs'] .map((key) => getArtistsAndContrib(thing, key)) - .filter(({ contrib }) => contrib) + .filter(({contrib}) => contrib) .map((props) => ({ album: thing.album || thing, track: thing.album ? thing : null, @@ -76,7 +76,7 @@ export function write(artist, { wikiData }) { ...props, })) ), - ["date", "album"] + ['date', 'album'] ); const commentaryListChunks = chunkByProperties( @@ -84,7 +84,7 @@ export function write(artist, { wikiData }) { album: thing.album || thing, track: thing.album ? thing : null, })), - ["album"] + ['album'] ); const allTracks = sortAlbumsTracksChronologically( @@ -101,19 +101,19 @@ export function write(artist, { wikiData }) { date: +track.date, album: track.album, duration: track.duration, - artists: track.artistContribs.some(({ who }) => who === artist) - ? track.artistContribs.filter(({ who }) => who !== artist) - : track.contributorContribs.filter(({ who }) => who !== artist), + artists: track.artistContribs.some(({who}) => who === artist) + ? track.artistContribs.filter(({who}) => who !== artist) + : track.contributorContribs.filter(({who}) => who !== artist), contrib: { who: artist, whatArray: [ - track.artistContribs.find(({ who }) => who === artist)?.what, - track.contributorContribs.find(({ who }) => who === artist)?.what, + track.artistContribs.find(({who}) => who === artist)?.what, + track.contributorContribs.find(({who}) => who === artist)?.what, ].filter(Boolean), }, })), - ["date", "album"] - ).map(({ date, album, chunk }) => ({ + ['date', 'album'] + ).map(({date, album, chunk}) => ({ date, album, chunk, @@ -132,7 +132,7 @@ export function write(artist, { wikiData }) { group, contributions: usedGroups.filter((g) => g === group).length, })) - .filter(({ contributions }) => contributions > 0) + .filter(({contributions}) => contributions > 0) .sort((a, b) => b.contributions - a.contributions); }; @@ -151,10 +151,10 @@ export function write(artist, { wikiData }) { // want to show the full list of other contri8utors inline. // (It can often 8e very, very large!) artists: [], - contrib: flash.contributorContribs.find(({ who }) => who === artist), + contrib: flash.contributorContribs.find(({who}) => who === artist), })), - ["act"] - ).map(({ act, chunk }) => ({ + ['act'] + ).map(({act, chunk}) => ({ act, chunk, dateFirst: chunk[0].date, @@ -171,11 +171,11 @@ export function write(artist, { wikiData }) { contrib, }) => original - ? language.$("artistPage.creditList.entry.rerelease", { entry }) + ? language.$('artistPage.creditList.entry.rerelease', {entry}) : artists.length ? contrib.what || contrib.whatArray?.length ? language.$( - "artistPage.creditList.entry.withArtists.withContribution", + 'artistPage.creditList.entry.withArtists.withContribution', { entry, artists: getArtistString(artists), @@ -184,12 +184,12 @@ export function write(artist, { wikiData }) { : contrib.what, } ) - : language.$("artistPage.creditList.entry.withArtists", { + : language.$('artistPage.creditList.entry.withArtists', { entry, artists: getArtistString(artists), }) : contrib.what || contrib.whatArray?.length - ? language.$("artistPage.creditList.entry.withContribution", { + ? language.$('artistPage.creditList.entry.withContribution', { entry, contribution: contrib.whatArray ? language.formatUnitList(contrib.whatArray) @@ -199,16 +199,16 @@ export function write(artist, { wikiData }) { const unbound_generateTrackList = ( chunks, - { getArtistString, link, language } + {getArtistString, link, language} ) => fixWS` <dl> ${chunks .map( - ({ date, album, chunk, duration }) => fixWS` + ({date, album, chunk, duration}) => fixWS` <dt>${ date && duration ? language.$( - "artistPage.creditList.album.withDate.withDuration", + 'artistPage.creditList.album.withDate.withDuration', { album: link.album(album), date: language.formatDate(date), @@ -218,27 +218,27 @@ export function write(artist, { wikiData }) { } ) : date - ? language.$("artistPage.creditList.album.withDate", { + ? language.$('artistPage.creditList.album.withDate', { album: link.album(album), date: language.formatDate(date), }) : duration - ? language.$("artistPage.creditList.album.withDuration", { + ? language.$('artistPage.creditList.album.withDuration', { album: link.album(album), duration: language.formatDuration(duration, { approximate: true, }), }) - : language.$("artistPage.creditList.album", { + : language.$('artistPage.creditList.album', { album: link.album(album), }) }</dt> <dd><ul> ${chunk - .map(({ track, ...props }) => ({ + .map(({track, ...props}) => ({ original: track.originalReleaseTrack, entry: language.$( - "artistPage.creditList.entry.track.withDuration", + 'artistPage.creditList.entry.track.withDuration', { track: link.track(track), duration: language.formatDuration( @@ -248,10 +248,10 @@ export function write(artist, { wikiData }) { ), ...props, })) - .map(({ original, ...opts }) => + .map(({original, ...opts}) => html.tag( - "li", - { class: original && "rerelease" }, + 'li', + {class: original && 'rerelease'}, generateEntryAccents({ getArtistString, language, @@ -260,18 +260,18 @@ export function write(artist, { wikiData }) { }) ) ) - .join("\n")} + .join('\n')} </ul></dd> ` ) - .join("\n")} + .join('\n')} </dl> `; const unbound_serializeArtistsAndContrib = - (key, { serializeContribs, serializeLink }) => + (key, {serializeContribs, serializeLink}) => (thing) => { - const { artists, contrib } = getArtistsAndContrib(thing, key); + const {artists, contrib} = getArtistsAndContrib(thing, key); const ret = {}; ret.link = serializeLink(thing); if (contrib.what) ret.contribution = contrib.what; @@ -279,21 +279,21 @@ export function write(artist, { wikiData }) { return ret; }; - const unbound_serializeTrackListChunks = (chunks, { serializeLink }) => - chunks.map(({ date, album, chunk, duration }) => ({ + const unbound_serializeTrackListChunks = (chunks, {serializeLink}) => + chunks.map(({date, album, chunk, duration}) => ({ album: serializeLink(album), date, duration, - tracks: chunk.map(({ track }) => ({ + tracks: chunk.map(({track}) => ({ link: serializeLink(track), duration: track.duration, })), })); const data = { - type: "data", - path: ["artist", artist.directory], - data: ({ serializeContribs, serializeLink }) => { + type: 'data', + path: ['artist', artist.directory], + data: ({serializeContribs, serializeLink}) => { const serializeArtistsAndContrib = bindOpts( unbound_serializeArtistsAndContrib, { @@ -312,22 +312,22 @@ export function write(artist, { wikiData }) { return { albums: { asCoverArtist: artist.albumsAsCoverArtist?.map( - serializeArtistsAndContrib("coverArtistContribs") + serializeArtistsAndContrib('coverArtistContribs') ), asWallpaperArtist: artist.albumsAsWallpaperArtist?.map( - serializeArtistsAndContrib("wallpaperArtistContribs") + serializeArtistsAndContrib('wallpaperArtistContribs') ), asBannerArtist: artist.albumsAsBannerArtist?.map( - serializeArtistsAndContrib("bannerArtistContribs") + serializeArtistsAndContrib('bannerArtistContribs') ), }, flashes: wikiInfo.enableFlashesAndGames ? { asContributor: artist.flashesAsContributor ?.map((flash) => - getArtistsAndContrib(flash, "contributorContribs") + getArtistsAndContrib(flash, 'contributorContribs') ) - .map(({ contrib, thing: flash }) => ({ + .map(({contrib, thing: flash}) => ({ link: serializeLink(flash), contribution: contrib.what, })), @@ -335,10 +335,10 @@ export function write(artist, { wikiData }) { : null, tracks: { asArtist: artist.tracksAsArtist.map( - serializeArtistsAndContrib("artistContribs") + serializeArtistsAndContrib('artistContribs') ), asContributor: artist.tracksAsContributor.map( - serializeArtistsAndContrib("contributorContribs") + serializeArtistsAndContrib('contributorContribs') ), chunked: serializeTrackListChunks(trackListChunks), }, @@ -347,8 +347,8 @@ export function write(artist, { wikiData }) { }; const infoPage = { - type: "page", - path: ["artist", artist.directory], + type: 'page', + path: ['artist', artist.directory], page: ({ fancifyURL, generateCoverLink, @@ -367,7 +367,7 @@ export function write(artist, { wikiData }) { }); return { - title: language.$("artistPage.title", { artist: name }), + title: language.$('artistPage.title', {artist: name}), main: { content: fixWS` @@ -375,16 +375,16 @@ export function write(artist, { wikiData }) { artist.hasAvatar && generateCoverLink({ src: getArtistAvatar(artist), - alt: language.$("misc.alt.artistAvatar"), + alt: language.$('misc.alt.artistAvatar'), }) } - <h1>${language.$("artistPage.title", { + <h1>${language.$('artistPage.title', { artist: name, })}</h1> ${ contextNotes && fixWS` - <p>${language.$("releaseInfo.note")}</p> + <p>${language.$('releaseInfo.note')}</p> <blockquote> ${transformMultiline(contextNotes)} </blockquote> @@ -393,41 +393,41 @@ export function write(artist, { wikiData }) { } ${ urls?.length && - `<p>${language.$("releaseInfo.visitOn", { + `<p>${language.$('releaseInfo.visitOn', { links: language.formatDisjunctionList( - urls.map((url) => fancifyURL(url, { language })) + urls.map((url) => fancifyURL(url, {language})) ), })}</p>` } ${ hasGallery && - `<p>${language.$("artistPage.viewArtGallery", { + `<p>${language.$('artistPage.viewArtGallery', { link: link.artistGallery(artist, { text: language.$( - "artistPage.viewArtGallery.link" + 'artistPage.viewArtGallery.link' ), }), })}</p>` } - <p>${language.$("misc.jumpTo.withLinks", { + <p>${language.$('misc.jumpTo.withLinks', { links: language.formatUnitList( [ allTracks.length && `<a href="#tracks">${language.$( - "artistPage.trackList.title" + 'artistPage.trackList.title' )}</a>`, artThingsAll.length && `<a href="#art">${language.$( - "artistPage.artList.title" + 'artistPage.artList.title' )}</a>`, wikiInfo.enableFlashesAndGames && flashes.length && `<a href="#flashes">${language.$( - "artistPage.flashList.title" + 'artistPage.flashList.title' )}</a>`, commentaryThings.length && `<a href="#commentary">${language.$( - "artistPage.commentaryList.title" + 'artistPage.commentaryList.title' )}</a>`, ].filter(Boolean) ), @@ -436,22 +436,22 @@ export function write(artist, { wikiData }) { allTracks.length && fixWS` <h2 id="tracks">${language.$( - "artistPage.trackList.title" + 'artistPage.trackList.title' )}</h2> <p>${language.$( - "artistPage.contributedDurationLine", + 'artistPage.contributedDurationLine', { artist: artist.name, duration: language.formatDuration( totalDuration, - { approximate: true, unit: true } + {approximate: true, unit: true} ), } )}</p> - <p>${language.$("artistPage.musicGroupsLine", { + <p>${language.$('artistPage.musicGroupsLine', { groups: language.formatUnitList( - musicGroups.map(({ group, contributions }) => - language.$("artistPage.groupsLine.item", { + musicGroups.map(({group, contributions}) => + language.$('artistPage.groupsLine.item', { group: link.groupInfo(group), contributions: language.countContributions( @@ -468,25 +468,25 @@ export function write(artist, { wikiData }) { artThingsAll.length && fixWS` <h2 id="art">${language.$( - "artistPage.artList.title" + 'artistPage.artList.title' )}</h2> ${ hasGallery && `<p>${language.$( - "artistPage.viewArtGallery.orBrowseList", + 'artistPage.viewArtGallery.orBrowseList', { link: link.artistGallery(artist, { text: language.$( - "artistPage.viewArtGallery.link" + 'artistPage.viewArtGallery.link' ), }), } )}</p>` } - <p>${language.$("artistPage.artGroupsLine", { + <p>${language.$('artistPage.artGroupsLine', { groups: language.formatUnitList( - artGroups.map(({ group, contributions }) => - language.$("artistPage.groupsLine.item", { + artGroups.map(({group, contributions}) => + language.$('artistPage.groupsLine.item', { group: link.groupInfo(group), contributions: language.countContributions( @@ -499,9 +499,9 @@ export function write(artist, { wikiData }) { <dl> ${artListChunks .map( - ({ date, album, chunk }) => fixWS` + ({date, album, chunk}) => fixWS` <dt>${language.$( - "artistPage.creditList.album.withDate", + 'artistPage.creditList.album.withDate', { album: link.album(album), date: language.formatDate(date), @@ -518,20 +518,20 @@ export function write(artist, { wikiData }) { }) => ({ entry: track ? language.$( - "artistPage.creditList.entry.track", + 'artistPage.creditList.entry.track', { track: link.track(track), } ) : `<i>${language.$( - "artistPage.creditList.entry.album." + + 'artistPage.creditList.entry.album.' + { wallpaperArtistContribs: - "wallpaperArt", + 'wallpaperArt', bannerArtistContribs: - "bannerArt", + 'bannerArt', coverArtistContribs: - "coverArt", + 'coverArt', }[key] )}</i>`, ...props, @@ -545,11 +545,11 @@ export function write(artist, { wikiData }) { }) ) .map((row) => `<li>${row}</li>`) - .join("\n")} + .join('\n')} </ul></dd> ` ) - .join("\n")} + .join('\n')} </dl> ` } @@ -558,7 +558,7 @@ export function write(artist, { wikiData }) { flashes.length && fixWS` <h2 id="flashes">${language.$( - "artistPage.flashList.title" + 'artistPage.flashList.title' )}</h2> <dl> ${flashListChunks @@ -570,7 +570,7 @@ export function write(artist, { wikiData }) { dateLast, }) => fixWS` <dt>${language.$( - "artistPage.creditList.flashAct.withDateRange", + 'artistPage.creditList.flashAct.withDateRange', { act: link.flash(chunk[0].flash, { text: act.name, @@ -583,9 +583,9 @@ export function write(artist, { wikiData }) { )}</dt> <dd><ul> ${chunk - .map(({ flash, ...props }) => ({ + .map(({flash, ...props}) => ({ entry: language.$( - "artistPage.creditList.entry.flash", + 'artistPage.creditList.entry.flash', { flash: link.flash(flash), } @@ -600,11 +600,11 @@ export function write(artist, { wikiData }) { }) ) .map((row) => `<li>${row}</li>`) - .join("\n")} + .join('\n')} </ul></dd> ` ) - .join("\n")} + .join('\n')} </dl> ` } @@ -612,38 +612,38 @@ export function write(artist, { wikiData }) { commentaryThings.length && fixWS` <h2 id="commentary">${language.$( - "artistPage.commentaryList.title" + 'artistPage.commentaryList.title' )}</h2> <dl> ${commentaryListChunks .map( - ({ album, chunk }) => fixWS` + ({album, chunk}) => fixWS` <dt>${language.$( - "artistPage.creditList.album", + 'artistPage.creditList.album', { album: link.album(album), } )}</dt> <dd><ul> ${chunk - .map(({ album, track, ...props }) => + .map(({album, track, ...props}) => track ? language.$( - "artistPage.creditList.entry.track", + 'artistPage.creditList.entry.track', { track: link.track(track), } ) : `<i>${language.$( - "artistPage.creditList.entry.album.commentary" + 'artistPage.creditList.entry.album.commentary' )}</i>` ) .map((row) => `<li>${row}</li>`) - .join("\n")} + .join('\n')} </ul></dd> ` ) - .join("\n")} + .join('\n')} </dl> ` } @@ -661,8 +661,8 @@ export function write(artist, { wikiData }) { }; const galleryPage = hasGallery && { - type: "page", - path: ["artistGallery", artist.directory], + type: 'page', + path: ['artistGallery', artist.directory], page: ({ generateInfoGalleryLinks, getAlbumCover, @@ -672,26 +672,26 @@ export function write(artist, { wikiData }) { language, to, }) => ({ - title: language.$("artistGalleryPage.title", { artist: name }), + title: language.$('artistGalleryPage.title', {artist: name}), main: { - classes: ["top-index"], + classes: ['top-index'], content: fixWS` - <h1>${language.$("artistGalleryPage.title", { + <h1>${language.$('artistGalleryPage.title', { artist: name, })}</h1> <p class="quick-info">${language.$( - "artistGalleryPage.infoLine", + 'artistGalleryPage.infoLine', { coverArts: language.countCoverArts( artThingsGallery.length, - { unit: true } + {unit: true} ), } )}</p> <div class="grid-listing"> ${getGridHTML({ - entries: artThingsGallery.map((item) => ({ item })), + entries: artThingsGallery.map((item) => ({item})), srcFn: (thing) => thing.album ? getTrackCover(thing) @@ -723,30 +723,30 @@ function generateNavForArtist( artist, isGallery, hasGallery, - { generateInfoGalleryLinks, link, language, wikiData } + {generateInfoGalleryLinks, link, language, wikiData} ) { - const { wikiInfo } = wikiData; + const {wikiInfo} = wikiData; const infoGalleryLinks = hasGallery && generateInfoGalleryLinks(artist, isGallery, { link, language, - linkKeyGallery: "artistGallery", - linkKeyInfo: "artist", + linkKeyGallery: 'artistGallery', + linkKeyInfo: 'artist', }); return { - linkContainerClasses: ["nav-links-hierarchy"], + linkContainerClasses: ['nav-links-hierarchy'], links: [ - { toHome: true }, + {toHome: true}, wikiInfo.enableListings && { - path: ["localized.listingIndex"], - title: language.$("listingIndex.title"), + path: ['localized.listingIndex'], + title: language.$('listingIndex.title'), }, { - html: language.$("artistPage.nav.artist", { - artist: link.artist(artist, { class: "current" }), + html: language.$('artistPage.nav.artist', { + artist: link.artist(artist, {class: 'current'}), }), }, hasGallery && { diff --git a/src/page/flash.js b/src/page/flash.js index 864f44de..340927d6 100644 --- a/src/page/flash.js +++ b/src/page/flash.js @@ -1,29 +1,29 @@ -// @format -// +/** @format */ + // Flash page and index specifications. // Imports -import fixWS from "fix-whitespace"; +import fixWS from 'fix-whitespace'; -import * as html from "../util/html.js"; +import * as html from '../util/html.js'; -import { getFlashLink } from "../util/wiki-data.js"; +import {getFlashLink} from '../util/wiki-data.js'; // Page exports -export function condition({ wikiData }) { +export function condition({wikiData}) { return wikiData.wikiInfo.enableFlashesAndGames; } -export function targets({ wikiData }) { +export function targets({wikiData}) { return wikiData.flashData; } -export function write(flash, { wikiData }) { +export function write(flash, {wikiData}) { const page = { - type: "page", - path: ["flash", flash.directory], + type: 'page', + path: ['flash', flash.directory], page: ({ fancifyFlashURL, generateChronologyLinks, @@ -36,26 +36,26 @@ export function write(flash, { wikiData }) { language, transformInline, }) => ({ - title: language.$("flashPage.title", { flash: flash.name }), + title: language.$('flashPage.title', {flash: flash.name}), theme: getThemeString(flash.color, [ `--flash-directory: ${flash.directory}`, ]), main: { content: fixWS` - <h1>${language.$("flashPage.title", { + <h1>${language.$('flashPage.title', { flash: flash.name, })}</h1> ${generateCoverLink({ src: getFlashCover(flash), - alt: language.$("misc.alt.flashArt"), + alt: language.$('misc.alt.flashArt'), })} - <p>${language.$("releaseInfo.released", { + <p>${language.$('releaseInfo.released', { date: language.formatDate(flash.date), })}</p> ${ (flash.page || flash.urls?.length) && - `<p>${language.$("releaseInfo.playOn", { + `<p>${language.$('releaseInfo.playOn', { links: language.formatDisjunctionList( [ flash.page && getFlashLink(flash), @@ -69,15 +69,15 @@ export function write(flash, { wikiData }) { fixWS` <p>Tracks featured in <i>${flash.name.replace( /\.$/, - "" + '' )}</i>:</p> <ul> ${flash.featuredTracks .map((track) => - language.$("trackList.item.withArtists", { + language.$('trackList.item.withArtists', { track: link.track(track), by: `<span class="by">${language.$( - "trackList.item.withArtists.by", + 'trackList.item.withArtists.by', { artists: getArtistString( track.artistContribs @@ -87,14 +87,14 @@ export function write(flash, { wikiData }) { }) ) .map((row) => `<li>${row}</li>`) - .join("\n")} + .join('\n')} </ul> ` } ${ flash.contributorContribs.length && fixWS` - <p>${language.$("releaseInfo.contributors")}</p> + <p>${language.$('releaseInfo.contributors')}</p> <ul> ${flash.contributorContribs .map( @@ -104,14 +104,14 @@ export function write(flash, { wikiData }) { showIcons: true, })}</li>` ) - .join("\n")} + .join('\n')} </ul> ` } `, }, - sidebarLeft: generateSidebarForFlash(flash, { link, language, wikiData }), + sidebarLeft: generateSidebarForFlash(flash, {link, language, wikiData}), nav: generateNavForFlash(flash, { generateChronologyLinks, generatePreviousNextLinks, @@ -125,32 +125,32 @@ export function write(flash, { wikiData }) { return [page]; } -export function writeTargetless({ wikiData }) { - const { flashActData } = wikiData; +export function writeTargetless({wikiData}) { + const {flashActData} = wikiData; const page = { - type: "page", - path: ["flashIndex"], - page: ({ getFlashGridHTML, getLinkThemeString, link, language }) => ({ - title: language.$("flashIndex.title"), + type: 'page', + path: ['flashIndex'], + page: ({getFlashGridHTML, getLinkThemeString, link, language}) => ({ + title: language.$('flashIndex.title'), main: { - classes: ["flash-index"], + classes: ['flash-index'], content: fixWS` - <h1>${language.$("flashIndex.title")}</h1> + <h1>${language.$('flashIndex.title')}</h1> <div class="long-content"> - <p class="quick-info">${language.$("misc.jumpTo")}</p> + <p class="quick-info">${language.$('misc.jumpTo')}</p> <ul class="quick-info"> ${flashActData .filter((act) => act.jump) .map( - ({ anchor, jump, jumpColor }) => fixWS` + ({anchor, jump, jumpColor}) => fixWS` <li><a href="#${anchor}" style="${getLinkThemeString( jumpColor )}">${jump}</a></li> ` ) - .join("\n")} + .join('\n')} </ul> </div> ${flashActData @@ -171,11 +171,11 @@ export function writeTargetless({ wikiData }) { </div> ` ) - .join("\n")} + .join('\n')} `, }, - nav: { simple: true }, + nav: {simple: true}, }), }; @@ -186,32 +186,26 @@ export function writeTargetless({ wikiData }) { function generateNavForFlash( flash, - { - generateChronologyLinks, - generatePreviousNextLinks, - link, - language, - wikiData, - } + {generateChronologyLinks, generatePreviousNextLinks, link, language, wikiData} ) { - const { flashData, wikiInfo } = wikiData; + const {flashData, wikiInfo} = wikiData; const previousNextLinks = generatePreviousNextLinks(flash, { data: flashData, - linkKey: "flash", + linkKey: 'flash', }); return { - linkContainerClasses: ["nav-links-hierarchy"], + linkContainerClasses: ['nav-links-hierarchy'], links: [ - { toHome: true }, + {toHome: true}, { - path: ["localized.flashIndex"], - title: language.$("flashIndex.title"), + path: ['localized.flashIndex'], + title: language.$('flashIndex.title'), }, { - html: language.$("flashPage.nav.flash", { - flash: link.flash(flash, { class: "current" }), + html: language.$('flashPage.nav.flash', { + flash: link.flash(flash, {class: 'current'}), }), }, ], @@ -221,8 +215,8 @@ function generateNavForFlash( content: fixWS` <div> ${generateChronologyLinks(flash, { - headingString: "misc.chronology.heading.flash", - contribKey: "contributorContribs", + headingString: 'misc.chronology.heading.flash', + contribKey: 'contributorContribs', getThings: (artist) => artist.flashesAsContributor, })} </div> @@ -230,21 +224,21 @@ function generateNavForFlash( }; } -function generateSidebarForFlash(flash, { link, language, wikiData }) { +function generateSidebarForFlash(flash, {link, language, wikiData}) { // all hard-coded, sorry :( // this doesnt have a super portable implementation/design...yet!! - const { flashActData } = wikiData; + const {flashActData} = wikiData; - const act6 = flashActData.findIndex((act) => act.name.startsWith("Act 6")); + const act6 = flashActData.findIndex((act) => act.name.startsWith('Act 6')); const postCanon = flashActData.findIndex((act) => - act.name.includes("Post Canon") + act.name.includes('Post Canon') ); const outsideCanon = postCanon + flashActData .slice(postCanon) - .findIndex((act) => !act.name.includes("Post Canon")); + .findIndex((act) => !act.name.includes('Post Canon')); const actIndex = flashActData.indexOf(flash.act); const side = actIndex < 0 ? 0 : actIndex < act6 ? 1 : actIndex <= outsideCanon ? 2 : 3; @@ -252,18 +246,18 @@ function generateSidebarForFlash(flash, { link, language, wikiData }) { return { content: fixWS` - <h1>${link.flashIndex("", { - text: language.$("flashIndex.title"), + <h1>${link.flashIndex('', { + text: language.$('flashIndex.title'), })}</h1> <dl> ${flashActData .filter( (act) => - act.name.startsWith("Act 1") || - act.name.startsWith("Act 6 Act 1") || - act.name.startsWith("Hiveswap") || + act.name.startsWith('Act 1') || + act.name.startsWith('Act 6 Act 1') || + act.name.startsWith('Hiveswap') || // Sorry not sorry -Yiffy - (({ index = flashActData.indexOf(act) } = {}) => + (({index = flashActData.indexOf(act)} = {}) => index < act6 ? side === 1 : index < outsideCanon @@ -271,43 +265,43 @@ function generateSidebarForFlash(flash, { link, language, wikiData }) { : true)() ) .flatMap((act) => [ - (act.name.startsWith("Act 1") && + (act.name.startsWith('Act 1') && html.tag( - "dt", - { class: ["side", side === 1 && "current"] }, + 'dt', + {class: ['side', side === 1 && 'current']}, link.flash(act.flashes[0], { - color: "#4ac925", + color: '#4ac925', text: `Side 1 (Acts 1-5)`, }) )) || - (act.name.startsWith("Act 6 Act 1") && + (act.name.startsWith('Act 6 Act 1') && html.tag( - "dt", - { class: ["side", side === 2 && "current"] }, + 'dt', + {class: ['side', side === 2 && 'current']}, link.flash(act.flashes[0], { - color: "#1076a2", + color: '#1076a2', text: `Side 2 (Acts 6-7)`, }) )) || - (act.name.startsWith("Hiveswap Act 1") && + (act.name.startsWith('Hiveswap Act 1') && html.tag( - "dt", - { class: ["side", side === 3 && "current"] }, + 'dt', + {class: ['side', side === 3 && 'current']}, link.flash(act.flashes[0], { - color: "#008282", + color: '#008282', text: `Outside Canon (Misc. Games)`, }) )), - (({ index = flashActData.indexOf(act) } = {}) => + (({index = flashActData.indexOf(act)} = {}) => index < act6 ? side === 1 : index < outsideCanon ? side === 2 : true)() && html.tag( - "dt", - { class: act === currentAct && "current" }, - link.flash(act.flashes[0], { text: act.name }) + 'dt', + {class: act === currentAct && 'current'}, + link.flash(act.flashes[0], {text: act.name}) ), act === currentAct && fixWS` @@ -315,17 +309,17 @@ function generateSidebarForFlash(flash, { link, language, wikiData }) { ${act.flashes .map((f) => html.tag( - "li", - { class: f === flash && "current" }, + 'li', + {class: f === flash && 'current'}, link.flash(f) ) ) - .join("\n")} + .join('\n')} </ul></dd> `, ]) .filter(Boolean) - .join("\n")} + .join('\n')} </dl> `, }; diff --git a/src/page/group.js b/src/page/group.js index b6f99785..c7de2fbc 100644 --- a/src/page/group.js +++ b/src/page/group.js @@ -1,25 +1,25 @@ -// @format -// +/** @format */ + // Group page specifications. // Imports -import fixWS from "fix-whitespace"; +import fixWS from 'fix-whitespace'; -import * as html from "../util/html.js"; +import * as html from '../util/html.js'; -import { getTotalDuration, sortChronologically } from "../util/wiki-data.js"; +import {getTotalDuration, sortChronologically} from '../util/wiki-data.js'; // Page exports -export function targets({ wikiData }) { +export function targets({wikiData}) { return wikiData.groupData; } -export function write(group, { wikiData }) { - const { listingSpec, wikiInfo } = wikiData; +export function write(group, {wikiData}) { + const {listingSpec, wikiInfo} = wikiData; - const { albums } = group; + const {albums} = group; const tracks = albums.flatMap((album) => album.tracks); const totalDuration = getTotalDuration(tracks); @@ -29,8 +29,8 @@ export function write(group, { wikiData }) { })); const infoPage = { - type: "page", - path: ["groupInfo", group.directory], + type: 'page', + path: ['groupInfo', group.directory], page: ({ generateInfoGalleryLinks, generatePreviousNextLinks, @@ -41,57 +41,57 @@ export function write(group, { wikiData }) { language, transformMultiline, }) => ({ - title: language.$("groupInfoPage.title", { group: group.name }), + title: language.$('groupInfoPage.title', {group: group.name}), theme: getThemeString(group.color), main: { content: fixWS` - <h1>${language.$("groupInfoPage.title", { + <h1>${language.$('groupInfoPage.title', { group: group.name, })}</h1> ${ group.urls?.length && - `<p>${language.$("releaseInfo.visitOn", { + `<p>${language.$('releaseInfo.visitOn', { links: language.formatDisjunctionList( - group.urls.map((url) => fancifyURL(url, { language })) + group.urls.map((url) => fancifyURL(url, {language})) ), })}</p>` } <blockquote> ${transformMultiline(group.description)} </blockquote> - <h2>${language.$("groupInfoPage.albumList.title")}</h2> - <p>${language.$("groupInfoPage.viewAlbumGallery", { + <h2>${language.$('groupInfoPage.albumList.title')}</h2> + <p>${language.$('groupInfoPage.viewAlbumGallery', { link: link.groupGallery(group, { - text: language.$("groupInfoPage.viewAlbumGallery.link"), + text: language.$('groupInfoPage.viewAlbumGallery.link'), }), })}</p> <ul> ${albumLines - .map(({ album, otherGroup }) => { + .map(({album, otherGroup}) => { const item = album.date - ? language.$("groupInfoPage.albumList.item", { + ? language.$('groupInfoPage.albumList.item', { year: album.date.getFullYear(), album: link.album(album), }) : language.$( - "groupInfoPage.albumList.item.withoutYear", + 'groupInfoPage.albumList.item.withoutYear', { album: link.album(album), } ); return html.tag( - "li", + 'li', otherGroup ? language.$( - "groupInfoPage.albumList.item.withAccent", + 'groupInfoPage.albumList.item.withAccent', { item, accent: html.tag( - "span", - { class: "other-group-accent" }, + 'span', + {class: 'other-group-accent'}, language.$( - "groupInfoPage.albumList.item.otherGroupAccent", + 'groupInfoPage.albumList.item.otherGroupAccent', { group: link.groupInfo(otherGroup, { color: false, @@ -104,7 +104,7 @@ export function write(group, { wikiData }) { : item ); }) - .join("\n")} + .join('\n')} </ul> `, }, @@ -127,8 +127,8 @@ export function write(group, { wikiData }) { }; const galleryPage = { - type: "page", - path: ["groupGallery", group.directory], + type: 'page', + path: ['groupGallery', group.directory], page: ({ generateInfoGalleryLinks, generatePreviousNextLinks, @@ -138,17 +138,17 @@ export function write(group, { wikiData }) { link, language, }) => ({ - title: language.$("groupGalleryPage.title", { group: group.name }), + title: language.$('groupGalleryPage.title', {group: group.name}), theme: getThemeString(group.color), main: { - classes: ["top-index"], + classes: ['top-index'], content: fixWS` - <h1>${language.$("groupGalleryPage.title", { + <h1>${language.$('groupGalleryPage.title', { group: group.name, })}</h1> <p class="quick-info">${language.$( - "groupGalleryPage.infoLine", + 'groupGalleryPage.infoLine', { tracks: `<b>${language.countTracks(tracks.length, { unit: true, @@ -165,16 +165,16 @@ export function write(group, { wikiData }) { wikiInfo.enableGroupUI && wikiInfo.enableListings && html.tag( - "p", - { class: "quick-info" }, - language.$("groupGalleryPage.anotherGroupLine", { + 'p', + {class: 'quick-info'}, + language.$('groupGalleryPage.anotherGroupLine', { link: link.listing( listingSpec.find( - (l) => l.directory === "groups/by-category" + (l) => l.directory === 'groups/by-category' ), { text: language.$( - "groupGalleryPage.anotherGroupLine.link" + 'groupGalleryPage.anotherGroupLine.link' ), } ), @@ -222,45 +222,45 @@ export function write(group, { wikiData }) { function generateGroupSidebar( currentGroup, isGallery, - { getLinkThemeString, link, language, wikiData } + {getLinkThemeString, link, language, wikiData} ) { - const { groupCategoryData, wikiInfo } = wikiData; + const {groupCategoryData, wikiInfo} = wikiData; if (!wikiInfo.enableGroupUI) { return null; } - const linkKey = isGallery ? "groupGallery" : "groupInfo"; + const linkKey = isGallery ? 'groupGallery' : 'groupInfo'; return { content: fixWS` - <h1>${language.$("groupSidebar.title")}</h1> + <h1>${language.$('groupSidebar.title')}</h1> ${groupCategoryData .map((category) => html.tag( - "details", + 'details', { open: category === currentGroup.category, - class: category === currentGroup.category && "current", + class: category === currentGroup.category && 'current', }, [ html.tag( - "summary", - { style: getLinkThemeString(category.color) }, - language.$("groupSidebar.groupList.category", { + 'summary', + {style: getLinkThemeString(category.color)}, + language.$('groupSidebar.groupList.category', { category: `<span class="group-name">${category.name}</span>`, }) ), html.tag( - "ul", + 'ul', category.groups.map((group) => html.tag( - "li", + 'li', { - class: group === currentGroup && "current", + class: group === currentGroup && 'current', style: getLinkThemeString(group.color), }, - language.$("groupSidebar.groupList.item", { + language.$('groupSidebar.groupList.item', { group: link[linkKey](group), }) ) @@ -269,7 +269,7 @@ function generateGroupSidebar( ] ) ) - .join("\n")} + .join('\n')} </dl> `, }; @@ -286,18 +286,18 @@ function generateGroupNav( wikiData, } ) { - const { groupData, wikiInfo } = wikiData; + const {groupData, wikiInfo} = wikiData; if (!wikiInfo.enableGroupUI) { - return { simple: true }; + return {simple: true}; } - const urlKey = isGallery ? "localized.groupGallery" : "localized.groupInfo"; - const linkKey = isGallery ? "groupGallery" : "groupInfo"; + const urlKey = isGallery ? 'localized.groupGallery' : 'localized.groupInfo'; + const linkKey = isGallery ? 'groupGallery' : 'groupInfo'; const infoGalleryLinks = generateInfoGalleryLinks(currentGroup, isGallery, { - linkKeyGallery: "groupGallery", - linkKeyInfo: "groupInfo", + linkKeyGallery: 'groupGallery', + linkKeyInfo: 'groupInfo', }); const previousNextLinks = generatePreviousNextLinks(currentGroup, { @@ -306,16 +306,16 @@ function generateGroupNav( }); return { - linkContainerClasses: ["nav-links-hierarchy"], + linkContainerClasses: ['nav-links-hierarchy'], links: [ - { toHome: true }, + {toHome: true}, wikiInfo.enableListings && { - path: ["localized.listingIndex"], - title: language.$("listingIndex.title"), + path: ['localized.listingIndex'], + title: language.$('listingIndex.title'), }, { - html: language.$("groupPage.nav.group", { - group: link[linkKey](currentGroup, { class: "current" }), + html: language.$('groupPage.nav.group', { + group: link[linkKey](currentGroup, {class: 'current'}), }), }, { diff --git a/src/page/homepage.js b/src/page/homepage.js index 8d20accf..7701a73c 100644 --- a/src/page/homepage.js +++ b/src/page/homepage.js @@ -1,23 +1,23 @@ -// @format -// +/** @format */ + // Homepage specification. // Imports -import fixWS from "fix-whitespace"; +import fixWS from 'fix-whitespace'; -import * as html from "../util/html.js"; +import * as html from '../util/html.js'; -import { getNewAdditions, getNewReleases } from "../util/wiki-data.js"; +import {getNewAdditions, getNewReleases} from '../util/wiki-data.js'; // Page exports -export function writeTargetless({ wikiData }) { - const { newsData, staticPageData, homepageLayout, wikiInfo } = wikiData; +export function writeTargetless({wikiData}) { + const {newsData, staticPageData, homepageLayout, wikiInfo} = wikiData; const page = { - type: "page", - path: ["home"], + type: 'page', + path: ['home'], page: ({ getAlbumGridHTML, getLinkThemeString, @@ -35,7 +35,7 @@ export function writeTargetless({ wikiData }) { }, main: { - classes: ["top-index"], + classes: ['top-index'], content: fixWS` <h1>${wikiInfo.name}</h1> ${homepageLayout.rows @@ -46,21 +46,21 @@ export function writeTargetless({ wikiData }) { )}"> <h2>${row.name}</h2> ${ - row.type === "albums" && + row.type === 'albums' && fixWS` <div class="grid-listing"> ${getAlbumGridHTML({ entries: (row.sourceGroupByRef === - "new-releases" + 'new-releases' ? getNewReleases( row.countAlbumsFromGroup, - { wikiData } + {wikiData} ) : row.sourceGroupByRef === - "new-additions" + 'new-additions' ? getNewAdditions( row.countAlbumsFromGroup, - { wikiData } + {wikiData} ) : (row.sourceGroup?.albums ?? []) .slice() @@ -70,7 +70,7 @@ export function writeTargetless({ wikiData }) { album.isListedOnHomepage ) .slice(0, row.countAlbumsFromGroup) - .map((album) => ({ item: album })) + .map((album) => ({item: album})) ).concat( row.sourceAlbums.map((album) => ({ item: album, @@ -85,11 +85,11 @@ export function writeTargetless({ wikiData }) { ${row.actionLinks .map((action) => transformInline(action).replace( - "<a", + '<a', '<a class="box grid-item"' ) ) - .join("\n")} + .join('\n')} </div> ` } @@ -99,7 +99,7 @@ export function writeTargetless({ wikiData }) { </section> ` ) - .join("\n")} + .join('\n')} `, }, @@ -117,21 +117,21 @@ export function writeTargetless({ wikiData }) { // And no, I will not make [[news]] into part of transformMultiline // (even though that would 8e hilarious). content: transformMultiline( - homepageLayout.sidebarContent.replace("[[news]]", "__GENERATE_NEWS__") + homepageLayout.sidebarContent.replace('[[news]]', '__GENERATE_NEWS__') ).replace( - "<p>__GENERATE_NEWS__</p>", + '<p>__GENERATE_NEWS__</p>', wikiInfo.enableNews ? fixWS` - <h1>${language.$("homepage.news.title")}</h1> + <h1>${language.$('homepage.news.title')}</h1> ${newsData .slice(0, 3) .map((entry, i) => html.tag( - "article", + 'article', { class: [ - "news-entry", - i === 0 && "first-news-entry", + 'news-entry', + i === 0 && 'first-news-entry', ], }, fixWS` @@ -143,42 +143,42 @@ export function writeTargetless({ wikiData }) { entry.contentShort !== entry.content && link.newsEntry(entry, { text: language.$( - "homepage.news.entry.viewRest" + 'homepage.news.entry.viewRest' ), }) } ` ) ) - .join("\n")} + .join('\n')} ` : `<p><i>News requested in content description but this feature isn't enabled</i></p>` ), }, nav: { - linkContainerClasses: ["nav-links-index"], + linkContainerClasses: ['nav-links-index'], links: [ - link.home("", { text: wikiInfo.nameShort, class: "current", to }), + link.home('', {text: wikiInfo.nameShort, class: 'current', to}), wikiInfo.enableListings && - link.listingIndex("", { - text: language.$("listingIndex.title"), + link.listingIndex('', { + text: language.$('listingIndex.title'), to, }), wikiInfo.enableNews && - link.newsIndex("", { text: language.$("newsIndex.title"), to }), + link.newsIndex('', {text: language.$('newsIndex.title'), to}), wikiInfo.enableFlashesAndGames && - link.flashIndex("", { text: language.$("flashIndex.title"), to }), + link.flashIndex('', {text: language.$('flashIndex.title'), to}), ...staticPageData .filter((page) => page.showInNavigationBar) - .map((page) => link.staticPage(page, { text: page.nameShort })), + .map((page) => link.staticPage(page, {text: page.nameShort})), ] .filter(Boolean) - .map((html) => ({ html })), + .map((html) => ({html})), }, }), }; diff --git a/src/page/index.js b/src/page/index.js index 3d7e6fa8..149503f0 100644 --- a/src/page/index.js +++ b/src/page/index.js @@ -1,5 +1,5 @@ -// @format -// +/** @format */ + // NB: This is the index for the page/ directory and contains exports for all // other modules here! It's not the page spec for the homepage - see // homepage.js for that. @@ -41,15 +41,15 @@ // These functions should be referenced only from adjacent modules, as they // pertain only to site page generation. -export * as album from "./album.js"; -export * as albumCommentary from "./album-commentary.js"; -export * as artist from "./artist.js"; -export * as artistAlias from "./artist-alias.js"; -export * as flash from "./flash.js"; -export * as group from "./group.js"; -export * as homepage from "./homepage.js"; -export * as listing from "./listing.js"; -export * as news from "./news.js"; -export * as static from "./static.js"; -export * as tag from "./tag.js"; -export * as track from "./track.js"; +export * as album from './album.js'; +export * as albumCommentary from './album-commentary.js'; +export * as artist from './artist.js'; +export * as artistAlias from './artist-alias.js'; +export * as flash from './flash.js'; +export * as group from './group.js'; +export * as homepage from './homepage.js'; +export * as listing from './listing.js'; +export * as news from './news.js'; +export * as static from './static.js'; +export * as tag from './tag.js'; +export * as track from './track.js'; diff --git a/src/page/listing.js b/src/page/listing.js index 69fa4919..90415ded 100644 --- a/src/page/listing.js +++ b/src/page/listing.js @@ -1,5 +1,5 @@ -// @format -// +/** @format */ + // Listing page specification. // // The targets here are a bit different than for most pages: rather than data @@ -12,36 +12,36 @@ // Imports -import fixWS from "fix-whitespace"; +import fixWS from 'fix-whitespace'; -import * as html from "../util/html.js"; +import * as html from '../util/html.js'; -import { getTotalDuration } from "../util/wiki-data.js"; +import {getTotalDuration} from '../util/wiki-data.js'; // Page exports -export function condition({ wikiData }) { +export function condition({wikiData}) { return wikiData.wikiInfo.enableListings; } -export function targets({ wikiData }) { +export function targets({wikiData}) { return wikiData.listingSpec; } -export function write(listing, { wikiData }) { - if (listing.condition && !listing.condition({ wikiData })) { +export function write(listing, {wikiData}) { + if (listing.condition && !listing.condition({wikiData})) { return null; } - const { wikiInfo } = wikiData; + const {wikiInfo} = wikiData; - const data = listing.data ? listing.data({ wikiData }) : null; + const data = listing.data ? listing.data({wikiData}) : null; const page = { - type: "page", - path: ["listing", listing.directory], + type: 'page', + path: ['listing', listing.directory], page: (opts) => { - const { getLinkThemeString, link, language } = opts; + const {getLinkThemeString, link, language} = opts; const titleKey = `listingPage.${listing.stringsKey}.title`; return { @@ -63,7 +63,7 @@ export function write(listing, { wikiData }) { ${data .map((item) => listing.row(item, opts)) .map((row) => `<li>${row}</li>`) - .join("\n")} + .join('\n')} </ul> ` } @@ -80,14 +80,14 @@ export function write(listing, { wikiData }) { }, nav: { - linkContainerClasses: ["nav-links-hierarchy"], + linkContainerClasses: ['nav-links-hierarchy'], links: [ - { toHome: true }, + {toHome: true}, { - path: ["localized.listingIndex"], - title: language.$("listingIndex.title"), + path: ['localized.listingIndex'], + title: language.$('listingIndex.title'), }, - { toCurrentPage: true }, + {toCurrentPage: true}, ], }, }; @@ -97,21 +97,21 @@ export function write(listing, { wikiData }) { return [page]; } -export function writeTargetless({ wikiData }) { - const { albumData, trackData, wikiInfo } = wikiData; +export function writeTargetless({wikiData}) { + const {albumData, trackData, wikiInfo} = wikiData; const totalDuration = getTotalDuration(trackData); const page = { - type: "page", - path: ["listingIndex"], - page: ({ getLinkThemeString, language, link }) => ({ - title: language.$("listingIndex.title"), + type: 'page', + path: ['listingIndex'], + page: ({getLinkThemeString, language, link}) => ({ + title: language.$('listingIndex.title'), main: { content: fixWS` - <h1>${language.$("listingIndex.title")}</h1> - <p>${language.$("listingIndex.infoLine", { + <h1>${language.$('listingIndex.title')}</h1> + <p>${language.$('listingIndex.infoLine', { wiki: wikiInfo.name, tracks: `<b>${language.countTracks(trackData.length, { unit: true, @@ -125,7 +125,7 @@ export function writeTargetless({ wikiData }) { })}</b>`, })}</p> <hr> - <p>${language.$("listingIndex.exploreList")}</p> + <p>${language.$('listingIndex.exploreList')}</p> ${generateLinkIndexForListings(null, false, { link, language, @@ -143,7 +143,7 @@ export function writeTargetless({ wikiData }) { }), }, - nav: { simple: true }, + nav: {simple: true}, }), }; @@ -154,11 +154,11 @@ export function writeTargetless({ wikiData }) { function generateSidebarForListings( currentListing, - { getLinkThemeString, link, language, wikiData } + {getLinkThemeString, link, language, wikiData} ) { return fixWS` - <h1>${link.listingIndex("", { - text: language.$("listingIndex.title"), + <h1>${link.listingIndex('', { + text: language.$('listingIndex.title'), })}</h1> ${generateLinkIndexForListings(currentListing, true, { getLinkThemeString, @@ -172,24 +172,24 @@ function generateSidebarForListings( function generateLinkIndexForListings( currentListing, forSidebar, - { getLinkThemeString, link, language, wikiData } + {getLinkThemeString, link, language, wikiData} ) { - const { listingTargetSpec, wikiInfo } = wikiData; + const {listingTargetSpec, wikiInfo} = wikiData; const filteredByCondition = listingTargetSpec - .map(({ listings, ...rest }) => ({ + .map(({listings, ...rest}) => ({ ...rest, - listings: listings.filter(({ condition: c }) => !c || c({ wikiData })), + listings: listings.filter(({condition: c}) => !c || c({wikiData})), })) - .filter(({ listings }) => listings.length > 0); + .filter(({listings}) => listings.length > 0); const genUL = (listings) => html.tag( - "ul", + 'ul', listings.map((listing) => html.tag( - "li", - { class: [listing === currentListing && "current"] }, + 'li', + {class: [listing === currentListing && 'current']}, link.listing(listing, { text: language.$(`listingPage.${listing.stringsKey}.title.short`), }) @@ -199,30 +199,30 @@ function generateLinkIndexForListings( if (forSidebar) { return filteredByCondition - .map(({ title, listings }) => + .map(({title, listings}) => html.tag( - "details", + 'details', { open: !forSidebar || listings.includes(currentListing), - class: listings.includes(currentListing) && "current", + class: listings.includes(currentListing) && 'current', }, [ html.tag( - "summary", - { style: getLinkThemeString(wikiInfo.color) }, - html.tag("span", { class: "group-name" }, title({ language })) + 'summary', + {style: getLinkThemeString(wikiInfo.color)}, + html.tag('span', {class: 'group-name'}, title({language})) ), genUL(listings), ] ) ) - .join("\n"); + .join('\n'); } else { return html.tag( - "dl", - filteredByCondition.flatMap(({ title, listings }) => [ - html.tag("dt", title({ language })), - html.tag("dd", genUL(listings)), + 'dl', + filteredByCondition.flatMap(({title, listings}) => [ + html.tag('dt', title({language})), + html.tag('dd', genUL(listings)), ]) ); } diff --git a/src/page/news.js b/src/page/news.js index b988e348..bf581e43 100644 --- a/src/page/news.js +++ b/src/page/news.js @@ -1,40 +1,40 @@ -// @format -// +/** @format */ + // News entry & index page specifications. // Imports -import fixWS from "fix-whitespace"; +import fixWS from 'fix-whitespace'; // Page exports -export function condition({ wikiData }) { +export function condition({wikiData}) { return wikiData.wikiInfo.enableNews; } -export function targets({ wikiData }) { +export function targets({wikiData}) { return wikiData.newsData; } -export function write(entry, { wikiData }) { +export function write(entry, {wikiData}) { const page = { - type: "page", - path: ["newsEntry", entry.directory], + type: 'page', + path: ['newsEntry', entry.directory], page: ({ generatePreviousNextLinks, link, language, transformMultiline, }) => ({ - title: language.$("newsEntryPage.title", { entry: entry.name }), + title: language.$('newsEntryPage.title', {entry: entry.name}), main: { content: fixWS` <div class="long-content"> - <h1>${language.$("newsEntryPage.title", { + <h1>${language.$('newsEntryPage.title', { entry: entry.name, })}</h1> - <p>${language.$("newsEntryPage.published", { + <p>${language.$('newsEntryPage.published', { date: language.formatDate(entry.date), })}</p> ${transformMultiline(entry.content)} @@ -54,19 +54,19 @@ export function write(entry, { wikiData }) { return [page]; } -export function writeTargetless({ wikiData }) { - const { newsData } = wikiData; +export function writeTargetless({wikiData}) { + const {newsData} = wikiData; const page = { - type: "page", - path: ["newsIndex"], - page: ({ link, language, transformMultiline }) => ({ - title: language.$("newsIndex.title"), + type: 'page', + path: ['newsIndex'], + page: ({link, language, transformMultiline}) => ({ + title: language.$('newsIndex.title'), main: { content: fixWS` <div class="long-content news-index"> - <h1>${language.$("newsIndex.title")}</h1> + <h1>${language.$('newsIndex.title')}</h1> ${newsData .map( (entry) => fixWS` @@ -79,19 +79,19 @@ export function writeTargetless({ wikiData }) { entry.contentShort !== entry.content && `<p>${link.newsEntry(entry, { text: language.$( - "newsIndex.entry.viewRest" + 'newsIndex.entry.viewRest' ), })}</p>` } </article> ` ) - .join("\n")} + .join('\n')} </div> `, }, - nav: { simple: true }, + nav: {simple: true}, }), }; @@ -102,9 +102,9 @@ export function writeTargetless({ wikiData }) { function generateNewsEntryNav( entry, - { generatePreviousNextLinks, link, language, wikiData } + {generatePreviousNextLinks, link, language, wikiData} ) { - const { wikiInfo, newsData } = wikiData; + const {wikiInfo, newsData} = wikiData; // The newsData list is sorted reverse chronologically (newest ones first), // so the way we find next/previous entries is flipped from normal. @@ -112,21 +112,21 @@ function generateNewsEntryNav( link, language, data: newsData.slice().reverse(), - linkKey: "newsEntry", + linkKey: 'newsEntry', }); return { - linkContainerClasses: ["nav-links-hierarchy"], + linkContainerClasses: ['nav-links-hierarchy'], links: [ - { toHome: true }, + {toHome: true}, { - path: ["localized.newsIndex"], - title: language.$("newsEntryPage.nav.news"), + path: ['localized.newsIndex'], + title: language.$('newsEntryPage.nav.news'), }, { - html: language.$("newsEntryPage.nav.entry", { + html: language.$('newsEntryPage.nav.entry', { date: language.formatDate(entry.date), - entry: link.newsEntry(entry, { class: "current" }), + entry: link.newsEntry(entry, {class: 'current'}), }), }, previousNextLinks && { diff --git a/src/page/static.js b/src/page/static.js index ecd77c9a..f4a81972 100644 --- a/src/page/static.js +++ b/src/page/static.js @@ -1,24 +1,24 @@ -// @format -// +/** @format */ + // Static content page specification. (These are static pages coded into the // wiki data folder, used for a variety of purposes, e.g. wiki info, // changelog, and so on.) // Imports -import fixWS from "fix-whitespace"; +import fixWS from 'fix-whitespace'; // Page exports -export function targets({ wikiData }) { +export function targets({wikiData}) { return wikiData.staticPageData; } -export function write(staticPage, { wikiData }) { +export function write(staticPage, {wikiData}) { const page = { - type: "page", - path: ["staticPage", staticPage.directory], - page: ({ language, transformMultiline }) => ({ + type: 'page', + path: ['staticPage', staticPage.directory], + page: ({language, transformMultiline}) => ({ title: staticPage.name, stylesheet: staticPage.stylesheet, @@ -31,7 +31,7 @@ export function write(staticPage, { wikiData }) { `, }, - nav: { simple: true }, + nav: {simple: true}, }), }; diff --git a/src/page/tag.js b/src/page/tag.js index efd95e16..4b2322d0 100644 --- a/src/page/tag.js +++ b/src/page/tag.js @@ -1,34 +1,34 @@ -// @format -// +/** @format */ + // Art tag page specification. // Imports -import fixWS from "fix-whitespace"; +import fixWS from 'fix-whitespace'; // Page exports -export function condition({ wikiData }) { +export function condition({wikiData}) { return wikiData.wikiInfo.enableArtTagUI; } -export function targets({ wikiData }) { +export function targets({wikiData}) { return wikiData.artTagData.filter((tag) => !tag.isContentWarning); } -export function write(tag, { wikiData }) { - const { wikiInfo } = wikiData; - const { taggedInThings: things } = tag; +export function write(tag, {wikiData}) { + const {wikiInfo} = wikiData; + const {taggedInThings: things} = tag; // Display things featuring this art tag in reverse chronological order, // sticking the most recent additions near the top! const thingsReversed = things.slice().reverse(); - const entries = thingsReversed.map((item) => ({ item })); + const entries = thingsReversed.map((item) => ({item})); const page = { - type: "page", - path: ["tag", tag.directory], + type: 'page', + path: ['tag', tag.directory], page: ({ generatePreviousNextLinks, getAlbumCover, @@ -39,14 +39,14 @@ export function write(tag, { wikiData }) { language, to, }) => ({ - title: language.$("tagPage.title", { tag: tag.name }), + title: language.$('tagPage.title', {tag: tag.name}), theme: getThemeString(tag.color), main: { - classes: ["top-index"], + classes: ['top-index'], content: fixWS` - <h1>${language.$("tagPage.title", { tag: tag.name })}</h1> - <p class="quick-info">${language.$("tagPage.infoLine", { + <h1>${language.$('tagPage.title', {tag: tag.name})}</h1> + <p class="quick-info">${language.$('tagPage.infoLine', { coverArts: language.countCoverArts(things.length, { unit: true, }), @@ -83,24 +83,24 @@ export function write(tag, { wikiData }) { function generateTagNav( tag, - { generatePreviousNextLinks, link, language, wikiData } + {generatePreviousNextLinks, link, language, wikiData} ) { const previousNextLinks = generatePreviousNextLinks(tag, { data: wikiData.artTagData.filter((tag) => !tag.isContentWarning), - linkKey: "tag", + linkKey: 'tag', }); return { - linkContainerClasses: ["nav-links-hierarchy"], + linkContainerClasses: ['nav-links-hierarchy'], links: [ - { toHome: true }, + {toHome: true}, wikiData.wikiInfo.enableListings && { - path: ["localized.listingIndex"], - title: language.$("listingIndex.title"), + path: ['localized.listingIndex'], + title: language.$('listingIndex.title'), }, { - html: language.$("tagPage.nav.tag", { - tag: link.tag(tag, { class: "current" }), + html: language.$('tagPage.nav.tag', { + tag: link.tag(tag, {class: 'current'}), }), }, /* diff --git a/src/page/track.js b/src/page/track.js index 5827197d..a9758ec2 100644 --- a/src/page/track.js +++ b/src/page/track.js @@ -1,37 +1,37 @@ -// @format -// +/** @format */ + // Track page specification. // Imports -import fixWS from "fix-whitespace"; +import fixWS from 'fix-whitespace'; import { generateAlbumChronologyLinks, generateAlbumNavLinks, generateAlbumSecondaryNav, generateAlbumSidebar, -} from "./album.js"; +} from './album.js'; -import * as html from "../util/html.js"; +import * as html from '../util/html.js'; -import { bindOpts } from "../util/sugar.js"; +import {bindOpts} from '../util/sugar.js'; import { getTrackCover, getAlbumListTag, sortChronologically, -} from "../util/wiki-data.js"; +} from '../util/wiki-data.js'; // Page exports -export function targets({ wikiData }) { +export function targets({wikiData}) { return wikiData.trackData; } -export function write(track, { wikiData }) { - const { groupData, wikiInfo } = wikiData; - const { album, referencedByTracks, referencedTracks, otherReleases } = track; +export function write(track, {wikiData}) { + const {groupData, wikiInfo} = wikiData; + const {album, referencedByTracks, referencedTracks, otherReleases} = track; const listTag = getAlbumListTag(album); @@ -50,12 +50,12 @@ export function write(track, { wikiData }) { ); } - const unbound_getTrackItem = (track, { getArtistString, link, language }) => + const unbound_getTrackItem = (track, {getArtistString, link, language}) => html.tag( - "li", - language.$("trackList.item.withArtists", { + 'li', + language.$('trackList.item.withArtists', { track: link.track(track), - by: `<span class="by">${language.$("trackList.item.withArtists.by", { + by: `<span class="by">${language.$('trackList.item.withArtists.by', { artists: getArtistString(track.artistContribs), })}</span>`, }) @@ -63,46 +63,46 @@ export function write(track, { wikiData }) { const unbound_generateTrackList = ( tracks, - { getArtistString, link, language } + {getArtistString, link, language} ) => html.tag( - "ul", + 'ul', tracks.map((track) => - unbound_getTrackItem(track, { getArtistString, link, language }) + unbound_getTrackItem(track, {getArtistString, link, language}) ) ); const hasCommentary = track.commentary || otherReleases.some((t) => t.commentary); - const generateCommentary = ({ link, language, transformMultiline }) => + const generateCommentary = ({link, language, transformMultiline}) => transformMultiline( [ track.commentary, ...otherReleases.map((track) => track.commentary - ?.split("\n") - .filter((line) => line.replace(/<\/b>/g, "").includes(":</i>")) + ?.split('\n') + .filter((line) => line.replace(/<\/b>/g, '').includes(':</i>')) .map( (line) => fixWS` ${line} ${language.$( - "releaseInfo.artistCommentary.seeOriginalRelease", + 'releaseInfo.artistCommentary.seeOriginalRelease', { original: link.track(track), } )} ` ) - .join("\n") + .join('\n') ), ] .filter(Boolean) - .join("\n") + .join('\n') ); const data = { - type: "data", - path: ["track", track.directory], + type: 'data', + path: ['track', track.directory], data: ({ serializeContribs, serializeCover, @@ -145,19 +145,19 @@ export function write(track, { wikiData }) { // they don't get parsed and displayed, generally speaking), so // override the link argument so that artist "links" just show // their names. - link: { artist: (artist) => artist.name }, + link: {artist: (artist) => artist.name}, }); - if (!hasArtists && !hasCoverArtists) return ""; + if (!hasArtists && !hasCoverArtists) return ''; return language.formatString( - "trackPage.socialEmbed.body" + - [hasArtists && ".withArtists", hasCoverArtists && ".withCoverArtists"] + 'trackPage.socialEmbed.body' + + [hasArtists && '.withArtists', hasCoverArtists && '.withCoverArtists'] .filter(Boolean) - .join(""), + .join(''), Object.fromEntries( [ - hasArtists && ["artists", getArtistString(track.artistContribs)], + hasArtists && ['artists', getArtistString(track.artistContribs)], hasCoverArtists && [ - "coverArtists", + 'coverArtists', getArtistString(track.coverArtistContribs), ], ].filter(Boolean) @@ -166,8 +166,8 @@ export function write(track, { wikiData }) { }; const page = { - type: "page", - path: ["track", track.directory], + type: 'page', + path: ['track', track.directory], page: ({ absoluteTo, fancifyURL, @@ -196,24 +196,23 @@ export function write(track, { wikiData }) { const cover = getTrackCover(track); return { - title: language.$("trackPage.title", { track: track.name }), - stylesheet: getAlbumStylesheet(album, { to }), + title: language.$('trackPage.title', {track: track.name}), + stylesheet: getAlbumStylesheet(album, {to}), theme: getThemeString(track.color, [ `--album-directory: ${album.directory}`, `--track-directory: ${track.directory}`, ]), socialEmbed: { - heading: language.$("trackPage.socialEmbed.heading", { + heading: language.$('trackPage.socialEmbed.heading', { album: track.album.name, }), - headingLink: absoluteTo("localized.album", album.directory), - title: language.$("trackPage.socialEmbed.title", { + headingLink: absoluteTo('localized.album', album.directory), + title: language.$('trackPage.socialEmbed.title', { track: track.name, }), - description: getSocialEmbedDescription({ getArtistString, language }), - image: - "/" + getTrackCover(track, { to: urls.from("shared.root").to }), + description: getSocialEmbedDescription({getArtistString, language}), + image: '/' + getTrackCover(track, {to: urls.from('shared.root').to}), color: track.color, }, @@ -234,23 +233,23 @@ export function write(track, { wikiData }) { cover && generateCoverLink({ src: cover, - alt: language.$("misc.alt.trackCover"), + alt: language.$('misc.alt.trackCover'), tags: track.artTags, }) } - <h1>${language.$("trackPage.title", { + <h1>${language.$('trackPage.title', { track: track.name, })}</h1> <p> ${[ - language.$("releaseInfo.by", { + language.$('releaseInfo.by', { artists: getArtistString(track.artistContribs, { showContrib: true, showIcons: true, }), }), track.coverArtistContribs.length && - language.$("releaseInfo.coverArtBy", { + language.$('releaseInfo.coverArtBy', { artists: getArtistString( track.coverArtistContribs, { @@ -260,45 +259,45 @@ export function write(track, { wikiData }) { ), }), track.date && - language.$("releaseInfo.released", { + language.$('releaseInfo.released', { date: language.formatDate(track.date), }), track.coverArtDate && +track.coverArtDate !== +track.date && - language.$("releaseInfo.artReleased", { + language.$('releaseInfo.artReleased', { date: language.formatDate(track.coverArtDate), }), track.duration && - language.$("releaseInfo.duration", { + language.$('releaseInfo.duration', { duration: language.formatDuration( track.duration ), }), ] .filter(Boolean) - .join("<br>\n")} + .join('<br>\n')} </p> <p>${ track.urls?.length - ? language.$("releaseInfo.listenOn", { + ? language.$('releaseInfo.listenOn', { links: language.formatDisjunctionList( track.urls.map((url) => - fancifyURL(url, { language }) + fancifyURL(url, {language}) ) ), }) - : language.$("releaseInfo.listenOn.noLinks") + : language.$('releaseInfo.listenOn.noLinks') }</p> ${ otherReleases.length && fixWS` - <p>${language.$("releaseInfo.alsoReleasedAs")}</p> + <p>${language.$('releaseInfo.alsoReleasedAs')}</p> <ul> ${otherReleases .map( (track) => fixWS` <li>${language.$( - "releaseInfo.alsoReleasedAs.item", + 'releaseInfo.alsoReleasedAs.item', { track: link.track(track), album: link.album(track.album), @@ -306,14 +305,14 @@ export function write(track, { wikiData }) { )}</li> ` ) - .join("\n")} + .join('\n')} </ul> ` } ${ track.contributorContribs.length && fixWS` - <p>${language.$("releaseInfo.contributors")}</p> + <p>${language.$('releaseInfo.contributors')}</p> <ul> ${track.contributorContribs .map( @@ -323,18 +322,18 @@ export function write(track, { wikiData }) { showIcons: true, })}</li>` ) - .join("\n")} + .join('\n')} </ul> ` } ${ referencedTracks.length && fixWS` - <p>${language.$("releaseInfo.tracksReferenced", { + <p>${language.$('releaseInfo.tracksReferenced', { track: `<i>${track.name}</i>`, })}</p> ${html.tag( - "ul", + 'ul', referencedTracks.map(getTrackItem) )} ` @@ -342,7 +341,7 @@ export function write(track, { wikiData }) { ${ referencedByTracks.length && fixWS` - <p>${language.$("releaseInfo.tracksThatReference", { + <p>${language.$('releaseInfo.tracksThatReference', { track: `<i>${track.name}</i>`, })}</p> ${generateTrackListDividedByGroups( @@ -358,24 +357,24 @@ export function write(track, { wikiData }) { wikiInfo.enableFlashesAndGames && flashesThatFeature.length && fixWS` - <p>${language.$("releaseInfo.flashesThatFeature", { + <p>${language.$('releaseInfo.flashesThatFeature', { track: `<i>${track.name}</i>`, })}</p> <ul> ${flashesThatFeature - .map(({ flash, as }) => + .map(({flash, as}) => html.tag( - "li", - { class: as !== track && "rerelease" }, + 'li', + {class: as !== track && 'rerelease'}, as === track ? language.$( - "releaseInfo.flashesThatFeature.item", + 'releaseInfo.flashesThatFeature.item', { flash: link.flash(flash), } ) : language.$( - "releaseInfo.flashesThatFeature.item.asDifferentRelease", + 'releaseInfo.flashesThatFeature.item.asDifferentRelease', { flash: link.flash(flash), track: link.track(as), @@ -383,14 +382,14 @@ export function write(track, { wikiData }) { ) ) ) - .join("\n")} + .join('\n')} </ul> ` } ${ track.lyrics && fixWS` - <p>${language.$("releaseInfo.lyrics")}</p> + <p>${language.$('releaseInfo.lyrics')}</p> <blockquote> ${transformLyrics(track.lyrics)} </blockquote> @@ -399,7 +398,7 @@ export function write(track, { wikiData }) { ${ hasCommentary && fixWS` - <p>${language.$("releaseInfo.artistCommentary")}</p> + <p>${language.$('releaseInfo.artistCommentary')}</p> <blockquote> ${generateCommentary({ link, @@ -422,23 +421,23 @@ export function write(track, { wikiData }) { }), nav: { - linkContainerClasses: ["nav-links-hierarchy"], + linkContainerClasses: ['nav-links-hierarchy'], links: [ - { toHome: true }, + {toHome: true}, { - path: ["localized.album", album.directory], + path: ['localized.album', album.directory], title: album.name, }, - listTag === "ol" + listTag === 'ol' ? { - html: language.$("trackPage.nav.track.withNumber", { + html: language.$('trackPage.nav.track.withNumber', { number: album.tracks.indexOf(track) + 1, - track: link.track(track, { class: "current", to }), + track: link.track(track, {class: 'current', to}), }), } : { - html: language.$("trackPage.nav.track", { - track: link.track(track, { class: "current", to }), + html: language.$('trackPage.nav.track', { + track: link.track(track, {class: 'current', to}), }), }, ].filter(Boolean), |