From 2dcdd72d693f9a886a2751ab65fc0e85c04d1e1a Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Tue, 29 Apr 2025 19:23:58 -0300 Subject: Add "mapentry" and "sitemap" subcommands --- deps.mk | 2 ++ src/conf | 12 ++++++++++++ src/mapentry | 19 +++++++++++++++++++ src/sitemap | 22 ++++++++++++++++++++++ 4 files changed, 55 insertions(+) create mode 100755 src/mapentry create mode 100755 src/sitemap diff --git a/deps.mk b/deps.mk index 49c90a3..c65c232 100644 --- a/deps.mk +++ b/deps.mk @@ -10,6 +10,8 @@ libexec.sh = \ src/indexbody \ src/indexentry \ src/links \ + src/mapentry \ + src/sitemap \ src/snippets \ src/sortdata \ src/symlinks \ diff --git a/src/conf b/src/conf index 16c43a8..6951462 100755 --- a/src/conf +++ b/src/conf @@ -168,6 +168,9 @@ cat -- "$CONF" url="$(printf '%s\n' "${UNPREFIXED%.adoc}.html" | shesc)" + +lastmod_epoch="$(stat --printf='%Y' "$FILENAME" | shesc)" + collurl= date_iso= date_epoch= @@ -180,15 +183,21 @@ if is_article; then date_iso="$(dateiso "$lastdirnames" | shesc)" date_epoch="$(dateepoch "$date_iso" | shesc)" date_formatted="$(datefmt "$date_iso" | shesc)" + lastmod_epoch="$date_epoch" if [ -n "${updatedat:-}" ]; then updatedat_iso="$(dateiso "$updatedat" | shesc)" updatedat_epoch="$(dateepoch "$updatedat_iso" | shesc)" updatedat_formatted="$(datefmt "$updatedat_iso" | shesc)" + lastmod_epoch="$updatedat_epoch" fi file="$(basename "$url")" collurl="$(printf '%s\n' "$lastdirnames" | sed 's|-|/|g' | shesc)/$file" fi +lastmod_iso="$(dateiso "@$lastmod_epoch" | shesc)" +lastmod_formatted="$(datefmt "$lastmod_iso" | shesc)" + + BASE_URL="$(base_url)" TITLE_RAW="$(cat -- "$FILENAME" | grep '^= .*' | head -n1 | cut -d' ' -f2- || echo 'MISSING')" @@ -257,6 +266,9 @@ cat <<-EOF export title_html="$title_html" export titlefull="$titlefull" export titlefull_html="$titlefull_html" + export lastmod_iso="$lastmod_iso" + export lastmod_epoch="$lastmod_epoch" + export lastmod_formatted="$lastmod_formatted" export date_iso="$date_iso" export date_epoch="$date_epoch" export date_formatted="$date_formatted" diff --git a/src/mapentry b/src/mapentry new file mode 100755 index 0000000..857d4bd --- /dev/null +++ b/src/mapentry @@ -0,0 +1,19 @@ +#!/bin/sh +set -euo pipefail + + +usage() { + echo 'Usage: mapentry FILENAME.conf' +} + +FILENAME="${1:-}" +eval "$(assert-arg -- "$FILENAME" 'FILENAME.conf')" +. ./"$FILENAME" + + +cat < + $url_absolute + $lastmod_iso + +EOF diff --git a/src/sitemap b/src/sitemap new file mode 100755 index 0000000..48be5ea --- /dev/null +++ b/src/sitemap @@ -0,0 +1,22 @@ +#!/bin/sh +set -euo pipefail + + +opening() { + cat <<'EOF' + + +EOF +} + +closing() { + echo '' +} + + +opening +cat "$@" +closing -- cgit v1.2.3