From e7254223846dbec352628aa9d156e0fe323a4e93 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Fri, 27 May 2022 13:27:21 -0500 Subject: New post, asset moving, dir-locals, etc. --- Makefile | 8 +++-- asset/casa.css | 36 ++++++++++++++++++++ ht.awk | 24 ++++++++++++- ht.sh | 7 ++-- src/.dir-locals.el | 4 +++ src/_head.htm | 2 +- src/_index.htm | 3 +- src/paper-airplane-day-and-two-fire-alarms.ht | 49 +++++++++++++++++++++++++++ src/static/casa.css | 32 ----------------- src/static/rss.xml | 27 --------------- src/twtxt.ht | 22 ++++++++++++ 11 files changed, 146 insertions(+), 68 deletions(-) create mode 100644 asset/casa.css create mode 100644 src/.dir-locals.el create mode 100644 src/paper-airplane-day-and-two-fire-alarms.ht delete mode 100644 src/static/casa.css delete mode 100644 src/static/rss.xml create mode 100644 src/twtxt.ht diff --git a/Makefile b/Makefile index 537fabe..328e634 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,7 @@ UPLOAD_TARGET = hetzner:/var/www/acdw.casa/ SITE_TITLE = acdw.casa INPUT = src +ASSET = asset BUILD = build HTAWK = ./ht.awk @@ -39,7 +40,7 @@ ITMPC = \ done) \ ITMPR = \ - index.html: ${ITMPL} $$(cat ${TPG}); \ + index.html: ${ITMPL} _index.htm ${INCLUDES} $$(cat ${TPG}); \ env HTTMP='$T' HTOUT='\$$@' \ ${HTSH} "${ITMPL}" < /dev/null > '\$$@' @@ -50,7 +51,7 @@ RTMPR = \ ${HTSH} "${RTMPL}" < /dev/null > '\$$@' TMPL = ${PTMPL} ${ITMPL} ${RTMPL} -BUILD_INPUTS = ${INPUT}/* ${TMPL} ${HT} +BUILD_INPUTS = ${INPUT}/* ${ASSET}/* ${TMPL} ${HT} RSYNCEXCLUDE = \ "*.ht" \ @@ -60,7 +61,8 @@ RSYNCEXCLUDE = \ "*.awk" \ "*.bod.txt" \ "tmpl.*" \ - "tmp/" + "tmp/" \ + "tw.txt" RSYNCEXCLUDEFILE = ${BUILD}/.rsync-exclude RSYNC = rsync -auvz --exclude-from="${RSYNCEXCLUDEFILE}" --delete diff --git a/asset/casa.css b/asset/casa.css new file mode 100644 index 0000000..47f496f --- /dev/null +++ b/asset/casa.css @@ -0,0 +1,36 @@ +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; +} + +code { + color: #c0ffee; +} diff --git a/ht.awk b/ht.awk index faa729d..a382ae7 100755 --- a/ht.awk +++ b/ht.awk @@ -11,7 +11,8 @@ function bufpush(s) { function buflush() { if (BUF) print BUF; BUF = ""; - if (tag && (tag != "html")) print ""; + if (tag && (tag != "html") && (tag != "raw")) + print ""; } function esc(t) { @@ -19,6 +20,7 @@ function esc(t) { gsub(/&/, "\\&", t); gsub(//, "\\>", t); + sub(/^ /, "\\ ", t); return t; } @@ -30,7 +32,21 @@ function esc(t) { next; } +/^```$/ { # Raw block + if (! (tag == "raw")) { + tag = "raw"; + getline; + bufpush("
" $0);
+    } else {
+        bufpush("
"); + buflush(); + tag = ""; + } + next; +} + /^=>/ { # Links (Gemini-style) + if (tag == "raw") next; link = "" $3; for (i=4;i<=NF;i++) link = link " " $i; link = link ""; @@ -39,21 +55,25 @@ function esc(t) { } /^-/ { # Unordered lists + if (tag == "raw") next; if (! (tag == "ul")) tag = "ul"; sub(/^-[ \t]*/, "
  • "); } /^[0-9]+\./ { # Ordered lists + if (tag == "raw") next; if (! (tag == "ol")) tag = "ol"; sub(/^[0-9]+\.[ \t]/, "
  • "); } /^>/ { # Blockquotes + if (tag == "raw") next; if (! (tag == "blockquote")) tag = "blockquote"; sub(/^>[ \t]*/,""); } /^#+/ { # Headers + if (tag == "raw") next; match($0, /^#+/); if (! (tag == "h" RLENGTH)) { buflush(); @@ -63,6 +83,7 @@ function esc(t) { } /^$/ { + if (tag == "raw") next; buflush(); tag = ""; } @@ -70,6 +91,7 @@ function esc(t) { /./ { if (! tag) tag = "p"; if (! BUF) bufpush("<" tag ">"); + if (tag == "raw") $0 = esc($0); bufpush($0); } diff --git a/ht.sh b/ht.sh index 9c3302f..e874e3c 100755 --- a/ht.sh +++ b/ht.sh @@ -27,7 +27,7 @@ htt() { # htt FILES... ht_build_env() { # ht_build_env FILE... print "body() { cat \"$HTBOD\"; }" > "$HTENV" - : > "$HTBOD"; # clear out body + : > "$HTBOD"; # clear while read -r line; do case "$line" in *@@*:*@@*) # "simple" metadata; just a string @@ -38,7 +38,8 @@ ht_build_env() { # ht_build_env FILE... print "$line" | sed 's/.*@@\([^:]*\):: \?\(.*\)@@.*/\1() { \2 ; }/' ;; - esac >> "$HTENV" + esac | + sed '/%s() {.*}/d' >> "$HTENV" # Still print the line to the body (no need to escape or w/e) print "$line" >> "$HTBOD" done @@ -53,7 +54,7 @@ ht_main() { # main TEMPLATE < INPUT exit 1 fi - eval "ht_build_env; . \"$HTENV\"; print \"\$(htt \"\$@\")\";"; + eval "ht_build_env; . \"$HTENV\"; htt \"\$@\";"; } # To keep this POSIX-compliant, we can't use a bashism like diff --git a/src/.dir-locals.el b/src/.dir-locals.el new file mode 100644 index 0000000..8e332c0 --- /dev/null +++ b/src/.dir-locals.el @@ -0,0 +1,4 @@ +;;; Directory Local Variables +;;; For more information see (info "(emacs) Directory Variables") + +((fundamental-mode . ((compile-command . "make build")))) diff --git a/src/_head.htm b/src/_head.htm index e8ec1cc..0eef7ac 100644 --- a/src/_head.htm +++ b/src/_head.htm @@ -8,7 +8,7 @@ $(title) - + diff --git a/src/_index.htm b/src/_index.htm index 6b7b809..918edf5 100644 --- a/src/_index.htm +++ b/src/_index.htm @@ -1,7 +1,8 @@

    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. + I should probably throw the source up somewhere, but I haven't yet. + Download the source here!

    diff --git a/src/paper-airplane-day-and-two-fire-alarms.ht b/src/paper-airplane-day-and-two-fire-alarms.ht new file mode 100644 index 0000000..58720ed --- /dev/null +++ b/src/paper-airplane-day-and-two-fire-alarms.ht @@ -0,0 +1,49 @@ +;@@title: Paper airplane day and two fire alarms@@ +;@@date: 2022-05-26@@ + +Apparently, today is National Paper Airplane Day, so we had a little paper +airplane contest at work. It was quite fun, though my go-to airplane style +didn't win over the YouTube-d and other "professionally"-done airplanes. + +We also had a potluck with my department and another, and in preparation the +ovens set off two fire alarms. The first was totally charred french bread and +the second was some drippings that were left on foil in the oven for who knows +how long. Quite annoying, but the potluck turned out quite well! + +I've also sold my desk as we prepare for our move, and I'm looking at others. +Thinking an Ikea number, maybe. + +I'm back on nyan-mode in my mode-line. Oh, I need to remember the +actually-selected-window package, which I wrote I belive +for nyan-mode! I'll do that when I'm done here. + +I also wrote a little function to make it easier to post on this blog. Here it +is: + +``` +(defun blog-post (title &optional date) + "Make a new blog post, with TITLE on DATE." + (interactive (list (read-string "Title: ") + (format-time-string "%F"))) + (let ((blog-directory (expand-file-name "~/src/hat-trick/src/")) + (metadata-format ";@@%s: %s@@\n") + (slug (string-trim (downcase (replace-regexp-in-string "[^[:alnum:]]" + "-" title)) + "-" "-"))) + (find-file (expand-file-name (concat slug ".ht") blog-directory)) + (insert (format metadata-format "title" title)) + (when date + (insert (format metadata-format "date" date))) + (insert "\n"))) +``` + +I think the next thing I should do is make a major-mode ... or maybe I should +just use web-mode.... + +And of course, I need to update the syntax of these .ht files. They're +okay, but I think I could improve them in a few ways. Not that I've +figured out what those ways are, lol. + +
    + +Wow, this was a long one! That's good, I spose :) diff --git a/src/static/casa.css b/src/static/casa.css deleted file mode 100644 index 36bdda0..0000000 --- a/src/static/casa.css +++ /dev/null @@ -1,32 +0,0 @@ -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 deleted file mode 100644 index 44617d8..0000000 --- a/src/static/rss.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - 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/src/twtxt.ht b/src/twtxt.ht new file mode 100644 index 0000000..7ae86c9 --- /dev/null +++ b/src/twtxt.ht @@ -0,0 +1,22 @@ +;@@title: TwTxt ? What's next!?@@ +;@@date: 2022-05-25@@ + +Whoa, two posts in one day. Better be careful, lol. + +Anyway, this is to say I've also got a +=> tw.txt twtxt +set up as well, and even forked +=> https://github.com/duckwork/twtxt-el twtxt.el +to work for my needs! + +Luckily, rsync's --delete flag +doesn't do anything with excluded files by default, so I can +just throw it in the site root and have a grand ol' time. + +Still to do: + +- Finalize hat-trick markup +- Figure out a way to cross-post to gemini and gopher too, why not +- Write more content? I suppose? +- ... +- Profit!!! -- cgit 1.4.1-21-gabe81