Natural sorting and pelican series
A little while ago I made a few changes to this site to support series of related posts. I needed this to make the series of posts about how an internet page request makes it through a modern computing system through to the actual hardware.
Lately due to the whole lockdown situation I've also been writing a new series of posts about this rock climbing wall. I reached the 10th post in that series which has exposed an annoying bug in the underlying plugin that handles series of posts:
These sorts of bugs have been talked about for a LONG time. In this case I think this is pretty egregious since the series in the metadata I have for these posts are all numbers:
--- Title: Creating a topo map - day 2 Date: 2020-06-10 Tags: rock-climbing, photography, image-editing Slug: topo_map_day2 Category: Misc Authors: Janis Lesinskis Summary: Creating a topographic map - day 2. First photo shoot with a proper DLSR camera. Series: TopoMapCreationProject series_index: 20 ---
And day 10:
--- Title: Creating a topo map - day 10 Date: 2020-07-09 Tags: history Slug: topo_map_day10 Category: Misc Authors: Janis Lesinskis Summary: Creating a topographic map - day 10. Series: TopoMapCreationProject series_index: 100 ---
What's going wrong here is that these are being compared as strings, the character "1" is less than "2" so post "100" goes before post "20". This really should be dealt with as though the type represented with the
series_index were an integer and not a string.
A bit like the frustrations I had dealing with Canvas LMS the other day the solution to this problem if I couldn't change the code to fix the bug would be to bend my workflow to match the shortcoming of the plugin. I don't like doing this, and thankfully because I vendored the plugin I can just change the code locally in the interim while upstream considers if they want to merge my patch. (Note I don't as a rule like to vendor in the dependencies I use but in this case the main deliverable I care about here is the site, not the code. Nobody will use my static site generation code in a library so some of the worst dependency issues that come from vendoring them in won't apply here.)
EDIT: Turns out the fix was fairly straightforward, see this blog post for details.
By Janis Lesinskis