some changes

This commit is contained in:
Abdullah Islam 2023-09-23 10:05:17 +06:00
parent 0e89ab80fc
commit 7677de9acf
6 changed files with 44 additions and 29 deletions

View File

@ -20,8 +20,8 @@ upload:
scp -r html/* techn0path@vern.cc:public_html
test: testing/input.gmi testing/input_feed.txt
mawk -f scripts/navbar.awk -f scripts/path.awk -f scripts/html.awk -- testing/input.gmi > testing/output.html
mawk -f scripts/navbar.awk -f scripts/path.awk -f scripts/gemini.awk -- testing/input.gmi > testing/output.gmi
mawk -f scripts/navbar.awk -f scripts/path.awk -f scripts/html.awk -v 'sourcePath=src/ outputPath=testing/'-- testing/input.gmi > testing/output.html
mawk -f scripts/navbar.awk -f scripts/path.awk -f scripts/gemini.awk -v 'sourcePath=src/ outputPath=testing/'-- testing/input.gmi > testing/output.gmi
mawk -f scripts/path.awk -f scripts/feed.awk -- testing/input_feed.txt > testing/output.atom
html5validator testing/output.html
@ -47,16 +47,16 @@ html/%.html: src/%.gmi scripts/html.awk scripts/navbar.awk
mawk -f scripts/navbar.awk -f scripts/path.awk -v 'sourcePath=src/ outputPath=html/' -f scripts/html.awk -- $< > $@
gmi/%.gmi: src/%.gmi scripts/gemini.awk scripts/navbar.awk
mawk -f scripts/navbar.awk -f scripts/path.awk -v 'sourcePath=src/ outputPath=html/' -f scripts/gemini.awk -- $< > $@
gmi/sitemap.gmi: $(SITEMAP_INDEX_FILES) scripts/sitemap_gmi.awk scripts/navbar.awk
mawk -f scripts/navbar.awk -f scripts/path.awk -v 'sourcePath=src/ outputPath=html/' -f scripts/sitemap_gmi.awk -- $(SITEMAP_INDEX_FILES) > $@
mawk -f scripts/navbar.awk -f scripts/path.awk -v 'sourcePath=src/ outputPath=gmi/' -f scripts/gemini.awk -- $< > $@
html/sitemap.html: $(SITEMAP_INDEX_FILES) scripts/sitemap_html.awk scripts/navbar.awk
mawk -f scripts/navbar.awk -f scripts/path.awk -v 'sourcePath=src/ outputPath=html/' -f scripts/sitemap_html.awk -- $(SITEMAP_INDEX_FILES) > $@
gmi/feed.atom: scripts/feed.awk
git log --diff-filter=A --pretty=format:'%aI "%s"' --name-only src/ | mawk -f scripts/path.awk -f scripts/feed.awk -- - > $@
gmi/sitemap.gmi: $(SITEMAP_INDEX_FILES) scripts/sitemap_gmi.awk scripts/navbar.awk
mawk -f scripts/navbar.awk -f scripts/path.awk -v 'sourcePath=src/ outputPath=gmi/' -f scripts/sitemap_gmi.awk -- $(SITEMAP_INDEX_FILES) > $@
html/feed.atom: scripts/feed.awk
git log --diff-filter=A --pretty=format:'%aI "%s"' --name-only src/ | mawk -v 'willConvertLinks=1' -f scripts/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 scripts/path.awk -f scripts/feed.awk -- - > $@

View File

@ -1,5 +1,5 @@
BEGIN {
printf "%s", genNavbarGMI(FILENAME, "src/", "gmi/")
printf "%s", genNavbarGMI(FILENAME, sourcePath, outputPath)
}
{ print }

View File

@ -2,6 +2,7 @@ BEGIN {
title = "techn0path - no title"
body = ""
subHeadings[0] = ""
insideRange = 0
}
/^#[^#]/ {
@ -62,21 +63,26 @@ BEGIN {
}
/^```/ {
body = body "<pre>\n"
insideRange = !insideRange
while (getline == 1) {
if ($0 ~ "^```") break
gsub("&", "\\&amp;")
gsub("<", "\\&lt;")
gsub(">", "\\&gt;")
gsub("'", "\\&apos;")
gsub("\"", "\\&quot;")
body = body $0 "\n"
if (insideRange) {
body = body "<pre>\n"
} else {
body = body "</pre>\n"
}
body = body "</pre>\n"
next
}
insideRange {
gsub("&", "\\&amp;")
gsub("<", "\\&lt;")
gsub(">", "\\&gt;")
gsub("'", "\\&apos;")
gsub("\"", "\\&quot;")
body = body $0 "\n"
next
}
@ -153,7 +159,6 @@ END {
gsub(sourcePath, outputPath, dirname)
gsub(sourcePath, outputPath, filename)
printf "<!DOCTYPE html>\n\
<html>\n\
<head>\n\

View File

@ -2,18 +2,21 @@ function genNavbarHTML(filename, sourcePath, outputPath) {
if (filename == "-" || filename == "/dev/stdout/")
return ""
gsub(sourcePath, outputPath, filename)
dirname = getDirname(filename)
gsub(/(\.|\[|\]|\*)/, "\\&", sourcePath)
gsub(sourcePath, outputPath, dirname)
gsub(sourcePath, outputPath, filename)
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><br>\n", \
getRelativePath(dirname, outputPath "/index.html"), \
getRelativePath(dirname, outputPath "/useful/index.html"), \
getRelativePath(dirname, outputPath "/notes/index.html"), \
getRelativePath(dirname, outputPath "/sitemap.html"), \
getRelativePath(dirname, outputPath "/feed.atom"))
}
@ -22,17 +25,20 @@ function genNavbarGMI(filename, sourcePath, outputPath) {
if (filename == "-" || filename == "/dev/stdout/")
return ""
gsub(sourcePath, outputPath, dirname)
dirname = getDirname(filename)
gsub(/(\.|\[|\]|\*)/, "\\&", sourcePath)
gsub(sourcePath, outputPath, dirname)
gsub(sourcePath, outputPath, filename)
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, outputPath "/index.gmi"), \
getRelativePath(dirname, outputPath "/useful/index.gmi"), \
getRelativePath(dirname, outputPath "/notes/index.gmi"), \
getRelativePath(dirname, outputPath "/sitemap.gmi"), \
getRelativePath(dirname, outputPath "/feed.atom"))
}

View File

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

View File

@ -12,6 +12,8 @@
<header>
<nav id='navbar'>
<a href='index.html'>home</a> |
<a href='useful/index.html'>useful</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>