added gemini sitemap functionality
This commit is contained in:
parent
384e6bf008
commit
fd60aca75d
11
Makefile
11
Makefile
|
@ -1,7 +1,8 @@
|
||||||
SHELL = /bin/sh
|
SHELL = /bin/sh
|
||||||
SOURCES = $(shell find src/ -type f)
|
SOURCES = $(shell find src/ -type f)
|
||||||
|
SITEMAP_INDEX_FILES = $(filter %/index.gmi , $(SOURCES))
|
||||||
|
|
||||||
all: subdirs $(SOURCES:src/%.gmi=html/%.html) $(SOURCES:src/%.gmi=gmi/%.gmi) subdirs
|
all: subdirs $(SOURCES:src/%.gmi=html/%.html) $(SOURCES:src/%.gmi=gmi/%.gmi) gmi/sitemap.gmi # html/sitemap.html
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf html/* gmi/*
|
rm -rf html/* gmi/*
|
||||||
|
@ -13,4 +14,10 @@ html/%.html: src/%.gmi tmpl/html.awk
|
||||||
mawk -f tmpl/html.awk -- $< > $@
|
mawk -f tmpl/html.awk -- $< > $@
|
||||||
|
|
||||||
gmi/%.gmi: src/%.gmi tmpl/gemini.awk
|
gmi/%.gmi: src/%.gmi tmpl/gemini.awk
|
||||||
mawk -f tmpl/gemini.awk $< > $@
|
mawk -f tmpl/gemini.awk -- $< > $@
|
||||||
|
|
||||||
|
# html/sitemap.html: $(SITEMAP_INDEX_FILES) tmpl/sitemap_html.awk
|
||||||
|
# mawk -f tmpl/sitemap_html.awk $(SITEMAP_INDEX_FILES) > $@
|
||||||
|
|
||||||
|
gmi/sitemap.gmi: $(SITEMAP_INDEX_FILES) tmpl/sitemap_gmi.awk
|
||||||
|
mawk -f tmpl/sitemap_gmi.awk $(SITEMAP_INDEX_FILES) > $@
|
||||||
|
|
|
@ -5,10 +5,8 @@ function getDirname(path, pathComponents, npathComponents, dirname) {
|
||||||
dirname = ""
|
dirname = ""
|
||||||
|
|
||||||
if (npathComponents < 1) return "."
|
if (npathComponents < 1) return "."
|
||||||
|
else for (i = 1; i < npathComponents; i++)
|
||||||
for (i = 1; i < npathComponents; i++)
|
|
||||||
dirname = dirname pathComponents[i] "/"
|
dirname = dirname pathComponents[i] "/"
|
||||||
|
|
||||||
return dirname
|
return dirname
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +19,7 @@ BEGIN {
|
||||||
FS = " "
|
FS = " "
|
||||||
title = "techn0path - no title"
|
title = "techn0path - no title"
|
||||||
body = ""
|
body = ""
|
||||||
|
|
||||||
subheadings[0] = ""
|
subheadings[0] = ""
|
||||||
nsubheadings = 0
|
nsubheadings = 0
|
||||||
}
|
}
|
||||||
|
@ -37,7 +36,6 @@ BEGIN {
|
||||||
body = body "<h2>" $0 "</h2>\n"
|
body = body "<h2>" $0 "</h2>\n"
|
||||||
subheadings[nsubheadings] = $0
|
subheadings[nsubheadings] = $0
|
||||||
nsubheadings ++
|
nsubheadings ++
|
||||||
|
|
||||||
next
|
next
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,6 +72,12 @@ BEGIN {
|
||||||
body = body "<pre>"
|
body = body "<pre>"
|
||||||
getline
|
getline
|
||||||
while ($0 != "```") {
|
while ($0 != "```") {
|
||||||
|
gsub("<", "\<")
|
||||||
|
gsub(">", "\>")
|
||||||
|
gsub("&", "\&")
|
||||||
|
gsub("\'", "\'")
|
||||||
|
gsub("\"", "\"")
|
||||||
|
|
||||||
body = body $0 "\n"
|
body = body $0 "\n"
|
||||||
getline
|
getline
|
||||||
}
|
}
|
||||||
|
@ -99,7 +103,7 @@ END {
|
||||||
navbar = sprintf("<a href='%s'>home</a> | \
|
navbar = sprintf("<a href='%s'>home</a> | \
|
||||||
<a href='%s'>notes</a> | \
|
<a href='%s'>notes</a> | \
|
||||||
<a href='%s'>useful</a> | \
|
<a href='%s'>useful</a> | \
|
||||||
<a href='%s'>howto</a>", relpath(dirname, ENVIRON["PWD"] "/src/index.html"), relpath(dirname, ENVIRON["PWD"] "/src/notes/index.html"), relpath(dirname, ENVIRON["PWD"] "/src/useful/index.html"), relpath(dirname, ENVIRON["PWD"] "/src/howto/index.html"))
|
<a href='%s'>howto</a> \n", relpath(dirname, ENVIRON["PWD"] "/src/index.html"), relpath(dirname, ENVIRON["PWD"] "/src/notes/index.html"), relpath(dirname, ENVIRON["PWD"] "/src/useful/index.html"), relpath(dirname, ENVIRON["PWD"] "/src/howto/index.html"))
|
||||||
|
|
||||||
toc = ""
|
toc = ""
|
||||||
if (nsubheadings > 0) {
|
if (nsubheadings > 0) {
|
||||||
|
@ -134,7 +138,7 @@ body { margin: 15px; }\n\
|
||||||
<nav id='navbar'>\n\
|
<nav id='navbar'>\n\
|
||||||
%s\n\
|
%s\n\
|
||||||
</nav>\n\
|
</nav>\n\
|
||||||
</header>\n\
|
</header><hr>\n\
|
||||||
<article id='content'>\n\
|
<article id='content'>\n\
|
||||||
%s\n\
|
%s\n\
|
||||||
%s\n\
|
%s\n\
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
BEGIN {
|
||||||
|
printf "# Sitemap\n\
|
||||||
|
This document is automatically generated. See:\n\
|
||||||
|
=> howto/website-generation.gmi\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDirname(path, pathComponents, npathComponents, dirname) {
|
||||||
|
pathComponents[1] = ""
|
||||||
|
sub("/$", "", path)
|
||||||
|
npathComponents = split(path, pathComponents, "/")
|
||||||
|
dirname = ""
|
||||||
|
|
||||||
|
if (npathComponents < 1) return "."
|
||||||
|
else for (i = 1; i < npathComponents; i++)
|
||||||
|
dirname = dirname pathComponents[i] "/"
|
||||||
|
return dirname
|
||||||
|
}
|
||||||
|
|
||||||
|
/^#[^#]/ {
|
||||||
|
sub("^#([ ]*)", "")
|
||||||
|
printf "## %s\n", $0
|
||||||
|
}
|
||||||
|
|
||||||
|
/^=>/ {
|
||||||
|
if (match($1, "^=>([^ ]*)")) {
|
||||||
|
link = $1
|
||||||
|
sub("^=>", "", link)
|
||||||
|
$1 = ""
|
||||||
|
description = $0
|
||||||
|
} else if (NF < 2) next
|
||||||
|
else {
|
||||||
|
link = $2
|
||||||
|
$1 = ""
|
||||||
|
$2 = ""
|
||||||
|
description = $0
|
||||||
|
}
|
||||||
|
sub("^([ ]*)", "", description)
|
||||||
|
|
||||||
|
sprintf("realpath %s/%s", getDirname(FILENAME), link) | getline absolutePath
|
||||||
|
sprintf("realpath --relative-to=\"%s\" \"%s\"", ENVIRON["PWD"], absolutePath) | getline link
|
||||||
|
|
||||||
|
printf "=> %s %s\n", link, description
|
||||||
|
}
|
Loading…
Reference in New Issue