πΎ Archived View for benjaminja.com βΊ log βΊ 2024 βΊ 01 βΊ 13-rewriting_site_gen captured on 2024-08-25 at 00:15:22. Gemini links have been rewritten to link to archived content
β¬ οΈ Previous capture (2024-06-16)
-=-=-=-=-=-=-
2024-01-13
Itβs a new year and a new me. Now that I have finally graduated, I feel that I have more time to work on my side projects. One of the first big things I have done is rewriting my site generator once again.
Rather than creating my own templating engine, I decided to use [tera].
Keeping similar vibes to my original site generator: any additional features is implemented through shell scripts. There are a few important features baked in with the generator and all of the very site specific features are python scripts I created.
It is inspired by [kiln]
~~but from all of my research it seems that the site has gone down as well as the repo that was holding it.~~
Update 2024-01-16:
It turns out that source hut was hit by a DDoS attack and kiln was part of the cross-fire. Everything seems to be back up now.
Here is a copy of my configuration file for https.
# Specify file structure content = "content"scripts = "scripts"templates = "templates"output = "www/html"static = "static"# file types that will be rendered in content directorytemplate_types = ["md", "gmi", "html", "xml"] # Where the output will live on the web root = "/"# The base url name for the websiteurl = "https://benjaminja.info"# Any scripts to run before renderingpre = [ "proc/pretty-url.py", "proc/tags.py", # tags script creates the tag system for my log"proc/pretty-url.py", ] # Any scripts to run after renderingpost = [ "proc/proc_html.py", ] # After rendering a file, convert it using the provided convert for each file # type[converters] md = { ext = "html", cmd = ["gmi-conv", "-i", "md", "-o", "html"] } gmi = { ext = "html", cmd = ["gmi-conv", "-i", "gmi", "-o", "html"] }
As an example of what a file might go through, I will show you how this file gets rendered.
Letβs say that I have the text
{% raw -%} > The site was rendered at {{ now | ftime(fmt="%B %e, %Y @ %r %:z") }} {%- endraw %}
Here is the output:
The site was rendered at {{ now | ftime(fmt='%B %e, %Y @ %r %:z') }}
First, the `pretty-url.py` script will be run which renames this file from `content/log/2024/01/13-rewriting_site_gen.md` to `content/log/2024/01/13-rewriting_site_gen/index.md`. After that the `tags.py` script will be run which adds this file to the `capsule` and `projects` tags. The `pretty-url.py` script gets run again for any generated files, then the rendering starts.
Since this is an `md` file, it will get rendered. After being rendered it will be converted to html using `gmi-conv -i md -o html`. (There is another configuration rendering to gemini). After it is converted, the file will be passed through several templates. To be specific:
1. `templates/logs/2024/_root.html` which adds the title, date, and mentions.
2. `templates/_root.html` which adds the base html boilerplate.
Weβre not done yet, finally the `proc_html.py` script gets run. This will use beautiful soup to find any code blocks and adds formatting to it as well as differentiates gemini links as gemini links.
ββββββββββββββββββββββββββββββββββββββββ
I have two configurations running. One for html and one for gemini. I only need to write my capsule once and it will be rendered to both endpoints which is pretty nice.
There are still a few oddities about the software that Iβm not very happy with. I also want to add a bunch of documentation so that you can actually know how to use it. So I wonβt be releasing my site generator until it is in better shape.
This software is probably a bit into the βYou need to be a computer wiz to use this softwareβ territory, but If I were to add some sane 3rd party scripts and some good tutorials, I think it might could be usable by an average person.