diff options
| -rw-r--r-- | src/content/dependencies/generateAdditionalFilesListChunk.js | 4 | ||||
| -rw-r--r-- | src/content/dependencies/generateArtistInfoPageAdditionalFilesChunkItem.js | 135 | ||||
| -rw-r--r-- | src/content/dependencies/generateListAllAdditionalFilesChunk.js | 2 | ||||
| -rw-r--r-- | src/data/things/Language.js | 10 | ||||
| -rw-r--r-- | src/static/css/miscellany.css | 3 | ||||
| -rw-r--r-- | src/strings-default.yaml | 205 | ||||
| -rw-r--r-- | src/urls-default.yaml | 2 |
7 files changed, 126 insertions, 235 deletions
diff --git a/src/content/dependencies/generateAdditionalFilesListChunk.js b/src/content/dependencies/generateAdditionalFilesListChunk.js index 75bac56a..27753b7f 100644 --- a/src/content/dependencies/generateAdditionalFilesListChunk.js +++ b/src/content/dependencies/generateAdditionalFilesListChunk.js @@ -1,7 +1,7 @@ import {stitchArrays} from '#sugar'; export default { - relations: (relation, query, file) => ({ + relations: (relation, file) => ({ description: relation('transformContent', file.description), @@ -13,7 +13,7 @@ export default { relation('generateArtistCredit', file.artistContribs, []), }), - data: (_query, file) => ({ + data: (file) => ({ title: file.title, diff --git a/src/content/dependencies/generateArtistInfoPageAdditionalFilesChunkItem.js b/src/content/dependencies/generateArtistInfoPageAdditionalFilesChunkItem.js index 8352edba..c1dc8787 100644 --- a/src/content/dependencies/generateArtistInfoPageAdditionalFilesChunkItem.js +++ b/src/content/dependencies/generateArtistInfoPageAdditionalFilesChunkItem.js @@ -1,3 +1,5 @@ +import {stitchArrays} from '#sugar'; + export default { query(_artist, contribs) { const query = {}; @@ -27,6 +29,11 @@ export default { relation('generateArtistCredit', query.additionalFile.artistContribs, [artist.mockSimpleContribution]), + + fileLinks: + query.additionalFile.filenames + .map(filename => + relation('linkAdditionalFile', query.additionalFile, filename)), }), data: (query, _artist, contribs) => ({ @@ -38,8 +45,8 @@ export default { title: query.additionalFile.title, - files: - query.additionalFile.filenames.length, + filenames: + query.additionalFile.filenames, contribAnnotationParts: contribs.flatMap(contrib => contrib.annotationParts), @@ -57,59 +64,75 @@ export default { }, }, - generate: (data, relations, slots, {html, language}) => - relations.template.slots({ + generate(data, relations, slots, {html, language}) { + const numFiles = data.filenames.length; + const capsule = + language.encapsulate( + 'artistPage.creditList.entry', data.for, slots.string); + + relations.template.setSlots({ annotation: - (data.contribAnnotationParts - ? language.formatUnitList(data.contribAnnotationParts) - : html.blank()), - - content: - language.encapsulate('artistPage.creditList.entry', entryCapsule => { - let workingCapsule = entryCapsule; - let workingOptions = {}; - - workingCapsule += '.' + data.for + '.' + slots.string; - - const additionalFileCapsule = workingCapsule; - - if (data.for === 'track') { - workingOptions.track = - relations.trackLink; - } - - if (data.title) { - relations.artistCredit.setSlots({ - normalStringKey: - additionalFileCapsule + '.credit.alongsideTitle', - }); - } else if (data.files && !slots.disableStandaloneWithFiles) { - relations.artistCredit.setSlots({ - normalStringKey: - additionalFileCapsule + '.credit.standaloneWithFiles', - - additionalStringOptions: { - files: language.countFiles(data.files, {unitOnly: true}), - }, - }); - } else { - relations.artistCredit.setSlots({ - normalStringKey: - additionalFileCapsule + '.credit', - }); - } - - if (!html.isBlank(relations.artistCredit)) { - workingCapsule += '.withCredit'; - workingOptions.credit = relations.artistCredit; - } - - if (data.title) { - workingCapsule += '.withTitle'; - workingOptions.title = language.sanitize(data.title); - } - - return language.$(workingCapsule, workingOptions); - }), - }), + language.formatUnitList(data.contribAnnotationParts), + }); + + const titleLine = + language.encapsulate(capsule, workingCapsule => { + const workingOptions = {}; + + const titlePart = + (data.title + ? language.sanitize(data.title) + : language.$(capsule, 'placeholderTitle')); + + workingOptions.title = + (numFiles <= 1 + ? relations.fileLinks[0].slot('content', titlePart) + : html.tag('b', titlePart)); + + if (data.for === 'track') { + workingOptions.track = relations.trackLink; + } + + relations.artistCredit.setSlots({ + normalStringKey: capsule + '.credit', + }); + + if (!html.isBlank(relations.artistCredit)) { + workingCapsule += '.withCredit'; + workingOptions.credit = relations.artistCredit; + } + + if (numFiles === 0) { + workingCapsule += '.withNoFiles'; + } else if (numFiles >= 2) { + workingCapsule += '.withMultipleFiles'; + workingOptions.files = + language.countFiles(numFiles, {unit: true}); + } + + return language.$(workingCapsule, workingOptions); + }); + + if (relations.fileLinks.length <= 1) { + relations.template.setSlot('content', titleLine); + } else { + const summary = + html.tag('summary', + html.tag('span', titleLine)); + + const list = + html.tag('ul', + stitchArrays({ + link: relations.fileLinks, + filename: data.filenames, + }).map(({link, filename}) => + html.tag('li', + link.slot('content', language.sanitize(filename))))); + + const details = html.tag('details', [summary, list]); + relations.template.setSlot('content', details); + } + + return relations.template; + }, }; diff --git a/src/content/dependencies/generateListAllAdditionalFilesChunk.js b/src/content/dependencies/generateListAllAdditionalFilesChunk.js index fea565cb..dff652f6 100644 --- a/src/content/dependencies/generateListAllAdditionalFilesChunk.js +++ b/src/content/dependencies/generateListAllAdditionalFilesChunk.js @@ -114,7 +114,7 @@ export default { })))); return ( - html.tag('li', {class: 'has-details'}, + html.tag('li', html.tag('details', [summary, list])) ); })))), diff --git a/src/data/things/Language.js b/src/data/things/Language.js index 5265d851..dc8c0368 100644 --- a/src/data/things/Language.js +++ b/src/data/things/Language.js @@ -955,7 +955,6 @@ export class Language extends Thing { const countHelper = (stringKey, optionName = stringKey) => function(value, { unit = false, - unitOnly = false, blankIfZero = false, } = {}) { // Null or undefined value is blank content. @@ -969,16 +968,11 @@ const countHelper = (stringKey, optionName = stringKey) => } const string = - (unitOnly - ? `count.${stringKey}.unitOnly.` + this.getUnitForm(value) - : unit + (unit ? `count.${stringKey}.withUnit.` + this.getUnitForm(value) : `count.${stringKey}`); - const options = - (unitOnly - ? {} - : {[optionName]: this.formatNumber(value)}); + const options = {[optionName]: this.formatNumber(value)}; return this.formatString(string, options); }; diff --git a/src/static/css/miscellany.css b/src/static/css/miscellany.css index 0f4cf1a9..1f2cf890 100644 --- a/src/static/css/miscellany.css +++ b/src/static/css/miscellany.css @@ -103,8 +103,7 @@ line-height: 1.1; } - /* "has-details" means a "has a <details> element" here. */ - ul > li.has-details { + ul > li:has(> details) { list-style-type: none; margin-left: -17px; } diff --git a/src/strings-default.yaml b/src/strings-default.yaml index 2f50fe9b..f84cff21 100644 --- a/src/strings-default.yaml +++ b/src/strings-default.yaml @@ -48,14 +48,6 @@ count: many: "" other: "{ALBUMS} albums" - unitOnly: - zero: "" - one: "album" - two: "" - few: "" - many: "" - other: "albums" - artTags: _: "{TAGS}" @@ -67,14 +59,6 @@ count: many: "" other: "{TAGS} tags" - unitOnly: - zero: "" - one: "tag" - two: "" - few: "" - many: "" - other: "tags" - artworks: _: "{ARTWORKS}" @@ -86,14 +70,6 @@ count: many: "" other: "{ARTWORKS} artworks" - unitOnly: - zero: "" - one: "artwork" - two: "" - few: "" - many: "" - other: "artworks" - commentaryEntries: _: "{ENTRIES}" @@ -105,14 +81,6 @@ count: many: "" other: "{ENTRIES} entries" - unitOnly: - zero: "" - one: "entry" - two: "" - few: "" - many: "" - other: "entries" - contributions: _: "{CONTRIBUTIONS}" @@ -124,14 +92,6 @@ count: many: "" other: "{CONTRIBUTIONS} contributions" - unitOnly: - zero: "" - one: "contribution" - two: "" - few: "" - many: "" - other: "contributions" - files: _: "{FILES}" @@ -143,14 +103,6 @@ count: many: "" other: "{FILES} files" - unitOnly: - zero: "" - one: "file" - two: "" - few: "" - many: "" - other: "files" - flashes: _: "{FLASHES}" @@ -162,14 +114,6 @@ count: many: "" other: "{FLASHES} flashes" - unitOnly: - zero: "" - one: "flash" - two: "" - few: "" - many: "" - other: "flashes" - tracks: _: "{TRACKS}" @@ -181,14 +125,6 @@ count: many: "" other: "{TRACKS} tracks" - unitOnly: - zero: "" - one: "track" - two: "" - few: "" - many: "" - other: "tracks" - # Count more abstract stuff days: @@ -202,14 +138,6 @@ count: many: "" other: "{DAYS} days" - unitOnly: - zero: "" - one: "day" - two: "" - few: "" - many: "" - other: "days" - months: _: "{MONTHS}" @@ -221,14 +149,6 @@ count: many: "" other: "{MONTHS} months" - unitOnly: - zero: "" - one: "month" - two: "" - few: "" - many: "" - other: "months" - timesFeatured: _: "{TIMES_FEATURED}" @@ -240,14 +160,6 @@ count: many: "" other: "featured {TIMES_FEATURED} times" - unitOnly: - zero: "" - one: "time featured" - two: "" - few: "" - many: "" - other: "times featured" - timesReferenced: _: "{TIMES_REFERENCED}" @@ -259,14 +171,6 @@ count: many: "" other: "{TIMES_REFERENCED} times referenced" - unitOnly: - zero: "" - one: "time referenced" - two: "" - few: "" - many: "" - other: "times referenced" - timesUsed: _: "{TIMES_USED}" @@ -278,14 +182,6 @@ count: many: "" other: "used {TIMES_USED} times" - unitOnly: - zero: "" - one: "time used" - two: "" - few: "" - many: "" - other: "times used" - weeks: _: "{WEEKS}" @@ -297,14 +193,6 @@ count: many: "" other: "{WEEKS} weeks" - unitOnly: - zero: "" - one: "week" - two: "" - few: "" - many: "" - other: "weeks" - words: _: "{WORDS}" thousand: "{WORDS}k" @@ -317,14 +205,6 @@ count: many: "" other: "{WORDS} words" - unitOnly: - zero: "" - one: "word" - two: "" - few: "" - many: "" - other: "words" - years: _: "{YEARS}" @@ -336,14 +216,6 @@ count: many: "" other: "{YEARS} years" - unitOnly: - zero: "" - one: "year" - two: "" - few: "" - many: "" - other: "years" - # Numerical things that aren't exactly counting, per se duration: @@ -1797,66 +1669,69 @@ artistPage: track.miscellaneousAdditionalFile: _: >- - {TRACK} - - withTitle: >- - {TRACK} — {TITLE} + {TITLE}: {TRACK} withCredit: >- - {TRACK}: {CREDIT} + {TITLE} ({CREDIT}): {TRACK} - withCredit.withTitle: >- - {TRACK}: {TITLE} {CREDIT} + withMultipleFiles: >- + {TITLE}: {TRACK} ({FILES}) - credit: >- - files by {ARTISTS} + withNoFiles: >- + {TITLE}: {TRACK} (no files) - credit.standaloneWithFiles: >- - {FILES} by {ARTISTS} + withCredit.withMultipleFiles: >- + {TITLE} ({CREDIT}): {TRACK} ({FILES}) - credit.alongsideTitle: >- - by {ARTISTS} + withCredit.withNoFiles: >- + {TITLE} ({CREDIT}): {TRACK} (no files) + + placeholderTitle: "Additional file" + credit: "by {ARTISTS}" track.sheetMusicFile: _: >- - {TRACK} - - withTitle: >- - {TRACK} — {TITLE} + {TITLE}: {TRACK} withCredit: >- - {TRACK}: {CREDIT} + {TITLE} ({CREDIT}): {TRACK} - withCredit.withTitle: >- - {TRACK}: {TITLE} {CREDIT} + withMultipleFiles: >- + {TITLE}: {TRACK} ({FILES}) - credit: >- - sheet music by {ARTISTS} + withNoFiles: >- + {TITLE}: {TRACK} (no files) - credit.alongsideTitle: >- - by {ARTISTS} + withCredit.withMultipleFiles: >- + {TITLE} ({CREDIT}): {TRACK} ({FILES}) + + withCredit.withNoFiles: >- + {TITLE} ({CREDIT}): {TRACK} (no files) + + placeholderTitle: "Sheet music" + credit: "by {ARTISTS}" track.midiProjectFile: _: >- - {TRACK} - - withTitle: >- - {TRACK} — {TITLE} + {TITLE}: {TRACK} withCredit: >- - {TRACK}: {CREDIT} + {TITLE} ({CREDIT}): {TRACK} - withCredit.withTitle: >- - {TRACK}: {TITLE} {CREDIT} + withMultipleFiles: >- + {TITLE}: {TRACK} ({FILES}) - credit: >- - files by {ARTISTS} + withNoFiles: >- + {TITLE}: {TRACK} (no files) - credit.standaloneWithFiles: >- - {FILES} by {ARTISTS} + withCredit.withMultipleFiles: >- + {TITLE} ({CREDIT}): {TRACK} ({FILES}) - credit.alongsideTitle: >- - by {ARTISTS} + withCredit.withNoFiles: >- + {TITLE} ({CREDIT}): {TRACK} (no files) + + placeholderTitle: "MIDI or project music" + credit: "by {ARTISTS}" # album: # The artist info page doesn't display if the artist is diff --git a/src/urls-default.yaml b/src/urls-default.yaml index dfa5b0e9..5c6f7245 100644 --- a/src/urls-default.yaml +++ b/src/urls-default.yaml @@ -11,7 +11,7 @@ yamlAliases: # part of a build. This is so that multiple builds of a wiki can coexist # served from the same server / file system root: older builds' HTML files # refer to earlier values of STATIC_VERSION, avoiding name collisions. - - &staticVersion 5p10 + - &staticVersion 5p11 data: prefix: 'data/' |