From 6439fdf5b61d982838daf3c5b553577e5d54392c Mon Sep 17 00:00:00 2001 From: Simon L Date: Thu, 5 Oct 2023 13:05:22 +0200 Subject: [PATCH 1/3] Move inline docs to online documentation Signed-off-by: Simon L --- apps/settings/appinfo/routes.php | 2 +- apps/settings/css/help.css | 36 +++++++---- .../lib/Controller/HelpController.php | 21 ++----- apps/settings/templates/help.php | 60 +++++++------------ core/doc/admin/index.html | 2 - core/doc/user/index.html | 2 - 6 files changed, 51 insertions(+), 72 deletions(-) delete mode 100644 core/doc/admin/index.html delete mode 100644 core/doc/user/index.html diff --git a/apps/settings/appinfo/routes.php b/apps/settings/appinfo/routes.php index e238510b1a75f..d13984e315eab 100644 --- a/apps/settings/appinfo/routes.php +++ b/apps/settings/appinfo/routes.php @@ -77,7 +77,7 @@ ['name' => 'TwoFactorSettings#update', 'url' => '/settings/api/admin/twofactorauth', 'verb' => 'PUT' , 'root' => ''], ['name' => 'AISettings#update', 'url' => '/settings/api/admin/ai', 'verb' => 'PUT' , 'root' => ''], - ['name' => 'Help#help', 'url' => '/settings/help/{mode}', 'verb' => 'GET', 'defaults' => ['mode' => ''] , 'root' => ''], + ['name' => 'Help#help', 'url' => '/settings/help', 'verb' => 'GET', 'root' => ''], ['name' => 'WebAuthn#startRegistration', 'url' => '/settings/api/personal/webauthn/registration', 'verb' => 'GET' , 'root' => ''], ['name' => 'WebAuthn#finishRegistration', 'url' => '/settings/api/personal/webauthn/registration', 'verb' => 'POST' , 'root' => ''], diff --git a/apps/settings/css/help.css b/apps/settings/css/help.css index a18538c20e662..e5fdd04af7f80 100644 --- a/apps/settings/css/help.css +++ b/apps/settings/css/help.css @@ -1,16 +1,32 @@ -.help-includes { - overflow: hidden !important; -} - .help-list__text { margin-left: 24px; } -.help-iframe { - width: 100%; +.help-wrapper { + display: flex; + justify-content: center; + align-items: center; height: 100%; - margin: 0; - padding: 0; - border: 0; - overflow: auto; + width: 100%; +} + +.help-content__heading { + text-align: center; + padding: 20px; +} + +.help-content { + display: block; + padding: 20px; +} + +.help-content__body { + display: flex; + justify-content: center; + align-items: center; + flex-wrap: wrap; +} + +.help-content__body > .button { + margin: 20px; } diff --git a/apps/settings/lib/Controller/HelpController.php b/apps/settings/lib/Controller/HelpController.php index aa850b7d42e74..cf202c28d9819 100644 --- a/apps/settings/lib/Controller/HelpController.php +++ b/apps/settings/lib/Controller/HelpController.php @@ -79,32 +79,19 @@ public function __construct( * @NoAdminRequired * @NoSubAdminRequired */ - public function help(string $mode = 'user'): TemplateResponse { + public function help(): TemplateResponse { $this->navigationManager->setActiveEntry('help'); - $pageTitle = $this->l10n->t('Administrator documentation'); - if ($mode !== 'admin') { - $pageTitle = $this->l10n->t('User documentation'); - $mode = 'user'; - } + $pageTitle = $this->l10n->t('Nextcloud help overview'); - $documentationUrl = $this->urlGenerator->getAbsoluteURL( - $this->urlGenerator->linkTo('', 'core/doc/' . $mode . '/index.html') - ); - - $urlUserDocs = $this->urlGenerator->linkToRoute('settings.Help.help', ['mode' => 'user']); - $urlAdminDocs = $this->urlGenerator->linkToRoute('settings.Help.help', ['mode' => 'admin']); + $urlUserDocs = $this->urlGenerator->linkToDocs('user'); + $urlAdminDocs = $this->urlGenerator->linkToDocs('admin'); $response = new TemplateResponse('settings', 'help', [ 'admin' => $this->groupManager->isAdmin($this->userId), - 'url' => $documentationUrl, 'urlUserDocs' => $urlUserDocs, 'urlAdminDocs' => $urlAdminDocs, - 'mode' => $mode, 'pageTitle' => $pageTitle, ]); - $policy = new ContentSecurityPolicy(); - $policy->addAllowedFrameDomain('\'self\''); - $response->setContentSecurityPolicy($policy); return $response; } } diff --git a/apps/settings/templates/help.php b/apps/settings/templates/help.php index 18cba18559a51..58e38feb64c9d 100644 --- a/apps/settings/templates/help.php +++ b/apps/settings/templates/help.php @@ -1,48 +1,28 @@ - - - + diff --git a/core/doc/admin/index.html b/core/doc/admin/index.html deleted file mode 100644 index ac24d0503bf9f..0000000000000 --- a/core/doc/admin/index.html +++ /dev/null @@ -1,2 +0,0 @@ -Here goes the admin documentation. -In the meantime go to nextcloud.com/support/ diff --git a/core/doc/user/index.html b/core/doc/user/index.html deleted file mode 100644 index 409495a42c999..0000000000000 --- a/core/doc/user/index.html +++ /dev/null @@ -1,2 +0,0 @@ -Here goes the user documentation -In the meantime go to nextcloud.com/support/ From e5b11ced4a209bfee445bebb98f38d07fb5365c0 Mon Sep 17 00:00:00 2001 From: Simon L Date: Fri, 6 Oct 2023 16:08:26 +0200 Subject: [PATCH 2/3] address review Signed-off-by: Simon L --- apps/settings/appinfo/routes.php | 2 +- apps/settings/css/help.css | 13 +++ .../lib/Controller/HelpController.php | 37 +++++++- apps/settings/templates/help.php | 91 ++++++++++++++----- config/config.sample.php | 6 ++ core/doc/admin/index.html | 2 + core/doc/user/index.html | 2 + 7 files changed, 125 insertions(+), 28 deletions(-) create mode 100644 core/doc/admin/index.html create mode 100644 core/doc/user/index.html diff --git a/apps/settings/appinfo/routes.php b/apps/settings/appinfo/routes.php index d13984e315eab..e238510b1a75f 100644 --- a/apps/settings/appinfo/routes.php +++ b/apps/settings/appinfo/routes.php @@ -77,7 +77,7 @@ ['name' => 'TwoFactorSettings#update', 'url' => '/settings/api/admin/twofactorauth', 'verb' => 'PUT' , 'root' => ''], ['name' => 'AISettings#update', 'url' => '/settings/api/admin/ai', 'verb' => 'PUT' , 'root' => ''], - ['name' => 'Help#help', 'url' => '/settings/help', 'verb' => 'GET', 'root' => ''], + ['name' => 'Help#help', 'url' => '/settings/help/{mode}', 'verb' => 'GET', 'defaults' => ['mode' => ''] , 'root' => ''], ['name' => 'WebAuthn#startRegistration', 'url' => '/settings/api/personal/webauthn/registration', 'verb' => 'GET' , 'root' => ''], ['name' => 'WebAuthn#finishRegistration', 'url' => '/settings/api/personal/webauthn/registration', 'verb' => 'POST' , 'root' => ''], diff --git a/apps/settings/css/help.css b/apps/settings/css/help.css index e5fdd04af7f80..6023a979bdf99 100644 --- a/apps/settings/css/help.css +++ b/apps/settings/css/help.css @@ -1,7 +1,20 @@ +.help-includes { + overflow: hidden !important; +} + .help-list__text { margin-left: 24px; } +.help-iframe { + width: 100%; + height: 100%; + margin: 0; + padding: 0; + border: 0; + overflow: auto; +} + .help-wrapper { display: flex; justify-content: center; diff --git a/apps/settings/lib/Controller/HelpController.php b/apps/settings/lib/Controller/HelpController.php index cf202c28d9819..3128cbfaa2343 100644 --- a/apps/settings/lib/Controller/HelpController.php +++ b/apps/settings/lib/Controller/HelpController.php @@ -39,6 +39,7 @@ use OCP\INavigationManager; use OCP\IRequest; use OCP\IURLGenerator; +use OCP\IConfig; #[IgnoreOpenAPI] class HelpController extends Controller { @@ -55,6 +56,9 @@ class HelpController extends Controller { /** @var string */ private $userId; + /** @var IConfig */ + private $config; + public function __construct( string $appName, IRequest $request, @@ -62,7 +66,8 @@ public function __construct( IURLGenerator $urlGenerator, ?string $userId, IGroupManager $groupManager, - IL10N $l10n + IL10N $l10n, + IConfig $config, ) { parent::__construct($appName, $request); $this->navigationManager = $navigationManager; @@ -70,6 +75,7 @@ public function __construct( $this->userId = $userId; $this->groupManager = $groupManager; $this->l10n = $l10n; + $this->config = $config; } /** @@ -79,19 +85,40 @@ public function __construct( * @NoAdminRequired * @NoSubAdminRequired */ - public function help(): TemplateResponse { + public function help(string $mode = 'user'): TemplateResponse { $this->navigationManager->setActiveEntry('help'); - $pageTitle = $this->l10n->t('Nextcloud help overview'); + $pageTitle = $this->l10n->t('Administrator documentation'); + if ($mode !== 'admin') { + $pageTitle = $this->l10n->t('User documentation'); + $mode = 'user'; + } + + $documentationUrl = $this->urlGenerator->getAbsoluteURL( + $this->urlGenerator->linkTo('', 'core/doc/' . $mode . '/index.html') + ); + + $urlUserDocs = $this->urlGenerator->linkToRoute('settings.Help.help', ['mode' => 'user']); + $urlAdminDocs = $this->urlGenerator->linkToRoute('settings.Help.help', ['mode' => 'admin']); - $urlUserDocs = $this->urlGenerator->linkToDocs('user'); - $urlAdminDocs = $this->urlGenerator->linkToDocs('admin'); + $knowledgebaseEmbedded = $this->config->getSystemValueBool('knowledgebase.embedded', false); + if (!$knowledgebaseEmbedded) { + $pageTitle = $this->l10n->t('Nextcloud help overview'); + $urlUserDocs = $this->urlGenerator->linkToDocs('user'); + $urlAdminDocs = $this->urlGenerator->linkToDocs('admin'); + } $response = new TemplateResponse('settings', 'help', [ 'admin' => $this->groupManager->isAdmin($this->userId), + 'url' => $documentationUrl, 'urlUserDocs' => $urlUserDocs, 'urlAdminDocs' => $urlAdminDocs, + 'mode' => $mode, 'pageTitle' => $pageTitle, + 'knowledgebaseEmbedded' => $knowledgebaseEmbedded, ]); + $policy = new ContentSecurityPolicy(); + $policy->addAllowedFrameDomain('\'self\''); + $response->setContentSecurityPolicy($policy); return $response; } } diff --git a/apps/settings/templates/help.php b/apps/settings/templates/help.php index 58e38feb64c9d..850ca388996ba 100644 --- a/apps/settings/templates/help.php +++ b/apps/settings/templates/help.php @@ -1,28 +1,75 @@ + +