waitForPhotoUpload waits on FilePond processing-complete; AE1/AE4 use input.filepond--browser + the .photo-convert-status error status; V3/V4 back to FilePond limit + non-image rejection; reauth hint -> .photo-reauth-hint; test-form-config asserts type:filepond. Verified against a live server via a browser smoke run (HEIC->JPEG attach, corrupt fail-closed, draft restore).
81 lines
3.5 KiB
Bash
Executable File
81 lines
3.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Validates that post-form.md is wired correctly for the add-page-by-form plugin.
|
|
# Fast, no server needed. Catches the class of bug that caused silent post failures.
|
|
set -euo pipefail
|
|
|
|
FORM="user/pages/02.post/post-form.md"
|
|
SITE="user/config/site.yaml"
|
|
PASS=0
|
|
FAIL=0
|
|
ERRORS=()
|
|
|
|
ok() { echo " ✓ $1"; PASS=$((PASS+1)); }
|
|
fail() { echo " ✗ $1"; FAIL=$((FAIL+1)); ERRORS+=("$1"); }
|
|
|
|
check_grep() {
|
|
local desc="$1"; local pattern="$2"; local file="${3:-$FORM}"
|
|
if grep -q "$pattern" "$file"; then ok "$desc"; else fail "$desc"; fi
|
|
}
|
|
|
|
check_absent() {
|
|
local desc="$1"; local pattern="$2"; local file="${3:-$FORM}"
|
|
if grep -q "$pattern" "$file"; then fail "$desc"; else ok "$desc"; fi
|
|
}
|
|
|
|
echo ""
|
|
echo "Form config validator — $FORM"
|
|
echo "────────────────────────────────────────"
|
|
|
|
# Plugin trigger: must use add_page or addpage — NOT add-page-by-form
|
|
grep -q "add_page:\|addpage:" "$FORM" && ok "Process action is 'add_page' (plugin trigger)" \
|
|
|| fail "Process action must be 'add_page: true' — 'add-page-by-form' is not handled by the plugin"
|
|
|
|
# Parent is now injected server-side from site.active_trip by the cache-on-save
|
|
# plugin (U1). The form must NOT hardcode pageconfig.parent — that coupling was
|
|
# the silent-misfile bug this whole change removes.
|
|
check_absent "pageconfig.parent is NOT hardcoded (injected server-side from active_trip)" "^\s*parent:"
|
|
check_grep "pageconfig block exists in frontmatter" "^pageconfig:"
|
|
check_grep "slug_field set (determines entry folder name)" "slug_field:"
|
|
check_grep "pagefrontmatter block exists in frontmatter" "^pagefrontmatter:"
|
|
check_grep "template: entry (creates entry.md filename)" "template: entry"
|
|
|
|
# The active trip — the server-side injection source — must be set in site.yaml.
|
|
check_grep "active_trip set in site.yaml (injection source)" "^active_trip:\s*\S" "$SITE"
|
|
|
|
# Form name must stay 'new-entry' — cache-on-save plugin checks this exact string
|
|
check_grep "form name is 'new-entry' (required by cache-on-save plugin)" "name: new-entry"
|
|
|
|
# Core form fields
|
|
check_grep "title field present" "name: title"
|
|
check_grep "date field present" "name: date"
|
|
check_grep "content field present" "name: content"
|
|
check_grep "photos field present" "name: photos"
|
|
check_grep "lat field present" "name: lat"
|
|
check_grep "lng field present" "name: lng"
|
|
check_grep "location_city field present" "name: location_city"
|
|
check_grep "location_country field present" "name: location_country"
|
|
|
|
# Fields exposed by U2 (weather picker + transport + advanced trio)
|
|
check_grep "weather_desc field present" "name: weather_desc"
|
|
check_grep "weather_temp_c field present" "name: weather_temp_c"
|
|
check_grep "transport_mode field present" "name: transport_mode"
|
|
check_grep "hero_image field present" "name: hero_image"
|
|
check_grep "force_connect field present" "name: force_connect"
|
|
check_grep "featured field present" "name: featured"
|
|
|
|
# Photos use Grav's filepond field; post-form.js hooks its beforeAddFile to
|
|
# convert HEIC->JPEG before FilePond uploads (U4).
|
|
check_grep "photos field uses the filepond type" "type: filepond"
|
|
|
|
echo "────────────────────────────────────────"
|
|
echo " $PASS passed, $FAIL failed"
|
|
|
|
if [ ${#ERRORS[@]} -gt 0 ]; then
|
|
echo ""
|
|
echo "Failed checks:"
|
|
for e in "${ERRORS[@]}"; do echo " → $e"; done
|
|
echo ""
|
|
exit 1
|
|
fi
|
|
echo ""
|