πŸ’Ύ Archived View for benjaminja.info β€Ί log β€Ί 2024 β€Ί 01 β€Ί 13-rewriting_site_gen captured on 2024-05-10 at 10:39:29. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2024-03-21)

➑️ Next capture (2024-06-20)

🚧 View Differences

-=-=-=-=-=-=-

Rewriting my Site Generator

2024-01-13

#Capsule

#Projects

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.

Simple Site Generator

Rather than creating my own templating engine, I decided to use [tera].

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]

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.

Configuration

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.

Making this Publicly Available

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.

πŸ”Ό Log - 2024

πŸ“­ Message me

πŸ“Or mention this post