aboutsummaryrefslogtreecommitdiffstats
path: root/apps/settings/lib/SetupChecks/Woff2Loading.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/settings/lib/SetupChecks/Woff2Loading.php')
-rw-r--r--apps/settings/lib/SetupChecks/Woff2Loading.php51
1 files changed, 25 insertions, 26 deletions
diff --git a/apps/settings/lib/SetupChecks/Woff2Loading.php b/apps/settings/lib/SetupChecks/Woff2Loading.php
index d54cbc908ef..27aff4ea999 100644
--- a/apps/settings/lib/SetupChecks/Woff2Loading.php
+++ b/apps/settings/lib/SetupChecks/Woff2Loading.php
@@ -3,25 +3,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2024 Ferdinand Thiessen <opensource@fthiessen.de>
- *
- * @author Ferdinand Thiessen <opensource@fthiessen.de>
- *
- * @license AGPL-3.0-or-later
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Settings\SetupChecks;
@@ -29,12 +12,13 @@ use OCP\Http\Client\IClientService;
use OCP\IConfig;
use OCP\IL10N;
use OCP\IURLGenerator;
+use OCP\SetupCheck\CheckServerResponseTrait;
use OCP\SetupCheck\ISetupCheck;
use OCP\SetupCheck\SetupResult;
use Psr\Log\LoggerInterface;
/**
- * Check whether the WOFF2 URLs works
+ * Check whether the OTF and WOFF2 URLs works
*/
class Woff2Loading implements ISetupCheck {
use CheckServerResponseTrait;
@@ -53,13 +37,20 @@ class Woff2Loading implements ISetupCheck {
}
public function getName(): string {
- return $this->l10n->t('WOFF2 file loading');
+ return $this->l10n->t('Font file loading');
}
public function run(): SetupResult {
- $url = $this->urlGenerator->linkTo('', 'core/fonts/NotoSans-Regular-latin.woff2');
+ $result = $this->checkFont('otf', $this->urlGenerator->linkTo('theming', 'fonts/OpenDyslexic-Regular.otf'));
+ if ($result->getSeverity() !== SetupResult::SUCCESS) {
+ return $result;
+ }
+ return $this->checkFont('woff2', $this->urlGenerator->linkTo('', 'core/fonts/NotoSans-Regular-latin.woff2'));
+ }
+
+ protected function checkFont(string $fileExtension, string $url): SetupResult {
$noResponse = true;
- $responses = $this->runHEAD($url);
+ $responses = $this->runRequest('HEAD', $url);
foreach ($responses as $response) {
$noResponse = false;
if ($response->getStatusCode() === 200) {
@@ -69,14 +60,22 @@ class Woff2Loading implements ISetupCheck {
if ($noResponse) {
return SetupResult::info(
- $this->l10n->t('Could not check for WOFF2 loading support. Please check manually if your webserver serves `.woff2` files.') . "\n" . $this->serverConfigHelp(),
+ str_replace(
+ '{extension}',
+ $fileExtension,
+ $this->l10n->t('Could not check for {extension} loading support. Please check manually if your webserver serves `.{extension}` files.') . "\n" . $this->serverConfigHelp(),
+ ),
$this->urlGenerator->linkToDocs('admin-nginx'),
);
}
return SetupResult::warning(
- $this->l10n->t('Your web server is not properly set up to deliver .woff2 files. This is typically an issue with the Nginx configuration. For Nextcloud 15 it needs an adjustement to also deliver .woff2 files. Compare your Nginx configuration to the recommended configuration in our documentation.'),
+ str_replace(
+ '{extension}',
+ $fileExtension,
+ $this->l10n->t('Your web server is not properly set up to deliver .{extension} files. This is typically an issue with the Nginx configuration. For Nextcloud 15 it needs an adjustment to also deliver .{extension} files. Compare your Nginx configuration to the recommended configuration in our documentation.'),
+ ),
$this->urlGenerator->linkToDocs('admin-nginx'),
);
-
+
}
}