Files
website/scripts/sync-methoden.sh
tobias 98baac3d54 Änderungshistorie pro Methode/Variante + Übersichtsseite /aenderungen/
scripts/generate-dates.sh ersetzt durch scripts/generate-verlauf.rb: liest
weiterhin Erstellt-/Geaendert-Datum aus der Git-Historie von _content/,
zusaetzlich aber die vollstaendige Commit-Historie je Datei mit
Frontmatter-Diff zwischen aufeinanderfolgenden Commits (Autor + geaenderte
Feldnamen je Eintrag, neueste zuerst). hugo/data/methoden.json/varianten.json
bekommen dafuer ein neues 'verlauf'-Array, 'erstellt'/'geaendert' bleiben
unveraendert bestehen.

Neues Partial aenderungssatz.html rendert einen Eintrag als deutschen Satz
('<Felder> von <Titel> wurde(n) am <Datum> durch <Name> geaendert.' bzw.
'<Titel> wurde am <Datum> durch <Name> angelegt.', Singular/Plural nach
Feldanzahl) - wiederverwendet von aenderungshistorie.html (Anzeige am Ende
von Methoden-/Varianten-Seiten, bei Methoden ueber alle Varianten
aggregiert, analog zu variantenspanne.html) und von der neuen
Uebersichtsseite /aenderungen/ (reine Log-Ansicht, keine Karten - jede
Aenderung eine Zeile, Titel verlinkt, filterbar nach Zielgruppe/
Kompetenzbereich/Kategorie/Lizenz/Dauer/Gruppengroesse/Zeitraum ueber
dasselbe clientseitige Facetten-Muster wie die Startseite, siehe
static/js/aenderungen.js). Footer-Link 'Änderungsverlauf' unter Redaktion,
bewusst nicht in der Hauptnavigation.
2026-08-26 07:58:48 +02:00

67 lines
3.4 KiB
Bash
Executable File

#!/bin/bash
# Fetches the current state of the separate methods repo
# (ableger_demo/ableger_methoden) into ./_content - for local development and
# in the deploy hook on Uberspace. _content/ is deliberately not part of this
# repo (see .gitignore) and is freshly fetched here on every call instead of
# being pinned as a submodule. Hugo mounts _content/methoden (see
# hugo/hugo.toml) - the content repo itself contains a methoden/ subfolder,
# not just the methods directly at its root (Decap CMS workaround, see
# admin/config.yml).
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
# shellcheck source=/dev/null
source "$ROOT/install.env"
# ABLEGER_METHODEN_URL completely overrides this fallback in the deploy hook
# (a local filesystem path on the same Uberspace account, see
# the installation guide on the project website) - the SSH fallback built here from install.env is
# only needed for local development without that environment variable set.
REPO_URL="${ABLEGER_METHODEN_URL:-ssh://${GITEA_SSH_USER}@${GITEA_DOMAIN}:${GITEA_SSH_PORT}/${METHODEN_REPO}.git}"
TARGET="$ROOT/_content"
if [ -d "$TARGET/.git" ]; then
# "remote set-url" ALWAYS before the fetch, not only on first clone: an
# already existing worktree otherwise keeps the remote URL from its
# original clone time, even if REPO_URL has changed since (e.g. after a
# repo rename/transfer to a different organization). This broke live
# exactly this way: after transferring ableger_methoden to the
# "ableger_demo" organization, the worktree already present on the server
# kept pointing at the old path (tobias/ableger_methoden.git), and the
# cron job then failed on every run (every 10 minutes) until this was
# fixed manually.
git -C "$TARGET" remote set-url origin "$REPO_URL"
git -C "$TARGET" fetch origin main
git -C "$TARGET" reset --hard origin/main
else
rm -rf "$TARGET"
git clone "$REPO_URL" "$TARGET"
fi
echo "_content/ aktuell: $(git -C "$TARGET" rev-parse --short HEAD)"
# Validate against the Manifest chapter on the project website (website repo) BEFORE
# apply-veroeffentlicht.rb and compute-methoden-sichtbarkeit.rb translate the
# state for Hugo - the validation script needs the real, committed state
# (with "veroeffentlicht", without Hugo's "draft"), otherwise its own rules
# (e.g. Regel 12: no derived fields stored) could never be satisfiable
# against its own translation. set -e above ensures that an error (exit
# code 1) here aborts the entire sync/build before a broken reference or
# similar goes live unnoticed (see the project website (background/analysis notes), Befund A/B) -
# warnings (exit code 0) deliberately do not block.
ruby "$(dirname "${BASH_SOURCE[0]}")/validate.rb"
# Recompute creation/change dates and the change history from the freshly
# fetched history.
ruby "$(dirname "${BASH_SOURCE[0]}")/generate-verlauf.rb"
# Translate the variants' "veroeffentlicht" field (positive polarity) into
# Hugo's native draft field - must run before compute-methoden-
# sichtbarkeit.rb, which reads that draft field. See
# admin/config.template.yml and the script's own comments.
ruby "$(dirname "${BASH_SOURCE[0]}")/apply-veroeffentlicht.rb"
# Mark methods without a published variant as draft, locally (not in the
# content repo) - see admin/config.template.yml and the script's own comment.
ruby "$(dirname "${BASH_SOURCE[0]}")/compute-methoden-sichtbarkeit.rb"