Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Readme

Creates an RSS feed of my read items from Readwise Reader.

Reader docs here: https://readwise.io/reader_api

In order to get read items from Readwise Reader -> Workflowy, this turns the read items (aka "archive") into an RSS feed, which Zapier picks up, and creates bullets in Workflowy.

Ideally would store the generated RSS or the last fetch date, and only get new items, but for now readwiseReaderDocumentList re-fetches the full history each time.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { dataToRSS } from "https://esm.town/v/stevekrouse/dataToRSS";
import { readwiseReaderDocumentList } from "https://esm.town/v/zerovox/readwiseReaderDocumentList";
export async function readwiseReaderReadItemsRss() {
// Get all of a user's archived documents
const archivedData = await readwiseReaderDocumentList(Deno.env.get("readwiseReaderApiToken"), undefined, "archive");
// Later, if you want to get new documents updated after some date, do this:
// const docsAfterDate = new Date(Date.now() - 24 * 60 * 60 * 1000); // use your own stored date
// const newData = await fetchDocumentListApi(docsAfterDate.toISOString());
return new Response(dataToRSS(
archivedData.map((blog) => ({
title: escapeXml(blog.title + " - " + blog.author),
link: escapeXml(blog.source_url),
pubDate: new Date(blog.published_date),
description: escapeXml(blog.summary),
})),
{
title: "Tim's Read Items",
link: "https://zerovox-readwisereaderreaditemsrss.web.val.run",
rssLink: "https://zerovox-readwisereaderreaditemsrss.web.val.run",
},
));
}
function escapeXml(unsafe) {
return unsafe.replace(/[<>&'"]/g, function(c) {
switch (c) {
case "<":
return "&lt;";
case ">":
return "&gt;";
case "&":
return "&amp;";
case "'":
return "&apos;";
case "\"":
return "&quot;";
}
});
}
zerovox-readwisereaderreaditemsrss.web.val.run
June 19, 2024