Updates to the Blog

By Clemens Tiedt

2023-02-02
#rust
#axum
#rss
#database


Recently, I did some major work on the infrastructure of this blog. You may have noticed that the design moved away from GitHub's Primer framework and hopefully that loading times have also improved. In this article, I want to walk you through what changes I made and why I made them.

Moving to axum

Originally, when I created this blog in 2021 I decided to build it using the Rocket framework. This allowed me to quickly get the blog up and running, but in some regards it was limiting. Being such a batteries-included framework is in my opinion a double-edged sword. It makes getting started easy, but if you run into limitations, you may have to go deeper into the framework to work around them. Another argument against Rocket is that development is headed by a single person. While Rocket has about 250 contributors on GitHub at the time of writing this, its main developer remains a bottleneck for updates and releases. While the repository is pretty active, the latest version right now is a release candidate from July of last year. That said, Rocket is still great if you want to quickly get a web backend up and running, it's just not the framework for me.

Following these points of frustration I decided to move to axum for this blog. Axum is built and maintained by the tokio team, meaning that it lives in the centre of Rust's asynchronous programming community. You'll have to interact with more moving parts from the start, but overall it's still easy enough to build a nice and performant backend. Another nice feature is the ease of integrating tower services to provide the middlewares you may need.

Of course, axum is also not perfect. I'm still having some trouble with error handling at times since axum routes don't play nice with my usual color_eyre-based error handling and the greater flexibility comes with some more verbosity. With all that in mind, I still believe that at this time axum is the right tool for this job.

Design changes

I'll admit it: I hate CSS. I'm not a particularly talented person when it comes to design, so when I built the blog I went with the easiest way I could find to make it look somewhat nice. I wanted to avoid complex frameworks and doing too much with JavaScript. So, I decided on Primer CSS which is the design system used by GitHub. Primer was great because it let me quickly make a blog that didn't look like it was from the 90s. However, I feel like my usage of the design ended up less readable than I wanted. For my blog, my first design requirement was ease of use. I want a design that gets out of your way and lets you focus on the content. After looking at a number of CSS frameworks, I decided to move the design to Bulma (which I already use on my main website) and use a premade theme. At the same time, I made some changes that hopefully make the blog easier to read on mobile devices.

Adding a database

Originally, I stored my articles only in a directory. Any time the articles were listed, the blog software read the entries in that directory, parsed them into Rust structs, and then displayed them. I knew for a while that this approach is not very scalable. I experimented with a manually implemented cache, but I was also not satisfied with this implementation. So, I turned to the Rust-based database sled. Articles are now cached in there and updated based on file system events courtesy of notify. This more efficient storage is also the mechanism that allows me to present you recommended articles when you're done reading one.

Feed Support

Finally, I decided to implement one brand-new feature: Support for syndicated feeds. Many years ago, a combination of RSS feeds was one of my biggest sources of news and entertainment. Recently, I was reminded that these feeds are a pretty cool way to keep up with all the sources you are personally interested in and it's actually very simple to implement in Rust (using the rss and atom_syndication crates). Now, you can add this blog to basically any modern feed reader (such as Fluent Reader on Desktop) and keep up to date. There are still some changes I want to make, but feeds are already usable now.

Conclusions

If you are a reader of this blog, I hope the recent changes I made have improved your experience. You can find the main components I used to build this blog on the about page. More changes are coming and when they do, I will update this post or create another one. I'm hoping that this year I manage to use this platform more. I already have ideas (including ones that go beyond programming), so stay tuned!


Read more:

How do Trait Objects work?

As all good deep dives do, this article starts with a slightly contrived code example. Let's say, I have this file containing a number and want to read that. Here's a (very) naive Rust implementation:...

2021-08-27 #rust #trait

Share this article: Updates to the Blog