« 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/album.js50
-rw-r--r--src/page/art-tag.js (renamed from src/page/tag.js)14
-rw-r--r--src/page/artist-alias.js28
-rw-r--r--src/page/artist.js10
-rw-r--r--src/page/group.js39
-rw-r--r--src/page/homepage.js2
-rw-r--r--src/page/index.js2
-rw-r--r--src/page/static.js1
-rw-r--r--src/page/track.js30
9 files changed, 133 insertions, 43 deletions
diff --git a/src/page/album.js b/src/page/album.js
index c7327cc8..696e2854 100644
--- a/src/page/album.js
+++ b/src/page/album.js
@@ -1,3 +1,5 @@
+import {empty} from '#sugar';
+
 export const description = `per-album info, artwork gallery & commentary pages`;
 
 export function targets({wikiData}) {
@@ -5,8 +7,6 @@ export function targets({wikiData}) {
 }
 
 export function pathsForTarget(album) {
-  const hasCommentaryPage = !!album.commentary || album.tracks.some(t => t.commentary);
-
   return [
     {
       type: 'page',
@@ -28,7 +28,7 @@ export function pathsForTarget(album) {
       },
     },
 
-    hasCommentaryPage && {
+    {
       type: 'page',
       path: ['albumCommentary', album.directory],
 
@@ -38,6 +38,34 @@ export function pathsForTarget(album) {
       },
     },
 
+    {
+      type: 'page',
+      path: ['albumReferencedArtworks', album.directory],
+
+      condition: () =>
+        album.hasCoverArt &&
+        !empty(album.coverArtworks[0].referencedArtworks),
+
+      contentFunction: {
+        name: 'generateAlbumReferencedArtworksPage',
+        args: [album],
+      },
+    },
+
+    {
+      type: 'page',
+      path: ['albumReferencingArtworks', album.directory],
+
+      condition: () =>
+        album.hasCoverArt &&
+        !empty(album.coverArtworks[0].referencedByArtworks),
+
+      contentFunction: {
+        name: 'generateAlbumReferencingArtworksPage',
+        args: [album],
+      },
+    },
+
     /*
     {
       type: 'data',
@@ -60,13 +88,15 @@ export function pathsTargetless({wikiData: {wikiInfo}}) {
       contentFunction: {name: 'generateCommentaryIndexPage'},
     },
 
-    wikiInfo.canonicalBase === 'https://hsmusic.wiki/' &&
-      {
-        type: 'redirect',
-        fromPath: ['page', 'list/all-commentary'],
-        toPath: ['commentaryIndex'],
-        title: 'Album Commentary',
-      },
+    {
+      type: 'redirect',
+      fromPath: ['page', 'list/all-commentary'],
+      toPath: ['commentaryIndex'],
+      title: 'Album Commentary',
+
+      condition: () =>
+        wikiInfo.canonicalBase === 'https://hsmusic.wiki/',
+    },
   ];
 }
 
diff --git a/src/page/tag.js b/src/page/art-tag.js
index 8942aea9..5b61229d 100644
--- a/src/page/tag.js
+++ b/src/page/art-tag.js
@@ -1,6 +1,6 @@
 // Art tag page specification.
 
-export const description = `per-artwork-tag gallery pages`;
+export const description = `per-art-tag info & gallery pages`;
 
 export function condition({wikiData}) {
   return wikiData.wikiInfo.enableArtTagUI;
@@ -14,7 +14,17 @@ export function pathsForTarget(tag) {
   return [
     {
       type: 'page',
-      path: ['tag', tag.directory],
+      path: ['artTagInfo', tag.directory],
+
+      contentFunction: {
+        name: 'generateArtTagInfoPage',
+        args: [tag],
+      },
+    },
+
+    {
+      type: 'page',
+      path: ['artTagGallery', tag.directory],
 
       contentFunction: {
         name: 'generateArtTagGalleryPage',
diff --git a/src/page/artist-alias.js b/src/page/artist-alias.js
index c1177798..6af5ef8a 100644
--- a/src/page/artist-alias.js
+++ b/src/page/artist-alias.js
@@ -1,18 +1,32 @@
 export const description = `redirects for aliased artist names`;
 
 export function targets({wikiData}) {
-  return wikiData.artistData.filter(artist => artist.isAlias);
+  const normalArtistDirectories =
+    wikiData.artistData
+      .filter(artist => !artist.isAlias)
+      .map(artist => artist.directory);
+
+  return (
+    wikiData.artistData
+      .filter(artist => artist.isAlias)
+
+      // Don't generate a redirect page if this aliased name resolves to the
+      // same directory as the original artist! See issue #280.
+      .filter(aliasArtist =>
+        aliasArtist.directory !==
+        aliasArtist.aliasedArtist.directory)
+
+      // And don't generate a redirect page if this aliased name resolves to the
+      // same directory as any *other, non-alias* artist. In that case we really
+      // just need the page (at this directory) to lead to the actual artist with
+      // this directory - not be a redirect. See issue #543.
+      .filter(aliasArtist =>
+        !normalArtistDirectories.includes(aliasArtist.directory)));
 }
 
 export function pathsForTarget(aliasArtist) {
   const {aliasedArtist} = aliasArtist;
 
-  // Don't generate a redirect page if this aliased name resolves to the same
-  // directory as the original artist! See issue #280.
-  if (aliasArtist.directory === aliasedArtist.directory) {
-    return [];
-  }
-
   return [
     {
       type: 'redirect',
diff --git a/src/page/artist.js b/src/page/artist.js
index f80bd906..257e060d 100644
--- a/src/page/artist.js
+++ b/src/page/artist.js
@@ -8,10 +8,6 @@ export function targets({wikiData}) {
 }
 
 export function pathsForTarget(artist) {
-  const hasGalleryPage =
-    !empty(artist.tracksAsCoverArtist) ||
-    !empty(artist.albumsAsCoverArtist);
-
   return [
     {
       type: 'page',
@@ -23,10 +19,14 @@ export function pathsForTarget(artist) {
       },
     },
 
-    hasGalleryPage && {
+    {
       type: 'page',
       path: ['artistGallery', artist.directory],
 
+      condition: () =>
+        !empty(artist.albumCoverArtistContributions) ||
+        !empty(artist.trackCoverArtistContributions),
+
       contentFunction: {
         name: 'generateArtistGalleryPage',
         args: [artist],
diff --git a/src/page/group.js b/src/page/group.js
index b0ed5baf..87590eaf 100644
--- a/src/page/group.js
+++ b/src/page/group.js
@@ -7,8 +7,6 @@ export function targets({wikiData}) {
 }
 
 export function pathsForTarget(group) {
-  const hasGalleryPage = !empty(group.albums);
-
   return [
     {
       type: 'page',
@@ -20,10 +18,13 @@ export function pathsForTarget(group) {
       },
     },
 
-    hasGalleryPage && {
+    {
       type: 'page',
       path: ['groupGallery', group.directory],
 
+      condition: () =>
+        !empty(group.albums),
+
       contentFunction: {
         name: 'generateGroupGalleryPage',
         args: [group],
@@ -34,20 +35,24 @@ export function pathsForTarget(group) {
 
 export function pathsTargetless({wikiData: {wikiInfo}}) {
   return [
-    wikiInfo.canonicalBase === 'https://hsmusic.wiki/' &&
-      {
-        type: 'redirect',
-        fromPath: ['page', 'albums/fandom'],
-        toPath: ['groupGallery', 'fandom'],
-        title: 'Fandom - Gallery',
-      },
+    {
+      type: 'redirect',
+      fromPath: ['page', 'albums/fandom'],
+      toPath: ['groupGallery', 'fandom'],
+      title: 'Fandom - Gallery',
 
-    wikiInfo.canonicalBase === 'https://hsmusic.wiki/' &&
-      {
-        type: 'redirect',
-        fromPath: ['page', 'albums/official'],
-        toPath: ['groupGallery', 'official'],
-        title: 'Official - Gallery',
-      },
+      condition: () =>
+        wikiInfo.canonicalBase === 'https://hsmusic.wiki/',
+    },
+
+    {
+      type: 'redirect',
+      fromPath: ['page', 'albums/official'],
+      toPath: ['groupGallery', 'official'],
+      title: 'Official - Gallery',
+
+      condition: () =>
+        wikiInfo.canonicalBase === 'https://hsmusic.wiki/',
+    },
   ];
 }
diff --git a/src/page/homepage.js b/src/page/homepage.js
index 53ee6e46..cfcdd6e1 100644
--- a/src/page/homepage.js
+++ b/src/page/homepage.js
@@ -7,7 +7,7 @@ export function pathsTargetless({wikiData}) {
       path: ['home'],
 
       contentFunction: {
-        name: 'generateWikiHomePage',
+        name: 'generateWikiHomepagePage',
         args: [wikiData.homepageLayout],
       },
     },
diff --git a/src/page/index.js b/src/page/index.js
index 21d93c8f..ae480136 100644
--- a/src/page/index.js
+++ b/src/page/index.js
@@ -1,6 +1,7 @@
 export * as album from './album.js';
 export * as artist from './artist.js';
 export * as artistAlias from './artist-alias.js';
+export * as artTag from './art-tag.js';
 export * as flash from './flash.js';
 export * as flashAct from './flash-act.js';
 export * as group from './group.js';
@@ -8,5 +9,4 @@ export * as homepage from './homepage.js';
 export * as listing from './listing.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/static.js b/src/page/static.js
index c9d806ff..733844de 100644
--- a/src/page/static.js
+++ b/src/page/static.js
@@ -12,6 +12,7 @@ export function pathsForTarget(staticPage) {
     {
       type: 'page',
       path: ['staticPage', staticPage.directory],
+      absoluteLinks: staticPage.absoluteLinks,
 
       contentFunction: {
         name: 'generateStaticPage',
diff --git a/src/page/track.js b/src/page/track.js
index e75b6958..95647334 100644
--- a/src/page/track.js
+++ b/src/page/track.js
@@ -1,5 +1,7 @@
 // Track page specification.
 
+import {empty} from '#sugar';
+
 export const description = `per-track info pages`;
 
 export function targets({wikiData}) {
@@ -17,5 +19,33 @@ export function pathsForTarget(track) {
         args: [track],
       },
     },
+
+    {
+      type: 'page',
+      path: ['trackReferencedArtworks', track.directory],
+
+      condition: () =>
+        track.hasUniqueCoverArt &&
+        !empty(track.trackArtworks[0].referencedArtworks),
+
+      contentFunction: {
+        name: 'generateTrackReferencedArtworksPage',
+        args: [track],
+      },
+    },
+
+    {
+      type: 'page',
+      path: ['trackReferencingArtworks', track.directory],
+
+      condition: () =>
+        track.hasUniqueCoverArt &&
+        !empty(track.trackArtworks[0].referencedByArtworks),
+
+      contentFunction: {
+        name: 'generateTrackReferencingArtworksPage',
+        args: [track],
+      },
+    },
   ];
 }