From 4cd2cf07d029b33103c898870f164bb9fc3d043a Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Thu, 22 Sep 2022 15:55:03 -0500 Subject: bleh --- shite | 50 ++++++++++++++++++++++---------------------------- 1 file changed, 22 insertions(+), 28 deletions(-) diff --git a/shite b/shite index 74bd9af..951498b 100755 --- a/shite +++ b/shite @@ -2,38 +2,26 @@ # shite --- shit out a site # by C. Duckworth -dog() { - while IFS= read -r line; do - printf '%s\n' "$line" - done -} - expand() { end="expand_$(date +%s)_${count:=0}" eval "$( - echo "dog <<$end" - dog <"$1" + echo "cat <<$end" + cat "$1" echo echo "$end" )" && count=$((count + 1)) } -body() { - # because the metadata is in a comment, we can just - dog - # the whole input. -} - phtml() { sed -e '/./{H;1h;$!d;};x;s,^[ \n\t]\+,,;s,^[^<].*,

&

,' } meta() { - tmp="/tmp/$file.meta" - echo "$tmp" >>/tmp/shite.tmp - test -f "$tmp" || - sed -n '//p' >"$tmp" - sed -n "s/^[ \t]*$1:[ \t]*//p" "$tmp" + metaf="/tmp/$file.meta" + echo "$metaf" >>"$RMF" + test -f "$metaf" || + sed '//q' >"$metaf" + sed -n "s/^[ \t]*$1:[ \t]*//p" <"$metaf" } title() { @@ -45,15 +33,19 @@ pubdate() { } filters() { - body | phtml + phtml } pages() { for file; do echo >&2 "[build] $file" - mkdir -p "$OUT"/"${file%.htm}" - filters <"$file" | - expand .template.html >"$OUT"/"${file%.htm}"/index.html + outd="$OUT/${file%.htm}" + outf="$outd/index.html" + datf="/tmp/$file.dat" + echo "$datf" >>"$RMF" + mkdir -p "$outd" + filters <"$file" >"$datf" + expand .template.html <"$datf" >"$outf" done } @@ -64,7 +56,7 @@ index() { done | expand .index.html >"$OUT"/index.html } -feed() { +feed() { # generates RSS 2.0 for file; do echo >&2 "[feed] $file" echo "" @@ -79,7 +71,7 @@ feed() { } usage() { - dog < :: USAGE :: @@ -100,9 +92,9 @@ EOF cleanup() { while read f; do - rm "$f" - done /dev/null 2>&1 + done <"$RMF" + rm "$RMF" } main() { @@ -110,6 +102,7 @@ main() { DOMAIN="${SHITE_DOMAIN:-${PWD##*/}}" SOURCE="$PWD" OUT=out + RMF=/tmp/shite.rm while getopts d:C:o:h opt; do case "$opt" in d) DOMAIN="$OPTARG" ;; @@ -123,6 +116,7 @@ main() { cd "$SOURCE" mkdir -p "$OUT" + alias body=cat test -f ./.shite.sh && . ./.shite.sh pages *.htm index *.htm -- cgit 1.4.1-21-gabe81