diff options
-rw-r--r-- | src/content/dependencies/generateAlbumChronologyLinks.js | 53 | ||||
-rw-r--r-- | src/content/dependencies/generateAlbumInfoPage.js | 7 | ||||
-rw-r--r-- | src/content/dependencies/generateChronologyLinks.js | 112 | ||||
-rw-r--r-- | src/content/dependencies/generateChronologyLinksScopeSwitcher.js | 68 | ||||
-rw-r--r-- | src/content/dependencies/generateTrackChronologyLinks.js | 177 | ||||
-rw-r--r-- | src/content/dependencies/generateTrackInfoPage.js | 7 | ||||
-rw-r--r-- | src/content/util/getChronologyRelations.js | 57 | ||||
-rw-r--r-- | src/static/css/site.css | 18 | ||||
-rw-r--r-- | src/static/js/client.js | 108 |
9 files changed, 0 insertions, 607 deletions
diff --git a/src/content/dependencies/generateAlbumChronologyLinks.js b/src/content/dependencies/generateAlbumChronologyLinks.js deleted file mode 100644 index 3dd7a18e..00000000 --- a/src/content/dependencies/generateAlbumChronologyLinks.js +++ /dev/null @@ -1,53 +0,0 @@ -import {sortAlbumsTracksChronologically} from '#sort'; - -import getChronologyRelations from '../util/getChronologyRelations.js'; - -export default { - contentDependencies: [ - 'generateChronologyLinks', - 'linkAlbum', - 'linkArtist', - 'linkTrack', - ], - - relations: (relation, album) => ({ - chronologyLinks: - relation('generateChronologyLinks'), - - coverArtistChronologyContributions: - getChronologyRelations(album, { - contributions: album.coverArtistContribs ?? [], - - linkArtist: artist => relation('linkArtist', artist), - - linkThing: trackOrAlbum => - (trackOrAlbum.album - ? relation('linkTrack', trackOrAlbum) - : relation('linkAlbum', trackOrAlbum)), - - getThings(artist) { - const getDate = thing => thing.coverArtDate ?? thing.date; - - const things = - ([ - artist.albumCoverArtistContributions, - artist.trackCoverArtistContributions, - ]).flat() - .map(({thing}) => thing) - .filter(getDate); - - return sortAlbumsTracksChronologically(things, {getDate}); - }, - }), - }), - - generate: (relations) => - relations.chronologyLinks.slots({ - chronologyInfoSets: [ - { - headingString: 'misc.chronology.heading.coverArt', - contributions: relations.coverArtistChronologyContributions, - }, - ], - }), -} diff --git a/src/content/dependencies/generateAlbumInfoPage.js b/src/content/dependencies/generateAlbumInfoPage.js index 3af312bb..1bffe2d0 100644 --- a/src/content/dependencies/generateAlbumInfoPage.js +++ b/src/content/dependencies/generateAlbumInfoPage.js @@ -10,7 +10,6 @@ export default { 'generateAlbumSocialEmbed', 'generateAlbumStyleRules', 'generateAlbumTrackList', - 'generateAlbumChronologyLinks', 'generateCommentarySection', 'generateContentHeading', 'generatePageLayout', @@ -33,9 +32,6 @@ export default { albumNavAccent: relation('generateAlbumNavAccent', album, null), - chronologyLinks: - relation('generateAlbumChronologyLinks', album), - secondaryNav: relation('generateAlbumSecondaryNav', album), @@ -196,9 +192,6 @@ export default { }, ], - navContent: - relations.chronologyLinks, - banner: relations.banner ?? null, bannerPosition: 'top', diff --git a/src/content/dependencies/generateChronologyLinks.js b/src/content/dependencies/generateChronologyLinks.js deleted file mode 100644 index 7f24ded7..00000000 --- a/src/content/dependencies/generateChronologyLinks.js +++ /dev/null @@ -1,112 +0,0 @@ -import {accumulateSum, empty} from '#sugar'; - -export default { - extraDependencies: ['html', 'language'], - - slots: { - allowCollapsing: { - type: 'boolean', - default: true, - }, - - showOnly: { - type: 'boolean', - default: false, - }, - - chronologyInfoSets: { - validate: v => - v.strictArrayOf( - v.validateProperties({ - headingString: v.isString, - contributions: v.strictArrayOf(v.validateProperties({ - index: v.isCountingNumber, - only: v.isBoolean, - artistDirectory: v.isDirectory, - artistLink: v.isHTML, - previousLink: v.isHTML, - nextLink: v.isHTML, - })), - })), - } - }, - - generate(slots, {html, language}) { - if (empty(slots.chronologyInfoSets)) { - return html.blank(); - } - - let infoSets = slots.chronologyInfoSets; - - if (!slots.showOnly) { - infoSets = infoSets - .map(({contributions, ...entry}) => ({ - ...entry, - contributions: - contributions - .filter(({only}) => !only), - })) - .filter(({contributions}) => !empty(contributions)); - } - - const totalContributionCount = - accumulateSum( - infoSets, - ({contributions}) => contributions.length); - - if (totalContributionCount === 0) { - return html.blank(); - } - - if (slots.allowCollapsing && totalContributionCount > 8) { - return html.tag('div', {class: 'chronology'}, - language.$('misc.chronology.seeArtistPages')); - } - - return html.tags( - infoSets.map(({ - headingString, - contributions, - }) => - contributions.map(({ - index, - artistLink, - previousLink, - nextLink, - only, - }) => { - const heading = - html.tag('span', {class: 'heading'}, - language.$(headingString, { - index: - (only - ? language.formatString('misc.chronology.heading.onlyIndex') - : language.formatIndex(index)), - - artist: artistLink, - })); - - const navigation = - !only && - html.tag('span', {class: 'buttons'}, - language.formatUnitList([ - previousLink?.slots({ - tooltipStyle: 'browser', - color: false, - content: language.$('misc.nav.previous'), - }), - - nextLink?.slots({ - tooltipStyle: 'browser', - color: false, - content: language.$('misc.nav.next'), - }), - ].filter(Boolean))); - - return html.tag('div', {class: 'chronology'}, - (navigation - ? language.$('misc.chronology.withNavigation', {heading, navigation}) - : heading)); - }))); - }, -}; diff --git a/src/content/dependencies/generateChronologyLinksScopeSwitcher.js b/src/content/dependencies/generateChronologyLinksScopeSwitcher.js deleted file mode 100644 index 4a1b67a7..00000000 --- a/src/content/dependencies/generateChronologyLinksScopeSwitcher.js +++ /dev/null @@ -1,68 +0,0 @@ -import {stitchArrays} from '#sugar'; - -export default { - extraDependencies: ['html', 'language'], - - slots: { - scopes: { - validate: v => v.strictArrayOf(v.isStringNonEmpty), - }, - - contents: { - validate: v => v.strictArrayOf(v.isHTML), - }, - - open: { - type: 'boolean', - default: true, - }, - }, - - generate(slots, {html, language}) { - // TODO: Manual [html.onlyIfContent]-alike here is a bit unfortunate. - // We can't use a normal [html.onlyIfContent] because the summary counts - // as content - we'd need to encode that we want to exclude it from the - // content check (for the <details> element), somehow. - if (slots.contents.every(content => html.isBlank(content))) { - return html.blank(); - } - - const summary = - html.tag('summary', - {class: 'underline-white'}, - - html.tag('span', - language.encapsulate('trackPage.nav.chronology.scope', capsule => - language.$(capsule, 'title', { - scope: - slots.scopes.map((scope, index) => - html.tag('a', {class: 'switcher-link'}, - {href: '#'}, - - (index === 0 - ? {style: 'display: inline'} - : {style: 'display: none'}), - - language.$(capsule, scope))), - })))); - - const scopeContents = - stitchArrays({ - scope: slots.scopes, - content: slots.contents, - }).map(({scope, content}, index) => - html.tag('div', {class: 'scope-' + scope}, - (index === 0 - ? {style: 'display: block'} - : {style: 'display: none'}), - - content)); - - return ( - html.tag('details', {class: 'scoped-chronology-switcher'}, - slots.open && - {open: true}, - - [summary, scopeContents])); - }, -}; diff --git a/src/content/dependencies/generateTrackChronologyLinks.js b/src/content/dependencies/generateTrackChronologyLinks.js deleted file mode 100644 index f9ad6299..00000000 --- a/src/content/dependencies/generateTrackChronologyLinks.js +++ /dev/null @@ -1,177 +0,0 @@ -import {sortAlbumsTracksChronologically} from '#sort'; -import {accumulateSum, stitchArrays} from '#sugar'; - -import getChronologyRelations from '../util/getChronologyRelations.js'; - -export default { - contentDependencies: [ - 'generateChronologyLinks', - 'generateChronologyLinksScopeSwitcher', - 'linkAlbum', - 'linkArtist', - 'linkTrack', - ], - - relations(relation, track) { - function getScopedRelations(album) { - const albumFilter = - (album - ? track => track.album === album - : () => true); - - return { - chronologyLinks: - relation('generateChronologyLinks'), - - artistChronologyContributions: - getChronologyRelations(track, { - contributions: [ - ...track.artistContribs ?? [], - ...track.contributorContribs ?? [], - ], - - linkArtist: artist => relation('linkArtist', artist), - linkThing: track => relation('linkTrack', track), - - getThings(artist) { - const getDate = thing => thing.date; - - const things = - ([ - artist.trackArtistContributions, - artist.trackContributorContributions, - ]).flat() - .map(({thing}) => thing) - .filter(getDate) - .filter(albumFilter); - - return sortAlbumsTracksChronologically(things, {getDate}); - }, - }), - - coverArtistChronologyContributions: - getChronologyRelations(track, { - contributions: track.coverArtistContribs ?? [], - - linkArtist: artist => relation('linkArtist', artist), - - linkThing: trackOrAlbum => - (trackOrAlbum.album - ? relation('linkTrack', trackOrAlbum) - : relation('linkAlbum', trackOrAlbum)), - - getThings(artist) { - const getDate = thing => thing.coverArtDate ?? thing.date; - - // Album artwork isn't part of cover artist chronology scoped to - // even the same album - we use this list to show "nth track art". - const applicableContributions = - (album - ? artist.trackCoverArtistContributions - : ([ - artist.albumCoverArtistContributions, - artist.trackCoverArtistContributions, - ]).flat()); - - const things = - applicableContributions - .map(({thing}) => thing) - .filter(getDate) - .filter(albumFilter); - - return sortAlbumsTracksChronologically(things, {getDate}); - }, - }), - }; - } - - const relations = {}; - - relations.scopeSwitcher = - relation('generateChronologyLinksScopeSwitcher'); - - relations.wiki = - getScopedRelations(null); - - relations.album = - getScopedRelations(track.album); - - for (const setKey of [ - 'artistChronologyContributions', - 'coverArtistChronologyContributions', - ]) { - const wikiSet = relations.wiki[setKey]; - const albumSet = relations.album[setKey]; - - const wikiArtistDirectories = - wikiSet - .map(({artistDirectory}) => artistDirectory); - - albumSet.sort((a, b) => - (a.only === b.only && a.index === b.index - ? (wikiArtistDirectories.indexOf(a.artistDirectory) - - wikiArtistDirectories.indexOf(b.artistDirectory)) - : 0)); - } - - return relations; - }, - - generate(relations) { - function slotScopedRelations({content, artworkHeadingString}) { - return content.chronologyLinks.slots({ - showOnly: true, - allowCollapsing: false, - - chronologyInfoSets: [ - { - headingString: 'misc.chronology.heading.track', - contributions: content.artistChronologyContributions, - }, - { - headingString: `misc.chronology.heading.${artworkHeadingString}`, - contributions: content.coverArtistChronologyContributions, - }, - ], - }); - } - - const scopes = [ - 'wiki', - 'album', - ]; - - const contents = [ - relations.wiki, - relations.album, - ]; - - const artworkHeadingStrings = [ - 'coverArt', - 'trackArt', - ]; - - const totalContributionCount = - Math.max(... - contents.map(content => - accumulateSum([ - content.artistChronologyContributions, - content.coverArtistChronologyContributions, - ], contributions => contributions.length))); - - relations.scopeSwitcher.setSlots({ - scopes, - - open: - totalContributionCount <= 5, - - contents: - stitchArrays({ - content: contents, - artworkHeadingString: artworkHeadingStrings, - }).map(slotScopedRelations), - }); - - return relations.scopeSwitcher; - }, -}; diff --git a/src/content/dependencies/generateTrackInfoPage.js b/src/content/dependencies/generateTrackInfoPage.js index 09cf55f6..64ed0cb4 100644 --- a/src/content/dependencies/generateTrackInfoPage.js +++ b/src/content/dependencies/generateTrackInfoPage.js @@ -10,7 +10,6 @@ export default { 'generateContributionList', 'generatePageLayout', 'generateTrackAdditionalNamesBox', - 'generateTrackChronologyLinks', 'generateTrackCoverArtwork', 'generateTrackInfoPageFeaturedByFlashesList', 'generateTrackInfoPageOtherReleasesList', @@ -49,9 +48,6 @@ export default { albumNavAccent: relation('generateAlbumNavAccent', track.album, track), - chronologyLinks: - relation('generateTrackChronologyLinks', track), - secondaryNav: relation('generateAlbumSecondaryNav', track.album), @@ -397,9 +393,6 @@ export default { showExtraLinks: false, }), - navContent: - relations.chronologyLinks, - secondaryNav: relations.secondaryNav .slot('mode', 'track'), diff --git a/src/content/util/getChronologyRelations.js b/src/content/util/getChronologyRelations.js deleted file mode 100644 index c601a990..00000000 --- a/src/content/util/getChronologyRelations.js +++ /dev/null @@ -1,57 +0,0 @@ -export default function getChronologyRelations(thing, { - contributions, - linkArtist, - linkThing, - getThings, -}) { - // One call to getChronologyRelations is considered "lumping" together all - // contributions as carrying equivalent meaning (for example, "artist" - // contributions and "contributor" contributions are bunched together in - // one call to getChronologyRelations, while "cover artist" contributions - // are a separate call). getChronologyRelations prevents duplicates that - // carry the same meaning by only using the first instance of each artist - // in the contributions array passed to it. It's expected that the string - // identifying which kind of contribution ("track" or "cover art") is - // shared and applied to all contributions, as providing them together - // in one call to getChronologyRelations implies they carry the same - // meaning. - - const artistsSoFar = new Set(); - - contributions = contributions.filter(({artist}) => { - if (artistsSoFar.has(artist)) { - return false; - } else { - artistsSoFar.add(artist); - return true; - } - }); - - return contributions.map(({artist}) => { - const things = Array.from(new Set(getThings(artist))); - - // Don't show a line if this contribution isn't part of the artist's - // chronology at all (usually because this thing isn't dated). - const index = things.indexOf(thing); - if (index === -1) { - return; - } - - const previous = things[index - 1]; - const next = things[index + 1]; - - return { - index: index + 1, - artistDirectory: artist.directory, - only: !(previous || next), - - artistLink: linkArtist(artist), - previousLink: previous ? linkThing(previous) : null, - nextLink: next ? linkThing(next) : null, - }; - }).filter(Boolean) - .sort((a, b) => - (a.only === b.only ? b.index - a.index - : a.only ? +1 - : -1)) -} diff --git a/src/static/css/site.css b/src/static/css/site.css index b4c99788..80801c85 100644 --- a/src/static/css/site.css +++ b/src/static/css/site.css @@ -817,24 +817,6 @@ a:not([href]):hover { content: "\0020/\0020"; } -#header .chronology .heading, -#header .chronology .buttons { - white-space: nowrap; -} - -#header .scoped-chronology { - display: none; -} - -#header .scoped-chronology-switcher .switcher-link { - text-decoration: underline; - text-decoration-style: dotted; -} - -#header .scoped-chronology-switcher > div { - margin-left: 20px; -} - #secondary-nav { text-align: center; } diff --git a/src/static/js/client.js b/src/static/js/client.js index 38060999..21c3911a 100644 --- a/src/static/js/client.js +++ b/src/static/js/client.js @@ -3208,114 +3208,6 @@ clientSteps.getPageReferences.push(getAdditionalNamesBoxReferences); clientSteps.addInternalListeners.push(addAdditionalNamesBoxInternalListeners); clientSteps.addPageListeners.push(addAdditionalNamesBoxListeners); -// Scoped chronology links -------------------------------- - -const scopedChronologyLinksInfo = initInfo('scopedChronologyLinksInfo', { - switcher: null, - containers: null, - switcherLinks: null, - modes: null, - - session: { - selectedMode: 'wiki', - }, -}); - -function getScopedChronologyLinksReferences() { - const info = scopedChronologyLinksInfo; - - info.switcher = - document.querySelector('.scoped-chronology-switcher'); - - if (!info.switcher) { - return; - } - - info.containers = - Array.from(info.switcher.querySelectorAll(':scope > div')); - - info.switcherLinks = - Array.from(info.switcher.querySelectorAll('.switcher-link')); - - info.modes = - info.containers - .map(container => - Array.from(container.classList) - .find(className => className.startsWith('scope-')) - .slice('scope-'.length)); -} - -function addScopedChronologyLinksPageHandlers() { - const info = scopedChronologyLinksInfo; - const {session} = scopedChronologyLinksInfo; - - if (!info.switcher) { - return; - } - - for (const [index, { - container: currentContainer, - switcherLink: currentSwitcherLink, - }] of stitchArrays({ - container: info.containers, - switcherLink: info.switcherLinks, - }).entries()) { - const nextContainer = - atOffset(info.containers, index, +1, {wrap: true}); - - const nextSwitcherLink = - atOffset(info.switcherLinks, index, +1, {wrap: true}); - - const nextMode = - atOffset(info.modes, index, +1, {wrap: true}); - - currentSwitcherLink.addEventListener('click', domEvent => { - domEvent.preventDefault(); - - cssProp(currentContainer, 'display', 'none'); - cssProp(currentSwitcherLink, 'display', 'none'); - cssProp(nextContainer, 'display', 'block'); - cssProp(nextSwitcherLink, 'display', 'inline'); - - session.selectedMode = nextMode; - }); - } -} - -function mutateScopedChronologyLinksContent() { - const info = scopedChronologyLinksInfo; - - if (!info.switcher) { - return; - } - - const {selectedMode} = info.session; - - if (info.modes.includes(selectedMode)) { - const selectedIndex = info.modes.indexOf(selectedMode); - - for (const [index, { - container, - switcherLink, - }] of stitchArrays({ - container: info.containers, - switcherLink: info.switcherLinks, - }).entries()) { - if (index === selectedIndex) { - cssProp(container, 'display', 'block'); - cssProp(switcherLink, 'display', 'inline'); - } else { - cssProp(container, 'display', 'none'); - cssProp(switcherLink, 'display', 'none'); - } - } - } -} - -clientSteps.getPageReferences.push(getScopedChronologyLinksReferences); -clientSteps.mutatePageContent.push(mutateScopedChronologyLinksContent); -clientSteps.addPageListeners.push(addScopedChronologyLinksPageHandlers); - // Group contributions table ------------------------------ // TODO: Update to clientSteps style. |