« 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
diff options
context:
space:
mode:
Diffstat (limited to 'src/page')
-rw-r--r--src/page/artist.js8
-rw-r--r--src/page/flash.js17
-rw-r--r--src/page/group.js2
-rw-r--r--src/page/homepage.js34
-rw-r--r--src/page/news.js6
5 files changed, 27 insertions, 40 deletions
diff --git a/src/page/artist.js b/src/page/artist.js
index b89107fc..d0128050 100644
--- a/src/page/artist.js
+++ b/src/page/artist.js
@@ -32,11 +32,7 @@ export function targets({wikiData}) {
 export function write(artist, {wikiData}) {
     const { groupData, wikiInfo } = wikiData;
 
-    const {
-        name,
-        urls = [],
-        note = ''
-    } = artist;
+    const { name, urls, note } = artist;
 
     const artThingsAll = sortByDate(unique([
         ...artist.albumsAsCoverArtist ?? [],
@@ -305,7 +301,7 @@ export function write(artist, {wikiData}) {
                             </blockquote>
                             <hr>
                         `}
-                        ${urls.length && `<p>${strings('releaseInfo.visitOn', {
+                        ${urls?.length && `<p>${strings('releaseInfo.visitOn', {
                             links: strings.list.or(urls.map(url => fancifyURL(url, {strings})))
                         })}</p>`}
                         ${hasGallery && `<p>${strings('artistPage.viewArtGallery', {
diff --git a/src/page/flash.js b/src/page/flash.js
index 9d88bc79..8f6e4f85 100644
--- a/src/page/flash.js
+++ b/src/page/flash.js
@@ -49,13 +49,13 @@ export function write(flash, {wikiData}) {
                         alt: strings('misc.alt.flashArt')
                     })}
                     <p>${strings('releaseInfo.released', {date: strings.count.date(flash.date)})}</p>
-                    ${(flash.page || flash.urls.length) && `<p>${strings('releaseInfo.playOn', {
+                    ${(flash.page || flash.urls?.length) && `<p>${strings('releaseInfo.playOn', {
                         links: strings.list.or([
                             flash.page && getFlashLink(flash),
-                            ...flash.urls
+                            ...flash.urls ?? []
                         ].map(url => fancifyFlashURL(url, flash)))
                     })}</p>`}
-                    ${flash.tracks.length && fixWS`
+                    ${flash.tracks?.length && fixWS`
                         <p>Tracks featured in <i>${flash.name.replace(/\.$/, '')}</i>:</p>
                         <ul>
                             ${(flash.tracks
@@ -71,17 +71,10 @@ export function write(flash, {wikiData}) {
                                 .join('\n'))}
                         </ul>
                     `}
-                    ${flash.contributors.textContent && fixWS`
-                        <p>
-                            ${strings('releaseInfo.contributors')}
-                            <br>
-                            ${transformInline(flash.contributors.textContent)}
-                        </p>
-                    `}
-                    ${flash.contributors.length && fixWS`
+                    ${flash.contributorContribs.length && fixWS`
                         <p>${strings('releaseInfo.contributors')}</p>
                         <ul>
-                            ${flash.contributors
+                            ${flash.contributorContribs
                                 .map(contrib => `<li>${getArtistString([contrib], {
                                     showContrib: true,
                                     showIcons: true
diff --git a/src/page/group.js b/src/page/group.js
index 47828965..c51f0e38 100644
--- a/src/page/group.js
+++ b/src/page/group.js
@@ -52,7 +52,7 @@ export function write(group, {wikiData}) {
             main: {
                 content: fixWS`
                     <h1>${strings('groupInfoPage.title', {group: group.name})}</h1>
-                    ${group.urls.length && `<p>${
+                    ${group.urls?.length && `<p>${
                         strings('releaseInfo.visitOn', {
                             links: strings.list.or(group.urls.map(url => fancifyURL(url, {strings})))
                         })
diff --git a/src/page/homepage.js b/src/page/homepage.js
index e40392a1..37dac2c8 100644
--- a/src/page/homepage.js
+++ b/src/page/homepage.js
@@ -16,7 +16,7 @@ import {
 // Page exports
 
 export function writeTargetless({wikiData}) {
-    const { newsData, staticPageData, homepageInfo, wikiInfo } = wikiData;
+    const { newsData, staticPageData, homepageLayout, wikiInfo } = wikiData;
 
     const page = {
         type: 'page',
@@ -40,27 +40,24 @@ export function writeTargetless({wikiData}) {
                 classes: ['top-index'],
                 content: fixWS`
                     <h1>${wikiInfo.name}</h1>
-                    ${homepageInfo.rows.map((row, i) => fixWS`
+                    ${homepageLayout.rows?.map((row, i) => fixWS`
                         <section class="row" style="${getLinkThemeString(row.color)}">
                             <h2>${row.name}</h2>
                             ${row.type === 'albums' && fixWS`
                                 <div class="grid-listing">
                                     ${getAlbumGridHTML({
                                         entries: (
-                                            row.group === 'new-releases' ? getNewReleases(row.groupCount, {wikiData}) :
-                                            row.group === 'new-additions' ? getNewAdditions(row.groupCount, {wikiData}) :
-                                            ((find.group(row.group, {wikiData})?.albums || [])
+                                            row.sourceGroupByRef === 'new-releases' ? getNewReleases(row.countAlbumsFromGroup, {wikiData}) :
+                                            row.sourceGroupByRef === 'new-additions' ? getNewAdditions(row.countAlbumsFromGroup, {wikiData}) :
+                                            ((row.sourceGroup?.albums ?? [])
                                                 .slice()
                                                 .reverse()
-                                                .slice(0, row.groupCount)
+                                                .slice(0, row.countAlbumsFromGroup)
                                                 .map(album => ({item: album})))
-                                        ).concat(row.albums
-                                            .map(album => find.album(album, {wikiData}))
-                                            .map(album => ({item: album}))
-                                        ),
+                                        ).concat(row.sourceAlbums.map(album => ({item: album}))),
                                         lazy: i > 0
                                     })}
-                                    ${row.actions.length && fixWS`
+                                    ${row.actions?.length && fixWS`
                                         <div class="grid-actions">
                                             ${row.actions.map(action => transformInline(action)
                                                 .replace('<a', '<a class="box grid-item"')).join('\n')}
@@ -73,7 +70,7 @@ export function writeTargetless({wikiData}) {
                 `
             },
 
-            sidebarLeft: homepageInfo.sidebar && {
+            sidebarLeft: homepageLayout.sidebarContent && {
                 wide: true,
                 collapse: false,
                 // This is a pretty filthy hack! 8ut otherwise, the [[news]] part
@@ -86,15 +83,15 @@ export function writeTargetless({wikiData}) {
                 //
                 // And no, I will not make [[news]] into part of transformMultiline
                 // (even though that would 8e hilarious).
-                content: (transformMultiline(homepageInfo.sidebar.replace('[[news]]', '__GENERATE_NEWS__'))
+                content: (transformMultiline(homepageLayout.sidebarContent.replace('[[news]]', '__GENERATE_NEWS__'))
                     .replace('<p>__GENERATE_NEWS__</p>', wikiInfo.enableNews ? fixWS`
                         <h1>${strings('homepage.news.title')}</h1>
                         ${newsData.slice(0, 3).map((entry, i) => html.tag('article',
                             {class: ['news-entry', i === 0 && 'first-news-entry']},
                             fixWS`
                                 <h2><time>${strings.count.date(entry.date)}</time> ${link.newsEntry(entry)}</h2>
-                                ${transformMultiline(entry.bodyShort)}
-                                ${entry.bodyShort !== entry.body && link.newsEntry(entry, {
+                                ${transformMultiline(entry.contentShort)}
+                                ${entry.contentShort !== entry.content && link.newsEntry(entry, {
                                     text: strings('homepage.news.entry.viewRest')
                                 })}
                             `)).join('\n')}
@@ -105,15 +102,16 @@ export function writeTargetless({wikiData}) {
                 content: fixWS`
                     <h2 class="dot-between-spans">
                         ${[
-                            link.home('', {text: wikiInfo.shortName, class: 'current', to}),
+                            link.home('', {text: wikiInfo.nameShort, class: 'current', to}),
                             wikiInfo.enableListings &&
                             link.listingIndex('', {text: strings('listingIndex.title'), to}),
                             wikiInfo.enableNews &&
                             link.newsIndex('', {text: strings('newsIndex.title'), to}),
                             wikiInfo.enableFlashesAndGames &&
                             link.flashIndex('', {text: strings('flashIndex.title'), to}),
-                            ...staticPageData.filter(page => page.listed).map(page =>
-                                link.staticPage(page, {text: page.shortName}))
+                            ...(staticPageData
+                                .filter(page => page.showInNavigationBar)
+                                .map(page => link.staticPage(page, {text: page.nameShort})))
                         ].filter(Boolean).map(link => `<span>${link}</span>`).join('\n')}
                     </h2>
                 `
diff --git a/src/page/news.js b/src/page/news.js
index 75ae9e48..8dc65981 100644
--- a/src/page/news.js
+++ b/src/page/news.js
@@ -31,7 +31,7 @@ export function write(entry, {wikiData}) {
                     <div class="long-content">
                         <h1>${strings('newsEntryPage.title', {entry: entry.name})}</h1>
                         <p>${strings('newsEntryPage.published', {date: strings.count.date(entry.date)})}</p>
-                        ${transformMultiline(entry.body)}
+                        ${transformMultiline(entry.content)}
                     </div>
                 `
             },
@@ -68,8 +68,8 @@ export function writeTargetless({wikiData}) {
                         ${newsData.map(entry => fixWS`
                             <article id="${entry.directory}">
                                 <h2><time>${strings.count.date(entry.date)}</time> ${link.newsEntry(entry)}</h2>
-                                ${transformMultiline(entry.bodyShort)}
-                                ${entry.bodyShort !== entry.body && `<p>${link.newsEntry(entry, {
+                                ${transformMultiline(entry.contentShort)}
+                                ${entry.contentShort !== entry.content && `<p>${link.newsEntry(entry, {
                                     text: strings('newsIndex.entry.viewRest')
                                 })}</p>`}
                             </article>