From 482edbc0ff58da60e51a5f41f8888873d8740a03 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sun, 29 Oct 2023 15:29:20 -0300 Subject: content, client: integrate separate media cache --- src/content/dependencies/image.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/content') diff --git a/src/content/dependencies/image.js b/src/content/dependencies/image.js index 6c0aeecd..8aa9753b 100644 --- a/src/content/dependencies/image.js +++ b/src/content/dependencies/image.js @@ -77,6 +77,11 @@ export default { originalSrc = ''; } + // TODO: This feels janky. It's necessary to deal with static content that + // includes strings like , but processing the + // src string directly when a parts-formed path *is* available seems wrong. + // It should be possible to do urls.from(slots.path[0]).to(...slots.path), + // for example, but will require reworking the control flow here a little. let mediaSrc = null; if (originalSrc.startsWith(to('media.root'))) { mediaSrc = @@ -160,7 +165,7 @@ export default { // which is the HTML output-appropriate path including `../../` or // another alternate base path. const selectedSize = getThumbnailEqualOrSmaller(slots.thumb, mediaSrc); - thumbSrc = originalSrc.replace(/\.(jpg|png)$/, `.${selectedSize}.jpg`); + thumbSrc = to('thumb.path', mediaSrc.replace(/\.(png|jpg)$/, `.${selectedSize}.jpg`)); const dimensions = getDimensionsOfImagePath(mediaSrc); availableThumbs = getThumbnailsAvailableForDimensions(dimensions); -- cgit 1.3.0-6-gf8a5 From c1f93e2d270292bca7e991c180db618f4902a3f9 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Mon, 30 Oct 2023 22:35:18 -0300 Subject: content, data: fix places that assume coverArtDate defaults to date --- src/content/dependencies/generateArtTagGalleryPage.js | 2 +- .../dependencies/generateArtistInfoPageArtworksChunkedList.js | 10 +++++----- src/content/dependencies/generateTrackInfoPage.js | 2 +- src/content/dependencies/listArtistsByLatestContribution.js | 8 ++++---- 4 files changed, 11 insertions(+), 11 deletions(-) (limited to 'src/content') diff --git a/src/content/dependencies/generateArtTagGalleryPage.js b/src/content/dependencies/generateArtTagGalleryPage.js index c04bfb68..e28b54cb 100644 --- a/src/content/dependencies/generateArtTagGalleryPage.js +++ b/src/content/dependencies/generateArtTagGalleryPage.js @@ -23,7 +23,7 @@ export default { const things = tag.taggedInThings.slice(); sortAlbumsTracksChronologically(things, { - getDate: thing => thing.coverArtDate, + getDate: thing => thing.coverArtDate ?? thing.date, latestFirst: true, }); diff --git a/src/content/dependencies/generateArtistInfoPageArtworksChunkedList.js b/src/content/dependencies/generateArtistInfoPageArtworksChunkedList.js index aa6efe5e..a3bcf687 100644 --- a/src/content/dependencies/generateArtistInfoPageArtworksChunkedList.js +++ b/src/content/dependencies/generateArtistInfoPageArtworksChunkedList.js @@ -30,7 +30,7 @@ export default { entry: { type: 'albumCover', album: album, - date: album.coverArtDate, + date: album.coverArtDate ?? album.date, contribs: album.coverArtistContribs, }, })), @@ -40,7 +40,7 @@ export default { entry: { type: 'albumWallpaper', album: album, - date: album.coverArtDate, + date: album.coverArtDate ?? album.date, contribs: album.wallpaperArtistContribs, }, })), @@ -50,7 +50,7 @@ export default { entry: { type: 'albumBanner', album: album, - date: album.coverArtDate, + date: album.coverArtDate ?? album.date, contribs: album.bannerArtistContribs, }, })), @@ -60,7 +60,7 @@ export default { entry: { type: 'trackCover', album: track.album, - date: track.coverArtDate, + date: track.coverArtDate ?? track.date, track: track, contribs: track.coverArtistContribs, }, @@ -69,7 +69,7 @@ export default { sortEntryThingPairs(entries, things => sortAlbumsTracksChronologically(things, { - getDate: thing => thing.coverArtDate, + getDate: thing => thing.coverArtDate ?? thing.date, })); const chunks = diff --git a/src/content/dependencies/generateTrackInfoPage.js b/src/content/dependencies/generateTrackInfoPage.js index 1083d863..93334948 100644 --- a/src/content/dependencies/generateTrackInfoPage.js +++ b/src/content/dependencies/generateTrackInfoPage.js @@ -82,7 +82,7 @@ export default { ...artist.albumsAsCoverArtist, ...artist.tracksAsCoverArtist, ], { - getDate: albumOrTrack => albumOrTrack.coverArtDate, + getDate: thing => thing.coverArtDate ?? thing.date, }), }), diff --git a/src/content/dependencies/listArtistsByLatestContribution.js b/src/content/dependencies/listArtistsByLatestContribution.js index b6ea8e96..3870afde 100644 --- a/src/content/dependencies/listArtistsByLatestContribution.js +++ b/src/content/dependencies/listArtistsByLatestContribution.js @@ -143,10 +143,10 @@ export default { ], [ // TODO: Per-artwork dates, see #90. - ...artist.tracksAsCoverArtist.map(track => track.coverArtDate), - ...artist.albumsAsCoverArtist.map(album => album.coverArtDate), - ...artist.albumsAsWallpaperArtist.map(album => album.coverArtDate), - ...artist.albumsAsBannerArtist.map(album => album.coverArtDate), + ...artist.tracksAsCoverArtist.map(track => track.coverArtDate ?? track.date), + ...artist.albumsAsCoverArtist.map(album => album.coverArtDate ?? album.date), + ...artist.albumsAsWallpaperArtist.map(album => album.coverArtDate ?? album.date), + ...artist.albumsAsBannerArtist.map(album => album.coverArtDate ?? album.date), ], ]); -- cgit 1.3.0-6-gf8a5 From 9bf4b59f608022ab0ca2cadc4acff7bb6760ebd2 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Wed, 8 Nov 2023 19:54:01 -0400 Subject: content, repl: minor fixes and tweaks --- src/content/dependencies/generatePageLayout.js | 3 ++- src/content/dependencies/linkExternal.js | 25 ++++++++++++++++++++++--- 2 files changed, 24 insertions(+), 4 deletions(-) (limited to 'src/content') diff --git a/src/content/dependencies/generatePageLayout.js b/src/content/dependencies/generatePageLayout.js index cd831ba7..72dfbae5 100644 --- a/src/content/dependencies/generatePageLayout.js +++ b/src/content/dependencies/generatePageLayout.js @@ -449,7 +449,8 @@ export default { {[html.onlyIfContent]: true, class: 'skipper-list'}, processSkippers([ {id: 'tracks', string: 'tracks'}, - {id: 'art', string: 'flashes'}, + {id: 'art', string: 'artworks'}, + {id: 'flashes', string: 'flashes'}, {id: 'contributors', string: 'contributors'}, {id: 'references', string: 'references'}, {id: 'referenced-by', string: 'referencedBy'}, diff --git a/src/content/dependencies/linkExternal.js b/src/content/dependencies/linkExternal.js index 73c656e3..5de612e2 100644 --- a/src/content/dependencies/linkExternal.js +++ b/src/content/dependencies/linkExternal.js @@ -3,10 +3,20 @@ const BANDCAMP_DOMAINS = ['bc.s3m.us', 'music.solatrux.com']; const MASTODON_DOMAINS = ['types.pl']; export default { - extraDependencies: ['html', 'language'], + extraDependencies: ['html', 'language', 'wikiData'], - data(url) { - return {url}; + sprawl: ({wikiInfo}) => ({wikiInfo}), + + data(sprawl, url) { + const data = {url}; + + const {canonicalBase} = sprawl.wikiInfo; + if (canonicalBase) { + const {hostname: canonicalDomain} = new URL(canonicalBase); + Object.assign(data, {canonicalDomain}); + } + + return data; }, slots: { @@ -20,6 +30,7 @@ export default { let isLocal; let domain; let pathname; + try { const url = new URL(data.url); domain = url.hostname; @@ -28,6 +39,14 @@ export default { // No support for relative local URLs yet, sorry! (I.e, local URLs must // be absolute relative to the domain name in order to work.) isLocal = true; + domain = null; + pathname = null; + } + + // isLocal also applies for URLs which match the 'Canonical Base' under + // wiki-info.yaml, if present. + if (data.canonicalDomain && domain === data.canonicalDomain) { + isLocal = true; } const link = html.tag('a', -- cgit 1.3.0-6-gf8a5