aboutsummaryrefslogtreecommitdiff
path: root/v2/src/development
diff options
context:
space:
mode:
Diffstat (limited to 'v2/src/development')
-rwxr-xr-xv2/src/development/genconf.sh150
-rwxr-xr-xv2/src/development/genhtml.sh224
-rw-r--r--v2/src/development/lib.sh33
-rwxr-xr-xv2/src/development/security-txt.sh.in82
4 files changed, 0 insertions, 489 deletions
diff --git a/v2/src/development/genconf.sh b/v2/src/development/genconf.sh
deleted file mode 100755
index f9dfc14..0000000
--- a/v2/src/development/genconf.sh
+++ /dev/null
@@ -1,150 +0,0 @@
-#!/bin/sh
-set -eu
-
-
-usage() {
- cat <<-'EOF'
- Usage:
- src/development/genconf.sh FILENAME
- src/development/genconf.sh -h
- EOF
-}
-
-help() {
- cat <<-'EOF'
-
- Options:
- -h, --help show this message
-
- FILENAME the name of the input file, also to be used as
- URL.
-
-
- Separate the content from the "frontmatter", and emit the
- selected one, given the FILENAME.
-
-
- Examples:
-
- Get the "frontmatter" of src/f.conf:
-
- $ src/development/genconf.sh src/f.md > src/f.conf
- EOF
-}
-
-
-for flag in "$@"; do
- case "$flag" in
- --)
- break
- ;;
- --help)
- usage
- help
- exit
- ;;
- *)
- ;;
- esac
-done
-
-while getopts 'h' flag; do
- case "$flag" in
- h)
- usage
- help
- exit
- ;;
- *)
- usage >&2
- exit 2
- ;;
- esac
-done
-shift $((OPTIND - 1))
-
-. src/development/lib.sh
-
-FILENAME="${1:-}"
-eval "$(assert_arg "$FILENAME" 'FILENAME')"
-
-
-escape() {
- sed 's|\([`"$]\)|\\\1|g'
-}
-
-tee "$FILENAME".tmp < src/lib/base-conf
-DELIMITER=0
-while read -r line; do
- if [ "$line" = '---' ]; then
- DELIMITER=$((DELIMITER + 1))
- continue
- fi
- if [ "$DELIMITER" = 2 ]; then
- break
- fi
- if [ -z "$line" ]; then
- continue
- fi
-
- KEY="$( printf '%s' "$line" | cut -d: -f1)"
- VALUE="$(printf '%s' "$line" | cut -d: -f2- | sed 's|^ ||' | escape)"
- printf 'export %s="%s"\n' "$KEY" "$VALUE"
-done < "$FILENAME" | tee -a "$FILENAME".tmp
-# shellcheck source=/dev/null
-. "$FILENAME".tmp
-rm -f "$FILENAME".tmp
-
-cat src/lib/base."${lang:?}".conf
-# shellcheck source=/dev/null
-. src/lib/base."$lang".conf
-if [ -z "${title:-}" ]; then
- title="${site_name:?}"
- printf 'export title="%s"\n' "$(printf '%s' "$title" | escape)"
-fi
-
-if [ -n "${date:-}" ]; then
- formatted_date="$(LANG="$lang" date -d "${date:?}" +"${date_fmt:?}")"
- export formatted_date
- printf 'export date_html="%s"\n' "$(envsubst < src/lib/date."$lang".html | escape)"
-fi
-
-if [ -n "${update:-}" ]; then
- formatted_update="$(LANG="$lang" date -d "${update:?}" +"${date_fmt:?}")"
- export formatted_update
- printf 'export update_html="%s"\n' "$(envsubst < src/lib/update."$lang".html | escape)"
-fi
-
-
-url_part="$(printf '%s' "${FILENAME%.md}.html" | sed 's|^src/content/||')"
-title_uri="$(uri "$title")"
-
-printf 'export title_html="%s"\n' "$(printf '%s' "$title" | htmlesc | escape)"
-printf 'export filename="%s"\n' "$FILENAME"
-printf 'export url_part="%s"\n' "$url_part"
-printf 'export url="%s"\n' "$(url-for "$url_part" | absolute)"
-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')"
-
-for f in src/content/img/*.svg; do
- name="$(basename "$f" .svg | sed 's|-|_|g')"
- printf 'export icon_%s_url="%s"\n' "$name" "$(url-for -g "img/$(basename "$f")")"
-done
-
-# FIXME: special treatment of root
-printf 'export homepage_url="%s"\n' "$(url-for '/')"
-
-printf 'export about_url="%s"\n' "$(url-for "${about_url_name:?}")"
-
-
-if [ "${layout:-}" = 'post' ]; then
- export mailto_uri="$mailto_uri_prefix$title_uri"
- export discussions_url="$discussions_url_prefix$title_uri"
- export sourcecode_url="$sourcecode_url_prefix$FILENAME"
- printf 'export comment_html="%s"\n' "$(envsubst < src/lib/comment."$lang".html | escape)"
-fi
diff --git a/v2/src/development/genhtml.sh b/v2/src/development/genhtml.sh
deleted file mode 100755
index 1b2718a..0000000
--- a/v2/src/development/genhtml.sh
+++ /dev/null
@@ -1,224 +0,0 @@
-#!/bin/sh
-set -eu
-
-usage() {
- cat <<-'EOF'
- Usage:
- genhtml.sh FILENAME
- genhtml.sh -h
- EOF
-}
-
-help() {
- cat <<-'EOF'
-
- Options:
- -h, --help show this message
-
- FILENAME the name of the input file, to also be used as
- URL
-
-
- 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
- EOF
-}
-
-
-for f in "$@"; do
- case "$f" in
- --)
- break
- ;;
- --help)
- usage
- help
- exit
- ;;
- *)
- ;;
- esac
-done
-
-while getopts 'h' flag; do
- case "$flag" in
- h)
- usage
- help
- exit
- ;;
- *)
- usage >&2
- exit 2
- ;;
- esac
-done
-shift $((OPTIND - 1))
-
-. src/development/lib.sh
-
-FILENAME="${1:-}"
-eval "$(assert_arg "$FILENAME" 'FILENAME')"
-
-
-# shellcheck source=/dev/null
-. "${FILENAME%.md}.conf"
-
-#
-# Utility functions
-#
-
-SEEN_SLUGS="$(mkstemp)"
-slugify_once() {
- SLUG="$(printf '%s' "$1" | slugify)${2:+-$2}"
- if grep -q "^$SLUG$" "$SEEN_SLUGS"; then
- N="${2:-0}"
- N=$((N + 1))
- slugify_once "$1" "$N"
- else
- printf '%s\n' "$SLUG" >> "$SEEN_SLUGS"
- printf '%s' "$SLUG"
- fi
-}
-
-INDENT=' '
-markdown_to_html() {
- md2html | awk -vINDENT="$INDENT" '
- BEGIN {
- in_block = 0
- }
-
- {
- if (in_block == 0) {
- printf "%s", INDENT
- }
- print
- }
-
- /^<\/code><\/pre>$/ {
- in_block = 0
- }
-
- /^<pre><code/ {
- in_block = 1
- }
- '
-}
-
-extract_plaintext_snippets() {
- SNIPPETS="${FILENAME%.md}.snippets"
- rm -f "$SNIPPETS"
- F="$(mkstemp)"
- cat > "$F"
- (
- IFS=''
- BLOCK_NUMBER=0
- IN_BLOCK=
- while read -r line; do
- if [ "$line" = '</code></pre>' ]; then
- IN_BLOCK=
- fi
-
- if [ -n "$IN_BLOCK" ]; then
- printf '%s\n' "$line" | htmlesc -d >> "$OUT"
- fi
-
- if printf '%s' "$line" | grep -q "^$INDENT<pre><code"; then
- IN_BLOCK=1
- OUT="${FILENAME%.md}.html.$BLOCK_NUMBER.txt"
- BLOCK_NUMBER=$((BLOCK_NUMBER + 1))
- printf '%s\n' "$line" |
- sed "s|^\($INDENT<pre><code.*>\)\(.*\)$|\2|" |
- htmlesc -d > "$OUT"
- printf '%s\n' "$OUT" >> "$SNIPPETS"
- fi
- done < "$F"
-
- BLOCK_NUMBER=0
- while read -r line; do
- printf '%s\n' "$line"
-
- if [ "$line" = '</code></pre>' ]; then
- printf '%s<p class="plaintext-link"><a href="%s">plaintext</a></p>\n' \
- "$INDENT" \
- "$(basename "${url_part:?}").$BLOCK_NUMBER.txt"
- BLOCK_NUMBER=$((BLOCK_NUMBER + 1))
- fi
- done < "$F"
- )
-
-}
-
-add_line_numbers() {
- awk '
- /^<\/code><\/pre>$/ {
- in_block = 0
- printf "</tbody></table>%s\n", $0
- next
- }
-
- match($0, /^( +<pre><code.*>)(.*)$/, a) {
- printf "%s<table rules=columns class=\"code-block\"><tbody>", a[1]
-
- n = 1
- block_count++
- printf "<tr><td class=\"line-number\"><a id=\"B%s-L%s\" href=\"#B%s-L%s\">%s</a></td><td class=\"code-line\">%s</td></tr>\n", block_count, n, block_count, n, n, a[2]
- in_block = 1
- next
- }
-
- in_block == 1 {
- n++
- printf "<tr><td class=\"line-number\"><a id=\"B%s-L%s\" href=\"#B%s-L%s\">%s</a></td><td class=\"code-line\">%s</td></tr>\n", block_count, n, block_count, n, n, $0
- next
- }
-
- { print }
- '
-}
-
-add_headings_anchors() {
- (
- IFS=''
- while read -r line; do
- if ! printf '%s' "$line" | grep -q "^$INDENT<h[2-6]>"; then
- printf '%s\n' "$line"
- continue
- fi
- LVL="$(printf '%s' "$line" | sed "s|^$INDENT<h\(.\)>.*|\1|")"
- HEADING="$(printf '%s' "$line" | sed "s|^$INDENT<h.>\(.*\)</h.>$|\1|")"
- SLUG="$(slugify_once "$HEADING")"
- printf '%s<h%s class="header-anchor" id="%s">%s<a href="#%s" aria-hidden="true"><img class="svg-icon" src="%s" /></a></h%s>\n' \
- "$INDENT" \
- "$LVL" \
- "$SLUG" \
- "$HEADING" \
- "$SLUG" \
- "${icon_link_url:?}" \
- "$LVL"
- done
- )
-}
-
-emit_body() {
- < "${FILENAME%.md}.content" \
- markdown_to_html |
- extract_plaintext_snippets |
- add_line_numbers |
- add_headings_anchors
-}
-
-envsubst < src/lib/preamble.html
-emit_body
-envsubst < src/lib/postamble.html
diff --git a/v2/src/development/lib.sh b/v2/src/development/lib.sh
deleted file mode 100644
index 9d183f9..0000000
--- a/v2/src/development/lib.sh
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/bin/sh
-
-assert_arg() {
- if [ -z "$1" ]; then
- printf 'Missing %s.\n\n' "$2" >&2
- cat <<-'EOF'
- usage >&2
- exit 2
- EOF
- fi
-}
-
-uuid() {
- od -xN20 /dev/urandom |
- head -n1 |
- awk '{OFS="-"; print $2$3,$4,$5,$6,$7$8$9}'
-}
-
-tmpname() {
- echo "${TMPDIR:-/tmp}/uuid-tmpname with spaces.$(uuid)"
-}
-
-mkstemp() {
- name="$(tmpname)"
- touch "$name"
- echo "$name"
-}
-
-mkdtemp() {
- name="$(tmpname)"
- mkdir "$name"
- echo "$name"
-}
diff --git a/v2/src/development/security-txt.sh.in b/v2/src/development/security-txt.sh.in
deleted file mode 100755
index 8f6613f..0000000
--- a/v2/src/development/security-txt.sh.in
+++ /dev/null
@@ -1,82 +0,0 @@
-#!/bin/sh
-set -eu
-
-usage() {
- cat <<-'EOF'
- Usage:
- src/development/security-txt.sh
- src/development/security-txt.sh -h
- EOF
-}
-
-help() {
- cat <<-'EOF'
-
-
- Options:
- -h, --help show this message
-
-
- Generate the RFC 9116 "security.txt" file from data in the
- repository.
-
-
- Examples:
-
- Just run it:
-
- $ sh src/development/security-txt.sh > .well-known/security.txt
- EOF
-}
-
-
-for flag in "$@"; do
- case "$flag" in
- --)
- break
- ;;
- --help)
- usage
- help
- exit
- ;;
- *)
- ;;
- esac
-done
-
-while getopts 'h' flag; do
- case "$flag" in
- h)
- usage
- help
- exit
- ;;
- *)
- usage >&2
- exit 2
- esac
-done
-shift $((OPTIND - 1))
-
-
-
-EXPIRES="$(
- LANG=C.UTF-8 gpg --list-key eu@euandre.org |
- awk '/^pub/ { print substr($(NF), 1, 10) }'
-)T00:00:00z"
-
-LANGS="en$(
- echo po/??.po |
- sed 's|\.po$||' |
- sed 's|^po/|, |' |
- paste -sd,
-)"
-
-
-cat <<-EOF
- Contact: mailto:@EMAIL@
- Encryption: https://@DOMAIN@/public.asc.txt
- Expires: $EXPIRES
- Preferred-Languages: $LANGS
-EOF