From 70a1fffacce3bef06562589b06f424d341807528 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Fri, 4 Jun 2021 16:14:36 -0300 Subject: module-ify flash pages --- src/upd8.js | 237 ++---------------------------------------------------------- 1 file changed, 5 insertions(+), 232 deletions(-) (limited to 'src/upd8.js') diff --git a/src/upd8.js b/src/upd8.js index 20bb329..40e763c 100755 --- a/src/upd8.js +++ b/src/upd8.js @@ -2215,238 +2215,6 @@ function generateRedirectPage(title, target, {strings}) { `; } -function writeFlashPages({wikiData}) { - const { flashData, wikiInfo } = wikiData; - - if (!wikiInfo.features.flashesAndGames) { - return; - } - - return [ - writeFlashIndex({wikiData}), - ...flashData.map(flash => writeFlashPage(flash, {wikiData})) - ]; -} - -function writeFlashIndex({wikiData}) { - const { flashActData } = wikiData; - - const page = { - type: 'page', - path: ['flashIndex'], - page: ({ - getFlashGridHTML, - link, - strings - }) => ({ - title: strings('flashIndex.title'), - - main: { - classes: ['flash-index'], - content: fixWS` -

${strings('flashIndex.title')}

-
-

${strings('misc.jumpTo')}

- -
- ${flashActData.map((act, i) => fixWS` -

${link.flash(act.flashes[0], {text: act.name})}

-
- ${getFlashGridHTML({ - entries: act.flashes.map(flash => ({item: flash})), - lazy: i === 0 ? 4 : true - })} -
- `).join('\n')} - ` - }, - - nav: {simple: true} - }) - }; - - return [page]; -} - -function writeFlashPage(flash, {wikiData}) { - const page = { - type: 'page', - path: ['flash', flash.directory], - page: ({ - generateCoverLink, - getArtistString, - getFlashCover, - link, - strings, - transformInline - }) => ({ - title: strings('flashPage.title', {flash: flash.name}), - theme: getThemeString(flash.color, [ - `--flash-directory: ${flash.directory}` - ]), - - main: { - content: fixWS` -

${strings('flashPage.title', {flash: flash.name})}

- ${generateCoverLink({ - src: getFlashCover(flash), - alt: strings('misc.alt.flashArt') - })} -

${strings('releaseInfo.released', {date: strings.count.date(flash.date)})}

- ${(flash.page || flash.urls.length) && `

${strings('releaseInfo.playOn', { - links: strings.list.or([ - flash.page && getFlashLink(flash), - ...flash.urls - ].map(url => fancifyFlashURL(url, flash, {strings}))) - })}

`} - ${flash.tracks.length && fixWS` -

Tracks featured in ${flash.name.replace(/\.$/, '')}:

- - `} - ${flash.contributors.textContent && fixWS` -

- ${strings('releaseInfo.contributors')} -
- ${transformInline(flash.contributors.textContent)} -

- `} - ${flash.contributors.length && fixWS` -

${strings('releaseInfo.contributors')}

- - `} - ` - }, - - sidebarLeft: generateSidebarForFlash(flash, {link, strings, wikiData}), - nav: generateNavForFlash(flash, {link, strings, wikiData}) - }) - }; - - return [page]; -} - -function generateNavForFlash(flash, {link, strings, wikiData}) { - const { flashData, wikiInfo } = wikiData; - - const previousNextLinks = generatePreviousNextLinks(flash, { - link, strings, - data: flashData, - linkKey: 'flash' - }); - - return { - links: [ - { - path: ['localized.home'], - title: wikiInfo.shortName - }, - { - path: ['localized.flashIndex'], - title: strings('flashIndex.title') - }, - { - html: strings('flashPage.nav.flash', { - flash: link.flash(flash, {class: 'current'}) - }) - }, - previousNextLinks && - { - divider: false, - html: `(${previousNextLinks})` - } - ], - - content: fixWS` -
- ${generateChronologyLinks(flash, { - link, strings, wikiData, - headingString: 'misc.chronology.heading.flash', - contribKey: 'contributors', - getThings: artist => artist.flashes.asContributor - })} -
- ` - }; -} - -function generateSidebarForFlash(flash, {link, strings, wikiData}) { - // all hard-coded, sorry :( - // this doesnt have a super portable implementation/design...yet!! - - const { flashActData } = wikiData; - - const act6 = flashActData.findIndex(act => act.name.startsWith('Act 6')); - const postCanon = flashActData.findIndex(act => act.name.includes('Post Canon')); - const outsideCanon = postCanon + flashActData.slice(postCanon).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 - ); - const currentAct = flash && flash.act; - - return { - content: fixWS` -

${link.flashIndex('', {text: strings('flashIndex.title')})}

-
- ${flashActData.filter(act => - 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 < act6 ? side === 1 : - index < outsideCanon ? side === 2 : - true - ))() - ).flatMap(act => [ - act.name.startsWith('Act 1') && `
${link.flash(act.flashes[0], {color: '#4ac925', text: `Side 1 (Acts 1-5)`})}
` - || act.name.startsWith('Act 6 Act 1') && `
${link.flash(act.flashes[0], {color: '#1076a2', text: `Side 2 (Acts 6-7)`})}
` - || act.name.startsWith('Hiveswap Act 1') && `
${link.flash(act.flashes[0], {color: '#008282', text: `Outside Canon (Misc. Games)`})}
`, - (({index = flashActData.indexOf(act)} = {}) => ( - index < act6 ? side === 1 : - index < outsideCanon ? side === 2 : - true - ))() - && `
${link.flash(act.flashes[0], {text: act.name})}
`, - act === currentAct && fixWS` -
    - ${act.flashes.map(f => fixWS` -
  • ${link.flash(f)}
  • - `).join('\n')} -
- ` - ]).filter(Boolean).join('\n')} -
- ` - }; -} - function filterAlbumsByCommentary(albums) { return albums.filter(album => [album, ...album.tracks].some(x => x.commentary)); } @@ -3736,6 +3504,11 @@ async function main() { strings }); + bound.fancifyFlashURL = bindOpts(fancifyFlashURL, { + [bindOpts.bindIndex]: 2, + strings + }); + bound.getArtistString = bindOpts(getArtistString, { iconifyURL: bound.iconifyURL, link: bound.link, -- cgit 1.3.0-6-gf8a5