Improve GrampsWeb base href patching: find all index.html copies (STI-90)
Some checks failed
CI/CD Pipeline / test (push) Has been cancelled
CI/CD Pipeline / deploy (push) Has been cancelled
Code Quality / quality (push) Has been cancelled

The previous sed only patched two known paths. Now uses find to discover
and patch all index.html files containing <base href="/"> across the
entire container, with logging to show which files were patched.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
SysAdmin Agent
2026-03-24 08:44:21 +00:00
parent 55da366014
commit 2a579c83c0
2 changed files with 16 additions and 9 deletions

View File

@@ -209,12 +209,15 @@ services:
- |
if [ -n "$$GRAMPSWEB_SUBPATH" ] && [ "$$GRAMPSWEB_SUBPATH" != "/" ]; then
SUBPATH="$$GRAMPSWEB_SUBPATH"
# Ensure trailing slash for base href
case "$$SUBPATH" in */) ;; *) SUBPATH="$${SUBPATH}/" ;; esac
sed -i "s|<base href=\"/\">|<base href=\"$$SUBPATH\">|g" \
/app/src/gramps_webapi/static/index.html \
/app/static/index.html 2>/dev/null || true
echo "Patched <base href> to $$SUBPATH"
echo "[grampsweb] Patching <base href> to $$SUBPATH ..."
find / -name index.html -path "*/gramps*" -o -name index.html -path "*/static/*" 2>/dev/null | while read f; do
if grep -q '<base href="/">' "$$f" 2>/dev/null; then
sed -i "s|<base href=\"/\">|<base href=\"$$SUBPATH\">|g" "$$f"
echo "[grampsweb] patched: $$f"
fi
done
echo "[grampsweb] Done."
fi
exec gunicorn -w $${GUNICORN_NUM_WORKERS:-8} -b 0.0.0.0:5000 \
gramps_webapi.wsgi:app --timeout $${GUNICORN_TIMEOUT:-120} \

View File

@@ -136,10 +136,14 @@ services:
if [ -n "$$GRAMPSWEB_SUBPATH" ] && [ "$$GRAMPSWEB_SUBPATH" != "/" ]; then
SUBPATH="$$GRAMPSWEB_SUBPATH"
case "$$SUBPATH" in */) ;; *) SUBPATH="$${SUBPATH}/" ;; esac
sed -i "s|<base href=\"/\">|<base href=\"$$SUBPATH\">|g" \
/app/src/gramps_webapi/static/index.html \
/app/static/index.html 2>/dev/null || true
echo "Patched <base href> to $$SUBPATH"
echo "[grampsweb] Patching <base href> to $$SUBPATH ..."
find / -name index.html -path "*/gramps*" -o -name index.html -path "*/static/*" 2>/dev/null | while read f; do
if grep -q '<base href="/">' "$$f" 2>/dev/null; then
sed -i "s|<base href=\"/\">|<base href=\"$$SUBPATH\">|g" "$$f"
echo "[grampsweb] patched: $$f"
fi
done
echo "[grampsweb] Done."
fi
exec gunicorn -w $${GUNICORN_NUM_WORKERS:-8} -b 0.0.0.0:5000 \
gramps_webapi.wsgi:app --timeout $${GUNICORN_TIMEOUT:-120} \