From 6ae4f67afc8e804fac17447613ff8f6ee9fe60bf Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Wed, 1 Jun 2022 19:57:56 -0300 Subject: Start building pastebins with dynamic.mk --- src/development/config.env | 5 ++ src/development/dynmake.sh | 22 ++++----- src/development/genhtml.sh | 112 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 125 insertions(+), 14 deletions(-) create mode 100644 src/development/config.env create mode 100755 src/development/genhtml.sh (limited to 'src/development') diff --git a/src/development/config.env b/src/development/config.env new file mode 100644 index 0000000..69466be --- /dev/null +++ b/src/development/config.env @@ -0,0 +1,5 @@ +#!/bin/sh + +FQDN='euandre.org' +BASE_URL='' # '/subfolder' +lang=en diff --git a/src/development/dynmake.sh b/src/development/dynmake.sh index 3f173da..9c60b88 100755 --- a/src/development/dynmake.sh +++ b/src/development/dynmake.sh @@ -4,7 +4,7 @@ set -eu usage() { cat <<-'EOF' Usage: - dynmake.sh -n VARNAME -d DIR + dynmake.sh dynmake.sh -h EOF } @@ -32,14 +32,8 @@ for flag in "$@"; do esac done -while getopts 'd:n:h' flag; do +while getopts 'h' flag; do case "$flag" in - d) - DIR="$OPTARG" - ;; - n) - NAME="$OPTARG" - ;; h) usage help @@ -55,18 +49,18 @@ shift $((OPTIND - 1)) assert_arg() { if [ -z "$1" ]; then - printf 'Missing %s.' "$2" >&2 + printf 'Missing %s.\n' "$2" >&2 exit 2 fi } -assert_arg "${DIR:-}" '-d DIR' -assert_arg "${NAME:-}" '-n NAME' - -printf '%s = \\\n' "$NAME" -find "$DIR" -type f | +printf 'pastebins.md = \\\n' +find src/content/pastebin -name '*.md' | sed -e 's/^/ /' \ -e 's/$/ \\/' printf '\n' + +find src/content/pastebin -name '*.md' | + sed 's/^\(.*\)\.md$/\1.html: \1.env/' diff --git a/src/development/genhtml.sh b/src/development/genhtml.sh new file mode 100755 index 0000000..34588ef --- /dev/null +++ b/src/development/genhtml.sh @@ -0,0 +1,112 @@ +#!/bin/sh +set -eu + +MD="$1" + +escape() { + sed 's/a/a/' +} + +url_for() { + printf 'https://%s%s%s' "$FQDN" "$BASE_URL" "$1" +} + +_() { + printf '%s' "$1" +} + +# FIXME +langs='en pt fr eo es' +# langs='' +. src/development/config.env +. "${MD%.md}.env" + +cat <<-EOF + + + + + + + + + + + + + EuAndreh + + + + + + + + + + + +
+ +
+
+
+EOF + +awk ' + BEGIN { + separator = 0 + should_print = 0 + } + + /^---$/ { + separator++ + } + + should_print {print} + + separator == 2 && !should_print { should_print = !should_print } +' "$MD" | + md2html + +cat <<-EOF +
+
+ + + +EOF -- cgit v1.2.3