zerosleeps

Since 2010

Converting Jekyll posts

Monday 1 November 2021

Progress update on maybe possibly switching this site to Django.

So far so good. As predicted turning Jekyll posts (which are Markdown files with some YAML front matter) was pretty straightforward: a few regular expressions and a bit of json.dump gets me what I need. It’s not pretty, but it doesn’t need to be.

I dithered around a for a bit trying to work out if I should use migrations (with the posts data baked in since the source files won’t be available anywhere other than my local machine), or JSON fixtures. I’ve settled for fixtures, since I’ll need some realistic data to run tests against anyway, and it means I can load the posts whenever I want and as many times as I want.

Fun fact which doesn’t appear to be particularly well documented in the Django documents: if you include the “pk” value in a fixture, Django will create/update the corresponding record in the database. But you can also omit “pk” and it’ll always create a new record (assuming the model has an automatic primary key).

Also as predicted, turning the reading log entries into something sensible is going to be fiddly. Again, a couple of regular expressions has gotten me about 75% of the way, but for the other entries I’m just going to manually fix them up. There are only 87 of them in total (as I type this) so no big deal if I have to eyeball ≈20 of them.

My next challenge will be tackling Octopress' code blocks and img tags.