Files
Hermes 88d618b58a htmlviewer-directediting: HTML rendering in Nextcloud iOS app
- htmlviewer: IEditor + Bridge + srcdoc iframe template + content controller
- text app: open() bridges text/html to htmlviewer template
- idempotent install.sh for re-deployment after app updates
- iPhone-tested 2026-09-11
2026-09-11 12:19:44 +00:00

27 lines
1.3 KiB
Python

import re
APP='/media/orange/RocketChat/nextcloud1/nextcloud_data/custom_apps/htmlviewer'
p=APP+'/lib/AppInfo/Application.php'
c=open(p).read()
if 'RegisterDirectEditorListener' not in c:
c=c.replace(
'use OCP\\Security\\CSP\\AddContentSecurityPolicyEvent;',
'use OCP\\Security\\CSP\\AddContentSecurityPolicyEvent;\nuse OCA\\HtmlViewer\\Listener\\RegisterDirectEditorListener;\nuse OCP\\DirectEditing\\RegisterDirectEditorEvent;'
)
c=c.replace(
" $context->registerEventListener(AddContentSecurityPolicyEvent::class, CSPListener::class);",
" $context->registerEventListener(AddContentSecurityPolicyEvent::class, CSPListener::class);\n $context->registerEventListener(RegisterDirectEditorEvent::class, RegisterDirectEditorListener::class);"
)
open(p,'w').write(c)
print('Application.php patched:', 'RegisterDirectEditorEvent' in open(p).read())
p=APP+'/appinfo/routes.php'
c=open(p).read()
if 'Direct#content' not in c:
c=c.replace(
"['name' => 'settings#disableWarning', 'url' => '/settings/warning', 'verb' => 'GET'],",
"['name' => 'settings#disableWarning', 'url' => '/settings/warning', 'verb' => 'GET'],\n\t\t['name' => 'Direct#content', 'url' => '/direct/{fileId}', 'verb' => 'GET'],"
)
open(p,'w').write(c)
print('routes.php patched:', 'Direct#content' in open(p).read())