added new note 'how i generate this website', removed old note 'using awk+make+sh for website generation'

This commit is contained in:
Abdullah Islam 2023-06-20 15:44:52 +06:00
parent a8f50d42cc
commit 1f5e287f9b
2 changed files with 24 additions and 29 deletions

View File

@ -1,32 +1,13 @@
# use awk+make for static site generation
Very few static site generators make BOTH gemtext and HTML from raw gemtext. I saw Karl Berlin using "make" as a static site generator. I also saw the mkws project, but since it didn't meet my needs, I used it's preprocessor, pp. However, I was using AWK a lot, and wondered if I could switch to it full time. My pp templates were scanning the same file again and again using various utilities, whereas AWK would read each file only one time. So I switched.
# using AWK+make for static site generation
NOTE: This article is deprecated, see:
=> how-i-generate-this-website.gmi How I generate this website
The benefit of using make + awk is how extensible and simple it is. You can easily change whole parts of your website by editing a few files, which you can't say about Hugo.
First, I write raw gemtext. Then I run make, which first copies src/'s directory structure into html/ and gmi/, then runs AWK scripts outputting the pages you see, and finally uploads them to vern.cc.
Karl Berlin's article:
My HTML generation script html.awk converts gemtext to HTML. gemini.awk merely adds elements to gemtext. navbar.awk is an AWK library file handling navigation bar generation. The index files of this website's sections are used to make the sitemap.
After changing my scripts, I run them on testing input, and record the output using git, which will show any changes.
## related
=> https://www.karl.berlin/static-site.html Karl Berlin: 'make' as a static site generator
## how it actually works
First, the raw content of my website is written in src/ as gemtext. Running make copies src/'s directory structure into html/ and gmi/, then runs AWK scripts on my raw content, outputting the pages you see on this website. Images are copied as well. I use mawk since it's faster then gawk, even though some features are sacrificed.
This code copies src/'s directory structure into html/ and gmi/:
```
find src/ -type d -mindepth 1 -printf '%P\0' | xargs -0 -I{} mkdir -p gmi/{} html/{}
```
I can test that my output is valid, by running my scripts on testing files. After doing that, I record the output using git, telling me any differences in it.
My HTML generation script, html.awk, converts gemtext files to HTML files, along with some other elements sprinked in. getline is used for multi-line elements, such as lists, blockquotes, and code blocks.
gemini.awk merely regurgitates the document with a navigation bar at the top.
navbar.awk is an AWK library file handling navigation bar generation. The functions can also accept an input directory path, and an output directory path.
I generate my sitemap using src/*/index.gmi. Then I generate my ATOM feeds using src/feed.ass.
Finally, I upload html/ and gmi/ using the following code in my Makefile:
```
upload:
scp -r gmi/* techn0path@vern.cc:public_gemini
scp -r html/* techn0path@vern.cc:public_html
```
=> http://git.vern.cc/techn0path/website My Git Repository

View File

@ -0,0 +1,14 @@
# How I generate this website
First, I write raw gemtext. After doing that, I run make, which generates the pages on this website, and uploads it to vern.cc.
I use AWK since it's quick to write, has good syntax, and well-suited for processing text.
html.awk converts gemtext into HTML.
navbar.awk contains code for generating navigation bars.
gemini.awk adds navigation bars to gemtext.
sitemap_gmi.awk and sitemap_html.awk process all of the gemtext files and create a sitemap.
feed.awk creates ATOM feeds from git-history, which git-log must pass in a specific format. It's sloppy, but I don't know any other method for now.