Last active
June 15, 2023 02:00
-
-
Save keyboardcrunch/c25413adf31cf45318a3a70b974dadfd to your computer and use it in GitHub Desktop.
Deno code to create an rss feed of public entries from the sqlite database of a Shiori bookmark server.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<rss version="2.0"> | |
<channel> | |
<title>keyboardcrunch - recently read</title> | |
<link>https://blog.keyboardcrunch.com/</link> | |
<description>A list of stuff I found interesting or look forward to reading.</description> | |
<lastBuildDate>Thu, 15 Jun 2023 01:59:18 GMT</lastBuildDate> | |
<docs>https://validator.w3.org/feed/docs/rss2.html</docs> | |
<generator>https://github.com/jpmonette/feed</generator> | |
<item> | |
<title><![CDATA[A Begginers All Inclusive Guide to ETW — Blake's R&D]]></title> | |
<link>https://bmcder.com/blog/a-begginers-all-inclusive-guide-to-etw</link> | |
<guid>https://bmcder.com/blog/a-begginers-all-inclusive-guide-to-etw</guid> | |
<description><![CDATA[An all inclusive guide to ETW, from what it is to how we can use it.]]></description> | |
</item> | |
</channel> | |
</rss> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Database } from "https://deno.land/x/[email protected]/mod.ts"; | |
import { Feed } from 'https://jspm.dev/feed'; | |
// database work | |
const db = new Database("shiori.db"); | |
const bookmarkQuery = db.prepare( | |
"SELECT title, excerpt, url FROM bookmark WHERE public = 1", | |
); | |
const bookmarks = bookmarkQuery.all(); | |
db.close(); | |
console.log('Public Entry #: ', bookmarks.length); | |
// feed work | |
const newFeed = new Feed({ | |
title: 'keyboardcrunch - recently read', | |
description: 'A list of stuff I found interesting or look forward to reading.', | |
link: 'https://blog.keyboardcrunch.com/', | |
updated: new Date() | |
}); | |
for (const row of bookmarks) { | |
newFeed.addItem({ | |
title: row['title'], | |
link: row['url'], | |
description: row['excerpt'] | |
}) | |
} | |
// write out the rss feed | |
console.log(newFeed.rss2()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Needs to be run with
deno run --allow-env --allow-read --allow-ffi --unstable sqlite3_to_rss.js
flags, the sqlite3 module needs FFI, env, read, and unstable to operate.