From 5d1bbf4f3932be0d45acfece1c9bd468e86af14f Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sat, 31 Jan 2026 17:17:56 -0400 Subject: content: generateCommentaryEntry -> generateContentEntry --- .../dependencies/generateAlbumCommentaryPage.js | 4 +- src/content/dependencies/generateAlbumInfoPage.js | 2 +- .../generateCollapsedContentEntrySection.js | 2 +- .../dependencies/generateCommentaryEntry.js | 111 --------------------- .../dependencies/generateCommentaryEntryDate.js | 90 ----------------- src/content/dependencies/generateContentEntry.js | 111 +++++++++++++++++++++ .../dependencies/generateContentEntryDate.js | 90 +++++++++++++++++ src/content/dependencies/generateFlashInfoPage.js | 2 +- .../generateTrackArtistCommentarySection.js | 4 +- 9 files changed, 208 insertions(+), 208 deletions(-) delete mode 100644 src/content/dependencies/generateCommentaryEntry.js delete mode 100644 src/content/dependencies/generateCommentaryEntryDate.js create mode 100644 src/content/dependencies/generateContentEntry.js create mode 100644 src/content/dependencies/generateContentEntryDate.js (limited to 'src/content/dependencies') diff --git a/src/content/dependencies/generateAlbumCommentaryPage.js b/src/content/dependencies/generateAlbumCommentaryPage.js index ffa70dcf..b6c8edf6 100644 --- a/src/content/dependencies/generateAlbumCommentaryPage.js +++ b/src/content/dependencies/generateAlbumCommentaryPage.js @@ -60,7 +60,7 @@ export default { relations.albumCommentaryEntries = album.commentary - .map(entry => relation('generateCommentaryEntry', entry)); + .map(entry => relation('generateContentEntry', entry)); } relations.trackCommentaryHeadings = @@ -87,7 +87,7 @@ export default { query.tracksWithCommentary .map(track => track.commentary - .map(entry => relation('generateCommentaryEntry', entry))); + .map(entry => relation('generateContentEntry', entry))); return relations; }, diff --git a/src/content/dependencies/generateAlbumInfoPage.js b/src/content/dependencies/generateAlbumInfoPage.js index a27074ff..d60e6c50 100644 --- a/src/content/dependencies/generateAlbumInfoPage.js +++ b/src/content/dependencies/generateAlbumInfoPage.js @@ -61,7 +61,7 @@ export default { artistCommentaryEntries: album.commentary - .map(entry => relation('generateCommentaryEntry', entry)), + .map(entry => relation('generateContentEntry', entry)), creditingSourcesSection: relation('generateCollapsedContentEntrySection', diff --git a/src/content/dependencies/generateCollapsedContentEntrySection.js b/src/content/dependencies/generateCollapsedContentEntrySection.js index aec5fe28..127ec1b4 100644 --- a/src/content/dependencies/generateCollapsedContentEntrySection.js +++ b/src/content/dependencies/generateCollapsedContentEntrySection.js @@ -5,7 +5,7 @@ export default { entries: entries - .map(entry => relation('generateCommentaryEntry', entry)), + .map(entry => relation('generateContentEntry', entry)), }), slots: { diff --git a/src/content/dependencies/generateCommentaryEntry.js b/src/content/dependencies/generateCommentaryEntry.js deleted file mode 100644 index 38eb6b43..00000000 --- a/src/content/dependencies/generateCommentaryEntry.js +++ /dev/null @@ -1,111 +0,0 @@ -import {empty} from '#sugar'; - -export default { - relations: (relation, entry) => ({ - artistLinks: - (!empty(entry.artists) && !entry.artistText - ? entry.artists - .map(artist => relation('linkArtist', artist)) - : null), - - artistsContent: - (entry.artistText - ? relation('transformContent', entry.artistText) - : null), - - annotationContent: - (entry.annotation - ? relation('transformContent', entry.annotation) - : null), - - bodyContent: - (entry.body - ? relation('transformContent', entry.body) - : null), - - colorStyle: - relation('generateColorStyleAttribute'), - - date: - relation('generateCommentaryEntryDate', entry), - }), - - data: (entry) => ({ - isWikiEditorCommentary: - entry.isWikiEditorCommentary, - }), - - slots: { - color: {validate: v => v.isColor}, - }, - - generate: (data, relations, slots, {html, language}) => - language.encapsulate('misc.artistCommentary.entry', entryCapsule => - html.tags([ - html.tag('p', {class: 'commentary-entry-heading'}, - slots.color && - relations.colorStyle.clone() - .slot('color', slots.color), - - !html.isBlank(relations.date) && - {class: 'dated'}, - - language.encapsulate(entryCapsule, 'title', titleCapsule => [ - html.tag('span', {class: 'commentary-entry-heading-text'}, - language.encapsulate(titleCapsule, workingCapsule => { - const workingOptions = {}; - - workingOptions.artists = - html.tag('span', {class: 'commentary-entry-artists'}, - (relations.artistsContent - ? relations.artistsContent.slot('mode', 'inline') - : relations.artistLinks - ? language.formatConjunctionList(relations.artistLinks) - : language.$(titleCapsule, 'noArtists'))); - - const accent = - html.tag('span', {class: 'commentary-entry-accent'}, - {[html.onlyIfContent]: true}, - - language.encapsulate(titleCapsule, 'accent', accentCapsule => - language.encapsulate(accentCapsule, workingCapsule => { - const workingOptions = {}; - - if (relations.annotationContent) { - workingCapsule += '.withAnnotation'; - workingOptions.annotation = - relations.annotationContent.slots({ - mode: 'inline', - absorbPunctuationFollowingExternalLinks: false, - }); - } - - if (workingCapsule === accentCapsule) { - return html.blank(); - } else { - return language.$(workingCapsule, workingOptions); - } - }))); - - if (!html.isBlank(accent)) { - workingCapsule += '.withAccent'; - workingOptions.accent = accent; - } - - return language.$(workingCapsule, workingOptions); - })), - - relations.date, - ])), - - html.tag('blockquote', {class: 'commentary-entry-body'}, - slots.color && - relations.colorStyle.clone() - .slot('color', slots.color), - - data.isWikiEditorCommentary && - {class: 'wiki-commentary'}, - - relations.bodyContent.slot('mode', 'multiline')), - ])), -}; diff --git a/src/content/dependencies/generateCommentaryEntryDate.js b/src/content/dependencies/generateCommentaryEntryDate.js deleted file mode 100644 index e924f244..00000000 --- a/src/content/dependencies/generateCommentaryEntryDate.js +++ /dev/null @@ -1,90 +0,0 @@ -export default { - relations: (relation, _entry) => ({ - textWithTooltip: - relation('generateTextWithTooltip'), - - tooltip: - relation('generateTooltip'), - }), - - data: (entry) => ({ - date: entry.date, - secondDate: entry.secondDate, - dateKind: entry.dateKind, - - accessDate: entry.accessDate, - accessKind: entry.accessKind, - }), - - generate(data, relations, {html, language}) { - const titleCapsule = language.encapsulate('misc.artistCommentary.entry.title'); - - const willDisplayTooltip = - !!(data.accessKind && data.accessDate); - - const topAttributes = - {class: 'commentary-date'}; - - const time = - html.tag('time', - {[html.onlyIfContent]: true}, - - (willDisplayTooltip - ? {class: 'text-with-tooltip-interaction-cue'} - : topAttributes), - - language.encapsulate(titleCapsule, 'date', workingCapsule => { - const workingOptions = {}; - - if (!data.date) { - return html.blank(); - } - - const rangeNeeded = - data.dateKind === 'sometime' || - data.dateKind === 'throughout'; - - if (rangeNeeded && !data.secondDate) { - workingOptions.date = language.formatDate(data.date); - return language.$(workingCapsule, workingOptions); - } - - if (data.dateKind) { - workingCapsule += '.' + data.dateKind; - } - - if (data.secondDate) { - workingCapsule += '.range'; - workingOptions.dateRange = - language.formatDateRange(data.date, data.secondDate); - } else { - workingOptions.date = - language.formatDate(data.date); - } - - return language.$(workingCapsule, workingOptions); - })); - - if (willDisplayTooltip) { - return relations.textWithTooltip.slots({ - customInteractionCue: true, - - attributes: topAttributes, - text: time, - - tooltip: - relations.tooltip.slots({ - attributes: {class: 'commentary-date-tooltip'}, - - content: - language.$(titleCapsule, 'date', data.accessKind, { - date: - language.formatDate(data.accessDate), - }), - }), - }); - } else { - return time; - } - }, -} diff --git a/src/content/dependencies/generateContentEntry.js b/src/content/dependencies/generateContentEntry.js new file mode 100644 index 00000000..bebd690d --- /dev/null +++ b/src/content/dependencies/generateContentEntry.js @@ -0,0 +1,111 @@ +import {empty} from '#sugar'; + +export default { + relations: (relation, entry) => ({ + artistLinks: + (!empty(entry.artists) && !entry.artistText + ? entry.artists + .map(artist => relation('linkArtist', artist)) + : null), + + artistsContent: + (entry.artistText + ? relation('transformContent', entry.artistText) + : null), + + annotationContent: + (entry.annotation + ? relation('transformContent', entry.annotation) + : null), + + bodyContent: + (entry.body + ? relation('transformContent', entry.body) + : null), + + colorStyle: + relation('generateColorStyleAttribute'), + + date: + relation('generateContentEntryDate', entry), + }), + + data: (entry) => ({ + isWikiEditorCommentary: + entry.isWikiEditorCommentary, + }), + + slots: { + color: {validate: v => v.isColor}, + }, + + generate: (data, relations, slots, {html, language}) => + language.encapsulate('misc.artistCommentary.entry', entryCapsule => + html.tags([ + html.tag('p', {class: 'commentary-entry-heading'}, + slots.color && + relations.colorStyle.clone() + .slot('color', slots.color), + + !html.isBlank(relations.date) && + {class: 'dated'}, + + language.encapsulate(entryCapsule, 'title', titleCapsule => [ + html.tag('span', {class: 'commentary-entry-heading-text'}, + language.encapsulate(titleCapsule, workingCapsule => { + const workingOptions = {}; + + workingOptions.artists = + html.tag('span', {class: 'commentary-entry-artists'}, + (relations.artistsContent + ? relations.artistsContent.slot('mode', 'inline') + : relations.artistLinks + ? language.formatConjunctionList(relations.artistLinks) + : language.$(titleCapsule, 'noArtists'))); + + const accent = + html.tag('span', {class: 'commentary-entry-accent'}, + {[html.onlyIfContent]: true}, + + language.encapsulate(titleCapsule, 'accent', accentCapsule => + language.encapsulate(accentCapsule, workingCapsule => { + const workingOptions = {}; + + if (relations.annotationContent) { + workingCapsule += '.withAnnotation'; + workingOptions.annotation = + relations.annotationContent.slots({ + mode: 'inline', + absorbPunctuationFollowingExternalLinks: false, + }); + } + + if (workingCapsule === accentCapsule) { + return html.blank(); + } else { + return language.$(workingCapsule, workingOptions); + } + }))); + + if (!html.isBlank(accent)) { + workingCapsule += '.withAccent'; + workingOptions.accent = accent; + } + + return language.$(workingCapsule, workingOptions); + })), + + relations.date, + ])), + + html.tag('blockquote', {class: 'commentary-entry-body'}, + slots.color && + relations.colorStyle.clone() + .slot('color', slots.color), + + data.isWikiEditorCommentary && + {class: 'wiki-commentary'}, + + relations.bodyContent.slot('mode', 'multiline')), + ])), +}; diff --git a/src/content/dependencies/generateContentEntryDate.js b/src/content/dependencies/generateContentEntryDate.js new file mode 100644 index 00000000..e924f244 --- /dev/null +++ b/src/content/dependencies/generateContentEntryDate.js @@ -0,0 +1,90 @@ +export default { + relations: (relation, _entry) => ({ + textWithTooltip: + relation('generateTextWithTooltip'), + + tooltip: + relation('generateTooltip'), + }), + + data: (entry) => ({ + date: entry.date, + secondDate: entry.secondDate, + dateKind: entry.dateKind, + + accessDate: entry.accessDate, + accessKind: entry.accessKind, + }), + + generate(data, relations, {html, language}) { + const titleCapsule = language.encapsulate('misc.artistCommentary.entry.title'); + + const willDisplayTooltip = + !!(data.accessKind && data.accessDate); + + const topAttributes = + {class: 'commentary-date'}; + + const time = + html.tag('time', + {[html.onlyIfContent]: true}, + + (willDisplayTooltip + ? {class: 'text-with-tooltip-interaction-cue'} + : topAttributes), + + language.encapsulate(titleCapsule, 'date', workingCapsule => { + const workingOptions = {}; + + if (!data.date) { + return html.blank(); + } + + const rangeNeeded = + data.dateKind === 'sometime' || + data.dateKind === 'throughout'; + + if (rangeNeeded && !data.secondDate) { + workingOptions.date = language.formatDate(data.date); + return language.$(workingCapsule, workingOptions); + } + + if (data.dateKind) { + workingCapsule += '.' + data.dateKind; + } + + if (data.secondDate) { + workingCapsule += '.range'; + workingOptions.dateRange = + language.formatDateRange(data.date, data.secondDate); + } else { + workingOptions.date = + language.formatDate(data.date); + } + + return language.$(workingCapsule, workingOptions); + })); + + if (willDisplayTooltip) { + return relations.textWithTooltip.slots({ + customInteractionCue: true, + + attributes: topAttributes, + text: time, + + tooltip: + relations.tooltip.slots({ + attributes: {class: 'commentary-date-tooltip'}, + + content: + language.$(titleCapsule, 'date', data.accessKind, { + date: + language.formatDate(data.accessDate), + }), + }), + }); + } else { + return time; + } + }, +} diff --git a/src/content/dependencies/generateFlashInfoPage.js b/src/content/dependencies/generateFlashInfoPage.js index 935ffdc6..ac49dbf5 100644 --- a/src/content/dependencies/generateFlashInfoPage.js +++ b/src/content/dependencies/generateFlashInfoPage.js @@ -70,7 +70,7 @@ export default { artistCommentaryEntries: flash.commentary - .map(entry => relation('generateCommentaryEntry', entry)), + .map(entry => relation('generateContentEntry', entry)), creditingSourcesSection: relation('generateCollapsedContentEntrySection', diff --git a/src/content/dependencies/generateTrackArtistCommentarySection.js b/src/content/dependencies/generateTrackArtistCommentarySection.js index 39a3e145..999e5ecf 100644 --- a/src/content/dependencies/generateTrackArtistCommentarySection.js +++ b/src/content/dependencies/generateTrackArtistCommentarySection.js @@ -20,7 +20,7 @@ export default { mainReleaseArtistCommentaryEntries: (track.isSecondaryRelease ? track.commentaryFromMainRelease - .map(entry => relation('generateCommentaryEntry', entry)) + .map(entry => relation('generateContentEntry', entry)) : null), thisReleaseAlbumLink: @@ -28,7 +28,7 @@ export default { artistCommentaryEntries: track.commentary - .map(entry => relation('generateCommentaryEntry', entry)), + .map(entry => relation('generateContentEntry', entry)), otherReleaseTrackLinks: query.otherSecondaryReleasesWithCommentary -- cgit 1.3.0-6-gf8a5