From 05d812d91ec3a1d66f630afaf6a26eb0d4df12a7 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Mon, 11 Mar 2024 23:00:20 -0500 Subject: First commit --- .gitignore | 3 + ll | 118 +++++++++++++++++++++++++++++++++++++ things-im-doing-instead-of-work.ul | 7 +++ types-of-lists-ll-supports.dl | 13 ++++ 4 files changed, 141 insertions(+) create mode 100644 .gitignore create mode 100755 ll create mode 100644 things-im-doing-instead-of-work.ul create mode 100644 types-of-lists-ll-supports.dl diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9c25374 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*.xml +*.html +index.al \ No newline at end of file diff --git a/ll b/ll new file mode 100755 index 0000000..cd3fee2 --- /dev/null +++ b/ll @@ -0,0 +1,118 @@ +#!/bin/sh + +# Config +BASE_URL=. +SITE_TITLE="a listlog" +SITE_COPYRIGHT="Case Duckworth" +BACK_LINK=index.html,back + +wrap() { + title="$(sed 1q "$1")" + cat < +$title + + + +

$title

+HEAD + cat + cat < + + +FOOT +} + +# Library +list()(tag="$1";shift;echo "<$tag>"; sed 1d|awk "$@"; echo "") +# unordered list +ul()(list ul '/^$/{next}{printf "
  • %s
  • \n",$0}') +# ordered list +ol()(list ol '/^$/{next}{printf "
  • %s
  • \n",$0}') +# anchor (link) list +al()(list ul -F"\n" -vRS= '{printf "
  • %s
  • \n",$1,$2}') +# definition list +dl()(list dl -F"\n" -vRS= '{printf "
    %s
    \n
    %s
    \n",$1,$2}') + +rss() { + cat < + +$(sed 1q index.al) + + +$BASE_URL +$SITE_COPYRIGHT +$(date +%FT%TZ) +HEAD + # entries + awk -F"\n" -vRS= \ + -vbase="$BASE_URL" \ + -vauthor="$SITE_COPYRIGHT" \ + 'NR==1{next} +{ url=$1; title=$2; + file=url; sub(base "/", "", file) + printf "\n%s\n", url + printf "\n", url + printf "%s\n", title + printf "%s\n", author + printf "%s\n", updated(file) + printf "\n", + slurp(file) + printf "\n" +} +function updated (file) { + cmd = "stat -c %y " file " 2>/dev/null" + cmd = cmd " || stat -f %Sm -t %FT%TZ " file " 2>/dev/null" + cmd | getline upd + close(cmd) + return upd +} +function slurp (file, out, bodyp) { + oldRS=RS; RS="\n" + while ((getline < file) > 0) { + if ($0 ~ /LIST_END/) bodyp = 0 + if (bodyp) out = out (out?"\n":"") $0 + if ($0 ~ /LIST_START/) bodyp = 1 + } + RS=oldRS + return out +}' + cat < +FOOT +} + +# Main +main() { + printf "%s\n\n" "$SITE_TITLE" > index.al + ls -t *.ul *.dl *.ol *.al 2>/dev/null | + sed '/index.al/d' | + while read -r lst + do + printf >&2 "Processing %s..." "$lst" + "${lst##*.}" < "$lst" | + wrap "$lst" "$BACK_LINK" > "${lst%%.*}.html" + echo "$BASE_URL/${lst%%.*}.html" >> index.al + echo "$(sed 1q "$lst")" >> index.al + echo >> index.al + echo >&2 ok + done + printf >&2 "Processing index..." + al < index.al | wrap index.al > index.html && + echo >&2 ok + printf >&2 "Processing rss..." + rss < index.al > feed.xml && + echo >&2 ok +} + +main "$@" diff --git a/things-im-doing-instead-of-work.ul b/things-im-doing-instead-of-work.ul new file mode 100644 index 0000000..4ee8ba8 --- /dev/null +++ b/things-im-doing-instead-of-work.ul @@ -0,0 +1,7 @@ +Things I'm doing instead of work + +writing a linkblog software +drinking tea +chatting with friends +existential angst +stressing about work \ No newline at end of file diff --git a/types-of-lists-ll-supports.dl b/types-of-lists-ll-supports.dl new file mode 100644 index 0000000..93b0a36 --- /dev/null +++ b/types-of-lists-ll-supports.dl @@ -0,0 +1,13 @@ +Types of lists ll supports + +all lists +all lists are files with a header line at the top containing the list's title, then a series of lines forming the list items. items are at most 2 lines. blank lines are ignored. oh and list items are just html. + +ordered lists, unordered lists +these are the regular <ol> and <ul> lists you know and love. just put one item on each line. + +anchor (link) lists +make a list of links. items are separated by blank space and are 2 lines: the anchor (url) and its description. + +definition lists +the lesser-known html-standard list type. same as anchor lists, but with <dt> on line one and <dd> on line two. \ No newline at end of file -- cgit 1.4.1-21-gabe81