The Approximately Monthly Zoomer
To PHP or not to PHP
2022-12-06
Up until now my blog has been using PHP with a MySQL database to store blog entries. It was a nice exercise to try PHP again, every year the language becomes more and more bearable. However, it always seemed a bit overkill for what I’m trying to achieve: a few pages with nicely laid out text.
Why now?
I’m currently in the process of migrating all of my services onto a Proxmox cluster, so I guess now is as good a time as any.
The New, Better, Improved and 100% Future-Proof System
My blog neither has a lot of posts nor frequent updates, so a search function is something I can procrastinate doing for now. This means there is no need for anything else than a few static pages. The general idea I had was to write articles in markdown and have them converted into html. Without checking I was certain such a program already existed so I started thinking about the rest of the setup. I settled on a python script which takes the markdown files, which have a few lines of metadata at the beginning, and passes them to pandoc for conversion using templates. Since the python script runs on my local machine with trusted™ files and not on the server itself, I sleep with a clear conscience each night, knowing the security of the script and sanitizingh the input is not a thing to worry about.
Challenges
Passing one article to an html template is not a big deal, but what if you want three articles on the same page? Let’s say on the landing page? Templates within tempates? How do you use templates all the way down?
Turns out I don’t even know how to google that, so instead I’ll just generate the articles with pandoc and then manually insert multiple into a single page using a python script.
Et voilà
It’s better than good - it’s good enough! I’m happy with the way it turned out. To some it might be ugly spaghetti code, to others it might be pretty spaghetti code - either way, it’s my spaghet and I’m proud of it.