From 431014efacf8bf24b58a21180e71e0db865f30fe Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sun, 8 Oct 2023 12:42:15 -0300 Subject: content: listTagsBy{Name,Uses} -> listArtTagsBy{Name,Uses} --- src/content/dependencies/listArtTagsByName.js | 57 +++++++++++++++++++++++++++ src/content/dependencies/listArtTagsByUses.js | 54 +++++++++++++++++++++++++ src/content/dependencies/listTagsByName.js | 57 --------------------------- src/content/dependencies/listTagsByUses.js | 54 ------------------------- src/listing-spec.js | 8 ++-- src/strings-default.json | 12 +++--- 6 files changed, 121 insertions(+), 121 deletions(-) create mode 100644 src/content/dependencies/listArtTagsByName.js create mode 100644 src/content/dependencies/listArtTagsByUses.js delete mode 100644 src/content/dependencies/listTagsByName.js delete mode 100644 src/content/dependencies/listTagsByUses.js diff --git a/src/content/dependencies/listArtTagsByName.js b/src/content/dependencies/listArtTagsByName.js new file mode 100644 index 00000000..9bec9eaa --- /dev/null +++ b/src/content/dependencies/listArtTagsByName.js @@ -0,0 +1,57 @@ +import {stitchArrays, unique} from '#sugar'; +import {sortAlphabetically} from '#wiki-data'; + +export default { + contentDependencies: ['generateListingPage', 'linkArtTagGallery'], + extraDependencies: ['language', 'wikiData'], + + sprawl({artTagData}) { + return {artTagData}; + }, + + query({artTagData}, spec) { + return { + spec, + + artTags: + sortAlphabetically( + artTagData + .filter(artTag => !artTag.isContentWarning)), + }; + }, + + relations(relation, query) { + return { + page: relation('generateListingPage', query.spec), + + artTagLinks: + query.artTags + .map(artTag => relation('linkArtTagGallery', artTag)), + }; + }, + + data(query) { + return { + counts: + query.artTags.map(artTag => + unique([ + ...artTag.indirectlyTaggedInThings, + ...artTag.directlyTaggedInThings, + ]).length), + }; + }, + + generate(data, relations, {language}) { + return relations.page.slots({ + type: 'rows', + rows: + stitchArrays({ + link: relations.artTagLinks, + count: data.counts, + }).map(({link, count}) => ({ + tag: link, + timesUsed: language.countTimesUsed(count, {unit: true}), + })), + }); + }, +}; diff --git a/src/content/dependencies/listArtTagsByUses.js b/src/content/dependencies/listArtTagsByUses.js new file mode 100644 index 00000000..9eb6f185 --- /dev/null +++ b/src/content/dependencies/listArtTagsByUses.js @@ -0,0 +1,54 @@ +import {stitchArrays, unique} from '#sugar'; +import {filterByCount, sortAlphabetically, sortByCount} from '#wiki-data'; + +export default { + contentDependencies: ['generateListingPage', 'linkArtTagGallery'], + extraDependencies: ['language', 'wikiData'], + + sprawl: ({artTagData}) => + ({artTagData}), + + query({artTagData}, spec) { + const artTags = + sortAlphabetically( + artTagData + .filter(artTag => !artTag.isContentWarning)); + + const counts = + artTags.map(artTag => + unique([ + ...artTag.directlyTaggedInThings, + ...artTag.indirectlyTaggedInThings, + ]).length); + + filterByCount(artTags, counts); + sortByCount(artTags, counts, {greatestFirst: true}); + + return {spec, artTags, counts}; + }, + + relations: (relation, query) => ({ + page: + relation('generateListingPage', query.spec), + + artTagLinks: + query.artTags + .map(artTag => relation('linkArtTagGallery', artTag)), + }), + + data: (query) => + ({counts: query.counts}), + + generate: (data, relations, {language}) => + relations.page.slots({ + type: 'rows', + rows: + stitchArrays({ + link: relations.artTagLinks, + count: data.counts, + }).map(({link, count}) => ({ + tag: link, + timesUsed: language.countTimesUsed(count, {unit: true}), + })), + }), +}; diff --git a/src/content/dependencies/listTagsByName.js b/src/content/dependencies/listTagsByName.js deleted file mode 100644 index 9bec9eaa..00000000 --- a/src/content/dependencies/listTagsByName.js +++ /dev/null @@ -1,57 +0,0 @@ -import {stitchArrays, unique} from '#sugar'; -import {sortAlphabetically} from '#wiki-data'; - -export default { - contentDependencies: ['generateListingPage', 'linkArtTagGallery'], - extraDependencies: ['language', 'wikiData'], - - sprawl({artTagData}) { - return {artTagData}; - }, - - query({artTagData}, spec) { - return { - spec, - - artTags: - sortAlphabetically( - artTagData - .filter(artTag => !artTag.isContentWarning)), - }; - }, - - relations(relation, query) { - return { - page: relation('generateListingPage', query.spec), - - artTagLinks: - query.artTags - .map(artTag => relation('linkArtTagGallery', artTag)), - }; - }, - - data(query) { - return { - counts: - query.artTags.map(artTag => - unique([ - ...artTag.indirectlyTaggedInThings, - ...artTag.directlyTaggedInThings, - ]).length), - }; - }, - - generate(data, relations, {language}) { - return relations.page.slots({ - type: 'rows', - rows: - stitchArrays({ - link: relations.artTagLinks, - count: data.counts, - }).map(({link, count}) => ({ - tag: link, - timesUsed: language.countTimesUsed(count, {unit: true}), - })), - }); - }, -}; diff --git a/src/content/dependencies/listTagsByUses.js b/src/content/dependencies/listTagsByUses.js deleted file mode 100644 index 9eb6f185..00000000 --- a/src/content/dependencies/listTagsByUses.js +++ /dev/null @@ -1,54 +0,0 @@ -import {stitchArrays, unique} from '#sugar'; -import {filterByCount, sortAlphabetically, sortByCount} from '#wiki-data'; - -export default { - contentDependencies: ['generateListingPage', 'linkArtTagGallery'], - extraDependencies: ['language', 'wikiData'], - - sprawl: ({artTagData}) => - ({artTagData}), - - query({artTagData}, spec) { - const artTags = - sortAlphabetically( - artTagData - .filter(artTag => !artTag.isContentWarning)); - - const counts = - artTags.map(artTag => - unique([ - ...artTag.directlyTaggedInThings, - ...artTag.indirectlyTaggedInThings, - ]).length); - - filterByCount(artTags, counts); - sortByCount(artTags, counts, {greatestFirst: true}); - - return {spec, artTags, counts}; - }, - - relations: (relation, query) => ({ - page: - relation('generateListingPage', query.spec), - - artTagLinks: - query.artTags - .map(artTag => relation('linkArtTagGallery', artTag)), - }), - - data: (query) => - ({counts: query.counts}), - - generate: (data, relations, {language}) => - relations.page.slots({ - type: 'rows', - rows: - stitchArrays({ - link: relations.artTagLinks, - count: data.counts, - }).map(({link, count}) => ({ - tag: link, - timesUsed: language.countTimesUsed(count, {unit: true}), - })), - }), -}; diff --git a/src/listing-spec.js b/src/listing-spec.js index 2b33744a..5a2eaf5d 100644 --- a/src/listing-spec.js +++ b/src/listing-spec.js @@ -184,15 +184,15 @@ listingSpec.push({ listingSpec.push({ directory: 'tags/by-name', - stringsKey: 'listTags.byName', - contentFunction: 'listTagsByName', + stringsKey: 'listArtTags.byName', + contentFunction: 'listArtTagsByName', featureFlag: 'enableArtTagUI', }); listingSpec.push({ directory: 'tags/by-uses', - stringsKey: 'listTags.byUses', - contentFunction: 'listTagsByUses', + stringsKey: 'listArtTags.byUses', + contentFunction: 'listArtTagsByUses', featureFlag: 'enableArtTagUI', }); diff --git a/src/strings-default.json b/src/strings-default.json index 1ca6dfd0..02e1ad6c 100644 --- a/src/strings-default.json +++ b/src/strings-default.json @@ -491,12 +491,12 @@ "listingPage.listTracks.withMidiProjectFiles.chunk.title": "{ALBUM}", "listingPage.listTracks.withMidiProjectFiles.chunk.title.withDate": "{ALBUM} ({DATE})", "listingPage.listTracks.withMidiProjectFiles.chunk.item": "{TRACK}", - "listingPage.listTags.byName.title": "Tags - by Name", - "listingPage.listTags.byName.title.short": "...by Name", - "listingPage.listTags.byName.item": "{TAG} ({TIMES_USED})", - "listingPage.listTags.byUses.title": "Tags - by Uses", - "listingPage.listTags.byUses.title.short": "...by Uses", - "listingPage.listTags.byUses.item": "{TAG} ({TIMES_USED})", + "listingPage.listArtTags.byName.title": "Tags - by Name", + "listingPage.listArtTags.byName.title.short": "...by Name", + "listingPage.listArtTags.byName.item": "{TAG} ({TIMES_USED})", + "listingPage.listArtTags.byUses.title": "Tags - by Uses", + "listingPage.listArtTags.byUses.title.short": "...by Uses", + "listingPage.listArtTags.byUses.item": "{TAG} ({TIMES_USED})", "listingPage.other.allSheetMusic.title": "All Sheet Music", "listingPage.other.allSheetMusic.title.short": "All Sheet Music", "listingPage.other.allSheetMusic.albumFiles": "Album sheet music:", -- cgit 1.3.0-6-gf8a5