Published 2024-09-27
tag(s): #programming #blogging #meta
Because that's how we roll around here[1] this blog is hand-crafted from scratch. From the markup behind the text you are reading, to the code that uploads the files to storage.
Today I fixed the link from the posts list to one
particular page. It is not the
first time I do it.
But, why a link was broken?
I have a command, hoagie-site-new-post
, that prompts me for a title, appends the
date, and boom, we have the URL to the post and the filename. This last part is
important, because I run the same code in Windows and Linux, and valid filenames have
different rules in them.
However, I didn't really think of that when I wrote the function. Of course not. All I considered is that I didn't want spaces in my filenames because escaping those is a pain, so:
(filename (format "%s-%s.html"
today
;; maybe have more robust safeguards, then again,
;; what kind of title would I write?
(downcase
(replace-regexp-in-string " " "-" title))))
Implicitly, that was my requirement for the whole thing. "I don't want to type spaces in
filenames".
I
use dired
for all my file operations, and sometimes Windows Explorer/Whatever is the Fedora default
(Nautilus? I think), so I don't really type filenames, almost never! And replacing spaces in
URLs with a %20 is trivial.
I'll give myself a bit of a break in that I noted that maybe these safeguards weren't enough. I would like to think that comes from experience.
This is how the function looks today:
(filename (format "%s-%s.html"
today
;; maybe have more robust safeguards, then again,
;; what kind of title would I write?
;; UPDATE: I used a : in a title, worked in linux,
;; broke in Windows. LOL?
;; UPDATE 2: I used a ? in a title, turns out I
;; write all sort of weird titles
(downcase
(replace-regexp-in-string "[ :'\"?\(\)]"
"-"
title))))
The first update is the one that broke the link I just fixed. I used a ":" in the title, when I was trying to fetch the repo in Windows, it failed. So I renamed the file, but then I also had to fix the link. I don't know why/how the link was broken again.
But notice that it happened one more time, when I used a "?". Also notice my haha
very funny comment turns out I write all sort of weird titles
. The admission is that I
had no idea what kind of titles I would write, and I thought about it, but only came up with
the "no spaces" thing and moved on.
Which is perfectly fine, I didn't let that stop development of my tooling. But I would like to keep this immortalized[2] as a great example that we developers are quick to accuse users of being unclear with their requirements, not covering all cases, forgetting details. And yet here I am with one simple feature (rename the file so it is nice for URLs and filenames) and there are a lot of cases I didn't consider until I ran into them. And I am still to this day fixing links related to those requirement omissions.
Or product owner, or whatever you have in your context.
Sometimes the most obvious problems have intricacies that trip you.
Sometimes problems aren't as intuitive as they seem (hello, date and time operations).
Sometimes you misidentify what the "hard" part of a problem is/will be.
And a huge etc.
So, be kind, and patient.