minor changes to scripts/html.awk. i dunno, stuff to do with the navigation bar i guess. also added snapshot testing via git-diff

This commit is contained in:
Abdullah Islam 2023-05-14 15:30:49 +06:00
parent efdb49ffe7
commit ca092bac15
7 changed files with 188 additions and 17 deletions

View File

@ -5,24 +5,27 @@ SITEMAP_INDEX_FILES = $(wildcard src/*/index.gmi)
all: subdirs \
$(SOURCES:src/%.gmi=html/%.html) \
$(SOURCES:src/%.gmi=gmi/%.gmi) \
$(SOURCES:src/%.webp=gmi/%.webp) \
$(SOURCES:src/%.webp=html/%.webp) \
$(SOURCES:src/%.webp=gmi/%.webp) \
gmi/sitemap.gmi \
html/sitemap.html \
gmi/feed.atom \
html/feed.atom \
# test: testing/example.gmi testing/example.ass
# mawk -f ~/projects/awk_functions/lib.awk -f scripts/html.awk -- testing/example.gmi > testing/output.html
# mawk -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
clean:
rm -rf html/* gmi/*
test: testing/example.gmi testing/example.ass
mawk -f ~/projects/awk_functions/lib.awk -f scripts/html.awk -- testing/example.gmi > testing/output.html
mawk -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
subdirs:
find src -mindepth 1 -type d -printf '%P\0' | xargs -0 -I{} mkdir -p gmi/{} html/{}
html/%.png: src/%.png
cp $< $@
gmi/%.png: src/%.png
cp $< $@
html/%.webp: src/%.webp
cp $< $@

View File

@ -41,6 +41,9 @@ BEGIN {
sub("^[ ]*", "", link)
sub("^[ ]*", "", description)
if (description == "")
description = link
if (link !~ "^[a-zA-Z0-9_]*:")
sub("\.gmi$", ".html", link)
@ -74,13 +77,14 @@ BEGIN {
/^>/ {
articleBody = articleBody "<blockquote>\n"
while (match($0, "^>[ ]*")) {
gsub("&", "\&amp;")
gsub("<", "\&lt;")
gsub(">", "\&gt;")
gsub("'", "\&apos;")
gsub("\"", "\&quot;")
text = substr($0, RSTART + RLENGTH)
gsub("&", "\\&amp;", text)
gsub("<", "\\&lt;", text)
gsub(">", "\\&gt;", text)
gsub("'", "\\&apos;", text)
gsub("\"", "\\&quot;", text)
articleBody = articleBody substr($0, RSTART + RLENGTH) "\n"
articleBody = articleBody text "<br>\n"
if (getline != 1) break
}
articleBody = articleBody "</blockquote>\n"
@ -89,7 +93,7 @@ BEGIN {
/^\*/ {
articleBody = articleBody "<ul>\n"
while (match($0, "^\\*")) {
while (match($0, "^\\*[ ]*")) {
gsub("&", "\&amp;")
gsub("<", "\&lt;")
gsub(">", "\&gt;")
@ -109,7 +113,6 @@ BEGIN {
gsub(">", "\&gt;")
gsub("'", "\&apos;")
gsub("\"", "\&quot;")
articleBody = articleBody sprintf("<p>%s</p>\n", $0)
}
@ -139,7 +142,7 @@ END {
relpath(getDirname(FILENAME), "src/notes/index.html"), \
relpath(getDirname(FILENAME), "src/useful/index.html"), \
relpath(getDirname(FILENAME), "src/sitemap.html"), \
relpath(getDirname(FILENAME), "src/feed.atom")) \
relpath(getDirname(FILENAME), "src/feed.atom"))
printf "<!DOCTYPE html>\n\
<html>\n\

4
testing/example.ass Normal file
View File

@ -0,0 +1,4 @@
# comments
# so yeah
2030-01-01 this-is-the-future.gmi
2030-01-01 not-the-past.gmi this is the future,not the past

31
testing/example.gmi Normal file
View File

@ -0,0 +1,31 @@
# 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
>two things are infinite, the universe and human stupidity, and i aint sure about the universe
>- einstein
```
hahaha code
when: '```'
hehehe '```'
```
> less is more
> - a gentle MAN
* this is
* an unordered list
* which is epic
## WHat about me?
You too buddy
### What about me as well?
Yeah
#### what about me?
nope lol

24
testing/output.atom Normal file
View File

@ -0,0 +1,24 @@
<?xml version='1.0' encoding='UTF-8' ?>
<feed xmlns='http://www.w3.org/2005/Atom'>
<title>techn0path</title>
<link rel='self' href='' />
<author>
<name>techn0path</name>
</author>
<updated>2023-05-13T14:48:24Z</updated>
<id>urn:uuid:2e5efb05-3971-5e8f-a859-f87d49ab91dd</id>
<entry>
<title></title>
<link href='this-is-the-future.gmi' />
<id>urn:uuid:258db63b-a96f-5986-8154-586f2a6aae3a</id>
<updated>2030-01-01T00:00:00Z</updated>
<summary></summary>
</entry>
<entry>
<title>this is the future,not the past</title>
<link href='not-the-past.gmi' />
<id>urn:uuid:0abee9b4-5c42-534d-b1f0-0528757ee459</id>
<updated>2030-01-01T00:00:00Z</updated>
<summary>this is the future,not the past</summary>
</entry>
</feed>

38
testing/output.gmi Normal file
View File

@ -0,0 +1,38 @@
Navigation:
=> ../src/index.gmi home
=> ../src/notes/index.gmi notes
=> ../src/useful/index.gmi useful
=> ../src/sitemap.gmi sitemap
=> ../src/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
>two things are infinite, the universe and human stupidity, and i aint sure about the universe
>- einstein
```
hahaha code
when: '```'
hehehe '```'
```
> less is more
> - a gentle MAN
* this is
* an unordered list
* which is epic
## WHat about me?
You too buddy
### What about me as well?
Yeah
#### what about me?
nope lol

68
testing/output.html Normal file
View File

@ -0,0 +1,68 @@
<!DOCTYPE html>
<html>
<head>
<title>Whatssup gamers</title>
<meta name='author' content='techn0path' />
<meta name='referrer' content='no-referrer' />
<meta name='viewpoint' content='width=device-width,initial-scale=1.0' />
<style>
body { margin: 20px; }
#content { max-width: 80ch; }
.permalink { margin-left: 15px; }
</style>
</head>
<body>
<header>
<nav id='navbar'>
<a href='../index.html'>home</a> | <a href='../notes/index.html'>notes</a> | <a href='../useful/index.html'>useful</a> | <a href='../sitemap.html'>sitemap</a> | <a href='../feed.atom'>feed</a> </nav>
</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>
</ol> </details>
<h1>Whatssup gamers</h1>
<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='and-the-description-doesnt-exist-either.html'>and-the-description-doesnt-exist-either.gmi</a><br>
<p></p>
<blockquote>
two things are infinite, the universe and human stupidity, and i aint sure about the universe<br>
- einstein<br>
</blockquote>
<pre>
hahaha code
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>
<h2 id='what_about_me?'>WHat about me?</h2>
<a href='#what_about_me?'>Permalink</a><br/><br/>
<p>You too buddy</p>
<p></p>
<h3>What about me as well?</h3>
<p>Yeah </p>
<p></p>
<p>#### what about me?</p>
<p>nope lol</p>
</article>
</body>
</html>