made navbars and links work again

This commit is contained in:
Abdullah Islam 2024-03-07 19:58:21 +06:00
parent 054c065cf1
commit df5bf1d4d4
9 changed files with 62 additions and 65 deletions

View File

@ -1,63 +1,66 @@
SHELL = /bin/sh
SOURCES = $(shell find src/ -type f)
SITEMAP_INDEX_FILES = $(wildcard src/*/*)
all: subdirs \
$(SOURCES:src/%.gmi=html/%.html) \
$(SOURCES:src/%.png=html/%.png) \
$(SOURCES:src/%.webp=html/%.webp) \
$(SOURCES:src/%.gmi=gmi/%.gmi) \
$(SOURCES:src/%.png=gmi/%.png) \
$(SOURCES:src/%.webp=gmi/%.webp) \
gmi/sitemap.gmi \
gmi/feed.atom \
html/sitemap.html \
html/feed.atom \
html/style.css
$(SOURCES:src/%.gmi=build/html/%.html) \
$(SOURCES:src/%.png=build/html/%.png) \
$(SOURCES:src/%.webp=build/html/%.webp) \
$(SOURCES:src/%.gmi=build/gmi/%.gmi) \
$(SOURCES:src/%.png=build/gmi/%.png) \
$(SOURCES:src/%.webp=build/gmi/%.webp) \
build/gmi/sitemap.gmi \
build/gmi/feed.atom \
build/html/sitemap.html \
build/html/feed.atom \
build/html/style.css
upload:
scp -r gmi/* techn0path@vern.cc:public_gemini
scp -r html/* techn0path@vern.cc:public_html
scp -r build/gmi/* techn0path@vern.cc:public_gemini
scp -r build/html/* techn0path@vern.cc:public_html
test: testing/input/index.gmi testing/input/feed.txt
echo '' | mawk -f lib/navbar.awk -f lib/path.awk -f scripts/test.awk > testing/output/functionOutputs.txt
mawk -f lib/navbar.awk -f lib/path.awk -f scripts/html.awk -v 'sourcePath=testing/input' -- testing/input/index.gmi > testing/output/index.html
mawk -f lib/navbar.awk -f lib/path.awk -f scripts/gemini.awk -v 'sourcePath=testing/input' -- testing/input/index.gmi > testing/output/index.gmi
mawk -f lib/path.awk -f scripts/feed.awk -- testing/input/feed.txt > testing/output/feed.atom
html5validator testing/output/index.html
echo '' | mawk -f scripts/lib/navbar.awk -f scripts/lib/path.awk -f scripts/test.awk > testing/output/functionOutputs.txt
mawk -f scripts/lib/navbar.awk -f scripts/lib/path.awk -f scripts/html.awk -v 'sourcePath=testing/input' -v 'destPath=testing/output' -- testing/input/index.gmi > testing/output/index.html
mawk -f scripts/lib/navbar.awk -f scripts/lib/path.awk -f scripts/gemini.awk -v 'sourcePath=testing/input' -v 'destPath=testing/output' -- testing/input/index.gmi > testing/output/index.gmi
mawk -f scripts/lib/path.awk -f scripts/feed.awk -- testing/input/feed.txt > testing/output/feed.atom
traverse:
find src/ \
\(-mindepth 1 -type d -fprintf tmp/directories '%P\0'\) , \
\(-type f -fprintf tmp/sources\) | xargs -0 -I{} mkdir -p build/gmi/{} build/html/{}
subdirs:
find src -mindepth 1 -type d -printf '%P\0' | xargs -0 -I{} mkdir -p gmi/{} html/{}
find src -mindepth 1 -type d -printf '%P\0' | xargs -0 -I{} mkdir -p build/gmi/{} build/html/{}
html/%.png: src/%.png
build/html/%.png: src/%.png
cp $< $@
gmi/%.png: src/%.png
build/gmi/%.png: src/%.png
cp $< $@
html/%.webp: src/%.webp
build/html/%.webp: src/%.webp
cp $< $@
gmi/%.webp: src/%.webp
build/gmi/%.webp: src/%.webp
cp $< $@
html/style.css: src/style.css
cp $< $@
build/html/style.css: src/style.scss
sass $< > $@
html/%.html: src/%.gmi scripts/html.awk lib/navbar.awk
mawk -f lib/navbar.awk -f lib/path.awk -v 'sourcePath=src/' -f scripts/html.awk -- $< > $@
build/html/%.html: src/%.gmi scripts/html.awk scripts/lib/navbar.awk
mawk -f scripts/lib/navbar.awk -f scripts/lib/path.awk -v 'sourcePath=src/' -v 'destPath=build/html/' -f scripts/html.awk -- $< > $@
gmi/%.gmi: src/%.gmi scripts/gemini.awk lib/navbar.awk
mawk -f lib/navbar.awk -f lib/path.awk -v 'sourcePath=src/' -f scripts/gemini.awk -- $< > $@
build/gmi/%.gmi: src/%.gmi scripts/gemini.awk scripts/lib/navbar.awk
mawk -f scripts/lib/navbar.awk -f scripts/lib/path.awk -v 'sourcePath=src/' -v 'destPath=build/html/' -f scripts/gemini.awk -- $< > $@
html/sitemap.html: $(SITEMAP_INDEX_FILES) scripts/sitemap_html.awk lib/navbar.awk
mawk -f lib/navbar.awk -f lib/path.awk -v 'sourcePath=src/' -f scripts/sitemap_html.awk -- $(SITEMAP_INDEX_FILES) > $@
build/html/sitemap.html: $(SOURCES) scripts/sitemap_html.awk scripts/lib/navbar.awk
mawk -f scripts/lib/navbar.awk -f scripts/lib/path.awk -v 'sourcePath=src/' -v 'destPath=build/html/' -f scripts/sitemap_html.awk -- $(SOURCES) > $@
gmi/sitemap.gmi: $(SITEMAP_INDEX_FILES) scripts/sitemap_gmi.awk lib/navbar.awk
mawk -f lib/navbar.awk -f lib/path.awk -v 'sourcePath=src/' -f scripts/sitemap_gmi.awk -- $(SITEMAP_INDEX_FILES) > $@
build/gmi/sitemap.gmi: $(SOURCES) scripts/sitemap_gmi.awk scripts/lib/navbar.awk
mawk -f scripts/lib/navbar.awk -f scripts/lib/path.awk -v 'sourcePath=src/' -v 'destPath=build/html/' -f scripts/sitemap_gmi.awk -- $(SOURCES) > $@
html/feed.atom: scripts/feed.awk
git log --diff-filter=A --pretty=format:'%aI "%s"' --name-only src/ | mawk -v 'willConvertLinks=1' -f lib/path.awk -f scripts/feed.awk -- - > $@
build/html/feed.atom: scripts/feed.awk
git log --diff-filter=A --pretty=format:'%aI "%s"' --name-only src/ | mawk -v 'willConvertLinks=1' -f scripts/lib/path.awk -f scripts/feed.awk -- - > $@
gmi/feed.atom: scripts/feed.awk
git log --diff-filter=A --pretty=format:'%aI "%s"' --name-only src/ | mawk -f lib/path.awk -f scripts/feed.awk -- - > $@
build/gmi/feed.atom: scripts/feed.awk
git log --diff-filter=A --pretty=format:'%aI "%s"' --name-only src/ | mawk -f scripts/lib/path.awk -f scripts/feed.awk -- - > $@

View File

@ -155,7 +155,7 @@ END {
tocText = tocText "</ol> </details>\n"
}
navbarText = genHTMLNavbar(FILENAME, sourcePath)
navbarText = genHTMLNavbar(FILENAME, sourcePath, destPath)
dirname = getDirname(FILENAME)

View File

@ -1,4 +1,4 @@
function genHTMLNavbar(filename, sourcePath) {
function genHTMLNavbar(filename, sourcePath, destPath) {
if (filename == "-" || filename == "/dev/stdout/")
return ""
@ -8,20 +8,18 @@ function genHTMLNavbar(filename, sourcePath) {
return sprintf("<nav id='navbar'>\n\
<a href='%s'>home</a> | \n\
<a href='%s'>useful</a> | \n\
<a href='%s'>notes</a> | \n\
<a href='%s'>sitemap</a> | \n\
<a href='%s'>feed</a> | \n\
<a href='http://git.vern.cc/techn0path/'>git</a>\n\
</nav><hr>\n", \
getRelativePath(dirname, sourcePath "/index.html"), \
getRelativePath(dirname, sourcePath "/useful/index.html"), \
getRelativePath(dirname, sourcePath "/notes/index.html"), \
getRelativePath(dirname, sourcePath "/sitemap.html"), \
getRelativePath(dirname, sourcePath "/feed.atom"))
}
function genGemtextNavbar(filename, sourcePath) {
function genGemtextNavbar(filename, sourcePath, destPath) {
if (filename == "-" || filename == "/dev/stdout/")
return ""
@ -29,13 +27,11 @@ function genGemtextNavbar(filename, sourcePath) {
return sprintf("Navigation:\n\
=> %s home\n\
=> %s useful\n\
=> %s notes\n\
=> %s sitemap\n\
=> %s feed\n\
=> https://git.vern.cc/techn0path/ git\n\n", \
getRelativePath(dirname, sourcePath "/index.gmi"), \
getRelativePath(dirname, sourcePath "/useful/index.gmi"), \
getRelativePath(dirname, sourcePath "/notes/index.gmi"), \
getRelativePath(dirname, sourcePath "/sitemap.gmi"), \
getRelativePath(dirname, sourcePath "/feed.atom"))

View File

@ -37,7 +37,7 @@ function resolvePath(path, resolvedPath, pathComponents) {
function getRelativePath(base, path, resolvedPath, baseComponents, pathComponents, commonPrefix) {
pathComponents[1] = ""
baseComponents[1] = ""
endOfCommonPrefix = 1
commonPrefixEnd = 1
resolvedPath = ""
base = resolvePath(base)
@ -46,15 +46,15 @@ function getRelativePath(base, path, resolvedPath, baseComponents, pathComponent
split(path, pathComponents, "/")
split(base, baseComponents, "/")
while (pathComponents[endOfCommonPrefix] == baseComponents[endOfCommonPrefix] &&
endOfCommonPrefix < length(baseComponents) &&
endOfCommonPrefix < length(pathComponents))
endOfCommonPrefix++
while (commonPrefixEnd < length(baseComponents) + 1 &&
commonPrefixEnd < length(pathComponents) + 1 &&
baseComponents[commonPrefixEnd] == pathComponents[commonPrefixEnd])
commonPrefixEnd++
for (i = endOfCommonPrefix; i < length(baseComponents) + 1; i++)
for (i = commonPrefixEnd; i < length(baseComponents) + 1; i++)
resolvedPath = resolvedPath "../"
for (i = endOfCommonPrefix; i <= length(pathComponents); i++)
for (i = commonPrefixEnd; i < length(pathComponents) + 1; i++)
resolvedPath = resolvedPath pathComponents[i] "/"
sub(/\/+$/, "", resolvedPath)

View File

@ -31,7 +31,7 @@ BEGIN {
}
END {
dirname = getDirname(linkAddress)
dirname = getDirname(FILENAME)
stylesheetPath = getRelativePath(dirname, sourcePath "/style.css")
printf "<!DOCTYPE html>\n\

0
scripts/test.awk Normal file → Executable file
View File

View File

@ -11,4 +11,4 @@ path/to/file.txt == path/to/file.txt
=> getRelativePath('parent/directory/', 'parent/path/to/file.txt')
../path/to/file.txt == ../path/to/file.txt
=> getRelativePath('parent/directory/', 'parent/directory/path/to/file.txt')
path/to/file.txt != ../directory/path/to/file.txt
path/to/file.txt == path/to/file.txt

View File

@ -1,9 +1,8 @@
Navigation:
=> ../testing/input/index.gmi home
=> ../testing/input/useful/index.gmi useful
=> ../testing/input/notes/index.gmi notes
=> ../testing/input/sitemap.gmi sitemap
=> ../testing/input/feed.atom feed
=> testing/input/index.gmi home
=> testing/input/notes/index.gmi notes
=> testing/input/sitemap.gmi sitemap
=> testing/input/feed.atom feed
=> http://git.vern.cc/techn0path/ git
# Testing Input

View File

@ -6,16 +6,15 @@
<meta name='referrer' content='no-referrer' />
<meta name='viewpoint' content='width=device-width,initial-scale=1.0' />
<link rel='stylesheet' href='../input/style.css'/>
<link rel='stylesheet' href='style.css'/>
</head>
<body>
<header>
<nav id='navbar'>
<a href='../input/index.html'>home</a> |
<a href='../input/useful/index.html'>useful</a> |
<a href='../input/notes/index.html'>notes</a> |
<a href='../input/sitemap.html'>sitemap</a> |
<a href='../input/feed.atom'>feed</a> |
<a href='index.html'>home</a> |
<a href='notes/index.html'>notes</a> |
<a href='sitemap.html'>sitemap</a> |
<a href='feed.atom'>feed</a> |
<a href='http://git.vern.cc/techn0path/'>git</a>
</nav><hr>