I Built a Plugin System for DJ Press

It has been a busy time recently - I've really found a groove to developing code and have been super productive with my AI friends and getting my tooling dialled in. I whipped up the SPF Generator app in just a few hours, and now I've finished some major features for DJ Press over the last couple of days.

The headline feature for DJ Press is that it now has a plugin system built-in. I was inspired by Simon Willison's DjangoCon talk on building plugin systems. In his talk he suggested using pluggy, but it looked a bit too full-featured for my liking, and so I set about building my own system from scratch.

Of course, it wouldn't have been possible without some long and deep conversations with Claude about how plugin systems work, how hooks are made available to plugin authors, and how plugins are structured. To be honest, I had no idea how they worked before on embarking on this - it all felt like magic!

I've started off slowly, with just a few hooks for now, but the plugin system is working well and seems reliable. I created an example plugin which shows how simple it is to create a basic plugin that manipulates blog post content. Thanks to the uv tool, I was able to quickly and easily whip up a project folder, add it to my local site for testing, and then build and publish it to PyPi. You can find the djpress-example-plugin on PyPi.

The next plugin I wanted to create was one to publish my blog posts to Mastodon as they are created. I got this working pretty quickly, but realised that I needed some way of saving state so that I can track which posts have been posted to Mastodon - otherwise I risk posting the same links over and over again as I often update posts.

This required adding storage for plugins and I wanted to do this in a way that they didn't need to worry about migrations or models. So the DJ Press package now was an extra model for PluginStorage. It's a simple system where each plugin gets access to a blob of JSON that they can use as they see fit. This probably won't be a long-term solution but it works for now.

With this in place the Mastodon publishing plugin was easy to make and in my testing was working perfectly. This post will be the first real test - I'm hoping it appears on Mastodon shortly after publishing.

The plugin is also available on PyPi and the source is on GitHub.

I'm still not ready to take off the "very alpha" warning on DJ Press, I have a couple more fundamental features to finish before I'll be ready to promote it to "very beta" status. 😀 But with the docs starting to take shape, themes in a mostly OK state, and the plugin system growing, I'm pretty happy with the progress.