diff options
-rw-r--r-- | apps/settings/appinfo/routes.php | 2 | ||||
-rw-r--r-- | apps/settings/css/help.css | 13 | ||||
-rw-r--r-- | apps/settings/lib/Controller/HelpController.php | 37 | ||||
-rw-r--r-- | apps/settings/templates/help.php | 91 | ||||
-rw-r--r-- | config/config.sample.php | 6 | ||||
-rw-r--r-- | core/doc/admin/index.html | 2 | ||||
-rw-r--r-- | core/doc/user/index.html | 2 |
7 files changed, 125 insertions, 28 deletions
diff --git a/apps/settings/appinfo/routes.php b/apps/settings/appinfo/routes.php index d13984e315e..e238510b1a7 100644 --- a/apps/settings/appinfo/routes.php +++ b/apps/settings/appinfo/routes.php @@ -77,7 +77,7 @@ return [ ['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 e5fdd04af7f..6023a979bdf 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 cf202c28d98..3128cbfaa23 100644 --- a/apps/settings/lib/Controller/HelpController.php +++ b/apps/settings/lib/Controller/HelpController.php @@ -39,6 +39,7 @@ use OCP\IL10N; 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 @@ class HelpController extends Controller { IURLGenerator $urlGenerator, ?string $userId, IGroupManager $groupManager, - IL10N $l10n + IL10N $l10n, + IConfig $config, ) { parent::__construct($appName, $request); $this->navigationManager = $navigationManager; @@ -70,6 +75,7 @@ class HelpController extends Controller { $this->userId = $userId; $this->groupManager = $groupManager; $this->l10n = $l10n; + $this->config = $config; } /** @@ -79,19 +85,40 @@ class HelpController extends Controller { * @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 58e38feb64c..850ca388996 100644 --- a/apps/settings/templates/help.php +++ b/apps/settings/templates/help.php @@ -1,28 +1,75 @@ <?php \OC_Util::addStyle('settings', 'help'); ?> +<?php if ($_['knowledgebaseEmbedded'] === true) : ?> + <div id="app-navigation" role="navigation" tabindex="0"> + <ul> + <li> + <a class="icon-user <?php if ($_['mode'] === 'user') { + p('active'); + } ?>" <?php if ($_['mode'] === 'user') { print_unescaped('aria-current="page"'); } ?> + href="<?php print_unescaped($_['urlUserDocs']); ?>"> + <span class="help-list__text"> + <?php p($l->t('User documentation')); ?> + </span> + </a> + </li> + <?php if ($_['admin']) { ?> + <li> + <a class="icon-user-admin <?php if ($_['mode'] === 'admin') { + p('active'); + } ?>" <?php if ($_['mode'] === 'admin') { print_unescaped('aria-current="page"'); } ?> + href="<?php print_unescaped($_['urlAdminDocs']); ?>"> + <span class="help-list__text"> + <?php p($l->t('Administrator documentation')); ?> + </span> + </a> + </li> + <?php } ?> -<div id="app-content"> - <div class="help-wrapper"> - <div class="help-content"> - <h2 class="help-content__heading"> - <?php p($l->t('Nextcloud help overview')); ?> - </h2> - <div class="help-content__body"> - <a class="button" target="_blank" rel="noreferrer noopener" - href="<?php print_unescaped($_['urlAdminDocs']); ?>"> - <?php p($l->t('Administration documentation')); ?> ↗ - </a> - <a class="button" target="_blank" rel="noreferrer noopener" - href="<?php print_unescaped($_['urlUserDocs']); ?>"> - <?php p($l->t('Account documentation')); ?> ↗ - </a> - <a href="https://docs.nextcloud.com" class="button" target="_blank" rel="noreferrer noopener"> - <?php p($l->t('General documentation')); ?> ↗ - </a> - <a href="https://help.nextcloud.com" class="button" target="_blank" rel="noreferrer noopener"> - <?php p($l->t('Forum')); ?> ↗ - </a> + <li> + <a href="https://docs.nextcloud.com" class="icon-category-office" target="_blank" rel="noreferrer noopener"> + <span class="help-list__text"> + <?php p($l->t('Documentation')); ?> ↗ + </span> + </a> + </li> + <li> + <a href="https://help.nextcloud.com" class="icon-comment" target="_blank" rel="noreferrer noopener"> + <span class="help-list__text"> + <?php p($l->t('Forum')); ?> ↗ + </span> + </a> + </li> + </div> + + <div id="app-content" class="help-includes"> + <iframe src="<?php print_unescaped($_['url']); ?>" class="help-iframe" tabindex="0"> + </iframe> + </div> +<?php else: ?> + <div id="app-content"> + <div class="help-wrapper"> + <div class="help-content"> + <h2 class="help-content__heading"> + <?php p($l->t('Nextcloud help overview')); ?> + </h2> + <div class="help-content__body"> + <a class="button" target="_blank" rel="noreferrer noopener" + href="<?php print_unescaped($_['urlUserDocs']); ?>"> + <?php p($l->t('Account documentation')); ?> ↗ + </a> + <a class="button" target="_blank" rel="noreferrer noopener" + href="<?php print_unescaped($_['urlAdminDocs']); ?>"> + <?php p($l->t('Administration documentation')); ?> ↗ + </a> + <a href="https://docs.nextcloud.com" class="button" target="_blank" rel="noreferrer noopener"> + <?php p($l->t('General documentation')); ?> ↗ + </a> + <a href="https://help.nextcloud.com" class="button" target="_blank" rel="noreferrer noopener"> + <?php p($l->t('Forum')); ?> ↗ + </a> + </div> </div> </div> -</div> +<?php endif; ?> diff --git a/config/config.sample.php b/config/config.sample.php index 3db99c68c06..840a394abf7 100644 --- a/config/config.sample.php +++ b/config/config.sample.php @@ -235,6 +235,12 @@ $CONFIG = [ 'knowledgebaseenabled' => true, /** + * ``true`` embeds the documentation in an iframe inside Nextcloud. + * ``false`` only shows buttons to the online documentation. + */ +'knowledgebase.embedded' => false, + +/** * ``true`` allows users to change their display names (on their Personal * pages), and ``false`` prevents them from changing their display names. */ diff --git a/core/doc/admin/index.html b/core/doc/admin/index.html new file mode 100644 index 00000000000..ac24d0503bf --- /dev/null +++ b/core/doc/admin/index.html @@ -0,0 +1,2 @@ +Here goes the admin documentation. +In the meantime go to <a href="https://nextcloud.com/support/" target="_blank">nextcloud.com/support/</a> diff --git a/core/doc/user/index.html b/core/doc/user/index.html new file mode 100644 index 00000000000..409495a42c9 --- /dev/null +++ b/core/doc/user/index.html @@ -0,0 +1,2 @@ +Here goes the user documentation +In the meantime go to <a href="https://nextcloud.com/support/" target="_blank">nextcloud.com/support/</a> |