From 0d0d38ce51ca02b7c3bd91317b5fa0bbff1f06de Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sat, 10 Apr 2021 22:28:17 -0300 Subject: new Albums - by Date Added to Wiki listing --- strings-default.json | 3 +++ upd8-util.js | 13 ++++++++++++- upd8.js | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/strings-default.json b/strings-default.json index 3dc2e4b5..7a948d64 100644 --- a/strings-default.json +++ b/strings-default.json @@ -225,6 +225,9 @@ "listingPage.listAlbums.byDuration.item": "{ALBUM} ({DURATION})", "listingPage.listAlbums.byDate.title": "Albums - by Date", "listingPage.listAlbums.byDate.item": "{ALBUM} ({DATE})", + "listingPage.listAlbums.byDateAdded.title": "Albums - by Date Added to Wiki", + "listingPage.listAlbums.byDateAdded.date": "{DATE}", + "listingPage.listAlbums.byDateAdded.album": "{ALBUM}", "listingPage.listArtists.byName.title": "Artists - by Name", "listingPage.listArtists.byName.item": "{ARTIST} ({CONTRIBUTIONS})", "listingPage.listArtists.byContribs.title": "Artists - by Contributions", diff --git a/upd8-util.js b/upd8-util.js index 6ff34199..abeed6c1 100644 --- a/upd8-util.js +++ b/upd8-util.js @@ -370,7 +370,18 @@ module.exports.chunkByConditions = function(array, conditions) { }; module.exports.chunkByProperties = function(array, properties) { - return module.exports.chunkByConditions(array, properties.map(p => (a, b) => a[p] !== b[p] || a[p] != b[p])) + return module.exports.chunkByConditions(array, properties.map(p => (a, b) => { + if (a[p] instanceof Date && b[p] instanceof Date) + return +a[p] !== +b[p]; + + if (a[p] !== b[p]) return true; + + // Not sure if this line is still necessary with the specific check for + // d8tes a8ove, 8ut, uh, keeping it anyway, just in case....? + if (a[p] != b[p]) return true; + + return false; + })) .map(chunk => ({ ...Object.fromEntries(properties.map(p => [p, chunk[0][p]])), chunk diff --git a/upd8.js b/upd8.js index 732c35a1..66582f17 100755 --- a/upd8.js +++ b/upd8.js @@ -4135,6 +4135,38 @@ const listingSpec = [ } }, + { + directory: 'albusm/by-date-added', + title: ({strings}) => strings('listingPage.listAlbums.byDateAdded.title'), + + data() { + return chunkByProperties(albumData.slice().sort((a, b) => { + if (a.dateAdded < b.dateAdded) return -1; + if (a.dateAdded > b.dateAdded) return 1; + }), ['dateAdded']); + }, + + html(chunks, {strings, to}) { + return fixWS` +
+ ${chunks.map(({dateAdded, chunk: albums}) => fixWS` +
${strings('listingPage.listAlbums.byDateAdded.date', { + date: strings.count.date(dateAdded) + })}
+
    + ${(albums + .map(album => strings('listingPage.listAlbums.byDateAdded.album', { + album: strings.link.album(album, {to}) + })) + .map(row => `
  • ${row}
  • `) + .join('\n'))} +
+ `).join('\n')} +
+ `; + } + }, + { directory: 'artists/by-name', title: ({strings}) => strings('listingPage.listArtists.byName.title'), -- cgit 1.3.0-6-gf8a5