- 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
66 lines
3.0 KiB
Bash
Executable File
66 lines
3.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# htmlviewer-directediting installer
|
|
# Applies the HTML-in-iOS-App patches to a Nextcloud 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}"
|
|
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 (core-clean) ==="
|
|
echo "Container: $CONTAINER"
|
|
|
|
# 0. Sanity
|
|
docker exec "$CONTAINER" test -d "$APP" || { echo "ERROR: htmlviewer app not found at $APP"; exit 1; }
|
|
|
|
# 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
|
|
TMPDIR_ON_HOST=$(mktemp -d)
|
|
cp patches/htmlviewer/*.php "$TMPDIR_ON_HOST/"
|
|
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 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"
|
|
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. 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"; do
|
|
docker exec "$CONTAINER" php -l "$f"
|
|
done
|
|
|
|
echo "=== Restarting container ==="
|
|
docker restart "$CONTAINER"
|
|
echo "=== Done. iOS: long press HTML file -> 'Öffnen mit Office' renders the page. ===" |