From bdef19f601a11c25e8d58b56d7f8135a94722505 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 11 Feb 2025 09:51:56 -0400 Subject: content: generateWikiHome -> generateWikiHomepage, etc --- .../dependencies/generateWikiHomeAlbumsRow.js | 150 --------------------- .../dependencies/generateWikiHomeContentRow.js | 28 ---- .../dependencies/generateWikiHomeNewsBox.js | 86 ------------ src/content/dependencies/generateWikiHomePage.js | 116 ---------------- .../dependencies/generateWikiHomepageAlbumsRow.js | 150 +++++++++++++++++++++ .../dependencies/generateWikiHomepageContentRow.js | 28 ++++ .../dependencies/generateWikiHomepageNewsBox.js | 86 ++++++++++++ .../dependencies/generateWikiHomepagePage.js | 116 ++++++++++++++++ src/content/dependencies/linkWikiHome.js | 20 --- src/content/dependencies/linkWikiHomepage.js | 20 +++ 10 files changed, 400 insertions(+), 400 deletions(-) delete mode 100644 src/content/dependencies/generateWikiHomeAlbumsRow.js delete mode 100644 src/content/dependencies/generateWikiHomeContentRow.js delete mode 100644 src/content/dependencies/generateWikiHomeNewsBox.js delete mode 100644 src/content/dependencies/generateWikiHomePage.js create mode 100644 src/content/dependencies/generateWikiHomepageAlbumsRow.js create mode 100644 src/content/dependencies/generateWikiHomepageContentRow.js create mode 100644 src/content/dependencies/generateWikiHomepageNewsBox.js create mode 100644 src/content/dependencies/generateWikiHomepagePage.js delete mode 100644 src/content/dependencies/linkWikiHome.js create mode 100644 src/content/dependencies/linkWikiHomepage.js (limited to 'src/content/dependencies') diff --git a/src/content/dependencies/generateWikiHomeAlbumsRow.js b/src/content/dependencies/generateWikiHomeAlbumsRow.js deleted file mode 100644 index 84ed5545..00000000 --- a/src/content/dependencies/generateWikiHomeAlbumsRow.js +++ /dev/null @@ -1,150 +0,0 @@ -import {empty, stitchArrays} from '#sugar'; -import {getNewAdditions, getNewReleases} from '#wiki-data'; - -export default { - contentDependencies: [ - 'generateWikiHomeContentRow', - 'generateCoverCarousel', - 'generateCoverGrid', - 'image', - 'linkAlbum', - 'transformContent', - ], - - extraDependencies: ['language', 'wikiData'], - - sprawl({albumData}, row) { - const sprawl = {}; - - switch (row.sourceGroup) { - case 'new-releases': - sprawl.albums = getNewReleases(row.countAlbumsFromGroup, {albumData}); - break; - - case 'new-additions': - sprawl.albums = getNewAdditions(row.countAlbumsFromGroup, {albumData}); - break; - - default: - sprawl.albums = - (row.sourceGroup - ? row.sourceGroup.albums - .slice() - .reverse() - .filter(album => album.isListedOnHomepage) - .slice(0, row.countAlbumsFromGroup) - : []); - } - - if (!empty(row.sourceAlbums)) { - sprawl.albums.push(...row.sourceAlbums); - } - - return sprawl; - }, - - relations(relation, sprawl, row) { - const relations = {}; - - relations.contentRow = - relation('generateWikiHomeContentRow', row); - - if (row.displayStyle === 'grid') { - relations.coverGrid = - relation('generateCoverGrid'); - } - - if (row.displayStyle === 'carousel') { - relations.coverCarousel = - relation('generateCoverCarousel'); - } - - relations.links = - sprawl.albums - .map(album => relation('linkAlbum', album)); - - relations.images = - sprawl.albums - .map(album => relation('image', album.artTags)); - - if (row.actionLinks) { - relations.actionLinks = - row.actionLinks - .map(content => relation('transformContent', content)); - } - - return relations; - }, - - data(sprawl, row) { - const data = {}; - - data.displayStyle = row.displayStyle; - - if (row.displayStyle === 'grid') { - data.names = - sprawl.albums - .map(album => album.name); - } - - data.paths = - sprawl.albums - .map(album => - (album.hasCoverArt - ? ['media.albumCover', album.directory, album.coverArtFileExtension] - : null)); - - return data; - }, - - generate(data, relations, {language}) { - // Grids and carousels share some slots! Very convenient. - const commonSlots = {}; - - commonSlots.links = - relations.links; - - commonSlots.images = - stitchArrays({ - image: relations.images, - path: data.paths, - name: data.names ?? data.paths.slice().fill(null), - }).map(({image, path, name}) => - image.slots({ - path, - missingSourceContent: - language.$('misc.coverGrid.noCoverArt', { - [language.onlyIfOptions]: ['album'], - album: name, - }), - })); - - commonSlots.actionLinks = - (relations.actionLinks - ? relations.actionLinks - .map(contents => - contents - .slot('mode', 'single-link') - .content) - : null); - - let content; - - switch (data.displayStyle) { - case 'grid': - content = - relations.coverGrid.slots({ - ...commonSlots, - names: data.names, - }); - break; - - case 'carousel': - content = - relations.coverCarousel.slots(commonSlots); - break; - } - - return relations.contentRow.slots({content}); - }, -}; diff --git a/src/content/dependencies/generateWikiHomeContentRow.js b/src/content/dependencies/generateWikiHomeContentRow.js deleted file mode 100644 index 27b12e55..00000000 --- a/src/content/dependencies/generateWikiHomeContentRow.js +++ /dev/null @@ -1,28 +0,0 @@ -export default { - contentDependencies: ['generateColorStyleAttribute'], - extraDependencies: ['html'], - - relations: (relation, row) => ({ - colorStyle: - relation('generateColorStyleAttribute', row.color), - }), - - data: (row) => - ({name: row.name}), - - slots: { - content: { - type: 'html', - mutable: false, - }, - }, - - generate: (data, relations, slots, {html}) => - html.tag('section', {class: 'row'}, - relations.colorStyle, - - [ - html.tag('h2', data.name), - slots.content, - ]), -}; diff --git a/src/content/dependencies/generateWikiHomeNewsBox.js b/src/content/dependencies/generateWikiHomeNewsBox.js deleted file mode 100644 index 83a27695..00000000 --- a/src/content/dependencies/generateWikiHomeNewsBox.js +++ /dev/null @@ -1,86 +0,0 @@ -import {stitchArrays} from '#sugar'; - -export default { - contentDependencies: [ - 'generatePageSidebarBox', - 'linkNewsEntry', - 'transformContent', - ], - - extraDependencies: ['html', 'language', 'wikiData'], - - sprawl: ({newsData}) => ({ - entries: - newsData.slice(0, 3), - }), - - relations: (relation, sprawl) => ({ - box: - relation('generatePageSidebarBox'), - - entryContents: - sprawl.entries - .map(entry => relation('transformContent', entry.contentShort)), - - entryMainLinks: - sprawl.entries - .map(entry => relation('linkNewsEntry', entry)), - - entryReadMoreLinks: - sprawl.entries - .map(entry => - entry.contentShort !== entry.content && - relation('linkNewsEntry', entry)), - }), - - data: (sprawl) => ({ - entryDates: - sprawl.entries - .map(entry => entry.date), - }), - - generate: (data, relations, {html, language}) => - language.encapsulate('homepage.news', boxCapsule => - relations.box.slots({ - attributes: {class: 'latest-news-sidebar-box'}, - collapsible: false, - - content: [ - html.tag('h1', - {[html.onlyIfSiblings]: true}, - language.$(boxCapsule, 'title')), - - stitchArrays({ - date: data.entryDates, - content: relations.entryContents, - mainLink: relations.entryMainLinks, - readMoreLink: relations.entryReadMoreLinks, - }).map(({ - date, - content, - mainLink, - readMoreLink, - }, index) => - language.encapsulate(boxCapsule, 'entry', entryCapsule => - html.tag('article', {class: 'news-entry'}, - index === 0 && - {class: 'first-news-entry'}, - - [ - html.tag('h2', [ - html.tag('time', language.formatDate(date)), - mainLink, - ]), - - content.slot('thumb', 'medium'), - - html.tag('p', - {[html.onlyIfContent]: true}, - readMoreLink - ?.slots({ - content: language.$(entryCapsule, 'viewRest'), - })), - ]))), - ], - })), -}; diff --git a/src/content/dependencies/generateWikiHomePage.js b/src/content/dependencies/generateWikiHomePage.js deleted file mode 100644 index ee14a587..00000000 --- a/src/content/dependencies/generateWikiHomePage.js +++ /dev/null @@ -1,116 +0,0 @@ -export default { - contentDependencies: [ - 'generatePageLayout', - 'generatePageSidebar', - 'generatePageSidebarBox', - 'generateWikiHomeAlbumsRow', - 'generateWikiHomeNewsBox', - 'transformContent', - ], - - extraDependencies: ['wikiData'], - - sprawl({wikiInfo}) { - return { - wikiName: wikiInfo.name, - - enableNews: wikiInfo.enableNews, - }; - }, - - relations(relation, sprawl, homepageLayout) { - const relations = {}; - - relations.layout = - relation('generatePageLayout'); - - relations.sidebar = - relation('generatePageSidebar'); - - if (homepageLayout.sidebarContent) { - relations.customSidebarBox = - relation('generatePageSidebarBox'); - - relations.customSidebarContent = - relation('transformContent', homepageLayout.sidebarContent); - } - - if (sprawl.enableNews) { - relations.newsSidebarBox = - relation('generateWikiHomeNewsBox'); - } - - if (homepageLayout.navbarLinks) { - relations.customNavLinkContents = - homepageLayout.navbarLinks - .map(content => relation('transformContent', content)); - } - - relations.contentRows = - homepageLayout.rows.map(row => { - switch (row.type) { - case 'albums': - return relation('generateWikiHomeAlbumsRow', row); - default: - return null; - } - }); - - return relations; - }, - - data(sprawl) { - return { - wikiName: sprawl.wikiName, - }; - }, - - generate(data, relations) { - return relations.layout.slots({ - title: data.wikiName, - showWikiNameInTitle: false, - - mainClasses: ['top-index'], - headingMode: 'static', - - mainContent: [ - relations.contentRows, - ], - - leftSidebar: - relations.sidebar.slots({ - wide: true, - - boxes: [ - relations.customSidebarContent && - relations.customSidebarBox.slots({ - attributes: {class: 'custom-content-sidebar-box'}, - collapsible: false, - - content: - relations.customSidebarContent - .slot('mode', 'multiline'), - }), - - relations.newsSidebarBox, - ], - }), - - navLinkStyle: 'index', - navLinks: [ - {auto: 'home', current: true}, - - ...( - relations.customNavLinkContents - ?.map(content => ({ - html: - content.slots({ - mode: 'single-link', - preferShortLinkNames: true, - }), - })) - ?? []), - ], - }); - }, -}; diff --git a/src/content/dependencies/generateWikiHomepageAlbumsRow.js b/src/content/dependencies/generateWikiHomepageAlbumsRow.js new file mode 100644 index 00000000..047dca72 --- /dev/null +++ b/src/content/dependencies/generateWikiHomepageAlbumsRow.js @@ -0,0 +1,150 @@ +import {empty, stitchArrays} from '#sugar'; +import {getNewAdditions, getNewReleases} from '#wiki-data'; + +export default { + contentDependencies: [ + 'generateWikiHomepageContentRow', + 'generateCoverCarousel', + 'generateCoverGrid', + 'image', + 'linkAlbum', + 'transformContent', + ], + + extraDependencies: ['language', 'wikiData'], + + sprawl({albumData}, row) { + const sprawl = {}; + + switch (row.sourceGroup) { + case 'new-releases': + sprawl.albums = getNewReleases(row.countAlbumsFromGroup, {albumData}); + break; + + case 'new-additions': + sprawl.albums = getNewAdditions(row.countAlbumsFromGroup, {albumData}); + break; + + default: + sprawl.albums = + (row.sourceGroup + ? row.sourceGroup.albums + .slice() + .reverse() + .filter(album => album.isListedOnHomepage) + .slice(0, row.countAlbumsFromGroup) + : []); + } + + if (!empty(row.sourceAlbums)) { + sprawl.albums.push(...row.sourceAlbums); + } + + return sprawl; + }, + + relations(relation, sprawl, row) { + const relations = {}; + + relations.contentRow = + relation('generateWikiHomepageContentRow', row); + + if (row.displayStyle === 'grid') { + relations.coverGrid = + relation('generateCoverGrid'); + } + + if (row.displayStyle === 'carousel') { + relations.coverCarousel = + relation('generateCoverCarousel'); + } + + relations.links = + sprawl.albums + .map(album => relation('linkAlbum', album)); + + relations.images = + sprawl.albums + .map(album => relation('image', album.artTags)); + + if (row.actionLinks) { + relations.actionLinks = + row.actionLinks + .map(content => relation('transformContent', content)); + } + + return relations; + }, + + data(sprawl, row) { + const data = {}; + + data.displayStyle = row.displayStyle; + + if (row.displayStyle === 'grid') { + data.names = + sprawl.albums + .map(album => album.name); + } + + data.paths = + sprawl.albums + .map(album => + (album.hasCoverArt + ? ['media.albumCover', album.directory, album.coverArtFileExtension] + : null)); + + return data; + }, + + generate(data, relations, {language}) { + // Grids and carousels share some slots! Very convenient. + const commonSlots = {}; + + commonSlots.links = + relations.links; + + commonSlots.images = + stitchArrays({ + image: relations.images, + path: data.paths, + name: data.names ?? data.paths.slice().fill(null), + }).map(({image, path, name}) => + image.slots({ + path, + missingSourceContent: + language.$('misc.coverGrid.noCoverArt', { + [language.onlyIfOptions]: ['album'], + album: name, + }), + })); + + commonSlots.actionLinks = + (relations.actionLinks + ? relations.actionLinks + .map(contents => + contents + .slot('mode', 'single-link') + .content) + : null); + + let content; + + switch (data.displayStyle) { + case 'grid': + content = + relations.coverGrid.slots({ + ...commonSlots, + names: data.names, + }); + break; + + case 'carousel': + content = + relations.coverCarousel.slots(commonSlots); + break; + } + + return relations.contentRow.slots({content}); + }, +}; diff --git a/src/content/dependencies/generateWikiHomepageContentRow.js b/src/content/dependencies/generateWikiHomepageContentRow.js new file mode 100644 index 00000000..27b12e55 --- /dev/null +++ b/src/content/dependencies/generateWikiHomepageContentRow.js @@ -0,0 +1,28 @@ +export default { + contentDependencies: ['generateColorStyleAttribute'], + extraDependencies: ['html'], + + relations: (relation, row) => ({ + colorStyle: + relation('generateColorStyleAttribute', row.color), + }), + + data: (row) => + ({name: row.name}), + + slots: { + content: { + type: 'html', + mutable: false, + }, + }, + + generate: (data, relations, slots, {html}) => + html.tag('section', {class: 'row'}, + relations.colorStyle, + + [ + html.tag('h2', data.name), + slots.content, + ]), +}; diff --git a/src/content/dependencies/generateWikiHomepageNewsBox.js b/src/content/dependencies/generateWikiHomepageNewsBox.js new file mode 100644 index 00000000..83a27695 --- /dev/null +++ b/src/content/dependencies/generateWikiHomepageNewsBox.js @@ -0,0 +1,86 @@ +import {stitchArrays} from '#sugar'; + +export default { + contentDependencies: [ + 'generatePageSidebarBox', + 'linkNewsEntry', + 'transformContent', + ], + + extraDependencies: ['html', 'language', 'wikiData'], + + sprawl: ({newsData}) => ({ + entries: + newsData.slice(0, 3), + }), + + relations: (relation, sprawl) => ({ + box: + relation('generatePageSidebarBox'), + + entryContents: + sprawl.entries + .map(entry => relation('transformContent', entry.contentShort)), + + entryMainLinks: + sprawl.entries + .map(entry => relation('linkNewsEntry', entry)), + + entryReadMoreLinks: + sprawl.entries + .map(entry => + entry.contentShort !== entry.content && + relation('linkNewsEntry', entry)), + }), + + data: (sprawl) => ({ + entryDates: + sprawl.entries + .map(entry => entry.date), + }), + + generate: (data, relations, {html, language}) => + language.encapsulate('homepage.news', boxCapsule => + relations.box.slots({ + attributes: {class: 'latest-news-sidebar-box'}, + collapsible: false, + + content: [ + html.tag('h1', + {[html.onlyIfSiblings]: true}, + language.$(boxCapsule, 'title')), + + stitchArrays({ + date: data.entryDates, + content: relations.entryContents, + mainLink: relations.entryMainLinks, + readMoreLink: relations.entryReadMoreLinks, + }).map(({ + date, + content, + mainLink, + readMoreLink, + }, index) => + language.encapsulate(boxCapsule, 'entry', entryCapsule => + html.tag('article', {class: 'news-entry'}, + index === 0 && + {class: 'first-news-entry'}, + + [ + html.tag('h2', [ + html.tag('time', language.formatDate(date)), + mainLink, + ]), + + content.slot('thumb', 'medium'), + + html.tag('p', + {[html.onlyIfContent]: true}, + readMoreLink + ?.slots({ + content: language.$(entryCapsule, 'viewRest'), + })), + ]))), + ], + })), +}; diff --git a/src/content/dependencies/generateWikiHomepagePage.js b/src/content/dependencies/generateWikiHomepagePage.js new file mode 100644 index 00000000..73ab5dd4 --- /dev/null +++ b/src/content/dependencies/generateWikiHomepagePage.js @@ -0,0 +1,116 @@ +export default { + contentDependencies: [ + 'generatePageLayout', + 'generatePageSidebar', + 'generatePageSidebarBox', + 'generateWikiHomepageAlbumsRow', + 'generateWikiHomepageNewsBox', + 'transformContent', + ], + + extraDependencies: ['wikiData'], + + sprawl({wikiInfo}) { + return { + wikiName: wikiInfo.name, + + enableNews: wikiInfo.enableNews, + }; + }, + + relations(relation, sprawl, homepageLayout) { + const relations = {}; + + relations.layout = + relation('generatePageLayout'); + + relations.sidebar = + relation('generatePageSidebar'); + + if (homepageLayout.sidebarContent) { + relations.customSidebarBox = + relation('generatePageSidebarBox'); + + relations.customSidebarContent = + relation('transformContent', homepageLayout.sidebarContent); + } + + if (sprawl.enableNews) { + relations.newsSidebarBox = + relation('generateWikiHomepageNewsBox'); + } + + if (homepageLayout.navbarLinks) { + relations.customNavLinkContents = + homepageLayout.navbarLinks + .map(content => relation('transformContent', content)); + } + + relations.contentRows = + homepageLayout.rows.map(row => { + switch (row.type) { + case 'albums': + return relation('generateWikiHomepageAlbumsRow', row); + default: + return null; + } + }); + + return relations; + }, + + data(sprawl) { + return { + wikiName: sprawl.wikiName, + }; + }, + + generate(data, relations) { + return relations.layout.slots({ + title: data.wikiName, + showWikiNameInTitle: false, + + mainClasses: ['top-index'], + headingMode: 'static', + + mainContent: [ + relations.contentRows, + ], + + leftSidebar: + relations.sidebar.slots({ + wide: true, + + boxes: [ + relations.customSidebarContent && + relations.customSidebarBox.slots({ + attributes: {class: 'custom-content-sidebar-box'}, + collapsible: false, + + content: + relations.customSidebarContent + .slot('mode', 'multiline'), + }), + + relations.newsSidebarBox, + ], + }), + + navLinkStyle: 'index', + navLinks: [ + {auto: 'home', current: true}, + + ...( + relations.customNavLinkContents + ?.map(content => ({ + html: + content.slots({ + mode: 'single-link', + preferShortLinkNames: true, + }), + })) + ?? []), + ], + }); + }, +}; diff --git a/src/content/dependencies/linkWikiHome.js b/src/content/dependencies/linkWikiHome.js deleted file mode 100644 index d8d3d0a0..00000000 --- a/src/content/dependencies/linkWikiHome.js +++ /dev/null @@ -1,20 +0,0 @@ -export default { - contentDependencies: ['linkTemplate'], - extraDependencies: ['wikiData'], - - sprawl({wikiInfo}) { - return {wikiShortName: wikiInfo.nameShort}; - }, - - relations: (relation) => - ({link: relation('linkTemplate')}), - - data: (sprawl) => - ({wikiShortName: sprawl.wikiShortName}), - - generate: (data, relations) => - relations.link.slots({ - path: ['localized.home'], - content: data.wikiShortName, - }), -}; diff --git a/src/content/dependencies/linkWikiHomepage.js b/src/content/dependencies/linkWikiHomepage.js new file mode 100644 index 00000000..d8d3d0a0 --- /dev/null +++ b/src/content/dependencies/linkWikiHomepage.js @@ -0,0 +1,20 @@ +export default { + contentDependencies: ['linkTemplate'], + extraDependencies: ['wikiData'], + + sprawl({wikiInfo}) { + return {wikiShortName: wikiInfo.nameShort}; + }, + + relations: (relation) => + ({link: relation('linkTemplate')}), + + data: (sprawl) => + ({wikiShortName: sprawl.wikiShortName}), + + generate: (data, relations) => + relations.link.slots({ + path: ['localized.home'], + content: data.wikiShortName, + }), +}; -- cgit 1.3.0-6-gf8a5