Skip to content

Instantly share code, notes, and snippets.

@keyboardcrunch
Last active June 15, 2023 02:00
Show Gist options
  • Save keyboardcrunch/c25413adf31cf45318a3a70b974dadfd to your computer and use it in GitHub Desktop.
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.
<?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>
import { Database } from "https://deno.land/x/sqlite3@0.9.1/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());
@keyboardcrunch
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment