Perl programmer for hire: download my resume (PDF).
John Bokma's Hacking & Hiking

A JSON feed for tumblelog

April 3, 2019

Yesterday I started with adding a JSON feed to the static tumblelog generator I wrote in Perl. I used the JSON Feed Version 1 specification which has sufficient examples.

With the addition of a feed the user has to provide additional information via the command line:

The first two are also available as variables in the HTML template. The latter is used to create the feed URL by adding feed.json. This feed-url is also available in the HTML template.

Also, an additional Perl module needs to be installed for the script to be able to output JSON:

sudo apt install -y libjson-xs-perl

I currently use a makefile similar to the one given below:

TUMBLELOG = ../../projects/tumblelog
PERL = perl
SCSS = soothe.scss
SASS = sass --sourcemap=none -t compressed
CSS  = soothe.css
TEMPLATE = plurrrr.html
AUTHOR = 'John Bokma'
BLOG_URL = http://plurrrr.com/
NAME = 'Plurrrr'

all: local
	rsync -avh --delete -c htdocs/ ti:sites/plurrrr.com/public/

local:
	$(SASS) $(TUMBLELOG)/styles/$(SCSS) htdocs/$(CSS)
	$(PERL) $(TUMBLELOG)/tumblelog.pl --output-dir htdocs \
	  --template $(TEMPLATE) --css $(CSS) \
	  --author $(AUTHOR) --blog-url $(BLOG_URL) \
	  --name $(NAME) plurrrr.md

Note that I use --delete with rsync because I want an exact copy of the local directory on the server. If you have already a site on the server and want to keep those files make sure to remove the --delete.

A screenshot of Reeder with the Plurrrr JSON feed open
A screenshot of Reeder with the Plurrrr JSON feed open.

Yesterday I tested the feed in Reeder on OS X and the program can handle JSON feeds. Today, however, I discovered that links to images can't be relative, which I guess is a bug. I will report this bug.

Happy blogging!

Related