diff options
| author | EuAndreh <eu@euandre.org> | 2023-04-05 16:14:00 -0300 |
|---|---|---|
| committer | EuAndreh <eu@euandre.org> | 2023-04-05 16:14:00 -0300 |
| commit | 24e24b49fb6375189cfa527a113eb965087a293a (patch) | |
| tree | fc75f8267a22f6473432ee6b07c4013561c303dc /v2/src/development | |
| parent | v2: Recove h[2-6] anchor link and icon (diff) | |
| download | euandre.org-24e24b49fb6375189cfa527a113eb965087a293a.tar.gz euandre.org-24e24b49fb6375189cfa527a113eb965087a293a.tar.xz | |
v2: Support Atom feeds and collection translations
Diffstat (limited to '')
| -rwxr-xr-x | v2/src/bin/conf (renamed from v2/src/development/genconf.sh) | 42 | ||||
| -rwxr-xr-x | v2/src/bin/html (renamed from v2/src/development/genhtml.sh) | 21 | ||||
| -rwxr-xr-x | v2/src/bin/security-txt (renamed from v2/src/development/security-txt.sh.in) | 24 | ||||
| -rw-r--r-- | v2/src/lib.sh (renamed from v2/src/development/lib.sh) | 0 |
4 files changed, 49 insertions, 38 deletions
diff --git a/v2/src/development/genconf.sh b/v2/src/bin/conf index f9dfc14..ac02d98 100755 --- a/v2/src/development/genconf.sh +++ b/v2/src/bin/conf @@ -5,8 +5,8 @@ set -eu usage() { cat <<-'EOF' Usage: - src/development/genconf.sh FILENAME - src/development/genconf.sh -h + conf FILENAME + conf -h EOF } @@ -28,7 +28,7 @@ help() { Get the "frontmatter" of src/f.conf: - $ src/development/genconf.sh src/f.md > src/f.conf + $ conf src/f.md > src/f.conf EOF } @@ -63,7 +63,7 @@ while getopts 'h' flag; do done shift $((OPTIND - 1)) -. src/development/lib.sh +. src/lib.sh FILENAME="${1:-}" eval "$(assert_arg "$FILENAME" 'FILENAME')" @@ -73,7 +73,7 @@ escape() { sed 's|\([`"$]\)|\\\1|g' } -tee "$FILENAME".tmp < src/lib/base-conf +tee "$FILENAME".tmp < src/lib/base.conf DELIMITER=0 while read -r line; do if [ "$line" = '---' ]; then @@ -95,6 +95,11 @@ done < "$FILENAME" | tee -a "$FILENAME".tmp . "$FILENAME".tmp rm -f "$FILENAME".tmp + +lang="$(lang-for "$FILENAME")" +export lang +printf 'export lang="%s"\n' "$lang" + cat src/lib/base."${lang:?}".conf # shellcheck source=/dev/null . src/lib/base."$lang".conf @@ -104,19 +109,30 @@ if [ -z "${title:-}" ]; then fi if [ -n "${date:-}" ]; then - formatted_date="$(LANG="$lang" date -d "${date:?}" +"${date_fmt:?}")" + date_iso="$(date -ud "${date:?}" -Is)" + printf 'export date_iso="%s"\n' "$date_iso" + + formatted_date="$(LANG="$lang" date -ud "${date:?}" +"${date_fmt:?}")" export formatted_date printf 'export date_html="%s"\n' "$(envsubst < src/lib/date."$lang".html | escape)" + + echo "${FILENAME%.md}.xmlentry" > "$(dirname "$FILENAME")/$date_iso.sortdata" + touch "${FILENAME%.md}.sortref" fi if [ -n "${update:-}" ]; then - formatted_update="$(LANG="$lang" date -d "${update:?}" +"${date_fmt:?}")" + update_iso="$(date -ud "${update:?}" -Is)" + printf 'export update_iso="%s"\n' "$update_iso" + + formatted_update="$(LANG="$lang" date -ud "${update:?}" +"${date_fmt:?}")" export formatted_update printf 'export update_html="%s"\n' "$(envsubst < src/lib/update."$lang".html | escape)" + + printf 'export update_xml=" <updated>%s</updated>"\n' "$update_iso" fi -url_part="$(printf '%s' "${FILENAME%.md}.html" | sed 's|^src/content/||')" +url_part="$(printf '%s' "${FILENAME%.md}.html" | sed "s|^$CONTENT_PREFIX||")" title_uri="$(uri "$title")" printf 'export title_html="%s"\n' "$(printf '%s' "$title" | htmlesc | escape)" @@ -127,13 +143,13 @@ printf 'export mailto_uri="%s%s"\n' "${mailto_uri_prefix:?}" "$title_uri" printf 'export discussions_url="%s%s"\n' "${discussions_url_prefix:?}" "$title_uri" printf 'export sourcecode_url="%s%s"\n' "${sourcecode_url_prefix:?}" "$FILENAME" -printf 'export style_url="%s"\n' "$(url-for -g 'style.css')" -printf 'export favicon_url="%s"\n' "$(url-for -g 'favicon.svg')" -printf 'export pubkey_url="%s"\n' "$(url-for -g 'public.asc.txt')" +printf 'export style_url="%s"\n' "$(url-for 'style.css')" +printf 'export favicon_url="%s"\n' "$(url-for 'favicon.svg')" +printf 'export pubkey_url="%s"\n' "$(url-for 'public.asc.txt')" -for f in src/content/img/*.svg; do +for f in "$CONTENT_PREFIX"/img/*.svg; do name="$(basename "$f" .svg | sed 's|-|_|g')" - printf 'export icon_%s_url="%s"\n' "$name" "$(url-for -g "img/$(basename "$f")")" + printf 'export icon_%s_url="%s"\n' "$name" "$(url-for "img/$(basename "$f")")" done # FIXME: special treatment of root diff --git a/v2/src/development/genhtml.sh b/v2/src/bin/html index 1b2718a..7e6809c 100755 --- a/v2/src/development/genhtml.sh +++ b/v2/src/bin/html @@ -4,34 +4,29 @@ set -eu usage() { cat <<-'EOF' Usage: - genhtml.sh FILENAME - genhtml.sh -h + html FILENAME + html -h EOF } help() { cat <<-'EOF' + Options: -h, --help show this message - FILENAME the name of the input file, to also be used as - URL + FILENAME the name of the input file .md file Process the FILENAME, and generate a full HTML page. - The FILENAME is used to infer the output URL, by removing the - `src/content/` prefix, and replacing the trailing `.md` with - `.html`. This URL is used to build the self-referencing - "canonical" link, extracting plaintext snippets, etc. - Examples: Generate the HTML for a pastebin: - $ sh genhtml.sh src/content/a-paste.md > src/content/a-paste.html + $ html src/a-paste.md > src/a-paste.html EOF } @@ -66,7 +61,7 @@ while getopts 'h' flag; do done shift $((OPTIND - 1)) -. src/development/lib.sh +. src/lib.sh FILENAME="${1:-}" eval "$(assert_arg "$FILENAME" 'FILENAME')" @@ -118,7 +113,7 @@ markdown_to_html() { extract_plaintext_snippets() { SNIPPETS="${FILENAME%.md}.snippets" - rm -f "$SNIPPETS" + printf '' > "$SNIPPETS" F="$(mkstemp)" cat > "$F" ( @@ -220,5 +215,5 @@ emit_body() { } envsubst < src/lib/preamble.html -emit_body +emit_body | tee "${FILENAME%.md}.htmlbody" envsubst < src/lib/postamble.html diff --git a/v2/src/development/security-txt.sh.in b/v2/src/bin/security-txt index 8f6613f..7026969 100755 --- a/v2/src/development/security-txt.sh.in +++ b/v2/src/bin/security-txt @@ -4,8 +4,8 @@ set -eu usage() { cat <<-'EOF' Usage: - src/development/security-txt.sh - src/development/security-txt.sh -h + security-txt + security-txt -h EOF } @@ -25,7 +25,7 @@ help() { Just run it: - $ sh src/development/security-txt.sh > .well-known/security.txt + $ security-txt > .well-known/security.txt EOF } @@ -62,21 +62,21 @@ shift $((OPTIND - 1)) EXPIRES="$( - LANG=C.UTF-8 gpg --list-key eu@euandre.org | + LANG=C.UTF-8 gpg --list-key "$EMAIL" | awk '/^pub/ { print substr($(NF), 1, 10) }' )T00:00:00z" -LANGS="en$( - echo po/??.po | - sed 's|\.po$||' | - sed 's|^po/|, |' | - paste -sd, +LANGUAGES="$( + langs | + sed 's|^|, |' | + tr -d '\n' | + sed 's|^, ||' )" cat <<-EOF - Contact: mailto:@EMAIL@ - Encryption: https://@DOMAIN@/public.asc.txt + Contact: mailto:$EMAIL + Encryption: $(url-for 'public.asc.txt' | absolute) Expires: $EXPIRES - Preferred-Languages: $LANGS + Preferred-Languages: $LANGUAGES EOF diff --git a/v2/src/development/lib.sh b/v2/src/lib.sh index 9d183f9..9d183f9 100644 --- a/v2/src/development/lib.sh +++ b/v2/src/lib.sh |
