From d792cfc4f2b6b53bf2174c3f3e3fea147524ede8 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 17 Aug 2025 17:50:03 +0300 Subject: feat!: Update dunbar version The main difference is how the header and footer are handled. Before they were inserted as "include_markup", but now they are as "include". --- dunbar | 2 +- ext/footer.du.html | 15 ------ ext/header.du.html | 128 --------------------------------------------------- ext/meta.awk | 24 ---------- ext/pagenav.awk | 2 +- ext/presentation.awk | 15 ++++-- ext/teaching.awk | 3 ++ generate.sh | 25 ++++++---- html/footer.html | 14 ++++++ html/header.html | 127 ++++++++++++++++++++++++++++++++++++++++++++++++++ meta.awk | 33 +++++++++++++ 11 files changed, 206 insertions(+), 182 deletions(-) delete mode 100644 ext/footer.du.html delete mode 100644 ext/header.du.html delete mode 100644 ext/meta.awk create mode 100644 ext/teaching.awk create mode 100644 html/footer.html create mode 100644 html/header.html create mode 100644 meta.awk diff --git a/dunbar b/dunbar index cd8a136..7159acd 160000 --- a/dunbar +++ b/dunbar @@ -1 +1 @@ -Subproject commit cd8a136447a6a30a2b55acc1f4565eac91fda88f +Subproject commit 7159acd1f9903dd99265a8d127ff95ec17a46842 diff --git a/ext/footer.du.html b/ext/footer.du.html deleted file mode 100644 index 5745200..0000000 --- a/ext/footer.du.html +++ /dev/null @@ -1,15 +0,0 @@ -:text -
- - - -
︽
- - - - - - - diff --git a/ext/header.du.html b/ext/header.du.html deleted file mode 100644 index e272bc5..0000000 --- a/ext/header.du.html +++ /dev/null @@ -1,128 +0,0 @@ -:text - - - - - - - - - - - - - - - - - - - - - - - - [$TITLE] - - - - -
- - - diff --git a/ext/meta.awk b/ext/meta.awk deleted file mode 100644 index 35e4f2b..0000000 --- a/ext/meta.awk +++ /dev/null @@ -1,24 +0,0 @@ -BEGIN { - FS="\t" - while ((getline < ENVIRON["META"]) > 0) { - if ($1 == "") continue - meta_title[$1] = $2 " — Syndamia" - meta_description[$1] = $3 - if (length($3) > 200) - warning("Description for file \"" $1 "\" is longer than 200 characters!", "Shorten the description field in the \"" ENVIRON["META"] "\" file.") - } - FS=" " -} - -FNR == 0 { - STD_FILENAME = substr(FILENAME, length(ENVIRON["GEN_DIR"]) + 2) - - if (STD_FILENAME in meta_title) { - substitutions["TITLE"] = meta_title[STD_FILENAME] - substitutions["DESCRIPTION"] = meta_description[STD_FILENAME] - } - else { - delete substitutions["TITLE"] - delete substitutions["DESCRIPTION"] - } -} diff --git a/ext/pagenav.awk b/ext/pagenav.awk index f1d9212..d910a43 100644 --- a/ext/pagenav.awk +++ b/ext/pagenav.awk @@ -5,7 +5,7 @@ BEGIN { substitutions["pagination_end"] = "`[[url [$start_url] <<]]` || `[< [$prev_link]]`" } -FNR == 0 { +FNR == 1 { # Stats element stats = \ "
" ORS \ diff --git a/ext/presentation.awk b/ext/presentation.awk index 732def8..a3e7bec 100644 --- a/ext/presentation.awk +++ b/ext/presentation.awk @@ -23,9 +23,9 @@ BEGIN { define_div("centered" fontSizes[ind], "centered" fontClass) - define("slide" fontSizes[ind], "
", "
") - define("middle_slide" fontSizes[ind], "
", "
") - define("title_slide" fontSizes[ind], "
", "
") + define("slide" fontSizes[ind], "
", "
") + define("middle_slide" fontSizes[ind], "
", "
") + define("title_slide" fontSizes[ind], "
", "
") } @@ -67,3 +67,12 @@ function define_div(name, class) { if (!class) class = name define(name, "
", "
") } + +FNR == 1 { + slide_number = 0 + substitutions["SLIDEID"] = "slide-0" +} + +/^
"/dev/stderr" +} diff --git a/ext/teaching.awk b/ext/teaching.awk new file mode 100644 index 0000000..07aa590 --- /dev/null +++ b/ext/teaching.awk @@ -0,0 +1,3 @@ +BEGIN { + define("solution-link", "
<", " >
") +} diff --git a/generate.sh b/generate.sh index d2ba7f9..49096fa 100755 --- a/generate.sh +++ b/generate.sh @@ -1,8 +1,10 @@ #!/bin/bash -: ${SRC_DIR:=$PWD/src} +: ${SRC:=$PWD/src} +: ${HEADER:=$PWD/html/header.html} +: ${FOOTER:=$PWD/html/footer.html} : ${GEN_DIR:=./website} -: ${META_FILE:=meta.tsv} # Relative to SRC_DIR +: ${META_FILE:=meta.tsv} # Relative to SRC # 0 Fix hardlinks {{{ while read -r folder @@ -13,7 +15,7 @@ ln "$folder.du" "$folder/index.du" fi done << EOF -$(find "$SRC_DIR" -maxdepth 1 -type d) +$(find "$SRC" -maxdepth 1 -type d) EOF if [ ! "src/favicon.ico" -ef "src/img/favicon.ico" ] then @@ -24,22 +26,25 @@ EOF # }}} # 1. Dunbar source to HTML {{{ mkdir -p "$GEN_DIR" - cp -a "$SRC_DIR/." "$GEN_DIR" + cp -a "$SRC/." "$GEN_DIR" rm "$GEN_DIR/$META_FILE" "$GEN_DIR/."* - META="$SRC_DIR/$META_FILE" - export META GEN_DIR + META="$SRC/$META_FILE" + AWK="mawk" + export HEADER FOOTER META GEN_DIR AWK /usr/bin/env dash ./dunbar/dunbar_awk/dunbar.sh html \ - -o . \ - -e ./ext/meta.awk -e ./ext/attention.awk \ + -i \ + -e ./ext/attention.awk \ -e ./ext/heading-anchors.awk -e ./ext/pagenav.awk \ -e ./ext/icons.awk -e ./ext/presentation.awk \ - -e ./ext/contents.awk \ + -e ./ext/contents.awk -e ./ext/teaching.awk \ -wo \ - -he ./ext/header.du.html -fo ./ext/footer.du.html \ $(find "$GEN_DIR" -type f -name "*.du") # }}} +# 2. Meta handling {{{ + awk -f meta.awk $(find "$GEN_DIR" -type f -name "*.html") +# }}} # 2. Tiny version, strip away styles and other stuff {{{ # TODO # }}} diff --git a/html/footer.html b/html/footer.html new file mode 100644 index 0000000..605da32 --- /dev/null +++ b/html/footer.html @@ -0,0 +1,14 @@ +
+ +
+ +
︽
+ + + + + + + diff --git a/html/header.html b/html/header.html new file mode 100644 index 0000000..294e7cd --- /dev/null +++ b/html/header.html @@ -0,0 +1,127 @@ + + + + + + + + + + + + + + + + + + + + + + + + $TITLE + + + + +
+ + + diff --git a/meta.awk b/meta.awk new file mode 100644 index 0000000..d0aacbb --- /dev/null +++ b/meta.awk @@ -0,0 +1,33 @@ +BEGIN { + FS="\t" + while ((getline < ENVIRON["META"]) > 0) { + if ($1 == "") continue + meta_title[$1] = $2 " \\— Syndamia" + meta_description[$1] = $3 + if (length($3) > 200) + print "Description for file \"" $1 "\" is longer than 200 characters!", "Shorten the description field in the \"" ENVIRON["META"] "\" file." > "/dev/stderr" + } + FS=" " + + HEADER = getfile("./html/header.html") + FOOTER = getfile("./html/footer.html") + + for (i = ARGC; i > 0; --i) { + if (!ARGV[i]) continue + + start = HEADER + FILENAME = substr(ARGV[i], length(ENVIRON["GEN_DIR"]) + 2) + gsub(/\$TITLE/, meta_title[FILENAME], start) + gsub(/\$DESCRIPTION/, meta_description[FILENAME], start) + + print start getfile(ARGV[i]) FOOTER > ARGV[i] + } +} + +function getfile(filename, status, linebuf, filebuf) { + while ((status = getline linebuf < filename) > 0) + filebuf = filebuf linebuf ORS + close(filename) + sub(ORS "$", "", filebuf) + return filebuf +} -- cgit v1.3.1-26-gb76a