From d3ff0926ec1170596409cac501a8196ea76b4006 Mon Sep 17 00:00:00 2001 From: dakedres Date: Sat, 10 Feb 2024 16:42:31 -0700 Subject: [PATCH] Caches are valid rss feeds now! Yay! --- lib.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib.js b/lib.js index 22ace52..c762f3c 100644 --- a/lib.js +++ b/lib.js @@ -138,8 +138,11 @@ export const delayedFetch = async (url, options, courtesyWait = 5 * 1000) => { return await fetch(url, options) } +export const getCacheFilename = (source) => + source.name + '.xml' + export const getCachePath = (source, { directory }) => - Path.join(directory, source.name + '.xml') + Path.join(directory, getCacheFilename(source)) export const cacheSource = (source, cache) => write(getCachePath(source, cache), createCache(source, cache)) @@ -186,17 +189,16 @@ export const openCache = async (source, cache) => { export const buildCacheLink = source => new URL('https://' + source.hostname) -// TODO: Support atom links -// https://validator.w3.org/feed/docs/warning/MissingAtomSelfLink.html -// TODO: Add a description of some kind export const createCache = (source, cache) => `\ - + ${source.displayName} +${source.description} ${buildCacheLink(source)} + ${new Date(source.latestPostDate).toUTCString()} rssssing ${source.posts.map(post => post.item.outerHTML.replaceAll(/\n\s*/g, '')).join('\n')} @@ -582,6 +584,7 @@ export const tumblr = { createSource(user, courtesyWait, postReducerCallback, cache) { let lowercaseUser = user.toLowerCase() let source = { + description: `Aggregate feed for @${lowercaseUser} on tumblr.com`, hostname: lowercaseUser + '.tumblr.com', pathname: 'rss', courtesyWait, @@ -621,6 +624,7 @@ export const tumblr = { export const nitter = { createSource(user, instances, courtesyWait, postReducerCallback, cache) { let source = { + description: `Aggregate feed for @${user} on twitter.com`, instances, pathname: user + '/rss', courtesyWait,