From 08c9bcb3fed37d9483258bd97aaebc47b54b3fa3 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Sun, 17 Nov 2024 19:49:05 -0300 Subject: rm -rf v2/ --- v2/src/bin/absolute | 89 ---------------- v2/src/bin/categories | 80 --------------- v2/src/bin/category | 80 --------------- v2/src/bin/coll2path | 88 ---------------- v2/src/bin/collection-for | 87 ---------------- v2/src/bin/collections | 69 ------------- v2/src/bin/conf | 228 ----------------------------------------- v2/src/bin/dyn-po4a | 113 --------------------- v2/src/bin/eslaide | 77 -------------- v2/src/bin/feed | 112 -------------------- v2/src/bin/html | 234 ------------------------------------------ v2/src/bin/i18n | 97 ------------------ v2/src/bin/index | 152 ---------------------------- v2/src/bin/indexentry | 73 ------------- v2/src/bin/lang-for | 73 ------------- v2/src/bin/langs | 69 ------------- v2/src/bin/makemake | 253 ---------------------------------------------- v2/src/bin/mapentry | 75 -------------- v2/src/bin/security-txt | 82 --------------- v2/src/bin/series | 102 ------------------- v2/src/bin/sitemap | 72 ------------- v2/src/bin/url-for | 93 ----------------- v2/src/bin/xmlentry | 81 --------------- 23 files changed, 2479 deletions(-) delete mode 100755 v2/src/bin/absolute delete mode 100755 v2/src/bin/categories delete mode 100755 v2/src/bin/category delete mode 100755 v2/src/bin/coll2path delete mode 100755 v2/src/bin/collection-for delete mode 100755 v2/src/bin/collections delete mode 100755 v2/src/bin/conf delete mode 100755 v2/src/bin/dyn-po4a delete mode 100755 v2/src/bin/eslaide delete mode 100755 v2/src/bin/feed delete mode 100755 v2/src/bin/html delete mode 100755 v2/src/bin/i18n delete mode 100755 v2/src/bin/index delete mode 100755 v2/src/bin/indexentry delete mode 100755 v2/src/bin/lang-for delete mode 100755 v2/src/bin/langs delete mode 100755 v2/src/bin/makemake delete mode 100755 v2/src/bin/mapentry delete mode 100755 v2/src/bin/security-txt delete mode 100755 v2/src/bin/series delete mode 100755 v2/src/bin/sitemap delete mode 100755 v2/src/bin/url-for delete mode 100755 v2/src/bin/xmlentry (limited to 'v2/src/bin') diff --git a/v2/src/bin/absolute b/v2/src/bin/absolute deleted file mode 100755 index f475901..0000000 --- a/v2/src/bin/absolute +++ /dev/null @@ -1,89 +0,0 @@ -#!/bin/sh -set -eu - - -usage() { - cat <<-'EOF' - Usage: - absolute [CONTENT...] - absolute -h - EOF -} - -help() { - cat <<-'EOF' - - Options: - -h, --help show this message - - CONTENT a literal string to be prefixed - - - Add domain prefix to build a full URL. If CONTENT is not given, - get data from STDIN. - - Usually used in conjunction with url-for(1). - - - Examples: - - Get the URL for "static/style.css", and make it absolute: - - $ url-for 'static/style.css' | absolute - https://euandre.org/static/style.css - - - Get the absolute variant of a relative URL: - - $ absolute "$homepage_url" - https://euandre.org/pt/ - 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/lib/base.conf - - -prefix() { - sed "s|^/\?|https://$domain/|" -} - - -if [ $# = 0 ]; then - prefix -else - for s in "$@"; do - printf '%s\n' "$s" | prefix - done -fi diff --git a/v2/src/bin/categories b/v2/src/bin/categories deleted file mode 100755 index de65acb..0000000 --- a/v2/src/bin/categories +++ /dev/null @@ -1,80 +0,0 @@ -#!/bin/sh -set -eu - -usage() { - cat <<-'EOF' - Usage: - categories FILENAME - categories -h - EOF -} - -help() { - cat <<-'EOF' - Options: - -h, --help show this message - - FILENAME the target categories index to be built - - - Generate FILENAME as the indexed list of articles by category. - - - Examples: - - Generate the index.categories entry for english pastebins: - - $ categories src/en/pastebin/index.categories - 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/lib.sh - -FILENAME="${1:-}" -eval "$(assert_arg "$FILENAME" 'FILENAME')" -DIR="$(dirname "$FILENAME")" - - -mkdir -p "$DIR" -printf '' > "$FILENAME" -find "$DIR"/*.categorysort 2>/dev/null | - awk -F. '{ print $(NF-1) }' | - sort | - uniq | - while read -r category; do - find "$DIR"/*."$category".categorysort | - sort -nr | - xargs cat > "$DIR/$category.category" - printf '%s\n' "$category" >> "$FILENAME" - done diff --git a/v2/src/bin/category b/v2/src/bin/category deleted file mode 100755 index e3092cc..0000000 --- a/v2/src/bin/category +++ /dev/null @@ -1,80 +0,0 @@ -#!/bin/sh -set -eu - -usage() { - cat <<-'EOF' - Usage: - category FILENAME.md > FILENAME.categoryentry - category -h - EOF -} - -help() { - cat <<-'EOF' - - - Options: - -h, --help show this message - - FILENAME.md the name of the input file .md file - - - Process the FILENAME, and generate a the derived category files. - - - Examples: - - Generate the categories for a pastebin: - - $ categories src/a-paste.md > src/a-paste.categoryentry - 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/lib.sh - -FILENAME="${1:-}" -eval "$(assert_arg "$FILENAME" 'FILENAME.md')" - - -# shellcheck source=/dev/null -. "${FILENAME%.*}.conf" -DIR="$(dirname "$FILENAME")" - - - -echo "${categories:-}" | tr ' ' '\n' | grep . | while read -r category; do - echo "$FILENAME" > "$DIR/${date_iso:?}.$category.categorysort" -done - -envsubst < src/lib/category.html diff --git a/v2/src/bin/coll2path b/v2/src/bin/coll2path deleted file mode 100755 index 79b2f53..0000000 --- a/v2/src/bin/coll2path +++ /dev/null @@ -1,88 +0,0 @@ -#!/bin/sh -set -eu - -usage() { - cat <<-'EOF' - Usage: - coll2path LANGUAGE COLLECTION - coll2path -h - EOF -} - -help() { - cat <<-'EOF' - - - Options: - -h, --help show this message - - LANGUAGE in which language to list the collections - names for - COLLECTION what collection to get the path for - - - Get the path for the COLLECTION, doing the proper translation - on the way, and checking if is "article". - - - Examples: - - Get the path for "TIL" in portuguese: - - $ coll2path pt til - hea/ - - - Get the path for "articles" in english - - $ collections en articles - - 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/lib.sh - - -LANGUAGE="${1:-}" -COLLECTION="${2:-}" -eval "$(assert_arg "$LANGUAGE" 'LANGUAGE')" - -# shellcheck source=/dev/null -. src/lib/commencement."$LANGUAGE".conf - -if [ -z "$COLLECTION" ]; then - echo "${article_collection_name:-}" -else - NAME="$(eval "echo \"\$${COLLECTION}_collection_name\"")" - echo "$NAME${NAME:+/}" -fi diff --git a/v2/src/bin/collection-for b/v2/src/bin/collection-for deleted file mode 100755 index e46f345..0000000 --- a/v2/src/bin/collection-for +++ /dev/null @@ -1,87 +0,0 @@ -#!/bin/sh -set -eu - -usage() { - cat <<-'EOF' - Usage: - collection-for FILE - collection-for -h - EOF -} - -help() { - cat <<-'EOF' - - - Options: - -h, --help show this message - - FILE the path of the file to get the collection for - - - Say the collection of the given file, using the path of FILE. - - - Examples: - - Get "til" for "src/en/til/some-pt.md": - - $ collection-for src/en/til/some-pt.md - til - 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/lib.sh - - -FILE="${1:-}" -eval "$(assert_arg "$FILE" 'FILE')" - - -lang="$(lang-for "$FILE")" -DIR="$(dirname "$FILE")" -PAGE="${FILE%.*}.page" - -if [ -e "$PAGE" ]; then - exit 1 -else - collections | awk -v l="$lang" -v pre="$CONTENT_PREFIX" -v dir="$DIR" '{ - "coll2path " l " " $0 | getline coll_path - d = pre "/" l "/" coll_path - sub(/\/$/, "", d) - if (d == dir) { - print $0 - } - }' -fi diff --git a/v2/src/bin/collections b/v2/src/bin/collections deleted file mode 100755 index 0a8e156..0000000 --- a/v2/src/bin/collections +++ /dev/null @@ -1,69 +0,0 @@ -#!/bin/sh -set -eu - -usage() { - cat <<-'EOF' - Usage: - collections - collections -h - EOF -} - -help() { - cat <<-'EOF' - - - Options: - -h, --help show this message - - - List the registered collections to STDOUT. - - This is done by emiting the content of the "$COLLECTIONS" - environment variable. - - - Examples: - - Just run it: - - $ collections - til - pastebin - 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)) - - -echo "$COLLECTIONS" | - tr ' ' '\n' | - grep . diff --git a/v2/src/bin/conf b/v2/src/bin/conf deleted file mode 100755 index 9fb4664..0000000 --- a/v2/src/bin/conf +++ /dev/null @@ -1,228 +0,0 @@ -#!/bin/sh -set -eu - - -usage() { - cat <<-'EOF' - Usage: - conf [FILENAME] - conf -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. If FILENAME is not given, - generate the global config. - - - Examples: - - Get the "frontmatter" of src/f.conf: - - $ conf 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/lib.sh - - -FILENAME="${1:-}" -if [ -z "$FILENAME" ]; then - printf 'export style_url="%s"\n' "$(url-for 'style.css')" - printf 'export pubkey_url="%s"\n' "$(url-for 'public.asc.txt')" - printf 'export pubkey_id="%s"\n' "$( - LANG=C.UTF-8 gpg --list-key "$EMAIL" | - awk 'NR==2 { print substr($1, length($1) - 15) }' | - shesc - )" - - 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 "img/$(basename "$f")")" - done - for l in $(langs); do - for f in "$CONTENT_PREFIX"/img/*.svg; do - name="$(basename "$f" .svg | sed 's|-|_|g')" - printf 'export icon_%s_alt="%s"\n' "$name" "$(shesc < "$CONTENT_PREFIX/img/alt/$(basename "$f" .svg).$l.txt" )" - done > src/lib/generated."$l".conf - done - exit -fi - - -lang="$(lang-for "$FILENAME")" -export lang - -cat src/lib/base.conf src/lib/generated.conf src/lib/generated."$lang".conf | - tee "$FILENAME".tmp -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|^ ||' | shesc)" - printf 'export %s="%s"\n' "$KEY" "$VALUE" -done < "$FILENAME" | tee -a "$FILENAME".tmp -# shellcheck source=/dev/null -. "$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 -if [ -z "${title:-}" ]; then - title="${site_name:?}" - printf 'export title="%s"\n' "$(printf '%s' "$title" | shesc)" -fi - - -collection="$(collection-for "$FILENAME" ||:)" -if [ -n "$collection" ]; then - export collection - printf 'export collection="%s"\n' "$collection" - - coll_path="$(coll2path "$lang" "$collection")" - feed_title="$(eval "echo \"\$feed_${collection}_title\"" | htmlesc)" - - collection_head_html="$(printf ' ' \ - "$(url-for "$lang/$coll_path")" \ - "$(htmlesc "$feed_title")" - )" - printf 'export collection_head_html="%s"\n' "$(shesc "$collection_head_html")" -fi - -if [ -z "${layout:-}" ]; then - if [ -z "$collection" ]; then - layout=page - else - layout=post - - custom_layout="$(echo "$LAYOUTS" | grep . | - awk -v coll="$collection" '$1 == coll { print $2 }' - )" - if [ -n "$custom_layout" ]; then - layout="$custom_layout" - fi - fi - export layout - printf 'export layout="%s"\n' "$layout" -fi - - -if [ -r "$FILENAME".i18n ]; then - translations_head="$(awk -F: -v lang="$lang" '$1 != lang{ - printf " \n", - $3, $1 - }' "$FILENAME".i18n)" - translations_body="$(cat <<-EOF - - EOF - )" - printf 'export translations_head_html="%s"\n' "$(shesc "$translations_head")" - printf 'export translations_body_html="%s"\n' "$(shesc "$translations_body")" -fi - -if [ -n "${date:-}" ]; then - 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 formatted_date_html="%s"\n' "$(htmlesc "$formatted_date" | shesc)" - printf 'export date_html="%s"\n' "$(envsubst < src/lib/date."$lang".html | shesc)" - - echo "$FILENAME" > "$(dirname "$FILENAME")/$date_iso.sortdata" -fi - -if [ -n "${update:-}" ]; then - 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 | shesc)" - - printf 'export update_xml=" %s"\n' "$update_iso" -fi - - -url="$(url-for "$FILENAME")" -url_part="$(printf '%s' "$url" | sed 's|^/||')" -title_uri="$(uri "$title")" - -printf 'export title_html="%s"\n' "$(printf '%s' "$title" | htmlesc | shesc)" -printf 'export filename="%s"\n' "$FILENAME" -printf 'export url_part="%s"\n' "$url_part" -printf 'export url="%s"\n' "$url" -printf 'export url_absolute="%s"\n' "$(absolute "$url")" -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" - - -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 | shesc)" -fi diff --git a/v2/src/bin/dyn-po4a b/v2/src/bin/dyn-po4a deleted file mode 100755 index 9dde6d1..0000000 --- a/v2/src/bin/dyn-po4a +++ /dev/null @@ -1,113 +0,0 @@ -#!/bin/sh -set -eu - -usage() { - cat <<-'EOF' - Usage: - dyn-po4a > po/po4a.cfg - dyn-po4a -h - EOF -} - -help() { - cat <<-'EOF' - - - Options: - -h, --help show this message - - - Discover translatable files in the repository (via - git-ls-files(1)) that have '.en.' or '/en/' in their name and - emit the configuration file to be used with po4a(1). - - - Examples: - - Setup i18n on a new repository: - - $ mkdir po - $ touch po/pt.po - $ touch po/"$(basename "$PWD")".pot - $ dyn-po4a > po/po4a.cfg - $ po4a po/po4a.cfg - - - Conditionally update the configuration in a Makefile: - - po/po4a.cfg: ALWAYS - dyn-po4a | ifnew $@ - po4a $@ - 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/lib.sh - - -guess_type() { - case "$1" in - *.md) - echo text - ;; - *.[1-9]*.in) - echo man - ;; - *.html) - echo xhtml - ;; - *) - echo text - ;; - esac -} - - -cat <<-'EOF' - [options] --keep 0 --master-charset UTF-8 --localized-charset UTF-8 - - [po_directory] po - -EOF - -git ls-files | grep -F '.en.' | while read -r file; do - TYPE="$(guess_type "$file")" - # shellcheck disable=2016 - VAR_FILE="$(printf '%s' "$file" | sed 's|\.en\.|.$lang.|')" - # shellcheck disable=2016 - printf '[type: %s] %s $lang:%s\n' "$TYPE" "$file" "$VAR_FILE" -done - -if [ ! -t 0 ]; then - cat -fi diff --git a/v2/src/bin/eslaide b/v2/src/bin/eslaide deleted file mode 100755 index 925a3bf..0000000 --- a/v2/src/bin/eslaide +++ /dev/null @@ -1,77 +0,0 @@ -#!/bin/sh -set -eu - -usage() { - cat <<-'EOF' - Usage: - eslaide FILENAME.slides > FILENAME.ps - eslaide -h - EOF -} - -help() { - cat <<-'EOF' - - - Options: - -h, --help show this message - - FILENAME.slides the name of the input .slides file - - - Process the FILENAME.slides, and generate the derived PostScript - file. - - - Examples: - - Generate the PostScript for a presentation: - - $ eslaide src/a-presentation.md > src/a-presentation.ps - 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/lib.sh - -FILENAME="${1:-}" -eval "$(assert_arg "$FILENAME" 'FILENAME.slides)" - - -# shellcheck source=/dev/null -. "${FILENAME%.*}.conf" -DIR="$(dirname "$FILENAME")" - - - -echo TODO >&2 diff --git a/v2/src/bin/feed b/v2/src/bin/feed deleted file mode 100755 index 4e0d2f5..0000000 --- a/v2/src/bin/feed +++ /dev/null @@ -1,112 +0,0 @@ -#!/bin/sh -set -eu - -usage() { - cat <<-'EOF' - Usage: - feed FILENAME - feed -h - EOF -} - -help() { - cat <<-'EOF' - - - Options: - -h, --help show this message - - FILENAME the target feed to be generated - - - Generate FILENAME as an Atom feed. The collection type and - language are inferred by the name of FILENAME. - - - Examples: - - Generate a feed for TILs: - - $ feed src/en/til/feed.xml - 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/lib.sh - -FILENAME="${1:-}" -eval "$(assert_arg "$FILENAME" 'FILENAME')" - - -. src/lib/base.conf -# shellcheck source=/dev/null -. src/lib/base."$(lang-for "$FILENAME")".conf - - -now="$(date -uIs)" -url_absolute="$(url-for "${FILENAME#"$CONTENT_PREFIX"/}" | absolute)" -site_name_html="$(htmlesc "${site_name:?}")" -collection="$(collection-for "$FILENAME")" -coll_path="$(coll2path "${lang:?}" "$collection")" -collection_url_absolute="$(url-for "${lang:?}/$coll_path" | absolute)" -feed_title_html="$(eval "echo \"\$feed_${collection}_title\"" | htmlesc)" -export now url_absolute site_name_html collection_url_absolute feed_title_html - -DIR="$(dirname "$FILENAME")" -mkdir -p "$DIR" -{ - envsubst < src/lib/feed.xml - find "$DIR"/*.sortdata 2>/dev/null | - sort -nr | - xargs cat | - sed 's|\.md$|.xmlentry|' | - xargs cat - printf '\n' -} > "$FILENAME" - -printf '' > "$DIR"/index.extrafeeds -while read -r category; do - url_absolute="$(url-for "${DIR#"$CONTENT_PREFIX"/}/feed.$category.xml" | absolute)" - collection_url_absolute="$(url-for "${DIR#"$CONTENT_PREFIX"/}/${by_category_url_name:?}#$category" | absolute)" - feed_title_html="$(eval "echo \"\$index_category_${collection}_title\"" | htmlesc)" - export url_absolute collection_url_absolute feed_title_html - - { - envsubst < src/lib/feed.xml - < "$DIR/$category.category" \ - sed 's|\.md$|.xmlentry|' | - xargs cat - printf '\n' - } > "$DIR/feed.$category.xml" - echo "$DIR/feed.$category.xml" >> "$DIR"/index.extrafeeds -done < "$DIR"/index.categories diff --git a/v2/src/bin/html b/v2/src/bin/html deleted file mode 100755 index 4dabf00..0000000 --- a/v2/src/bin/html +++ /dev/null @@ -1,234 +0,0 @@ -#!/bin/sh -set -eu - -usage() { - cat <<-'EOF' - Usage: - html FILENAME - html -h - EOF -} - -help() { - cat <<-'EOF' - - - Options: - -h, --help show this message - - FILENAME the name of the input file .md file - - - Process the FILENAME, and generate a full HTML page. - - - Examples: - - Generate the HTML for a pastebin: - - $ html src/a-paste.md > src/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/lib.sh - -FILENAME="${1:-}" -eval "$(assert_arg "$FILENAME" 'FILENAME')" - - -# shellcheck source=/dev/null -. "${FILENAME%.*}.conf" - -# -# Utility functions -# - -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 - } - - /^
 "$SNIPPETS"
-	F="$(mkstemp)"
-	cat > "$F"
-	IFS=''
-	BLOCK_NUMBER=0
-	IN_BLOCK=
-	while read -r line; do
-		if [ "$line" = '
' ]; then - IN_BLOCK= - fi - - if [ -n "$IN_BLOCK" ]; then - printf '%s\n' "$line" | htmlesc -d >> "$OUT" - fi - - if printf '%s' "$line" | grep -q "^$INDENT
\)\(.*\)$|\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" = '
' ]; then - printf '%s\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 "%s\n", $0 - next - } - - match($0, /^( +
)(.*)$/, a) {
-			printf "%s", a[1]
-
-			n = 1
-			block_count++
-			printf "\n", block_count, n, block_count, n, n, a[2]
-			in_block = 1
-			next
-		}
-
-		in_block == 1 {
-			n++
-			printf "\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"; then
-			printf '%s\n' "$line"
-			continue
-		fi
-		LVL="$(printf '%s' "$line" | sed "s|^$INDENT.*|\1|")"
-		HEADING="$(printf '%s' "$line" | sed "s|^$INDENT\(.*\)$|\1|")"
-		SLUG="$(slugify "$HEADING")"
-		printf '%s%s\n' \
-			"$INDENT"  \
-			"$LVL"     \
-			"$SLUG"    \
-			"$HEADING" \
-			"$SLUG"    \
-			"${icon_link_url:?}" \
-			"$LVL"
-	done
-)
-
-
-warn_duplicate_ids() {
-	F="$(mkstemp)"
-	tee "$F"
-	{
-		grep "^$INDENT.*&2 < "$F"
-	rm "$F"
-}
-
-emit_body() {
-	< "${FILENAME%.*}.content" \
-		markdown_to_html           |
-		extract_plaintext_snippets |
-		add_line_numbers           |
-		add_headings_anchors       |
-		warn_duplicate_ids
-}
-
-if [ -r "$FILENAME".prev ]; then
-	collection_head_prev_html="$(
-		printf '    ' \
-			"$(url-for < "$FILENAME".prev)"
-	)"
-	export collection_head_prev_html
-fi
-
-if [ -r "$FILENAME".next ]; then
-	collection_head_next_html="$(
-		printf '    ' \
-			"$(url-for < "$FILENAME".next)"
-	)"
-	export collection_head_next_html
-fi
-
-envsubst < src/lib/preamble.html  | sed '/^$/d'
-emit_body | tee "${FILENAME%.*}.htmlbody"
-envsubst < src/lib/postamble.html | sed '/^$/d'
diff --git a/v2/src/bin/i18n b/v2/src/bin/i18n
deleted file mode 100755
index 30404eb..0000000
--- a/v2/src/bin/i18n
+++ /dev/null
@@ -1,97 +0,0 @@
-#!/bin/sh
-set -eu
-
-usage() {
-	cat <<-'EOF'
-		Usage:
-		  i18n
-		  i18n -h
-	EOF
-}
-
-help() {
-	cat <<-'EOF'
-
-
-		Options:
-		  -h, --help       show this message
-
-
-		Look at the mappings file provided via STDIN and notify all of
-		the files of all of their translations, so that they can include
-		it in their header.
-
-
-		Examples:
-
-		  Generate it from "po/i18n.mappings":
-
-		    $ i18n < po/i18n.mappings
-	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))
-
-
-
-awk '
-{
-	from = $3
-	idx[from][0] = "en:" from
-	for (i = 4; i <= NF; i++) {
-		to = $i
-		idx[from][length(idx[from])] = to
-	}
-}
-
-END {
-	for (k1 in idx) {
-		split(idx[k1][0], b, /:/)
-		base = b[2] ".i18n"
-		for (k2 in idx[k1]) {
-			split(idx[k1][k2], f, /:/)
-			file = f[2] ".i18n"
-			if (k2 == 0) {
-				for (k3 in idx[k1]) {
-					"url-for " f[2] | getline url
-					print idx[k1][k3] ":" url > file
-				}
-			} else {
-				ret = system("cp " base " " file)
-				if (ret) {
-					exit ret
-				}
-			}
-		}
-	}
-}
-'
diff --git a/v2/src/bin/index b/v2/src/bin/index
deleted file mode 100755
index 6212544..0000000
--- a/v2/src/bin/index
+++ /dev/null
@@ -1,152 +0,0 @@
-#!/bin/sh
-set -eu
-
-usage() {
-	cat <<-'EOF'
-		Usage:
-		  index FILENAME
-		  index -h
-	EOF
-}
-
-help() {
-	cat <<-'EOF'
-		Options:
-		  -h, --help    show this message
-
-		  FILENAME      the target collection HTML page to be generated
-
-
-		  Generate FILENAME as a collection index.  The collection type
-		  and language are inferred by the name of FILENAME.
-
-
-		Examples:
-
-		  Generate an index.html entry for english pastebins:
-
-		    $ index src/en/pastebin/index.html
-	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/lib.sh
-
-FILENAME="${1:-}"
-eval "$(assert_arg "$FILENAME" 'FILENAME')"
-DIR="$(dirname "$FILENAME")"
-
-
-l="$(lang-for "$FILENAME")"
-. src/lib/base.conf
-. src/lib/generated.conf
-# shellcheck source=/dev/null
-. src/lib/generated."$l".conf
-# shellcheck source=/dev/null
-. src/lib/base."$l".conf
-
-url_absolute="$(url-for "$FILENAME" | absolute)"
-collection="$(collection-for "$FILENAME")"
-feed_url="$(url-for "${DIR#"$CONTENT_PREFIX"/}"/feed.xml)"
-by_category_url="$(url-for "${DIR#"$CONTENT_PREFIX"/}/${by_category_url_name:?}")"
-title_html="$(eval "echo \"\$index_${collection}_title\"" | htmlesc)"
-index_recent_title_html="$(eval "echo \"\$index_recent_${collection}_title\"" | htmlesc)"
-index_category_title_html="$(eval "echo \"\$index_category_${collection}_title\"" | htmlesc)"
-export url_absolute feed_url by_category_url title_html index_recent_title_html \
-	index_category_title_html
-
-feed_title="$(eval "echo \"\$feed_${collection}_title\"")"
-collection_head_html="$(printf '    ' \
-	"$feed_url" \
-	"$(htmlesc "$feed_title")")"
-
-translations_head_html="$(langs |
-	awk -v lang="${lang:?}" -v coll="$collection" '$0 != lang {
-		"coll2path " $0 " " coll    | getline coll_path
-		"url-for " $0 "/" coll_path | getline url
-		printf "    \n",
-			url, $0
-	}'
-)"
-translations_body_html="$(cat <<-EOF
-	        
-EOF
-)"
-export collection_head_html translations_head_html translations_body_html
-
-
-
-mkdir -p "$DIR"
-{
-	cat src/lib/preamble.html src/lib/index-preamble.html | envsubst
-	find "$DIR"/*.sortdata 2>/dev/null |
-		sort -nr |
-		xargs cat |
-		sed 's|\.md$|.indexentry|' |
-		xargs cat
-	cat src/lib/index-postamble.html src/lib/postamble.html | envsubst
-} > "$FILENAME"
-
-
-CATEGORY_FILENAME="$CONTENT_PREFIX$by_category_url"
-echo "$CATEGORY_FILENAME" > "${FILENAME%.html}.extrahtml"
-
-url_absolute="$(absolute "$by_category_url")"
-title_html="$(eval "echo \"\$index_category_${collection}_title\"" | htmlesc)"
-export url_absolute title_html
-
-
-DIR="$(dirname "$CATEGORY_FILENAME")"
-mkdir -p "$DIR"
-{
-	envsubst < src/lib/preamble.html
-	while read -r category; do
-		feed_url="$(url-for "${DIR#"$CONTENT_PREFIX"/}/feed.$category.xml")"
-		index_recent_title_html="$category"
-		export category feed_url index_recent_title_html
-
-		envsubst < src/lib/category-header.html
-		echo '        
    ' - < "$DIR/$category.category" \ - sed 's|\.md$|.categoryentry|' | - xargs cat - echo '
' - done < "$DIR"/index.categories - envsubst < src/lib/postamble.html -} > "$CATEGORY_FILENAME" diff --git a/v2/src/bin/indexentry b/v2/src/bin/indexentry deleted file mode 100755 index f971a30..0000000 --- a/v2/src/bin/indexentry +++ /dev/null @@ -1,73 +0,0 @@ -#!/bin/sh -set -eu - -usage() { - cat <<-'EOF' - Usage: - indexentry FILENAME - indexentry -h - EOF -} - -help() { - cat <<-'EOF' - - - Options: - -h, --help show this message - - FILENAME the name of the input .md file - - - Process FILE, and generate an index collection entry. - - - Examples: - - Generate the index entry for a TIL: - - $ indexentry src/til/a-til.md > src/til/a-til.indexentry - 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/lib.sh - -FILENAME="${1:-}" -eval "$(assert_arg "$FILENAME" 'FILENAME')" - - -# shellcheck source=/dev/null -. "${FILENAME%.*}.conf" - -envsubst < src/lib/entry.html diff --git a/v2/src/bin/lang-for b/v2/src/bin/lang-for deleted file mode 100755 index f7c57a9..0000000 --- a/v2/src/bin/lang-for +++ /dev/null @@ -1,73 +0,0 @@ -#!/bin/sh -set -eu - -usage() { - cat <<-'EOF' - Usage: - lang-for FILE - lang-for -h - EOF -} - -help() { - cat <<-'EOF' - - - Options: - -h, --help show this message - - FILE the path of the file to get the language for - - - Say the language of the given file, using the path of FILE. - - - Examples: - - Get "en" for "src/en/some-pt.md": - - $ lang-for src/en/some-pt.md - en - 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/lib.sh - - -FILE="${1:-}" -eval "$(assert_arg "$FILE" 'FILE')" - - -echo "${FILE#"$CONTENT_PREFIX"/}" | - cut -d/ -f1 diff --git a/v2/src/bin/langs b/v2/src/bin/langs deleted file mode 100755 index 8e8aa63..0000000 --- a/v2/src/bin/langs +++ /dev/null @@ -1,69 +0,0 @@ -#!/bin/sh -set -eu - -usage() { - cat <<-'EOF' - Usage: - langs - langs -h - EOF -} - -help() { - cat <<-'EOF' - - - Options: - -h, --help show this message - - - List the supported languages, including english, to STDOUT. - - This is done in the same way that po4a(1) does it: by listing - the po/*.po files, and getting the name from it. - - - Examples: - - Just run it: - - $ langs - en - pt - 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)) - - -echo po/en.po po/*.po | - tr ' ' '\n' | - sed 's|^po/\(.*\)\.po$|\1|' diff --git a/v2/src/bin/makemake b/v2/src/bin/makemake deleted file mode 100755 index 3956844..0000000 --- a/v2/src/bin/makemake +++ /dev/null @@ -1,253 +0,0 @@ -#!/bin/sh -set -eu - - -usage() { - cat <<-'EOF' - Usage: - makemake - makemake -h - EOF -} - -help() { - cat <<-'EOF' - - Options: - -h, --help show this message - - - Generate make(1) code for later evaluation by make(1). What - this scripts does is fill the gap where make(1) can't handle - globs and dynamic dependencies, and uses some ad-hoc scripts - to generate those. - 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)) - - - -varlist() { - printf '%s = \\\n' "$1" - sed \ - -e 's/^/ /' \ - -e 's/$/ \\/' - printf '\n' -} - - -EXTENSIONS=' -.conf -.content -.html -.snippets -.htmlbody -.mapentry -' - -COLL_EXTENSIONS=' -.categoryentry -.indexentry -.xmlentry -' - -page_ext_filter="^($(echo "$COLL_EXTENSIONS" | - tr ' ' '\n' | - grep . | - paste -sd'|' -))\$" - - -extensions() { - echo "$EXTENSIONS" "$COLL_EXTENSIONS" "$@" | - tr ' ' '\n' | - grep . -} - - -printf '.POSIX:\n\n\n' -for lang in $(langs); do - for c in pages $(collections); do - if [ "$c" = 'pages' ]; then - filter="$page_ext_filter" - src='page' - coll_path='' - else - filter='^$' - src='md' - coll_path="$(coll2path "$lang" "$c")" - fi - - mds() { - git ls-files "$CONTENT_PREFIX/$lang/$coll_path"*."$src" | - sed 's|\.page$|.md|' - } - - exts() { - extensions | grep -Ev "$filter" - } - - mds | varlist "$c.$lang.md" - exts | sed "s|^\(.*\)\$|$c.$lang\1 = \$($c.$lang.md:.md=\1)|" - exts | sed "s|^\(.*\)\$|\$($c.$lang\1)|" | varlist "$c.$lang" - - mds | sed 's/^\(.*\)\.md$/\1.mapentry \1.conf \1.content: \1.md/' - mds | sed 's/^\(.*\)\.md$/\1.categoryentry \1.indexentry \1.html: \1.conf \1.content/' - mds | sed 's/^\(.*\)\.md$/\1.snippets \1.htmlbody: \1.html/' - if [ "$c" = 'pages' ]; then - mds | sed 's|\.md$|\.page|' | varlist "pages.$lang.page" - mds | sed "s|^\(.*\).md$|\1.md: \1.page|" - continue - fi - - mds | sed 's/^\(.*\)\.md$/\1.xmlentry: \1.htmlbody/' - - echo "$CONTENT_PREFIX/$lang/${coll_path}index.categories: \$($c.$lang.categoryentry)" - echo "$CONTENT_PREFIX/$lang/${coll_path}index.html: \$($c.$lang.indexentry) $CONTENT_PREFIX/$lang/${coll_path}index.categories" - echo "$CONTENT_PREFIX/$lang/${coll_path}feed.xml: \$($c.$lang.xmlentry) $CONTENT_PREFIX/$lang/${coll_path}index.categories" - - echo "$CONTENT_PREFIX/$lang/${coll_path}index.extrahtml: $CONTENT_PREFIX/$lang/${coll_path}index.html" - echo "$CONTENT_PREFIX/$lang/${coll_path}index.extrafeeds: $CONTENT_PREFIX/$lang/${coll_path}feed.xml" - - echo "$CONTENT_PREFIX/$lang/${coll_path}index.series: \$($c.$lang.conf)" - echo "\$($c.$lang.html): $CONTENT_PREFIX/$lang/${coll_path}index.series" - - printf '\n\n' - done - - coll_path="$(coll2path "$lang" slide)" - git ls-files "$CONTENT_PREFIX/$lang/$coll_path"*.slides | - varlist "slide.$lang.slides" - git ls-files "$CONTENT_PREFIX/$lang/$coll_path"*.slides | - sed 's/^\(.*\)\.slides$/\1.pdf: \1.ps/' - printf '\n\n' - - echo "slide.$lang.pdf = \$(slide.$lang.slides:.slides=.pdf)" - echo "all-generated.$lang.slides = \$(slide.$lang.slides)" - echo "all-generated.$lang.pdf = \$(slide.$lang.pdf)" - - for e in $(extensions); do - { - if ! printf '%s\n' "$e" | grep -qE "$page_ext_filter"; then - echo pages - fi - collections - } | - sed "s|^\(.*\)\$|\$(\1.$lang$e)|" | - varlist "all-generated.$lang$e" - done - - collections | - xargs -I% coll2path "$lang" % | - sed "s|^\(.*\)\$|$CONTENT_PREFIX/$lang/\1index.series|" | - varlist "all-generated.$lang.series" - - collections | - xargs -I% coll2path "$lang" % | - sed "s|^\(.*\)\$|$CONTENT_PREFIX/$lang/\1index.categories|" | - varlist "all-generated.$lang.categories" - - collections | - xargs -I% coll2path "$lang" % | - sed "s|^\(.*\)\$|$CONTENT_PREFIX/$lang/\1index.extrahtml|" | - varlist "all-generated.$lang.extrahtml" - - collections | - xargs -I% coll2path "$lang" % | - sed "s|^\(.*\)\$|$CONTENT_PREFIX/$lang/\1index.extrafeeds|" | - varlist "all-generated.$lang.extrafeeds" - - collections | - xargs -I% coll2path "$lang" % | - sed "s|^\(.*\)\$|$CONTENT_PREFIX/$lang/\1index.html|" | - varlist "all-generated.$lang.index" - - collections | - xargs -I% coll2path "$lang" % | - sed "s|^\(.*\)\$|$CONTENT_PREFIX/$lang/\1feed.xml|" | - varlist "all-generated.$lang.xml" - - extensions '.series' '.categories' '.extrahtml' '.extrafeeds' '.index' '.xml' '.pdf' | - sed "s|^\(.*\)\$|\$(all-generated.$lang\1)|" | - varlist "all-generated.$lang" - - - printf '\n' -done - - -git ls-files | - grep '\.uncolored' | - varlist 'svgs.uncolored' -# shellcheck disable=2016 -printf 'svgs = $(svgs.uncolored:.uncolored=)\n\n' - - -{ - git ls-files | - grep '\.page' | - sed "s|^$CONTENT_PREFIX\(.*\)\.page|\1.md|" - - git ls-files | - grep '\.uncolored' | - sed "s|^$CONTENT_PREFIX\(.*\)\.uncolored|\1|" -} > "$CONTENT_PREFIX"/.gitignore - - -for e in $(extensions '.series' '.categories' '.extrahtml' '.extrafeeds' '.index' '.xml' '.pdf'); do - langs | - sed "s|^\(.*\)\$|\$(all-generated.\1$e)|" | - varlist "all-generated$e" -done - -# shellcheck disable=2016 -langs | - sed 's|^\(.*\)$|$(pages.\1.md)|' | - varlist 'pages-mds' - -# shellcheck disable=2016 -langs | - sed 's|^\(.*\)$|$(all-generated.\1)|' | - varlist 'all-generated' - - -git ls-files src/ | - grep -v ^"$CONTENT_PREFIX"/ | - varlist 'non-content' - -git ls-files "$CONTENT_PREFIX"/ | - grep -v '\.md$' | - grep -v '\.page$' | - grep -v '\.uncolored$' | - grep -v '\.slides$' | - grep -v '\.ps$' | - varlist 'static-content' diff --git a/v2/src/bin/mapentry b/v2/src/bin/mapentry deleted file mode 100755 index 34b6e75..0000000 --- a/v2/src/bin/mapentry +++ /dev/null @@ -1,75 +0,0 @@ -#!/bin/sh -set -eu - -usage() { - cat <<-'EOF' - Usage: - mapentry FILENAME - mapentry -h - EOF -} - -help() { - cat <<-'EOF' - - - Options: - -h, --help show this message - - FILENAME the name of the input .md file - - - Process FILENAME, and generate a "mapentry": an "..." - entry to be included into the final sitemap.xml - - - Examples: - - Generate the sitemap entry entry for a TIL: - - $ xmlentry src/til/a-til.md > src/til/a-til.mapentry - 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/lib.sh - -FILENAME="${1:-}" -eval "$(assert_arg "$FILENAME" 'FILENAME')" - - -url_absolute="$(url-for "$FILENAME" | absolute)" -lastmod="$(git log -1 --format=%ad --date=short "$FILENAME")" -export url_absolute lastmod - -envsubst < src/lib/mapentry.xml diff --git a/v2/src/bin/security-txt b/v2/src/bin/security-txt deleted file mode 100755 index 7026969..0000000 --- a/v2/src/bin/security-txt +++ /dev/null @@ -1,82 +0,0 @@ -#!/bin/sh -set -eu - -usage() { - cat <<-'EOF' - Usage: - security-txt - security-txt -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: - - $ security-txt > .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 "$EMAIL" | - awk '/^pub/ { print substr($(NF), 1, 10) }' -)T00:00:00z" - -LANGUAGES="$( - langs | - sed 's|^|, |' | - tr -d '\n' | - sed 's|^, ||' -)" - - -cat <<-EOF - Contact: mailto:$EMAIL - Encryption: $(url-for 'public.asc.txt' | absolute) - Expires: $EXPIRES - Preferred-Languages: $LANGUAGES -EOF diff --git a/v2/src/bin/series b/v2/src/bin/series deleted file mode 100755 index 6712368..0000000 --- a/v2/src/bin/series +++ /dev/null @@ -1,102 +0,0 @@ -#!/bin/sh -set -eu - -usage() { - cat <<-'EOF' - Usage: - series FILENAME - series -h - EOF -} - -help() { - cat <<-'EOF' - Options: - -h, --help show this message - - FILENAME the sentinel file to be touched - - - Enumerate and sort all items of a collection type, and notify - them about their '' and '. - The collection type and language are inferred by FILENAME. - - The "notifying" part is done via a "$TARGET.next" file, that - is, a ".next" file is created to notify "$TARGET" about which - item is next to it via the content of the file. The same - applies for ".prev" files. - - - Examples: - - Generate the ".next" and ".prev" files for english pastebins: - - $ index src/en/pastebin/index.series - 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/lib.sh - -FILENAME="${1:-}" -eval "$(assert_arg "$FILENAME" 'FILENAME')" -DIR="$(dirname "$FILENAME")" - - -find "$DIR"/*.sortdata 2>/dev/null | - sort -n | - xargs cat | - awk ' - BEGIN { split("", items) } - { items[NR] = $0 } - END { - first = 1 - last = length(items) - for (i in items) { - item = items[i] - if (i != first) { - file = item ".prev" - prev = items[i-1] - print prev > file - } - if (i != last) { - file = item ".next" - nextt = items[i+1] - print nextt > file - } - } - } - ' - -touch "$FILENAME" diff --git a/v2/src/bin/sitemap b/v2/src/bin/sitemap deleted file mode 100755 index 09f7eb1..0000000 --- a/v2/src/bin/sitemap +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/sh -set -eu - -usage() { - cat <<-'EOF' - Usage: - sitemap - sitemap -h - EOF -} - -help() { - cat <<-'EOF' - - - Options: - -h, --help show this message - - - Process all generate "*.mapentry" files, combine them all - together into the final "sitemap.xml" file. - - - Examples: - - Generate the final sitemap.xml: - - $ sitemap > src/sitemap.xml - 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)) - - - -printf '\n' -printf '\n' - -find "$CONTENT_PREFIX"/ -type f -name '*.mapentry' | - LANG=POSIX.UTF-8 sort | - xargs cat - -printf '\n' diff --git a/v2/src/bin/url-for b/v2/src/bin/url-for deleted file mode 100755 index e0b1c9d..0000000 --- a/v2/src/bin/url-for +++ /dev/null @@ -1,93 +0,0 @@ -#!/bin/sh -set -eu - -usage() { - cat <<-'EOF' - Usage: - url-for [CONTENT...] - url-for -h - EOF -} - -help() { - cat <<-'EOF' - - Options: - -h, --help show this message - - CONTENT literal strings to be transformed into URLs - - - Build an URL without the $domain part, adding the required - $base_url. If CONTENT is not given, get data from STDIN. - - - Examples: - - Get the URL for "en/about.html", when $base_url is "v2": - - $ url-for 'about.html' - /v2/en/about.html - - - Get the URL for "static/favicon.svg", when $base_url is empty: - - $ echo 'img/link.svg' | url-for - /img/link.svg - 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/lib/base.conf - - -url() { - sed \ - -e "s|^$CONTENT_PREFIX/||" \ - -e 's|\.md|.html|' \ - -e 's|\.page|.html|' \ - -e 's|^/||' | - printf '%s%s\n' "${base_url:-/}" "$(cat -)" -} - -if [ $# = 0 ]; then - url -else - for f in "$@"; do - if [ "$f" = '/' ]; then - f='' - fi - printf '%s\n' "$f" | url - done -fi diff --git a/v2/src/bin/xmlentry b/v2/src/bin/xmlentry deleted file mode 100755 index f6fb6ea..0000000 --- a/v2/src/bin/xmlentry +++ /dev/null @@ -1,81 +0,0 @@ -#!/bin/sh -set -eu - -usage() { - cat <<-'EOF' - Usage: - xmlentry FILENAME - xmlentry -h - EOF -} - -help() { - cat <<-'EOF' - - - Options: - -h, --help show this message - - FILENAME the name of the input .md file - - - Process FILE, and generate an Atom feed entry. - - - Examples: - - Generate the XML entry for a TIL: - - $ xmlentry src/til/a-til.md > src/til/a-til.xml - 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/lib.sh - -FILENAME="${1:-}" -eval "$(assert_arg "$FILENAME" 'FILENAME')" - - -# shellcheck source=/dev/null -. "${FILENAME%.*}.conf" - -envsubst < src/lib/entry.xml - -head -n1 < "${FILENAME%.*}.htmlbody" | htmlesc -printf ' \n' -printf ' \n' "${url:?}" - -htmlesc < "${FILENAME%.*}.htmlbody" -printf ' \n' -printf ' \n' -- cgit v1.2.3
%s%s
%s%s