#!/bin/bash
# gen_web_hook.sh — generates static HTML header/footer files for the
# Apache autoindex listing of the danix Slackware package repository.
#
# Can be called standalone or from slackrepo's HOOK_FINISH.
# Usage: gen_web_hook.sh [/path/to/pkgrepo]
#
# If no argument is given, uses $SR_PKGREPO if set, otherwise /repo.
set -euo pipefail
PKGREPO="${1:-${SR_PKGREPO:-/repo}}"
log() { echo "gen_web_hook: $*"; }
warn() { echo "gen_web_hook: WARNING: $*" >&2; }
if [ ! -d "$PKGREPO" ]; then
warn "PKGREPO '$PKGREPO' not found."
exit 1
fi
log "Generating static web files in $PKGREPO ..."
# ── HTML escape ───────────────────────────────────────────────────────────────
html_escape() {
local s="$1"
s="${s//&/&}"
s="${s//<}"
s="${s//>/>}"
s="${s//\"/"}"
printf '%s' "$s"
}
# ── Shared CSS ────────────────────────────────────────────────────────────────
CSS=''
# ── Shared footer signature ───────────────────────────────────────────────────
footer_sig() {
cat << 'EOF'