Core-clean variant: editor id eurooffice, no text-app patch

- HtmlDirectEditor getId() now returns 'eurooffice' (hard-coded in the
  iOS/Android editor registry) -> 'Öffnen mit Office' long-press renders HTML
- install.sh restores the original TextDirectEditor if a previous
  install patched it; no core app patch anymore
- README rewritten: behavior, variant rationale, files
This commit is contained in:
Hermes
2026-09-11 12:28:13 +00:00
parent 84d455d19c
commit 818c793ce6
4 changed files with 55 additions and 224 deletions
+20 -31
View File
@@ -1,9 +1,16 @@
#!/usr/bin/env bash
# htmlviewer-directediting installer
# Applies the HTML-in-iOS-App patches to a Nextcloud container.
# Usage: ./install.sh <container-name> [custom_apps-path-in-container]
# Usage: ./install.sh <container-name>
# default container: nextcloud1-app-1
# Idempotent: safe to re-run after app updates.
#
# This version is CORE-CLEAN: the Nextcloud text app is NOT patched.
# The htmlviewer app registers its editor under the hard-coded app
# editor id "eurooffice" ("Öffnen mit Office" via long press). Plain
# tap on an HTML file still opens the source view (iOS default) —
# single-tap auto-open would require patching the text app, see
# README.md "Varianten".
set -euo pipefail
CONTAINER="${1:-nextcloud1-app-1}"
@@ -11,67 +18,49 @@ APP="/var/www/html/custom_apps/htmlviewer"
TEXT="/var/www/html/apps/text/lib/DirectEditing/TextDirectEditor.php"
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
echo "=== htmlviewer-directediting installer ==="
echo "=== htmlviewer-directediting installer (core-clean) ==="
echo "Container: $CONTAINER"
# 0. Sanity
docker exec "$CONTAINER" test -d "$APP" || { echo "ERROR: htmlviewer app not found at $APP"; exit 1; }
# 1. Backup text editor (first run only)
if ! docker exec "$CONTAINER" test -f /tmp/TextDirectEditor.php.bak-htmlproject; then
docker exec "$CONTAINER" cp "$TEXT" /tmp/TextDirectEditor.php.bak-htmlproject 2>/dev/null || \
docker exec "$CONTAINER" bash -c "cp $TEXT /tmp/TextDirectEditor.php.bak-htmlproject" || true
# 1. RESTORE original text app if it was patched by an earlier install
if docker exec "$CONTAINER" test -f /tmp/TextDirectEditor.php.bak-htmlproject; then
echo "--- restoring original TextDirectEditor.php from backup"
docker exec "$CONTAINER" bash -c "cp /tmp/TextDirectEditor.php.bak-htmlproject $TEXT"
else
echo "--- no text-app backup found; nothing to restore (good)"
fi
# 2. Deploy htmlviewer files (from repo to container via /tmp)
# 2. Deploy htmlviewer files
TMPDIR_ON_HOST=$(mktemp -d)
cp patches/htmlviewer/*.php "$TMPDIR_ON_HOST/"
cp patches/text/TextDirectEditor.php "$TMPDIR_ON_HOST/TextDirectEditor-patched.php"
docker cp "$TMPDIR_ON_HOST/HtmlDirectEditor.php" "$CONTAINER:$APP/lib/DirectEditing/HtmlDirectEditor.php"
docker cp "$TMPDIR_ON_HOST/HtmlDirectEditorBridge.php" "$CONTAINER:$APP/lib/DirectEditing/HtmlDirectEditorBridge.php"
docker cp "$TMPDIR_ON_HOST/DirectController.php" "$CONTAINER:$APP/lib/Controller/DirectController.php"
docker cp "$TMPDIR_ON_HOST/RegisterDirectEditorListener.php" "$CONTAINER:$APP/lib/Listeners/RegisterDirectEditorListener.php"
docker cp "$TMPDIR_ON_HOST/directEditing-template.php" "$CONTAINER:$APP/templates/directEditing.php"
docker cp "$TMPDIR_ON_HOST/TextDirectEditor-patched.php" "$CONTAINER:/var/www/html/apps/text/lib/DirectEditing/TextDirectEditor.php"
docker exec "$CONTAINER" chown www-data:www-data \
"$APP/lib/DirectEditing/HtmlDirectEditor.php" \
"$APP/lib/DirectEditing/HtmlDirectEditorBridge.php" \
"$APP/lib/Controller/DirectController.php" \
"$APP/lib/Listeners/RegisterDirectEditorListener.php" \
"$APP/templates/directEditing.php" \
/var/www/html/apps/text/lib/DirectEditing/TextDirectEditor.php
"$APP/templates/directEditing.php"
rm -rf "$TMPDIR_ON_HOST"
# 3. Register in Application.php + routes.php (idempotent)
docker cp patches/htmlviewer/patch_app.py "$CONTAINER:/tmp/patch_app.py"
docker exec "$CONTAINER" python3 /tmp/patch_app.py
# 4. Text-app mimic list: remove text/html so iOS picks... (NO — text stays owner)
# NOTE: text/html must STAY in the text editor's mimetypes list so the
# iOS app (which only knows editor id "text") opens HTML via the bridge.
# If it was removed by an older version of this installer, re-add it.
docker exec "$CONTAINER" python3 - <<'PYEOF'
p='/var/www/html/apps/text/lib/DirectEditing/TextDirectEditor.php'
c=open(p).read()
if "'text/html'" not in c:
c=c.replace("\t\t\t'text/css',", "\t\t\t'text/css',\n\t\t\t'text/html',")
open(p,'w').write(c)
print('text/html re-added to TextDirectEditor mimetypes')
else:
print('text/html present in TextDirectEditor')
PYEOF
# 5. Lint + restart
# 4. Lint + restart
for f in "$APP/lib/DirectEditing/HtmlDirectEditor.php" \
"$APP/lib/DirectEditing/HtmlDirectEditorBridge.php" \
"$APP/lib/Controller/DirectController.php" \
"$APP/lib/Listeners/RegisterDirectEditorListener.php" \
"$APP/templates/directEditing.php" \
/var/www/html/apps/text/lib/DirectEditing/TextDirectEditor.php; do
"$APP/templates/directEditing.php"; do
docker exec "$CONTAINER" php -l "$f"
done
echo "=== Restarting container ==="
docker restart "$CONTAINER"
echo "=== Done. Test: open an .html file in the iOS app (kill app first). ==="
echo "=== Done. iOS: long press HTML file -> 'Öffnen mit Office' renders the page. ==="