From af52a71c9b2d6d66ff00fb39386d8d7a5330b2b0 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Thu, 19 May 2022 11:49:53 -0500 Subject: Initial commit I'm doing content + generation in this ... who knows if it's smart, lol. --- .gitignore | 2 + Makefile | 88 +++++++++++++++++++++++++++++++++ ht.awk | 79 +++++++++++++++++++++++++++++ ht.sh | 66 +++++++++++++++++++++++++ ideas.org | 8 +++ src/_foot.htm | 6 +++ src/_head.htm | 14 ++++++ src/_index.htm | 7 +++ src/beans.html | 21 ++++++++ src/favicon.ht | 15 ++++++ src/gcl/index.html | 21 ++++++++ src/shameless-self-promotion/index.html | 11 +++++ src/static/casa.css | 32 ++++++++++++ src/static/rss.xml | 27 ++++++++++ tmpl.index.htm | 16 ++++++ tmpl.page.htm | 8 +++ 16 files changed, 421 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100755 ht.awk create mode 100755 ht.sh create mode 100644 ideas.org create mode 100644 src/_foot.htm create mode 100644 src/_head.htm create mode 100644 src/_index.htm create mode 100644 src/beans.html create mode 100644 src/favicon.ht create mode 100644 src/gcl/index.html create mode 100644 src/shameless-self-promotion/index.html create mode 100644 src/static/casa.css create mode 100644 src/static/rss.xml create mode 100644 tmpl.index.htm create mode 100644 tmpl.page.htm diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..af8a313 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.tmp +build/ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..5b3cadd --- /dev/null +++ b/Makefile @@ -0,0 +1,88 @@ +## HAT TRICK -*- tab-width: 8; -*- +# (C) 2022 C. Duckworth + +UPLOAD_TARGET = hetzner:/var/www/acdw.casa/ + +SITE_TITLE = acdw.casa + +INPUT = src +BUILD = build +LASTB = .last_build + +HTAWK = ./ht.awk +HTSH = ./ht.sh +HTMK = ht.mk +HT = ${HTAWK} ${HTSH} ${HTMK} + +T = .tmp +TMK = $T/mk +TPG = $T/ps + +PTMPL = tmpl.page.htm +PTMPC = \ + $$(title) \ + $$(body) +PTMPR = \ + $$hb: $$ht ; \ + ${HTAWK} < '$$ht' | \ + env HTTMP='$T' HTENV='$T/\$$<.env' HTOUT='\$$@' \ + ${HTSH} '${PTMPL}' > '\$$@' + +ITMPL = tmpl.index.htm +ITMPC = \ + ${SITE_TITLE} \ + +ITMPR = \ + index.html: ${ITMPL} $$(cat ${TPG}); \ + env HTTMP='$T' HTOUT='\$$@' \ + ${HTSH} "${ITMPL}" < /dev/null > '\$$@' + +TMPL = ${PTMPL} ${ITMPL} +BUILD_INPUTS = ${INPUT}/* ${TMPL} ${HT} + +${BUILD}: ${BUILD_INPUTS} + @touch ${LASTB} + @mkdir -p ${BUILD} + cp -a ${BUILD_INPUTS} $@ + ${MAKE} -C $@ -f ${HTMK} build + +${HTMK}: Makefile ${INPUT}/*.ht $T + @printf '%s' 'Generating "$@"...' + @: > '$@' + @: > '${TPG}' + + @for ht in $$(find ${INPUT} -type f -name '*.ht'); do \ + ht="$$(echo "$$ht" | sed 's#${INPUT}/##')"; \ + hb="$${ht}ml"; \ + printf '%s ' "$$hb" >> "${TPG}"; \ + printf '%s\n' "${PTMPR}"; \ + done >> '$@' + + @printf '%s\n' "${ITMPR}" >> '$@' + @printf "build: $$(cat ${TPG}) index.html" >> '$@' + @printf '%s\n' 'done' + +$T: ; mkdir -p "$@" +${PTMPL}: ; printf '${PTMPC}' > '$@' +${ITMPL}: ; printf '${ITMPC}' > '$@' + +.PHONY: clean clean-build nuke +clean: ; -rm -rf ${BUILD} ${HTMK} $T ${LASTB} +clean-build: + rm -rf '${BUILD}/$T' + for file in ${BUILD}/*; do \ + case "$$file" in \ + *.ht|*.sh|*.htm|*.mk|*.awk) rm -rf "$$file" ;; \ + esac \ + done +nuke: clean ; -rm ${TMPL} + +.PHONY: publish +publish: build clean-build + scp -r ${BUILD}/* '${UPLOAD_TARGET}'; \ + diff --git a/ht.awk b/ht.awk new file mode 100755 index 0000000..5328361 --- /dev/null +++ b/ht.awk @@ -0,0 +1,79 @@ +#!/usr/bin/awk -f +# HAT TRICK +# (C) 2022 C. Duckworth + +# ht.awk converts mostly-html (with some conveniences) to actual html + +function bufpush(s) { + BUF = BUF (BUF ? "\n" : "") s; +} + +function buflush() { + if (BUF) print BUF; + BUF = ""; + if (tag && (tag != "html")) print ""; +} + +function esc(t) { + gsub(/&/, "\\&", t); + gsub(//, "\\>", t); + return t; +} + +/^;/ { sub(/^;/,""); print ""; next; } + +/^/ { # Links (Gemini-style) + link = "" esc($3); + for (i=4;i<=NF;i++) link = link " " esc($i); + link = link ""; + bufpush(link); + next; +} + +/^-/ { # Unordered lists + if (! (tag == "ul")) tag = "ul"; + esc($0); + sub(/^-[ \t]*/, "
  • "); +} + +/^[0-9]+\./ { # Ordered lists + if (! (tag == "ol")) tag = "ol"; + esc($0); + sub(/^[0-9]+\.[ \t]/, "
  • "); +} + +/^>/ { # Blockquotes + if (! (tag == "blockquote")) tag = "blockquote"; + sub(/^>[ \t]*/,""); + esc($0); +} + +/^#+/ { # Headers + match($0, /^#+/); + if (! (tag == "h" RLENGTH)) { + buflush(); + tag = "h" RLENGTH; + } + sub(/^#+[ \t]*/,""); + esc($0); +} + +/^$/ { + buflush(); + tag = ""; +} + +/./ { + if (! tag) tag = "p"; + if (! BUF) bufpush("<" tag ">"); + bufpush($0); +} + +END { buflush(); } diff --git a/ht.sh b/ht.sh new file mode 100755 index 0000000..de58fe1 --- /dev/null +++ b/ht.sh @@ -0,0 +1,66 @@ +#!/bin/sh +# HAT TRICK +# (C) 2022 C. Duckworth + +[ "x$DEBUG" = "xYES" ] && set -x + +: "${HTDAT:=$(date +%s)}" +: "${HTTMP:=/tmp/ht}"; mkdir -p "$HTTMP" +: "${HTENV:=$HTTMP/env-$HTDAT.sh}" +: "${HTBOD:=$HTTMP/bod-$HTDAT.txt}" +export HTDAT HTTMP HTENV HTBOD + +HT_TMPL_COUNT=1 +HT_TMPL_PRE=: + +print() { # print STRING... + ## A sane version of `echo`. + printf '%s\n' "$*" +} + +htt() { # htt FILES... + # Like `cat`, but with templating. + ht_end="ht_main_$HTDAT_$HT_TMPL_COUNT" # be extra double sure + eval "$(print "cat <<$ht_end"; cat "$@"; print; print "$ht_end")" + HT_TMPL_COUNT=$(expr $HT_TMPL_COUNT + 1) +} + +ht_build_env() { # ht_build_env FILE... + print "body() { cat \"$HTBOD\"; }" > "$HTENV" + while read -r line; do + case "$line" in + *@@*:*@@*) # "simple" metadata; just a string + print "$line" | + sed 's/.*@@\([^:]*\): \?\(.*\)@@.*/\1() { print "\2"; }/' + ;; + *@@*::*@@*) # "complex" metadata: can be anything + print "$line" | + sed 's/.*@@\([^:]*\):: \?\(.*\)@@.*/\1() { \2 ; }/' + ;; + esac >> "$HTENV" + # Still print the line to the body (no need to escape or w/e) + print "$line" >> "$HTBOD" + done + env | grep '^HT' | sort | uniq >> "$HTENV" +} + +ht_main() { # main TEMPLATE < INPUT + ## Apply TEMPLATE to INPUT and print it. + # TEMPLATE will be interpreted as a heredoc. + if [ $# -eq 0 ]; then + print "ht.sh TEMPLATE < INPUT" >&2 + exit 1 + fi + + eval "ht_build_env; . \"$HTENV\"; print \"\$(htt \"\$@\")\";"; +} + +# To keep this POSIX-compliant, we can't use a bashism like +# [[ "$0" == # "$BASH_SOURCE[0]" ]]. However, there are still ways to guess +# whether the user is sourcing this file as a library or executing it as a +# script. + +case "$0" in + *ht.sh) ht_main "$@" ;; + *) print "Sourcing ht.sh" ;; +esac diff --git a/ideas.org b/ideas.org new file mode 100644 index 0000000..27b15e5 --- /dev/null +++ b/ideas.org @@ -0,0 +1,8 @@ +#+TITLE: ideas for hat-trick + +* Syntax: ht.awk + +It'd be great to have a format that could triple into HTML, Gemini, and Gopher. Gemini-like, line-based syntax would be easiest to work with, i think. + +The current separation into paragraphs with blocks is a good idea. Also, starting a line with ~<~ /within/ a paragraph could be a good signal that the following is HTML code. Maybe auto-close the tag? + diff --git a/src/_foot.htm b/src/_foot.htm new file mode 100644 index 0000000..287b2ba --- /dev/null +++ b/src/_foot.htm @@ -0,0 +1,6 @@ + + + diff --git a/src/_head.htm b/src/_head.htm new file mode 100644 index 0000000..762965e --- /dev/null +++ b/src/_head.htm @@ -0,0 +1,14 @@ + + + + + + + $(title) + + + + + diff --git a/src/_index.htm b/src/_index.htm new file mode 100644 index 0000000..6b7b809 --- /dev/null +++ b/src/_index.htm @@ -0,0 +1,7 @@ +

    Ahoy! This here is my little home-away-from-home on the interwebs. + I'm currently experimenting with a custom little SSG + I'm calling HAT TRICK. + I should probably throw the source up somewhere, but I haven't yet. +

    + + diff --git a/src/beans.html b/src/beans.html new file mode 100644 index 0000000..ff89934 --- /dev/null +++ b/src/beans.html @@ -0,0 +1,21 @@ +html,body { + min-height: 100vh; + margin:0; padding: 0; +} + +html { + font: 18px serif; + background: #385180; +} + +body { + max-width: 79ch; + padding: 0 2ch; + margin: 0 auto; + background: #405990; + color: white; +} + +a { + color: yellow; +} diff --git a/src/favicon.ht b/src/favicon.ht new file mode 100644 index 0000000..b9df118 --- /dev/null +++ b/src/favicon.ht @@ -0,0 +1,15 @@ +;@@title: Embedded data-url favicon@@ + +You might notice that I have a new favicon on this site. +I didn't want to make a whole nother request, so I took a page from +=> http://flower.codes/2022/05/10/disabling-favicon.html flower.codes +(who disabled their favicon completely) and made my favicon a data uri. + +I thought it might be complicated, but it was really pretty ding dang easy. +I found an easy-to-use +=> https://www.adminbooster.com/tool/data_uri file-to-data-uri converter tool +and uploaded a little image I made in the +GIMP. I tried PNG and GIF. +GIF was much smaller, so that's what I went with. + +Anyway, now you should see a little house on the tab you've loaded this on! Yay. diff --git a/src/gcl/index.html b/src/gcl/index.html new file mode 100644 index 0000000..3357702 --- /dev/null +++ b/src/gcl/index.html @@ -0,0 +1,21 @@ + + + + + Good Choices License + + + +

    Good Choices License

    +

    Everyone is permitted to do whatever they like with this software + without limitation. This software comes without any warranty + whatsoever, but with two pieces of advice:

    + + + diff --git a/src/shameless-self-promotion/index.html b/src/shameless-self-promotion/index.html new file mode 100644 index 0000000..f4c5710 --- /dev/null +++ b/src/shameless-self-promotion/index.html @@ -0,0 +1,11 @@ + + + Shameless self-promotion! + + +

    shameless

    +

    self

    +

    promotion

    +

    what can i say, i'm a cool guy.

    + + diff --git a/src/static/casa.css b/src/static/casa.css new file mode 100644 index 0000000..36bdda0 --- /dev/null +++ b/src/static/casa.css @@ -0,0 +1,32 @@ +html { + min-height: 100vh; + margin:0; padding: 0; +} + +html { + font: 18px serif; +} + +body { + max-width: 79ch; + margin: 0 auto; + padding: 0 2ch; + background: #385180; + color: white; +} + +main { + max-width: 79ch; + padding: 2ch; + margin: auto; + background: #405990; +} + +a { + color: yellow; +} + +footer { + text-align: right; + padding: 1ch 0; +} diff --git a/src/static/rss.xml b/src/static/rss.xml new file mode 100644 index 0000000..44617d8 --- /dev/null +++ b/src/static/rss.xml @@ -0,0 +1,27 @@ + + + + Acdw's Casa + My casa, in the middle of the web + https://acdw.casa + 2022 Case Duckworth + 2022-03-03 + 2022-03-03 + 1800 + + + And we're live + Hi basement + https://acdw.casa/ + 2022-03-03 + + + + Good Choices License + A license for people + https://acdw.casa/gcl/ + 2022-05-13 + + + + diff --git a/tmpl.index.htm b/tmpl.index.htm new file mode 100644 index 0000000..dc90a4d --- /dev/null +++ b/tmpl.index.htm @@ -0,0 +1,16 @@ +$(sed 's#$(title)#acdw.casa#' _head.htm) +
    +

    mi casa es su casa

    +
    +
    +
    + $(htt _index.htm) +
    +
    +

    pages here

    +
      + $(set -x;for p in ".tmp"/*.env; do . "$p"; print "
    • $(title)
    • "; done) +
    +
    +
    +$(htt _foot.htm) diff --git a/tmpl.page.htm b/tmpl.page.htm new file mode 100644 index 0000000..4165681 --- /dev/null +++ b/tmpl.page.htm @@ -0,0 +1,8 @@ +$(htt _head.htm) +
    +

    $(title)

    +
    +
    + $(body) +
    +$(htt _foot.htm) -- cgit 1.4.1-21-gabe81