From 9fb4baa667f76c51abc0c6469d95351f90266a6a Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Fri, 4 Jun 2021 16:27:15 -0300 Subject: module-ify tag pages --- src/page/index.js | 3 ++- src/page/tag.js | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/upd8.js | 68 ------------------------------------------------- 3 files changed, 78 insertions(+), 69 deletions(-) create mode 100644 src/page/tag.js (limited to 'src') diff --git a/src/page/index.js b/src/page/index.js index 101a1688..f580cbea 100644 --- a/src/page/index.js +++ b/src/page/index.js @@ -47,6 +47,7 @@ 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 static from './static.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/tag.js b/src/page/tag.js new file mode 100644 index 00000000..c6f64bfc --- /dev/null +++ b/src/page/tag.js @@ -0,0 +1,76 @@ +// Art tag page specification. + +// Imports + +import fixWS from 'fix-whitespace'; + +import { + getThemeString +} from '../util/colors.js'; + +// Page exports + +export function condition({wikiData}) { + return wikiData.wikiInfo.features.artTagUI; +} + +export function targets({wikiData}) { + return wikiData.tagData.filter(tag => !tag.isCW); +} + +export function write(tag, {wikiData}) { + const { wikiInfo } = wikiData; + const { things } = tag; + + const page = { + type: 'page', + path: ['tag', tag.directory], + page: ({ + getAlbumCover, + getGridHTML, + getTrackCover, + link, + strings, + to + }) => ({ + title: strings('tagPage.title', {tag: tag.name}), + theme: getThemeString(tag.color), + + main: { + classes: ['top-index'], + content: fixWS` +

${strings('tagPage.title', {tag: tag.name})}

+

${strings('tagPage.infoLine', { + coverArts: strings.count.coverArts(things.length, {unit: true}) + })}

+
+ ${getGridHTML({ + entries: things.map(item => ({item})), + srcFn: thing => (thing.album + ? getTrackCover(thing) + : getAlbumCover(thing)), + hrefFn: thing => (thing.album + ? to('localized.track', thing.directory) + : to('localized.album', thing.directory)) + })} +
+ ` + }, + + nav: { + links: [ + {toHome: true}, + wikiInfo.features.listings && + { + path: ['localized.listingIndex'], + title: strings('listingIndex.title') + }, + {toCurrentPage: true} + ] + } + }) + }; + + return [page]; +} + diff --git a/src/upd8.js b/src/upd8.js index 05b997ce..1aa1b5d4 100755 --- a/src/upd8.js +++ b/src/upd8.js @@ -2215,74 +2215,6 @@ function generateRedirectPage(title, target, {strings}) { `; } -function writeTagPages({wikiData}) { - const { tagData, wikiInfo } = wikiData; - - if (!wikiInfo.features.artTagUI) { - return; - } - - return tagData - .filter(tag => !tag.isCW) - .map(tag => writeTagPage(tag, {wikiData})); -} - -function writeTagPage(tag, {wikiData}) { - const { wikiInfo } = wikiData; - const { things } = tag; - - const page = { - type: 'page', - path: ['tag', tag.directory], - page: ({ - getAlbumCover, - getGridHTML, - getTrackCover, - link, - strings, - to - }) => ({ - title: strings('tagPage.title', {tag: tag.name}), - theme: getThemeString(tag.color), - - main: { - classes: ['top-index'], - content: fixWS` -

${strings('tagPage.title', {tag: tag.name})}

-

${strings('tagPage.infoLine', { - coverArts: strings.count.coverArts(things.length, {unit: true}) - })}

-
- ${getGridHTML({ - entries: things.map(item => ({item})), - srcFn: thing => (thing.album - ? getTrackCover(thing) - : getAlbumCover(thing)), - hrefFn: thing => (thing.album - ? to('localized.track', thing.directory) - : to('localized.album', thing.directory)) - })} -
- ` - }, - - nav: { - links: [ - {toHome: true}, - wikiInfo.features.listings && - { - path: ['localized.listingIndex'], - title: strings('listingIndex.title') - }, - {toCurrentPage: true} - ] - } - }) - }; - - return [page]; -} - function getArtistString(artists, { iconifyURL, link, strings, showIcons = false, -- cgit 1.3.0-6-gf8a5