« get me outta code hell

content: generateArtistInfoPage: show edits for wiki separately - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content/dependencies
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-08-15 14:14:41 -0300
committer(quasar) nebula <qznebula@protonmail.com>2024-08-15 14:14:41 -0300
commitbbfecd71976859e591d3ebef62853f4c0481484f (patch)
tree9ab9695eb974da26ffc4a054a7ca4f61a68ecf33 /src/content/dependencies
parent53794015af7ca4022b93e6536abb3dcee5ba9ece (diff)
content: generateArtistInfoPage: show edits for wiki separately
Diffstat (limited to 'src/content/dependencies')
-rw-r--r--src/content/dependencies/generateArtistInfoPage.js26
-rw-r--r--src/content/dependencies/generateArtistInfoPageArtworksChunkedList.js33
2 files changed, 48 insertions, 11 deletions
diff --git a/src/content/dependencies/generateArtistInfoPage.js b/src/content/dependencies/generateArtistInfoPage.js
index f9ce7e3b..f2fdc5b6 100644
--- a/src/content/dependencies/generateArtistInfoPage.js
+++ b/src/content/dependencies/generateArtistInfoPage.js
@@ -40,6 +40,7 @@ export default {
         artist.albumBannerArtistContributions,
         artist.trackCoverArtistContributions,
       ]).flat()
+        .filter(({annotation}) => !annotation?.startsWith('edits for wiki'))
         .map(({thing}) => thing),
 
     // Banners and wallpapers don't show up in the artist gallery page, only
@@ -78,7 +79,10 @@ export default {
       relation('generateArtistGroupContributionsInfo', query.allTracks),
 
     artworksChunkedList:
-      relation('generateArtistInfoPageArtworksChunkedList', artist),
+      relation('generateArtistInfoPageArtworksChunkedList', artist, false),
+
+    editsForWikiArtworksChunkedList:
+      relation('generateArtistInfoPageArtworksChunkedList', artist, true),
 
     artworksGroupInfo:
       relation('generateArtistGroupContributionsInfo', query.allArtworks),
@@ -181,10 +185,11 @@ export default {
                       {href: '#tracks'},
                       language.$(pageCapsule, 'trackList.title')),
 
-                  !html.isBlank(relations.artworksChunkedList) &&
-                    html.tag('a',
-                      {href: '#art'},
-                      language.$(pageCapsule, 'artList.title')),
+                  (!html.isBlank(relations.artworksChunkedList) ||
+                   !html.isBlank(relations.editsForWikiArtworksChunkedList)) &&
+                      html.tag('a',
+                        {href: '#art'},
+                        language.$(pageCapsule, 'artList.title')),
 
                   !html.isBlank(relations.flashesChunkedList) &&
                     html.tag('a',
@@ -276,6 +281,17 @@ export default {
                         countUnit: 'artworks',
                       })),
               }),
+
+            html.tags([
+              html.tag('p',
+                {[html.onlyIfSiblings]: true},
+
+                language.$(pageCapsule, 'wikiEditArtworks', {
+                  artist: data.name,
+                })),
+
+              relations.editsForWikiArtworksChunkedList,
+            ]),
           ]),
 
           html.tags([
diff --git a/src/content/dependencies/generateArtistInfoPageArtworksChunkedList.js b/src/content/dependencies/generateArtistInfoPageArtworksChunkedList.js
index caefb7a3..2be02577 100644
--- a/src/content/dependencies/generateArtistInfoPageArtworksChunkedList.js
+++ b/src/content/dependencies/generateArtistInfoPageArtworksChunkedList.js
@@ -8,7 +8,7 @@ export default {
     'generateArtistInfoPageArtworksChunk',
   ],
 
-  query(artist) {
+  query(artist, filterEditsForWiki) {
     const query = {};
 
     const allContributions = [
@@ -18,12 +18,19 @@ export default {
       ...artist.trackCoverArtistContributions,
     ];
 
+    const filteredContributions =
+      allContributions
+        .filter(({annotation}) =>
+          (filterEditsForWiki
+            ? annotation?.startsWith(`edits for wiki`)
+            : !annotation?.startsWith(`edits for wiki`)));
+
     sortContributionsChronologically(
-      allContributions,
+      filteredContributions,
       sortAlbumsTracksChronologically);
 
     query.contribs =
-      chunkByConditions(allContributions, [
+      chunkByConditions(filteredContributions, [
         ({date: date1}, {date: date2}) =>
           +date1 !== +date2,
         ({thing: thing1}, {thing: thing2}) =>
@@ -39,7 +46,7 @@ export default {
     return query;
   },
 
-  relations: (relation, query, _artist) => ({
+  relations: (relation, query, _artist, _filterEditsForWiki) => ({
     chunkedList:
       relation('generateArtistInfoPageChunkedList'),
 
@@ -51,8 +58,22 @@ export default {
           relation('generateArtistInfoPageArtworksChunk', album, contribs)),
   }),
 
-  generate: (relations) =>
+  data: (_query, _artist, filterEditsForWiki) => ({
+    filterEditsForWiki,
+  }),
+
+  generate: (data, relations) =>
     relations.chunkedList.slots({
-      chunks: relations.chunks,
+      chunks:
+        relations.chunks.map(chunk => {
+          if (data.filterEditsForWiki) {
+            chunk.setSlots({
+              trimAnnotations: true,
+              dates: [],
+            });
+          }
+
+          return chunk;
+        }),
     }),
 };