Adding an RSS feed to my wiki

TiddlyWiki is a single static HTML file. It does not generate an RSS feed of new entries. It doesn’t generate anything.

I treat my wiki at wiki.baty.net more like a blog than a wiki, so not having an RSS feed feels like an omission. Most of the time I consider this to be a feature. I like that I can write any old nonsense and it doesn’t actively go out and bother anyone. It’s my little secret, that you can read if you want.

On the other hand, I find it annoying when I’m interested in someone else’s writing and they don’t provide any feeds. So, I’ve decided to make it easier to follow me. I suppose if you deliberately subscribe to the wiki’s feed, you want to be bothered by the stuff I write there.

My solution is based on this article . The short version is that I created a new tiddler named “RSS Feed” containing the following:

 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
\define MyFilter(MyTag,domain)
[tag[$(MyTag)$]!sort[created]limit[10]]
\end

<?xml version="1.0" encoding="UTF-8" ?><br />
<rss version="2.0"><br />
<channel><br />
     <title>
{{$:/SiteTitle}}
</title><br />
     <link>{{$:/discoverfeed!!serverdomain}}</link><br />     <description>
{{$:/SiteSubtitle}}
</description><br />
     <lastBuildDate><$list filter="[!is[system]get[modified]!prefix[NaN]!sort[]limit[1]]" variable=modified><$list filter="[!is[system]modified<modified>]"><$view field="modified" format=date template="[UTC]ddd, 0DD mmm YYYY 0hh:0mm:0ss GMT"/></$list></$list></lastBuildDate><br />
<$set name="MyTag" value=Feed>
<$set name="domain" value={{$:/discoverfeed!!serverdomain}}>
<$list filter=<<MyFilter>>>
<item><br />     <title>
<$view field="title"/>
</title><br />
     <link><<domain>>#<$view field="title" format="urlencoded"/></link><br />
     <guid><<domain>>#<$view field="title" format="urlencoded"/></guid><br />
     <pubDate><$view field="modified" format=date template="[UTC]ddd, 0DD mmm YYYY 0hh:0mm:0ss GMT"/></pubDate><br />
     <description><![CDATA[<$view field="text" format=htmlwikified/>]]><br />     </description><br /></item><br />
</$list></$set></$set>
</channel><br /></rss><br />

This tiddler runs a filter finding the last 10 tiddlers tagged with Feed and renders them as RSS-formatted XML.

Extracting the rendered text from that tiddler out to an RSS file is done using my Makefile using the TiddlyWiki node.js module . The command is as follows:

tiddlywiki --load index.html --render "&#91;&#91;RSS Feed]]" "rss.xml" text/plain

This generates a file at ./output/rss.xml containing the rendered RSS text/xml. Later in the Makefile, I rsync rss.xml up to the server along with the rest of the wiki files. Here’s the complete Makefile:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
SERVER_HOST=server01.baty.net
SERVER_DIR=/home/jbaty/apps/rudimentarylathe.wiki/public_html
PUBLIC_DIR=~/Sync/wikis/rudimentarylathe/
TARGET=server01.baty.net

.POSIX:
.PHONY: checkpoint deploy

build:
        tiddlywiki --load index.html --render "&#91;&#91;RSS Feed]]" "rss.xml" text/plain

checkpoint:
        git add .
        git diff-index --quiet HEAD || git commit -m "Publish checkpoint"

deploy: build checkpoint
        git push
        @echo "\033&#91;0;32mDeploying updates to $(TARGET)...\033&#91;0m"
        rsync -v -rz --checksum --delete --no-perms $(PUBLIC_DIR)index.html $(SERVER_HOST):$(SERVER_DIR)
        rsync -v -rz --checksum --delete --no-perms $(PUBLIC_DIR)output/rss.xml $(SERVER_HOST):$(SERVER_DIR)
        rsync -v -rz --checksum --delete --no-perms $(PUBLIC_DIR)files $(SERVER_HOST):$(SERVER_DIR)

All this means is that you can now subscribe to the daily posts at wiki.baty.net using the following URL: https://wiki.baty.net/rss.xml .

The odd thing is that I normally create each daily post first thing in the morning and update it throughout the day. I’m not sure how different RSS readers will handle this, but it’s a start.

I haven’t added the discovery links yet, but should. I also don’t think the RSS tiddler needs all those non-breaking spaces so I may play with that later.

Update March 11, 2022: Saq Imtiaz sent a link to his experimental plugin for generating RSS and JSON feeds . Worth a look!