It was the summer of 2023 and I went to vacation. I wanted to start writing the details of the vacation together, so I went and reserved a hostname (gabrielszabo.info) and since I like working cheap, I redirected it to the cloud server I had already up and running. So I reconfigured the HTTP server (NGinx) to work with the two hostnames and I tried to hook it up with my Simple BLOG implementation. The problem is, that SimpleBLOG uses redirects and other weird stuff, which works fine, until it is directly hosted as a standalone server, but it won't play nice as soon as it is put behind a reverse proxy. So I needed another solution.
The problem was, that I was on vacation, and had only a smartphone on me, which had a SSH client, my cloud server, and that was about it.
So I wondered, how hard could it be to wire together what I already had partially done. I cloned my CGI Server project and started fiddling around with the NGinx configuration, so it will forward the requests correctly. After that, I was changing the markdown examples of the same project, to achieve something, which resembles a basic blog. Developing on a smartphone via the SSH client was challanging. For example: writing full blown shell script with a virtual keyboard isn't the easiest tasks. Not at all. It gets annoying pretty fast. But I succeeded. At least to some extent. And now the blog (this blog) is up and running.
I know this implementation isn't effective and it doesn't perform well. It is however the one I could come up with given the circumstances. On the other hand, it is funny to see, how the bots are trying to guess the technology if you set up a page like this. With no database, no login and no information whatsoever about the page, I don't think it is at a great risk.
The project can be found here. I invite you to build and expand upon it. Because why not?
The solution uses Perl script for Markdown to HTML conversion.
Mustache templating engine with Bash implementation for it is used for templating.
The templates are referring Bootstrap to make it look pretty.
The script is simple, and expects environment variables to be set. Especially the QUERY_STRING. It is used to request pages and images.
It expects basic Linux commands to be available (ls, awk, pwd, dd etc).
The script responses with the Content-type HTTP header set accordingly (text/html or image/jpeg).
The page does not set or use any cookies. Nor does it collect any data.
In essence, the blog is a single page application, where everything is provided by the simple index
script.
The menu items are a list the folder names holding the blog content. The images folder is ignored.
If no query string is provided, it will render the index.md
file.
If the ABOUT query string attribute is set, it will rende rthe about.md
.
If DIR query string attribute is set, it will list the content of the folder set. It only puts out the name of the files present.
If both the DIR and the ENTRY attributes are set, it will render the given entry. If it is a Markdown file, it will be converted to HTML, otherwise it will be oresented directly.
If the IMAGE attribute is set, then the file is looked up in the images
folder and it is returned by using the dd
command.
The script is very basic, and could be improved. It needs a bit of refactoring to make it more readable.
It also provides only basic sanity check on input.
Last but not least I am currently using absolute paths for the mustache templates and didn't checked whether it works with relative paths. Be aware, if you try to run this blog.