From f28aae306abf524dbdbbec7e4cedcd2222ba80e1 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Tue, 4 Apr 2023 14:21:07 -0300 Subject: v2: WIP genhtml via envsubst --- v2/src/development/genhtml.sh | 92 +------------------------------------------ v2/src/development/getconf.sh | 21 +++++++--- 2 files changed, 17 insertions(+), 96 deletions(-) (limited to 'v2/src/development') diff --git a/v2/src/development/genhtml.sh b/v2/src/development/genhtml.sh index 6839d23..8950b1d 100755 --- a/v2/src/development/genhtml.sh +++ b/v2/src/development/genhtml.sh @@ -193,93 +193,5 @@ emit_body() { add_headings_anchors } -if false; then - emit_body -fi - - - -# -# Main: generate the HTML to STDOUT. -# - -cat <<-EOF - - - - - - - - - $$title_html - - - - - - - - - - -
- -
-
-
-
- \$(emit_body) -
-EOF -exit - - -# .md.rehtml: -# F="$<"; . "$${F%.md}.conf"; envsubst < src/lib/reamble."$$lang".html > $@ -# -# .md.osthtml: -# F="$<"; . "$${F%.md}.conf"; envsubst < src/lib/ostamble."$$lang".html > $@ -# -# -# -#
-#
-# -# -# -# EOF - -# FIXMEs: -# - feeds -# - link to next and/or previous in -# - validate input variables: regex for date (same as _plugins/linter.rb) -# - `date -d` isn't POSIX -# - parse commonmark and use a custom HTML emitter over
 regex
-# - handle mixture of personal scripts
+envsubst < src/lib/preamble.html
+envsubst < src/lib/postamble.html
diff --git a/v2/src/development/getconf.sh b/v2/src/development/getconf.sh
index 4b615a8..aa90706 100755
--- a/v2/src/development/getconf.sh
+++ b/v2/src/development/getconf.sh
@@ -99,23 +99,32 @@ escape() {
 	# shellcheck source=/dev/null
 	. src/lib/base."$lang".conf
 
-	title="${title:-"$site_name"}"
+	if [ -z "${title:-}" ]; then
+		title="${site_name:?}"
+		printf 'title="%s"\n' "$(printf '%s' "$title" | escape)"
+	fi
+
+	if [ -z "${date:-}" ]; then
+		printf 'date_formatted="%s"\n' "$(LANG="$lang" date -d "${date:?}" +"${date_fmt:?}" | escape)"
+	fi
+
 	url_part="$(printf '%s' "${FILENAME%.md}.html" | sed 's|^src/content/||')"
 
-	printf 'title="%s"\n' "$(printf '%s' "$title" | escape)"
 	printf 'title_html="%s"\n' "$(printf '%s' "$title" | htmlesc | escape)"
 	printf 'filename="%s"\n' "$FILENAME"
 	printf 'url_part="%s"\n' "$url_part"
 	printf 'url="%s"\n' "$(url-for "$url_part" | absolute)"
-	printf 'date_formatted="%s"\n' "$(LANG="$lang" date -d "${date:?}" +"${date_fmt:?}" | escape)"
 	printf 'mailto_uri="%s%s"\n' "${mailto_uri_prefix:?}" "$(uri "$title")"
 	printf 'discussions_url="%s%s"\n' "${discussions_url_prefix:?}" "$(uri "$title")"
 	printf 'sourcecode_url="%s%s"\n' "${sourcecode_url_prefix:?}" "$FILENAME"
 
-	printf 'lang_url="%s"\n' "$(url-for "$lang"/)"
+	printf 'style_url="%s"\n'   "$(url-for -g 'style.css')"
+	printf 'favicon_url="%s"\n' "$(url-for -g 'favicon.svg')"
 
-	printf 'style_url="%s"\n' "$(url-for 'style.css')"
-	printf 'favicon_url="%s"\n' "$(url-for 'favicon.svg')"
+	# FIXME: special treatment of root
+	printf 'homepage_url="%s"\n' "$(url-for '/')"
+	
+	printf 'about_url="%s"\n' "$(url-for "${about_url_name:?}")"
 
 	rm -f "$FILENAME".tmp
 } | grep . | sed 's|^|export |'
-- 
cgit v1.2.3