Compare commits

...

9 Commits

Author SHA1 Message Date
Abdullah Islam 1f5e287f9b added new note 'how i generate this website', removed old note 'using awk+make+sh for website generation' 2023-06-20 15:44:52 +06:00
Abdullah Islam a8f50d42cc added scripts/path.awk 2023-06-20 15:41:21 +06:00
Abdullah Islam 080f608c95 changed the style of the website 2023-06-18 15:49:50 +06:00
Abdullah Islam c42cb19caa added content to my 'great software' page, while removing useless words 2023-06-18 15:40:58 +06:00
Abdullah Islam 9f82488f2e minor changes to the index page of my notes 2023-06-18 15:29:26 +06:00
Abdullah Islam 947f7b4f45 minor changes to the index page 2023-06-18 15:29:01 +06:00
Abdullah Islam 299e20ceb9 changed testing input: part 2 2023-06-18 15:28:19 +06:00
Abdullah Islam 387d592123 changed testing input 2023-06-18 15:27:10 +06:00
Abdullah Islam da581590d0 a few tiny changes to my scripts 2023-06-04 20:34:03 +06:00
13 changed files with 182 additions and 163 deletions

View File

@ -1,4 +1,4 @@
{ body = body $0 "\n" }
{ print }
END {
printf "%s", genNavbarGMI(FILENAME, "src/", "gmi/")

View File

@ -1,34 +1,39 @@
BEGIN {
title = "techn0path - no title"
body = ""
subHeadings[1] = ""
subHeadings[0] = ""
}
/^#[^#]/ {
match($0, "^#[ ]*")
headingText = substr($0, RSTART + RLENGTH)
body = body sprintf("<h1>%s</h1>\n", headingText)
title = headingText
body = body sprintf("<h1>%s</h1>\n", headingText)
next
}
/^##[^#]/ {
match($0, "^##[ ]*")
headingText = substr($0, RSTART + RLENGTH)
subHeadings[length(subHeadings)] = headingText
body = body sprintf("<h2 id='%s'>%s</h2>\n\
<a href='#%s'>Permalink</a><br/><br/>\n", \
toFilename(headingText), \
headingText, \
toFilename(headingText))
subHeadings[length(subHeadings)] = headingText
next
}
/^###[^#]/ {
match($0, "^###[ ]*")
headingText = substr($0, RSTART + RLENGTH)
body = body sprintf("<h3>%s</h3>\n", headingText)
next
}
@ -36,13 +41,14 @@ BEGIN {
match($0, "^=>[ ]*[^ ]*")
link = substr($0, 3, RLENGTH - 2)
description = substr($0, RSTART + RLENGTH)
sub("^[ ]*", "", link)
sub("^[ ]*", "", description)
if (description == "") description = link
if (link !~ "^[a-zA-Z0-9_]*:")
sub("\.gmi$", ".html", link)
if (description == "") description = link
gsub("&", "\\&amp;", description)
gsub("<", "\\&lt;", description)
gsub(">", "\\&gt;", description)
@ -55,8 +61,10 @@ BEGIN {
/^```/ {
body = body "<pre>\n"
getline
while ($0 !~ "^```") {
while (getline == 1) {
if ($0 ~ "^```") break
gsub("&", "\\&amp;")
gsub("<", "\\&lt;")
gsub(">", "\\&gt;")
@ -64,16 +72,18 @@ BEGIN {
gsub("\"", "\\&quot;")
body = body $0 "\n"
if (getline != 1) break
}
body = body "</pre>\n"
next
}
/^>/ {
body = body "<blockquote>\n"
while (match($0, "^>[ ]*")) {
while (getline == 1 && match($0, "^>[ ]*")) {
text = substr($0, RSTART + RLENGTH)
gsub("&", "\\&amp;", text)
gsub("<", "\\&lt;", text)
gsub(">", "\\&gt;", text)
@ -81,15 +91,16 @@ BEGIN {
gsub("\"", "\\&quot;", text)
body = body text "<br>\n"
if (getline != 1) break
}
body = body "</blockquote>\n"
next
}
/^\*/ {
body = body "<ul>\n"
while (match($0, "^\\*[ ]*")) {
while (getline == 1 && match($0, "^\\*[ ]*")) {
gsub("&", "\\&amp;")
gsub("<", "\\&lt;")
gsub(">", "\\&gt;")
@ -97,8 +108,8 @@ BEGIN {
gsub("\"", "\\&quot;")
body = body sprintf("<li>%s</li>\n", substr($0, RSTART + RLENGTH))
if (getline != 1) break
}
body = body "</ul>\n"
next
}
@ -109,21 +120,20 @@ BEGIN {
gsub(">", "\\&gt;")
gsub("'", "\\&apos;")
gsub("\"", "\\&quot;")
body = body sprintf("<p>%s</p>\n", $0)
}
END {
if (length(subHeadings) == 1 && subHeadings[1] == "")
delete subHeadings
delete subHeadings[0]
if (length(subHeadings) > 0) {
tocText = "\n\
<details id='toc'>\n\
<summary>Table of content</summary>\n\
<ol>\n"
tocText = "<details id='toc'> <summary>Table of content</summary> <ol>\n"
for (i in subHeadings)
tocText = tocText sprintf("<li><a href='#%s'>%s</a></li>\n", toFilename(subHeadings[i]), subHeadings[i])
tocText = tocText sprintf("<li><a href='#%s'>%s</a></li>\n", \
toFilename(subHeadings[i]), \
subHeadings[i])
tocText = tocText "</ol> </details>\n"
}
@ -134,27 +144,27 @@ END {
<html>\n\
<head>\n\
<title>%s</title>\n\
\n\
<meta name='author' content='techn0path' />\n\
<meta name='referrer' content='no-referrer' />\n\
<meta name='viewpoint' content='width=device-width,initial-scale=1.0' />\n\
\n\
<style>\n\
body { margin: 20px; }\n\
#content { max-width: 80ch; }\n\
#content { max-width: 70ch; margin: auto; padding: 10px; }\n\
#navbar { max-width: 70ch; margin: auto; padding: 10px; background: teal; color: white; }\n\
#navbar a { color: white; }\n\
hr { max-width: 70ch; }\n\
.permalink { margin-left: 15px; }\n\
</style>\n\
</head>\n\
<body>\n\
<header>\n\
%s\n\
</header><hr>\n\
%s\n\
</header>\n\
<article id='content'>\n\
%s\n\
%s\n\
</article>\n\
<hr>\n\
<p>If you have any suggestions, let me know at <a href='mailto:logicartist123@gmail.com'>logicartist123@gmail.com</a>. Sorry, I still use GMail. :/</p>\n\
</article>\n\
</body>\n\
</html>", \
title, \

51
scripts/path.awk Normal file
View File

@ -0,0 +1,51 @@
function getDirname(path, pathComponents, dirname) {
dirname = ""
pathComponents[1] = ""
sub(/\/+$/, "", path)
split(path, pathComponents, "/")
if (length(pathComponents) < 2) return "."
for (i in pathComponents)
dirname = dirname pathComponents[i] "/"
return dirname
}
function resolvePath(path, resolvedPath, pathComponents) {
pathComponents[1] = ""
resolvedPath = ""
sub(/\/+$/, "", path)
split(path, pathComponents, "/")
for (i in pathComponents)
if (pathComponents[i] == "." || pathComponents[i+1] == ".." || pathComponents[i] == ""))
continue
else
resolvedPath = resolvedPath pathComponents[i] "/"
return resolvedPath
}
function getRelativePath(base, path, resolvedPath, baseComponents, pathComponents, commonPrefix) {
path = resolvePath(path)
base = resolvePath(base)
pathComponents[1] = ""
baseComponents[1] = ""
isCommonPrefixUnfinished = 1
sub(/\/+$/, "", base)
sub(/\/+$/, "", path)
for (i in pathComponents)
if (baseComponents[i] == pathComponents[i] && isCommonPrefixUnfinished)
resolvedPath = resolvedPath "../"
else {
isCommonPrefixUnfinished = 0
resolvedPath = resolvedPath pathComponents[i] "/"
}
return resolvedPath
}

View File

@ -17,16 +17,15 @@ FILENAME != filename {
printf "\n"
}
/^#[^#]/ { sub("^#([ ]*)", "## "); print }
/^#[^#]/ { sub("^#[ ]*", "## "); print }
/^=>/ {
match($0, "^=>([ ]*)([^ ]*)")
match($0, "^=>[ ]*[^ ]*")
link = substr($0, 3, RSTART + RLENGTH - 3)
description = substr($0, RSTART + RLENGTH, length($0))
sub("^([ ]*)", "", link)
sub("^([ ]*)", "", description)
sub("^[ ]*", "", link)
sub("^[ ]*", "", description)
link = relpath("src", resolvePath(getDirname(FILENAME) "/" link))

View File

@ -3,19 +3,19 @@ BEGIN {
}
/^#[^#]/ {
sub("^#([ ]*)", "")
sub("^#[ ]*", "")
body = body sprintf("<h2>%s</h2>", $0)
}
/^=>/ {
match($0, "^=>([ ]*)([^ ]*)")
match($0, "^=>[ ]*[^ ]*")
descriptionStart = RSTART + RLENGTH
link = substr($0, 3, descriptionStart - 3)
description = substr($0, descriptionStart, length($0))
sub("^([ ]*)", "", link)
sub("^([ ]*)", "", description)
sub("^[ ]*", "", link)
sub("^[ ]*", "", description)
gsub("&", "&amp;", description)
gsub("<", "&lt;", description)
@ -25,7 +25,7 @@ BEGIN {
link = relpath("src", resolvePath(getDirname(FILENAME) "/" link))
if (link !~ "^([a-zA-Z0-9_]):") sub("\.gmi$", ".html", link)
if (link !~ "^[a-zA-Z0-9_]:") sub("\.gmi$", ".html", link)
body = body sprintf("<a href='%s'>%s</a><br>\n", link, description)
}

View File

@ -1,5 +1,6 @@
# techn0path's website
On this personal website of mine, I talk about stuff.
=> todo.gmi Todo list for this website
## Highlights

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.

View File

@ -3,3 +3,4 @@ An ever-growing collection of information.
=> on-personal-websites.gmi On personal websites
=> software-freedom.gmi On software freedom
=> how-i-generate-this-website.gmi How I generate this website

View File

@ -1,14 +1,10 @@
# Great Software
* Password Store
* Vis
* AWK
* make
* execline
* zathura
* qemu
execline is a non-interactive scripting language that uses chain loading, where one program executes another program after ending. Since scripting glues programs instead of creating them, execlineb lacks functions, variables, and globbing.
So yeah today we are going to be talking about pieces of software that vastly outcompete their competitors.
Password Store, or pass, is a local password manager that stores your passwords at ~/.password-store, and optionally uses git to make accidents reversable. Passwords stored using it are easily manipulated using core utilities.
First of all, there's execline, a non-interactive scripting language. It's better then shell because it's way less complex, and therefore has less things that could go wrong. The UNIX philosophy is about making things less complex, after all.
AWK is a programming language for processing text files. AWK Scripts are easy to write, and AWK is optimized specifically for it's purpose.
Then there's make
Vis is a modal text editor; think of it as if you are giving commands to edit text files. Macros repeat commands again and again.
mitmproxy is a proxy that displays connections sent through it. It is useful for checking software for spyware.

View File

@ -1,33 +1,24 @@
# Whatssup gamers
# Testing Input
This is testing input.
Today we are gonna play a game called Test your applikayshens!
And this text should be <escaped>, so that the characters work in 'HTML.
=> this-link-doesnt-exist.gmi "REEEEE"
=>and-the-description-doesnt-exist-either.gmi
<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>
> Quotes should work.
> - Me
```
hahaha code
when: '```'
hehehe '```'
And code should work too.
Right?
> Well quotes within code don't work.
```
* this is
* an unordered list
* which is epic
* Unordered lists
* should work properly, hopefully
* spaces do seperate lists
* i wonder if they shouldn't
* And spaces seperate lists
## WHat about me?
You too buddy
## Level 2 Subheadings work
### What about me as well?
Yeah
### Level 3 Subheadings work
#### what about me?
nope lol
#### But not beyond that.

View File

@ -1,3 +1,27 @@
# Testing Input
This is testing input.
And this text should be <escaped>, so that the characters work in 'HTML.
> Quotes should work.
> - Me
```
And code should work too.
Right?
> Well quotes within code don't work.
```
* Unordered lists
* should work properly, hopefully
* And spaces seperate lists
## Level 2 Subheadings work
### Level 3 Subheadings work
#### But not beyond that.
Navigation:
=> ../gmi/index.gmi home
=> ../gmi/notes/index.gmi notes
@ -5,36 +29,3 @@ Navigation:
=> ../gmi/sitemap.gmi sitemap
=> ../gmi/feed.atom feed
=> http://git.vern.cc/techn0path/ git
# 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
<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
when: '```'
hehehe '```'
```
* this is
* an unordered list
* which is epic
* spaces do seperate lists
* i wonder if they shouldn't
## WHat about me?
You too buddy
### What about me as well?
Yeah
#### what about me?
nope lol

View File

@ -1,8 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title>Whatssup gamers</title>
<title>Testing Input</title>
<meta name='author' content='techn0path' />
<meta name='referrer' content='no-referrer' />
<meta name='viewpoint' content='width=device-width,initial-scale=1.0' />
@ -15,7 +14,7 @@ body { margin: 20px; }
</head>
<body>
<header>
<nav id='navbar'>
<nav id='navbar'>
<a href='../html/index.html'>home</a> |
<a href='../html/notes/index.html'>notes</a> |
<a href='../html/useful/index.html'>useful</a> |
@ -26,50 +25,35 @@ body { margin: 20px; }
</header><hr>
<article id='content'>
<details id='toc'>
<summary>Table of content</summary>
<ol>
<li><a href='#what_about_me?'>WHat about me?</a></li>
<details id='toc'> <summary>Table of content</summary> <ol>
<li><a href='#level_2_subheadings_work'>Level 2 Subheadings work</a></li>
</ol> </details>
<h1>Whatssup gamers</h1>
<h1>Testing Input</h1>
<p>This is testing input.</p>
<p></p>
<p>Today we are gonna play a game called Test your applikayshens!</p>
<p></p>
<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>And this text should be &lt;escaped&gt;, so that the characters work in &apos;HTML.</p>
<p></p>
<blockquote>
&quot;two things are infinite, the universe and human stupidity, and i aint sure about the universe&quot;<br>
- &lt;einstein&gt;<br>
- Me<br>
</blockquote>
<pre>
hahaha code
when: &apos;```&apos;
hehehe &apos;```&apos;
And code should work too.
Right?
&gt; Well quotes within code don&apos;t work.
</pre>
<p></p>
<ul>
<li>this is</li>
<li>an unordered list</li>
<li>which is epic</li>
<li>should work properly, hopefully</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>
<h2 id='level_2_subheadings_work'>Level 2 Subheadings work</h2>
<a href='#level_2_subheadings_work'>Permalink</a><br/><br/>
<p></p>
<h3>What about me as well?</h3>
<p>Yeah </p>
<h3>Level 3 Subheadings work</h3>
<p></p>
<p>#### what about me?</p>
<p>nope lol</p>
<p>#### But not beyond that.</p>
</article>
<hr>