From eefa49a6ef31bf54bac62f18ff85d908d866adbd Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 1 Jun 2021 20:24:47 -0300 Subject: module-ify group pages --- src/upd8.js | 208 ++---------------------------------------------------------- 1 file changed, 7 insertions(+), 201 deletions(-) (limited to 'src/upd8.js') diff --git a/src/upd8.js b/src/upd8.js index e199b1f..b37dabd 100755 --- a/src/upd8.js +++ b/src/upd8.js @@ -4640,42 +4640,6 @@ function generateChronologyLinks(currentThing, { }).filter(Boolean).join('\n'); } -function generateSidebarForGroup(currentGroup, isGallery, {link, strings, wikiData}) { - const { groupCategoryData, wikiInfo } = wikiData; - - if (!wikiInfo.features.groupUI) { - return null; - } - - const linkKey = isGallery ? 'groupGallery' : 'groupInfo'; - - return { - content: fixWS` -

${strings('groupSidebar.title')}

- ${groupCategoryData.map(category => - html.tag('details', { - open: category === currentGroup.category, - class: category === currentGroup.category && 'current' - }, [ - html.tag('summary', - {style: getLinkThemeString(category.color)}, - strings('groupSidebar.groupList.category', { - category: `${category.name}` - })), - html.tag('ul', - category.groups.map(group => fixWS` -
  • ${ - strings('groupSidebar.groupList.item', { - group: link[linkKey](group) - }) - }
  • - `)) - ])).join('\n')} - - ` - }; -} - function generateInfoGalleryLinks(currentThing, isGallery, { link, strings, linkKeyGallery, @@ -4725,170 +4689,6 @@ function generatePreviousNextLinks(current, { ].filter(Boolean).join(', '); } -function generateNavForGroup(currentGroup, isGallery, {link, strings, wikiData}) { - const { groupData, wikiInfo } = wikiData; - - if (!wikiInfo.features.groupUI) { - return {simple: true}; - } - - const urlKey = isGallery ? 'localized.groupGallery' : 'localized.groupInfo'; - const linkKey = isGallery ? 'groupGallery' : 'groupInfo'; - - const infoGalleryLinks = generateInfoGalleryLinks(currentGroup, isGallery, { - link, strings, - linkKeyGallery: 'groupGallery', - linkKeyInfo: 'groupInfo' - }); - - const previousNextLinks = generatePreviousNextLinks(currentGroup, { - link, strings, - data: groupData, - linkKey - }); - - return { - links: [ - {toHome: true}, - wikiInfo.features.listings && - { - path: ['localized.listingIndex'], - title: strings('listingIndex.title') - }, - { - html: strings('groupPage.nav.group', { - group: link[linkKey](currentGroup, {class: 'current'}) - }) - }, - { - divider: false, - html: (previousNextLinks - ? `(${infoGalleryLinks}; ${previousNextLinks})` - : `(${previousNextLinks})`) - } - ] - }; -} - -function writeGroupPages({wikiData}) { - return wikiData.groupData.map(group => writeGroupPage(group, {wikiData})); -} - -function writeGroupPage(group, {wikiData}) { - const { wikiInfo } = wikiData; - - const releasedAlbums = group.albums.filter(album => album.directory !== UNRELEASED_TRACKS_DIRECTORY); - const releasedTracks = releasedAlbums.flatMap(album => album.tracks); - const totalDuration = getTotalDuration(releasedTracks); - - const albumLines = group.albums.map(album => ({ - album, - otherGroup: album.groups.find(g => g !== group) - })); - - const infoPage = { - type: 'page', - path: ['groupInfo', group.directory], - page: ({ - link, - strings, - transformMultiline - }) => ({ - title: strings('groupInfoPage.title', {group: group.name}), - theme: getThemeString(group.color), - - main: { - content: fixWS` -

    ${strings('groupInfoPage.title', {group: group.name})}

    - ${group.urls.length && `

    ${ - strings('releaseInfo.visitOn', { - links: strings.list.or(group.urls.map(url => fancifyURL(url, {strings}))) - }) - }

    `} -
    - ${transformMultiline(group.description)} -
    -

    ${strings('groupInfoPage.albumList.title')}

    -

    ${ - strings('groupInfoPage.viewAlbumGallery', { - link: link.groupGallery(group, { - text: strings('groupInfoPage.viewAlbumGallery.link') - }) - }) - }

    - - ` - }, - - sidebarLeft: generateSidebarForGroup(group, false, {link, strings, wikiData}), - nav: generateNavForGroup(group, false, {link, strings, wikiData}) - }) - }; - - const galleryPage = { - type: 'page', - path: ['groupGallery', group.directory], - page: ({ - getAlbumGridHTML, - link, - strings - }) => ({ - title: strings('groupGalleryPage.title', {group: group.name}), - theme: getThemeString(group.color), - - main: { - classes: ['top-index'], - content: fixWS` -

    ${strings('groupGalleryPage.title', {group: group.name})}

    -

    ${ - strings('groupGalleryPage.infoLine', { - tracks: `${strings.count.tracks(releasedTracks.length, {unit: true})}`, - albums: `${strings.count.albums(releasedAlbums.length, {unit: true})}`, - time: `${strings.count.duration(totalDuration, {unit: true})}` - }) - }

    - ${wikiInfo.features.groupUI && wikiInfo.features.listings && html.tag('p', - {class: 'quick-info'}, - strings('groupGalleryPage.anotherGroupLine', { - link: link.listing(listingSpec.find(l => l.directory === 'groups/by-category'), { - text: strings('groupGalleryPage.anotherGroupLine.link') - }) - }) - )} -
    - ${getAlbumGridHTML({ - entries: sortByDate(group.albums.map(item => ({item}))).reverse(), - details: true - })} -
    - ` - }, - - sidebarLeft: generateSidebarForGroup(group, true, {link, strings, wikiData}), - nav: generateNavForGroup(group, true, {link, strings, wikiData}) - }) - }; - - return [infoPage, galleryPage]; -} - // RIP toAnythingMan (previously getHrefOfAnythingMan), 2020-05-25<>2021-05-14. // ........Yet the function 8reathes life anew as linkAnythingMan! ::::) function linkAnythingMan(anythingMan, {link, wikiData, ...opts}) { @@ -5607,7 +5407,7 @@ async function main() { const buildDictionary = pageSpecs; const buildSteps = (writeAll - ? Object.values(buildDictionary) + ? Object.entries(buildDictionary) : (Object.entries(buildDictionary) .filter(([ flag ]) => writeFlags[flag]))); @@ -5800,6 +5600,12 @@ async function main() { wikiData }); + bound.generateInfoGalleryLinks = bindOpts(generateInfoGalleryLinks, { + [bindOpts.bindIndex]: 2, + link: bound.link, + strings + }); + bound.generatePreviousNextLinks = bindOpts(generatePreviousNextLinks, { link: bound.link, strings -- cgit 1.3.0-6-gf8a5