Compare commits

...

10 Commits

11 changed files with 93 additions and 162 deletions

View File

@ -18,10 +18,10 @@ upload:
scp -r gmi/* techn0path@vern.cc:public_gemini
scp -r html/* techn0path@vern.cc:public_html
test: testing/example.gmi testing/example.ass
mawk -f scripts/navbar.awk -f ~/projects/awk_functions/lib.awk -f scripts/html.awk -- testing/example.gmi > testing/output.html
mawk -f scripts/navbar.awk -f ~/projects/awk_functions/lib.awk -f scripts/gemini.awk -- testing/example.gmi > testing/output.gmi
mawk -f ~/projects/awk_functions/lib.awk -f scripts/feed.awk -- testing/example.ass > testing/output.atom
test: testing/input.gmi testing/input.ass
mawk -f scripts/navbar.awk -f ~/projects/awk_functions/lib.awk -f scripts/html.awk -- testing/input.gmi > testing/output.html
mawk -f scripts/navbar.awk -f ~/projects/awk_functions/lib.awk -f scripts/gemini.awk -- testing/input.gmi > testing/output.gmi
mawk -f ~/projects/awk_functions/lib.awk -f scripts/feed.awk -- testing/input.ass > testing/output.atom
subdirs:
find src -mindepth 1 -type d -printf '%P\0' | xargs -0 -I{} mkdir -p gmi/{} html/{}

8
feed.txt Normal file
View File

@ -0,0 +1,8 @@
# comments are not interpreted, so i can talk about stuff :D
# possible entries
# /hash
# /title
# /file
# /content
# > some content
# > some moar

View File

@ -43,11 +43,11 @@ BEGIN {
if (link !~ "^[a-zA-Z0-9_]*:")
sub("\.gmi$", ".html", link)
gsub("&", "&", description)
gsub("<", "&lt;", description)
gsub(">", "&gt;", description)
gsub("'", "&apos;", description)
gsub("\"", "&quot;", description)
gsub("&", "\\&amp;", description)
gsub("<", "\\&lt;", description)
gsub(">", "\\&gt;", description)
gsub("'", "\\&apos;", description)
gsub("\"", "\\&quot;", description)
body = body sprintf("<a href='%s'>%s</a><br>\n", link, description)
next
@ -57,11 +57,11 @@ BEGIN {
body = body "<pre>\n"
getline
while ($0 !~ "^```") {
gsub("&", "\&amp;")
gsub("<", "\&lt;")
gsub(">", "\&gt;")
gsub("'", "\&apos;")
gsub("\"", "\&quot;")
gsub("&", "\\&amp;")
gsub("<", "\\&lt;")
gsub(">", "\\&gt;")
gsub("'", "\\&apos;")
gsub("\"", "\\&quot;")
body = body $0 "\n"
if (getline != 1) break
@ -90,11 +90,11 @@ BEGIN {
/^\*/ {
body = body "<ul>\n"
while (match($0, "^\\*[ ]*")) {
gsub("&", "\&amp;")
gsub("<", "\&lt;")
gsub(">", "\&gt;")
gsub("'", "\&apos;")
gsub("\"", "\&quot;")
gsub("&", "\\&amp;")
gsub("<", "\\&lt;")
gsub(">", "\\&gt;")
gsub("'", "\\&apos;")
gsub("\"", "\\&quot;")
body = body sprintf("<li>%s</li>\n", substr($0, RSTART + RLENGTH))
if (getline != 1) break
@ -104,11 +104,11 @@ BEGIN {
}
{
gsub("&", "\&amp;")
gsub("<", "\&lt;")
gsub(">", "\&gt;")
gsub("'", "\&apos;")
gsub("\"", "\&quot;")
gsub("&", "\\&amp;")
gsub("<", "\\&lt;")
gsub(">", "\\&gt;")
gsub("'", "\\&apos;")
gsub("\"", "\\&quot;")
body = body sprintf("<p>%s</p>\n", $0)
}

View File

@ -0,0 +1,6 @@
#!/usr/bin/execline
elgetopt "f:d:"
ifthen { test $# -eq 1 } {
printf "usage: new_feed_entry [-f <file>] [-d <description>]"
}
for { $@ }

View File

@ -1,12 +1,10 @@
BEGIN {
getline
filename = FILENAME
sitemapBody = ""
body = ""
}
/^#[^#]/ {
sub("^#([ ]*)", "")
sitemapBody = sitemapBody sprintf("<h2>%s</h2>", $0)
body = body sprintf("<h2>%s</h2>", $0)
}
/^=>/ {
@ -29,7 +27,7 @@ BEGIN {
if (link !~ "^([a-zA-Z0-9_]):") sub("\.gmi$", ".html", link)
sitemapBody = sitemapBody sprintf("<a href='%s'>%s</a><br>\n", link, description)
body = body sprintf("<a href='%s'>%s</a><br>\n", link, description)
}
END {
@ -61,6 +59,6 @@ body { margin: 20px; }\n\
<article id='content'>\n\
%s\n\
</article>\n\
</body>\n\
</html>", sitemapBody
</body>\n\
</html>", body
}

View File

@ -1,117 +1,32 @@
# use awk+make for static site generation
Very few static site generators make BOTH gemtext and HTML from raw gemtext. I saw Karl Berlin's article on using "make" as a static site generator. I also saw mkws, but since it didn't meet my needs, I investigated it's preprocessor, pp, then starting using it. 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.
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.
Here is Karl Berlin's article:
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.
Karl Berlin's article:
=> 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 in src/ as gemtext. Running make copies the directory structure of src/ into html/ and gmi/ using the 'subdirs' rule, then passes the files in src/ to AWK scripts that generate HTML and gemtext in html/ and gmi/ respectively.
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/:
```
subdirs:
find src -mindepth 1 -type d -printf '%P\0' | xargs -0 -I{} mkdir -p gmi/{} html/{}
html/%.html: src/%.gmi scripts/html.awk
mawk -f ~/projects/awk_functions/lib.awk -f scripts/html.awk -- $< > $@
gmi/%.gmi: src/%.gmi scripts/gemini.awk
mawk -f ~/projects/awk_functions/lib.awk -f scripts/gemini.awk -- $< > $@
find src/ -type d -mindepth 1 -printf '%P\0' | xargs -0 -I{} mkdir -p gmi/{} html/{}
```
A sitemap gives readers a full view of your website. So I generate it by scraping src/*/index.gmi. I have one version that generates HTML, and another version that generates gemtext.
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.
scripts/html.awk scrapes subheadings, title, and body, and outputs at the end, and makes a table of content.
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:
```
/^#[^#]/ {
match($0, "^#[ ]*")
heading = substr($0, RINDEX + RLENGTH)
title = heading
articleBody = articleBody sprintf("<h1>%s</h1>\n", heading)
next
}
/^##[^#]/ {
match($0, "^##[ ]*")
heading = substr($0, RINDEX + RLENGTH)
articleBody = articleBody sprintf("<h2>%s</h2>\n", heading)
subHeadings[length(subHeadings)] =
next
}
/^###[^#]/ {
match($0, "^###[ ]*")
heading = substr($0, RINDEX + RLENGTH)
articleBody = articleBody sprintf("<h3>%s</h3>\n", heading)
next
}
/^=>/ {
match($0, "^=>[ ]*[^ ]*")
link = substr($0, 3, RLENGTH - 2)
description = substr($0, RLENGTH - 2)
sub("^[ ]*", "", link)
sub("^[ ]*", "", description)
if (link ~ "^[a-zA-Z0-9_]*:")
sub("\\.gmi$", ".html", link)
gsub("&", "&amp;", description)
gsub(">", "&gt;", description)
gsub("<", "&lt;", description)
gsub("'", "&apos;", description)
gsub("\"", "&quot;", description)
articleBody = articleBody sprintf("<a href='%s'>%s</a>", link, description)
next
}
/^```/ {
articleBody = articleBody "<pre>\n"
getline
while ($0 !~ "```") {
gsub("&", "&amp;", description)
gsub(">", "&gt;", description)
gsub("<", "&lt;", description)
gsub("'", "&apos;", description)
gsub("\"", "&quot;", description)
articleBody = articleBody sprintf("%s\n", $0)
if (getline != 1) break
}
articleBody = articleBody "</pre>\n"
next
}
/^\*/ {
articleBody = articleBody "<ul>\n"
while (match($0, "^\\*[ ]*")) {
gsub("&", "&amp;", description)
gsub(">", "&gt;", description)
gsub("<", "&lt;", description)
gsub("'", "&apos;", description)
gsub("\"", "&quot;", description)
articleBody = articleBody sprintf("<li>%s</li>\n", $0)
if (getline != 1) break
}
articleBody = articleBody "</ul>\n"
next
}
/^>/ {
articleBody = articleBody "<blockquote>\n"
while (match($0, "^>[ ]*")) {
gsub("&", "&amp;", description)
gsub(">", "&gt;", description)
gsub("<", "&lt;", description)
gsub("'", "&apos;", description)
gsub("\"", "&quot;", description)
articleBody = articleBody sprintf("%s\n", $0)
if (getline != 1) break
}
articleBody = articleBody "</blockquote>\n"
next
}
upload:
scp -r gmi/* techn0path@vern.cc:public_gemini
scp -r html/* techn0path@vern.cc:public_html
```

View File

@ -1,11 +1,9 @@
# On Personal Websites
You are currently on my personal website. I want to talk about some of the reasons for building it.
The main purpose of this website for me is having fun; designing, writing, and structuring are enjoyable. But there are other reasons too. Others could learn from my experiences; People can give me feedback that improves my skills.
Of course, there are many reasons to build a website. Personal branding, restoring the Old/Personal web, learning about the Web Stack, or having fun like me.
The main purpose of this website for me is having fun; designing, writing, and structuring are enjoyable. But there are other reasons too. Others could learn from my experiences; People can give me feedback that improves my skills. Of course, there are many reasons to build a website: personal branding, restoring the Old web, learning about the web stack, or having fun like me.
## Related
=> ../howto/website-generation.gmi One way to build a website, I guess
=> awk-make-sh.gmi One way to build a website, I guess
=> https://ijver.me/blog/internet-tenancy/ Internet tenancy is a major problem
=> https://www.jvt.me/posts/2019/07/22/why-website/ Jamie Tanna: Why I have a website and why you should too

View File

@ -1,3 +1,6 @@
# Todo
* Add a search-engine targeted sitemap document
* Make this website more efficient
* Make the AWK scripts more efficient
* Make the 'upload' make rule more efficient, by making it only upload files that have been changed
* Use a single find command to gather data about all of the files at once, then use the results of that find command across the setup. This will avoid the need to scan the same directory multiple times.
* Instead of using src/feed.ass for ATOM feed generation, make a single feed.json file at the root, then add content to it using a script, which will take in a filepath of a recently updated file, and a description as an input.

View File

@ -6,7 +6,7 @@
<name>techn0path</name>
</author>
<updated>2023-05-13T14:48:24Z</updated>
<id>urn:uuid:2e5efb05-3971-5e8f-a859-f87d49ab91dd</id>
<id>urn:uuid:bbf734b2-3682-5c45-b5eb-49d491d1f0d7</id>
<entry>
<title></title>
<link href='this-is-the-future.gmi' />

View File

@ -1,19 +1,20 @@
Navigation:
=> ../src/index.gmi home
=> ../src/notes/index.gmi notes
=> ../src/useful/index.gmi useful
=> ../src/sitemap.gmi sitemap
=> ../src/feed.atom feed
=> ../gmi/index.gmi home
=> ../gmi/notes/index.gmi notes
=> ../gmi/useful/index.gmi useful
=> ../gmi/sitemap.gmi sitemap
=> ../gmi/feed.atom feed
# Whatssup gamers
Today we are gonna play a game called Test your applikayshens!
=> this-link-doesnt-exist.gmi REEEEE
=> and-the-description-doesnt-exist-either.gmi
=> this-link-doesnt-exist.gmi "REEEEE"
=>and-the-description-doesnt-exist-either.gmi
>two things are infinite, the universe and human stupidity, and i aint sure about the universe
>- einstein
<I shure 'hope that HTML escapin' works & that generally "my website" is good>
>"two things are infinite, the universe and human stupidity, and i aint sure about the universe"
>- <einstein>
```
hahaha code
@ -21,13 +22,13 @@ when: '```'
hehehe '```'
```
> less is more
> - a gentle MAN
* this is
* an unordered list
* which is epic
* spaces do seperate lists
* i wonder if they shouldn't
## WHat about me?
You too buddy

View File

@ -36,12 +36,14 @@ body { margin: 20px; }
<p></p>
<p>Today we are gonna play a game called Test your applikayshens!</p>
<p></p>
<a href='this-link-doesnt-exist.html'>REEEEE</a><br>
<a href='this-link-doesnt-exist.html'>&quot;REEEEE&quot;</a><br>
<a href='and-the-description-doesnt-exist-either.html'>and-the-description-doesnt-exist-either.gmi</a><br>
<p></p>
<p>&lt;I shure &apos;hope that HTML escapin&apos; works &amp; that generally &quot;my website&quot; is good&gt;</p>
<p></p>
<blockquote>
two things are infinite, the universe and human stupidity, and i aint sure about the universe<br>
- einstein<br>
&quot;two things are infinite, the universe and human stupidity, and i aint sure about the universe&quot;<br>
- &lt;einstein&gt;<br>
</blockquote>
<pre>
hahaha code
@ -49,15 +51,15 @@ when: &apos;```&apos;
hehehe &apos;```&apos;
</pre>
<p></p>
<blockquote>
less is more<br>
- a gentle MAN<br>
</blockquote>
<ul>
<li>this is</li>
<li>an unordered list</li>
<li>which is epic</li>
</ul>
<ul>
<li>spaces do seperate lists</li>
<li>i wonder if they shouldn&apos;t</li>
</ul>
<h2 id='what_about_me?'>WHat about me?</h2>
<a href='#what_about_me?'>Permalink</a><br/><br/>
<p>You too buddy</p>