Compare commits

...

2 Commits

Author SHA1 Message Date
9087f05a34 Refactor work 2023-02-17 16:15:53 +00:00
6735e712eb refactored tape ssg 2023-02-17 14:33:58 +00:00
6 changed files with 42 additions and 27 deletions

View File

@ -16,5 +16,7 @@ clean:
rm -rf out
build:
./render.sh
sitemap: out/sitemap.xml
./gensimap.sh
push: build
rclone sync -v out/ neo:/

View File

@ -1,6 +1,5 @@
divert(-1)
# extra macros for site structure
define(`_ytv',`<iframe width="ifdef(`$3',$1,560)" height="ifdef(`$3',$3,315)" src="$1" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>')
define(`_wrap',<$1>$2</$1>)
define(`_empty',`')
divert dnl
dnl extra macros for site structure
define(`_wrap',<$1>$2</$1>)dnl
define(`_a',<a href="$1">$2</a>)dnl
define(`_empty',`')dnl
define(`_ytv',`<iframe width="ifdef(`$3',$1,560)" height="ifdef(`$3',$3,315)" src="$1" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>')dnl

2
m4/linkdata.m4 Normal file
View File

@ -0,0 +1,2 @@
define(`entr', `pushdef(`_LINK',$1)')dnl
entr(`/,Home')

View File

@ -1,7 +1,11 @@
dnl template.m4.html v1.4-p1
dnl template.m4.html v2.0-p1
dnl Part of the tape-and-string suite used to construct the website
ifdef(`DEBUG',`traceon')dnl
include(`m4/lib.m4')dnl
# ifdef(`_INFILE',`dnl ',`errprint(`Macro _INFILE is not defined')
# m4exit(1)')dnl
include(`lib.m4')dnl
include(`linkdata.m4')dnl
define(`_la',`_a(`argn(`1',$1),argn(`2',$1)')
<!DOCTYPE html>
<html>
<head>
@ -12,10 +16,11 @@ include(`m4/lib.m4')dnl
</head>
<body>
<div class="header">
stack_foreach(`_LINK',`_la')
<a href="/">Home</a>
</div>
<div class="content">
include(`/dev/stdin')dnl Probably not a good idea, but whatever.
# esyscmd(`./tape.sh' _INFILE)dnl
</div>
</body>
</html>

View File

@ -1,6 +1,6 @@
#!/bin/bash
# render.sh: part of the tape-and-string framework.
# v3.4-p1
# v3.4-p2
#B: Load
enable -f /usr/lib/bash/csv csv
declare -A title
@ -9,21 +9,6 @@ declare -A title
function inf { 1>&2 echo -e "\x1B[1;32mINF\x1B[0m: $*"; }
function wrn { 1>&2 echo -e "\x1B[1;93mWRN\x1B[0m: $*"; }
function err { 1>&2 echo -e "\x1B[1;31mERR\x1B[0m: $*"; }
function tape {
if test -d "$1"; then
err "tape: Passed directory, $1"
return 1
fi
case $1 in
*.txti) redcloth "$1" ;;
*.org) org-ruby --translate html "$1" ;;
*.md) comrak --gfm "$1" ;;
*.html) cat $1 ;;
*.s[ac]ss) err "Told to render $1, shouldn't happen"; return 1 ;;
*.sh) (inf "Running shellscript $1, I hope you know what you're doing..."; source $1 );;
*) pandoc --columns 168 -t html "$1" || echo "Skipping $i, unknown format" ;;
esac
}
function dirs {
if test -d out; then
wrn "Directory 'out' already exists."
@ -50,9 +35,9 @@ function docs {
o="${i/in/out}"
echo "$i => $o"
if test -z "${title[$i]}"; then
tape $i | m4 -DCSSI=$(awk -f get_sd.awk <<< "$i") m4/main.html.m4 > ${o%.*}.html
m4 -I m4 -D_INFILE="$i" -DCSSI=$(awk -f get_sd.awk <<< "$i") m4/main.html.m4 > ${o%.*}.html
else
tape $i | m4 -DCSSI=$(awk -f get_sd.awk <<< "$i") -DTITLE="${title[$i]}" m4/main.html.m4 > ${o%.*}.html
m4 -I m4 -D_INFILE="$i" -DCSSI=$(awk -f get_sd.awk <<< "$i") -DTITLE="${title[$i]}" m4/main.html.m4 > ${o%.*}.html
fi
done
}

22
tape.sh Executable file
View File

@ -0,0 +1,22 @@
#!/bin/bash
function inf { 1>&2 echo -e "\x1B[1;32mINF\x1B[0m: $*"; }
function wrn { 1>&2 echo -e "\x1B[1;93mWRN\x1B[0m: $*"; }
function err { 1>&2 echo -e "\x1B[1;31mERR\x1B[0m: $*"; }
if test -d "$1"; then
err "tape: Passed directory, $1"
return 1
elif test -z "$*"; then
err "No files passed."
exit 1
fi
case $1 in
_INFILE) err "Passed raw macro."; exit 1;;
*.txti) redcloth "$1" ;;
*.org) org-ruby --translate html "$1" ;;
*.md) comrak --gfm "$1" ;;
*.html) cat $1 ;;
*.s[ac]ss) err "Told to render $1, shouldn't happen"; exit 1 ;;
*.sh) (inf "Running shellscript $1, I hope you know what you're doing..."; source $1 );;
*) pandoc --columns 168 -t html "$1" || echo "Skipping $i, unknown format" ;;
esac