« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/page/tag.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/page/tag.js')
-rw-r--r--src/page/tag.js115
1 files changed, 15 insertions, 100 deletions
diff --git a/src/page/tag.js b/src/page/tag.js
index 4253120..8942aea 100644
--- a/src/page/tag.js
+++ b/src/page/tag.js
@@ -1,110 +1,25 @@
 // Art tag page specification.
 
-// Imports
-
-import fixWS from 'fix-whitespace';
-
-// Page exports
+export const description = `per-artwork-tag gallery pages`;
 
 export function condition({wikiData}) {
-    return wikiData.wikiInfo.features.artTagUI;
+  return wikiData.wikiInfo.enableArtTagUI;
 }
 
 export function targets({wikiData}) {
-    return wikiData.tagData.filter(tag => !tag.isCW);
-}
-
-export function write(tag, {wikiData}) {
-    const { wikiInfo } = wikiData;
-    const { 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 page = {
-        type: 'page',
-        path: ['tag', tag.directory],
-        page: ({
-            generatePreviousNextLinks,
-            getAlbumCover,
-            getGridHTML,
-            getThemeString,
-            getTrackCover,
-            link,
-            strings,
-            to
-        }) => ({
-            title: strings('tagPage.title', {tag: tag.name}),
-            theme: getThemeString(tag.color),
-
-            main: {
-                classes: ['top-index'],
-                content: fixWS`
-                    <h1>${strings('tagPage.title', {tag: tag.name})}</h1>
-                    <p class="quick-info">${strings('tagPage.infoLine', {
-                        coverArts: strings.count.coverArts(things.length, {unit: true})
-                    })}</p>
-                    <div class="grid-listing">
-                        ${getGridHTML({
-                            entries,
-                            srcFn: thing => (thing.album
-                                ? getTrackCover(thing)
-                                : getAlbumCover(thing)),
-                            hrefFn: thing => (thing.album
-                                ? to('localized.track', thing.directory)
-                                : to('localized.album', thing.directory))
-                        })}
-                    </div>
-                `
-            },
-
-            nav: generateTagNav(tag, {
-                generatePreviousNextLinks,
-                link,
-                strings,
-                wikiData
-            })
-        })
-    };
-
-    return [page];
+  return wikiData.artTagData.filter((tag) => !tag.isContentWarning);
 }
 
-// Utility functions
-
-function generateTagNav(tag, {
-    generatePreviousNextLinks,
-    link,
-    strings,
-    wikiData
-}) {
-    const previousNextLinks = generatePreviousNextLinks(tag, {
-        data: wikiData.tagData.filter(tag => !tag.isCW),
-        linkKey: 'tag'
-    });
-
-    return {
-        links: [
-            {toHome: true},
-            wikiData.wikiInfo.features.listings &&
-            {
-                path: ['localized.listingIndex'],
-                title: strings('listingIndex.title')
-            },
-            {
-                html: strings('tagPage.nav.tag', {
-                    tag: link.tag(tag, {class: 'current'})
-                })
-            },
-            /*
-            previousNextLinks && {
-                divider: false,
-                html: `(${previousNextLinks})`
-            }
-            */
-        ]
-    };
+export function pathsForTarget(tag) {
+  return [
+    {
+      type: 'page',
+      path: ['tag', tag.directory],
+
+      contentFunction: {
+        name: 'generateArtTagGalleryPage',
+        args: [tag],
+      },
+    },
+  ];
 }