diff options
| Commit | d792cfc4f2b6b53bf2174c3f3e3fea147524ede8 (patch) | |
|---|---|---|
| Author | 2025-08-17 17:50:03 +0300 | |
| Committer | 2025-08-17 17:50:03 +0300 | |
| Files | 3c9fba8f4c7e848df3c4a6f0d646b74190632b50 | |
| syndamia.com-d792cfc4f2b6b53bf2174c3f3e3fea147524ede8.tar syndamia.com-d792cfc4f2b6b53bf2174c3f3e3fea147524ede8.tar.gz syndamia.com-d792cfc4f2b6b53bf2174c3f3e3fea147524ede8.zip | ||
| Parent | 3b29d095293d5e015a491061c190a68f6ab4014b (diff) | |
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".
9 files changed, 67 insertions, 43 deletions
| m--------- | dunbar | 0 | ||||
| -rw-r--r-- | ext/meta.awk | 24 | ||||
| -rw-r--r-- | ext/pagenav.awk | 2 | ||||
| -rw-r--r-- | ext/presentation.awk | 15 | ||||
| -rw-r--r-- | ext/teaching.awk | 3 | ||||
| -rwxr-xr-x | generate.sh | 25 | ||||
| -rw-r--r-- | html/footer.html (renamed from ext/footer.du.html) | 1 | ||||
| -rw-r--r-- | html/header.html (renamed from ext/header.du.html) | 7 | ||||
| -rw-r--r-- | meta.awk | 33 |
diff --git a/dunbar b/dunbar -Subproject cd8a136447a6a30a2b55acc1f4565eac91fda88 +Subproject 7159acd1f9903dd99265a8d127ff95ec17a4684 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 = \ " <div id=\"pagenav-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], "<div id=\"[SLIDEID]\" class=\"slide" fontClass "\">", "</div>") - define("middle_slide" fontSizes[ind], "<div id=\"[SLIDEID]\" class=\"slide centered-slide" fontClass "\"><div></div><div>", "</div><div></div></div>") - define("title_slide" fontSizes[ind], "<div id=\"[SLIDEID]\" class=\"slide centered-slide centered" fontClass "\"><div></div><div>", "</div><div></div></div>") + define("slide" fontSizes[ind], "<div id=\"[$SLIDEID]\" class=\"slide" fontClass "\">", "</div>") + define("middle_slide" fontSizes[ind], "<div id=\"[$SLIDEID]\" class=\"slide centered-slide" fontClass "\"><div></div><div>", "</div><div></div></div>") + define("title_slide" fontSizes[ind], "<div id=\"[$SLIDEID]\" class=\"slide centered-slide centered" fontClass "\"><div></div><div>", "</div><div></div></div>") } @@ -67,3 +67,12 @@ function define_div(name, class) { if (!class) class = name define(name, "<div class=\"" class "\">", "</div>") } + +FNR == 1 { + slide_number = 0 + substitutions["SLIDEID"] = "slide-0" +} + +/^<div id="\[SLIDEID\]"/ { + print sub(/\[SLIDEID\]/, "slide-" slide_number++) >"/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", "<div class=\"exercise-solution\"><", " ></div>") +} 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/ext/footer.du.html b/html/footer.html index 5745200..605da32 100644 --- a/ext/footer.du.html +++ b/html/footer.html @@ -1,4 +1,3 @@ -:text <div class="gap"></div> <footer> Unless stated otherwise - <a href="/licensing.html">CC BY-SA 4.0</a> - <a href="/about">Kamen</a> @ <a href="/">syndamia.com</a> diff --git a/ext/header.du.html b/html/header.html index e272bc5..294e7cd 100644 --- a/ext/header.du.html +++ b/html/header.html @@ -1,4 +1,3 @@ -:text <!DOCTYPE html> <html lang="en"> @@ -18,11 +17,11 @@ <meta name="description" content="[$DESCRIPTION]"> <!-- Thanks https://stackoverflow.com/a/25093272/12036073 --> <meta prefix="og: http://ogp.me/ns#" property="og:type" content="website"> - <meta prefix="og: http://ogp.me/ns#" property="og:title" content="[$TITLE]"> - <meta prefix="og: http://ogp.me/ns#" property="og:description" content="[$DESCRIPTION]"> + <meta prefix="og: http://ogp.me/ns#" property="og:title" content="$TITLE"> + <meta prefix="og: http://ogp.me/ns#" property="og:description" content="$DESCRIPTION"> <meta prefix="og: http://ogp.me/ns#" property="og:image" content="https://syndamia.com/img/meta-banner.png"> <meta prefix="og: http://ogp.me/ns#" property="og:url" content="https://syndamia.com"> - <title>[$TITLE]</title> + <title>$TITLE</title> </head> <body id="content-wrapper" text="black" bgcolor="white" link="#336700" vlink="#336700"> <nav id="sidebar"> 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 +} |