diff options
Diffstat (limited to 'v2')
-rwxr-xr-x | v2/aux/checks/shellcheck.sh | 6 | ||||
-rw-r--r-- | v2/dynamic.mk | 13 | ||||
-rwxr-xr-x | v2/src/bin/makemake | 5 | ||||
-rwxr-xr-x | v2/src/development/genhtml.sh | 93 | ||||
-rwxr-xr-x | v2/src/development/getconf.sh | 14 |
5 files changed, 77 insertions, 54 deletions
diff --git a/v2/aux/checks/shellcheck.sh b/v2/aux/checks/shellcheck.sh new file mode 100755 index 0000000..585a75f --- /dev/null +++ b/v2/aux/checks/shellcheck.sh @@ -0,0 +1,6 @@ +#!/bin/sh +set -eu + +git ls-files | + xargs awk '/^#!\/bin\/sh$/ { print FILENAME } { nextfile }' | + xargs shellcheck -x diff --git a/v2/dynamic.mk b/v2/dynamic.mk index d31be9f..92ff6ee 100644 --- a/v2/dynamic.mk +++ b/v2/dynamic.mk @@ -84,8 +84,15 @@ src/content/.well-known/security.txt: src/content/public.asc.txt src/development sh src/development/security-txt.sh > $@ -check: -dev: check + +test-files = \ + aux/checks/shellcheck.sh \ + +$(test-files): ALWAYS + sh $@ + +check: $(test-files) +dev: all check run: all serve -d public/ @@ -97,3 +104,5 @@ upload: public --delete \ --exclude 's/*' \ public/ $(DOMAIN):/srv/www/ + +ALWAYS: diff --git a/v2/src/bin/makemake b/v2/src/bin/makemake index f4ab87a..06a7d33 100755 --- a/v2/src/bin/makemake +++ b/v2/src/bin/makemake @@ -95,6 +95,7 @@ for r in $RESOURCES; do if [ "$e" = '.md' ]; then continue fi + # shellcheck disable=2016 printf '%s%s = $(%s.md:.md=%s)\n' "$r" "$e" "$r" "$e" done printf '%s =' "$r" @@ -102,6 +103,7 @@ for r in $RESOURCES; do if [ "$e" = '.md' ]; then continue fi + # shellcheck disable=2016 printf ' $(%s%s)' "$r" "$e" done printf '\n' @@ -110,11 +112,12 @@ for r in $RESOURCES; do done all_resources() { - echo $RESOURCES | tr ' ' '\n' + echo "$RESOURCES" | tr ' ' '\n' | grep . } all_vars() { EXT="$1" + # shellcheck disable=2016 all_resources | sed 's|^|$(|' | sed "s|$|$EXT)|" | diff --git a/v2/src/development/genhtml.sh b/v2/src/development/genhtml.sh index cb8fd73..d816fe6 100755 --- a/v2/src/development/genhtml.sh +++ b/v2/src/development/genhtml.sh @@ -72,6 +72,7 @@ FILENAME="${1:-}" eval "$(assert_arg "$FILENAME" 'FILENAME')" +# shellcheck source=/dev/null . "${FILENAME%.md}.conf" # @@ -185,14 +186,16 @@ add_headings_anchors() { } emit_body() { - cat "${FILENAME%.md}.entry-content" | + < "${FILENAME%.md}.content" \ markdown_to_html | extract_plaintext_snippets | add_line_numbers | add_headings_anchors } - +if false; then + emit_body +fi @@ -202,22 +205,22 @@ emit_body() { cat <<-EOF <!DOCTYPE html> - <html lang="$lang"> + <html lang="${lang:?}"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> - <link rel="stylesheet" type="text/css" href="$style_url" /> - <link rel="icon" type="image/svg+xml" href="$favicon_url" /> + <link rel="stylesheet" type="text/css" href="${style_url:?}" /> + <link rel="icon" type="image/svg+xml" href="${favicon_url:?}" /> <title>$$title_html</title> <meta name="author" content="EuAndreh" /> - <meta property="og:site_name" content="$site_name" /> - <meta property="og:locale" content="$lang" /> - <meta property="og:title" content="$title_html" /> + <meta property="og:site_name" content="${site_name:?}" /> + <meta property="og:locale" content="${lang:?}" /> + <meta property="og:title" content="${title_html:?}" /> - <link rel="canonical" href="$url" /> - <meta property="og:url" content="$url" /> + <link rel="canonical" href="${url:?}" /> + <meta property="og:url" content="${url:?}" /> </head> <body> <header> @@ -237,41 +240,41 @@ 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 > $@ - - - <p class="post-footer"> - <a href="mailto:~euandreh/public-inbox@lists.sr.ht?Subject=Re%3A%20$URI_TITLE">Comment</a> - and see - <a href="https://lists.sr.ht/~euandreh/public-inbox?search=$URI_TITLE">existing discussions</a> - | - <a href="https://euandre.org/git/euandre.org/tree/$FILENAME">view source</a> - </p> - </article> - </main> - <footer> - <hr /> - <ul> - <li> - <img class="svg-icon" src="$(url-for 'static/envelope.svg')" alt="a envelope icon representing an email address" /> - <a href="mailto:$email">$email</a> - </li> - <li> - <img class="svg-icon" src="$(url-for 'static/lock.svg')" alt="a lock icon representing a GPG public key" /> - <a href="$(url-for 'static/public.asc.txt')">81F90EC3CD356060</a> - </li> - </ul> - <p> - The content for this site is licensed under <a rel="license" href="https://creativecommons.org/licenses/by-sa/4.0/">CC BY-SA 4.0</a>. The <a href="https://euandre.org/git/euandre.org">code</a> is <a rel="license" href="https://euandre.org/git/euandre.org/tree/COPYING">AGPLv3 or later</a>. Patches welcome. - </p> - </footer> - </body> - </html> -EOF +# .md.rehtml: +# F="$<"; . "$${F%.md}.conf"; envsubst < src/lib/reamble."$$lang".html > $@ +# +# .md.osthtml: +# F="$<"; . "$${F%.md}.conf"; envsubst < src/lib/ostamble."$$lang".html > $@ +# +# +# <p class="post-footer"> +# <a href="mailto:~euandreh/public-inbox@lists.sr.ht?Subject=Re%3A%20$URI_TITLE">Comment</a> +# and see +# <a href="https://lists.sr.ht/~euandreh/public-inbox?search=$URI_TITLE">existing discussions</a> +# | +# <a href="https://euandre.org/git/euandre.org/tree/$FILENAME">view source</a> +# </p> +# </article> +# </main> +# <footer> +# <hr /> +# <ul> +# <li> +# <img class="svg-icon" src="$(url-for 'static/envelope.svg')" alt="a envelope icon representing an email address" /> +# <a href="mailto:$email">$email</a> +# </li> +# <li> +# <img class="svg-icon" src="$(url-for 'static/lock.svg')" alt="a lock icon representing a GPG public key" /> +# <a href="$(url-for 'static/public.asc.txt')">81F90EC3CD356060</a> +# </li> +# </ul> +# <p> +# The content for this site is licensed under <a rel="license" href="https://creativecommons.org/licenses/by-sa/4.0/">CC BY-SA 4.0</a>. The <a href="https://euandre.org/git/euandre.org">code</a> is <a rel="license" href="https://euandre.org/git/euandre.org/tree/COPYING">AGPLv3 or later</a>. Patches welcome. +# </p> +# </footer> +# </body> +# </html> +# EOF # FIXMEs: # - feeds diff --git a/v2/src/development/getconf.sh b/v2/src/development/getconf.sh index dd623f7..4b615a8 100755 --- a/v2/src/development/getconf.sh +++ b/v2/src/development/getconf.sh @@ -74,7 +74,7 @@ escape() { } { - cat src/lib/base-conf | tee "$FILENAME".tmp + tee "$FILENAME".tmp < src/lib/base-conf DELIMITER=0 while read -r line; do if [ "$line" = '---' ]; then @@ -92,9 +92,11 @@ escape() { VALUE="$(printf '%s' "$line" | cut -d: -f2- | sed 's|^ ||' | escape)" printf '%s="%s"\n' "$KEY" "$VALUE" done < "$FILENAME" | tee -a "$FILENAME".tmp + # shellcheck source=/dev/null . "$FILENAME".tmp - cat src/lib/base."$lang".conf + cat src/lib/base."${lang:?}".conf + # shellcheck source=/dev/null . src/lib/base."$lang".conf title="${title:-"$site_name"}" @@ -105,10 +107,10 @@ 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 '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"/)" |