From 3686bdacef66d9bc911b6ad02fdee18cb15ecf56 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.yaml | 46 ++++++++++----------- 6 files changed, 138 insertions(+), 138 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 (limited to 'src') diff --git a/src/content/dependencies/listArtTagsByName.js b/src/content/dependencies/listArtTagsByName.js new file mode 100644 index 00000000..31856478 --- /dev/null +++ b/src/content/dependencies/listArtTagsByName.js @@ -0,0 +1,57 @@ +import {sortAlphabetically} from '#sort'; +import {stitchArrays, unique} from '#sugar'; + +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..fcd324f7 --- /dev/null +++ b/src/content/dependencies/listArtTagsByUses.js @@ -0,0 +1,54 @@ +import {sortAlphabetically, sortByCount} from '#sort'; +import {filterByCount, stitchArrays, unique} from '#sugar'; + +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 31856478..00000000 --- a/src/content/dependencies/listTagsByName.js +++ /dev/null @@ -1,57 +0,0 @@ -import {sortAlphabetically} from '#sort'; -import {stitchArrays, unique} from '#sugar'; - -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 fcd324f7..00000000 --- a/src/content/dependencies/listTagsByUses.js +++ /dev/null @@ -1,54 +0,0 @@ -import {sortAlphabetically, sortByCount} from '#sort'; -import {filterByCount, stitchArrays, unique} from '#sugar'; - -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 749f009a..024700ea 100644 --- a/src/listing-spec.js +++ b/src/listing-spec.js @@ -196,15 +196,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.yaml b/src/strings-default.yaml index 5834facd..3e49197b 100644 --- a/src/strings-default.yaml +++ b/src/strings-default.yaml @@ -1644,6 +1644,29 @@ listingPage: title: "{DATE}" item: "{ALBUM}" + listArtTags: + + # listArtTags.byName: + # List art tags alphabetically without sorting or chunking by + # any other criteria. Also displays the number of times each + # art tag has been featured. + + byName: + title: "Tags - by Name" + title.short: "...by Name" + item: "{TAG} ({TIMES_USED})" + + # listArtTags.byUses: + # List art tags by number of times used, falling back to an + # alphabetical sort if two art tags have been featured the same + # number of times. Art tags which haven't haven't been featured + # at all yet are totally excluded from the list. + + byUses: + title: "Tags - by Uses" + title.short: "...by Uses" + item: "{TAG} ({TIMES_USED})" + listArtists: # listArtists.byName: @@ -1971,29 +1994,6 @@ listingPage: title.withDate: "{ALBUM} ({DATE})" item: "{TRACK}" - listTags: - - # listTags.byName: - # List art tags alphabetically without sorting or chunking by - # any other criteria. Also displays the number of times each - # art tag has been featured. - - byName: - title: "Tags - by Name" - title.short: "...by Name" - item: "{TAG} ({TIMES_USED})" - - # listTags.byUses: - # List art tags by number of times used, falling back to an - # alphabetical sort if two art tags have been featured the same - # number of times. Art tags which haven't haven't been featured - # at all yet are totally excluded from the list. - - byUses: - title: "Tags - by Uses" - title.short: "...by Uses" - item: "{TAG} ({TIMES_USED})" - other: # other.allSheetMusic: -- cgit 1.3.0-6-gf8a5