From 1716448358de81f4c9d970e7f2e57ac581717af2 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Fri, 2 Sep 2022 13:17:36 -0300 Subject: v2/: Centralize all env vars in the generated *.entry-env file --- v2/src/bin/extract | 22 ++++++++++++++++++++++ v2/src/development/config.env.in | 1 + v2/src/development/genhtml.sh | 29 ++--------------------------- 3 files changed, 25 insertions(+), 27 deletions(-) (limited to 'v2/src') diff --git a/v2/src/bin/extract b/v2/src/bin/extract index 4380be7..a086264 100755 --- a/v2/src/bin/extract +++ b/v2/src/bin/extract @@ -87,6 +87,7 @@ case "$TYPE" in ' "$FILENAME" ;; env) + cat src/development/config.env awk ' /^---$/ { if (++separator > 1) { @@ -99,6 +100,27 @@ case "$TYPE" in { print } ' "$FILENAME" printf "FILENAME='%s'\n" "$FILENAME" + cat <<-'REAL_EOF' + TITLE="${TITLE:-$SITE_NAME}" + + URI_TITLE="$(printf '%s' "$TITLE" | uri)" + + URL="$( + printf '%s' "$FILENAME" | + sed \ + -e 's|^src/content/||' \ + -e 's|md$|html|' + )" + + PREAMBLE="$(cat < + Posted on +

+ EOF + )" + REAL_EOF ;; *) printf 'Bad value for TYPE: "%s".\n\n' \ diff --git a/v2/src/development/config.env.in b/v2/src/development/config.env.in index 18d5367..ca2afe7 100644 --- a/v2/src/development/config.env.in +++ b/v2/src/development/config.env.in @@ -1,5 +1,6 @@ #!/bin/sh +SITE_NAME="EuAndreh's website" FQDN='@FQDN@' BASE_URL='@BASE_URL@' DATE_FMT='+%B %-d, %Y' diff --git a/v2/src/development/genhtml.sh b/v2/src/development/genhtml.sh index bcac28c..e4c6d1a 100755 --- a/v2/src/development/genhtml.sh +++ b/v2/src/development/genhtml.sh @@ -85,6 +85,8 @@ shift $((OPTIND - 1)) FILENAME="${1:-}" eval "$(assert-arg "$FILENAME" 'FILENAME')" +. "${FILENAME%.md}.entry-env" + # # Utility functions @@ -218,33 +220,6 @@ emit_body() { } -# -# Environment variables -# - -. src/development/config.env - -eval "$( - awk ' - /^---$/ { if (++separator > 1) exit; else next; } - { print } - ' "$FILENAME" -)" - -SITE_NAME="EuAndreh's website" -TITLE="${TITLE:-$SITE_NAME}" -URI_TITLE="$(printf '%s' "$TITLE" | uri)" -URL="$(printf '%s' "$FILENAME" | sed -e 's|^src/content/||' -e 's|md$|html|')" - -PREAMBLE="$( - cat <<-EOF - # $TITLE - -

- Posted on -

- EOF -)" -- cgit v1.2.3