diff options
author | (quasar) nebula <towerofnix@gmail.com> | 2021-04-10 22:28:17 -0300 |
---|---|---|
committer | (quasar) nebula <towerofnix@gmail.com> | 2021-04-10 22:28:17 -0300 |
commit | 0d0d38ce51ca02b7c3bd91317b5fa0bbff1f06de (patch) | |
tree | d78594d4b44bb806eccf7f2a3c4f8ec9707622d5 | |
parent | e99c48d128744a77c672cdf8f19dcf3cdc395b9b (diff) |
new Albums - by Date Added to Wiki listing
-rw-r--r-- | strings-default.json | 3 | ||||
-rw-r--r-- | upd8-util.js | 13 | ||||
-rwxr-xr-x | upd8.js | 32 |
3 files changed, 47 insertions, 1 deletions
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 @@ -4136,6 +4136,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` + <dl> + ${chunks.map(({dateAdded, chunk: albums}) => fixWS` + <dt>${strings('listingPage.listAlbums.byDateAdded.date', { + date: strings.count.date(dateAdded) + })}</dt> + <dd><ul> + ${(albums + .map(album => strings('listingPage.listAlbums.byDateAdded.album', { + album: strings.link.album(album, {to}) + })) + .map(row => `<li>${row}</li>`) + .join('\n'))} + </ul></dd> + `).join('\n')} + </dl> + `; + } + }, + + { directory: 'artists/by-name', title: ({strings}) => strings('listingPage.listArtists.byName.title'), |