From 72d45618ae99ba31205ef0c43d4b7c88bd33cc86 Mon Sep 17 00:00:00 2001 From: Rosia E Evans Date: Sun, 8 Oct 2023 23:39:29 +0100 Subject: [PATCH] page changes (I swear I'll move these from this repo soon) --- Resources/Input/ThisSite.md | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/Resources/Input/ThisSite.md b/Resources/Input/ThisSite.md index af1dddd..4eb1e8f 100644 --- a/Resources/Input/ThisSite.md +++ b/Resources/Input/ThisSite.md @@ -10,4 +10,28 @@ The driving idea behind this being that we've had computers that are powerful en Along with that I'd also spent time doing a module in my first year on the history of the internet and found the www's origins really inspiring, the idea of a language/system that was easy for just about anyone to learn, that was incredibly simple but super flexible. When learning about this I'd kind of started to feel like we'd lost that part of the internet. Websites are always generated with insane complexity which feels almost unnecessary when we still have that simple flexible system its all built on top of. I wanted to try and use that simple system again, to experience it for myself but also as a nice homage to it. -## Power Efficiency +## The Code +I wanted the system to be as lightweight and fast as it could be, hopefully leading to a very power-efficient result. I decided to use C++ as it was my main language and was also very fast. I was planning on writing the server code myself but found lighttpd, a relatively old and incredibly light weight server program, as I was researching good libraries and it seemed much more efficient than any of the libraries I could find were benchmarked for so I decided to use that. + +I initially planned to write a markdown parser and spent a day or two working on one, writing a [SAX-Style](https://en.wikipedia.org/wiki/Simple_API_for_XML) parser. I was unsure whether this was a workable idea for markdown but through thinking about it and planning how it would work I felt quite confident it would be much faster than a DOM parser. I soon found however that it would take most of my time up and I only wanted this to be a small project. I looked online and found [md4c][https://github.com/mity/md4c], a simple and insanely fast parser written in very low level c. It's benchmarks showed it could parse incredibly large documents in less than a millisecond which convinced me pretty quickly. It seemed much faster than any other option but also much simpler. After starting to implement this I discovered it actually parsed markdown text in the same SAX-Style system as I had planned to which made me very happy. + +After discovering this I implemented it along with code to read the filesystem and combine the resulting html with a template. This took a few revisions as I wanted to make it as flexible and reusable as possible, making little to no assumptions about the template being given. By default the code searched for an empty `
` body and placed the generated html within it and a similar thing for the `