aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/settings/lib/AppInfo/Application.php2
-rw-r--r--apps/settings/lib/SetupChecks/Woff2Loading.php82
-rw-r--r--apps/settings/src/admin.js5
-rw-r--r--core/js/setupchecks.js34
-rw-r--r--core/js/tests/specs/setupchecksSpec.js27
5 files changed, 86 insertions, 64 deletions
diff --git a/apps/settings/lib/AppInfo/Application.php b/apps/settings/lib/AppInfo/Application.php
index 8318391a2e6..279f8be496b 100644
--- a/apps/settings/lib/AppInfo/Application.php
+++ b/apps/settings/lib/AppInfo/Application.php
@@ -86,6 +86,7 @@ use OCA\Settings\SetupChecks\SupportedDatabase;
use OCA\Settings\SetupChecks\SystemIs64bit;
use OCA\Settings\SetupChecks\TempSpaceAvailable;
use OCA\Settings\SetupChecks\TransactionIsolation;
+use OCA\Settings\SetupChecks\Woff2Loading;
use OCA\Settings\UserMigration\AccountMigrator;
use OCA\Settings\WellKnown\ChangePasswordHandler;
use OCA\Settings\WellKnown\SecurityTxtHandler;
@@ -213,6 +214,7 @@ class Application extends App implements IBootstrap {
$context->registerSetupCheck(TempSpaceAvailable::class);
$context->registerSetupCheck(TransactionIsolation::class);
$context->registerSetupCheck(PushService::class);
+ $context->registerSetupCheck(Woff2Loading::class);
$context->registerUserMigrator(AccountMigrator::class);
}
diff --git a/apps/settings/lib/SetupChecks/Woff2Loading.php b/apps/settings/lib/SetupChecks/Woff2Loading.php
new file mode 100644
index 00000000000..d54cbc908ef
--- /dev/null
+++ b/apps/settings/lib/SetupChecks/Woff2Loading.php
@@ -0,0 +1,82 @@
+<?php
+
+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/>.
+ *
+ */
+namespace OCA\Settings\SetupChecks;
+
+use OCP\Http\Client\IClientService;
+use OCP\IConfig;
+use OCP\IL10N;
+use OCP\IURLGenerator;
+use OCP\SetupCheck\ISetupCheck;
+use OCP\SetupCheck\SetupResult;
+use Psr\Log\LoggerInterface;
+
+/**
+ * Check whether the WOFF2 URLs works
+ */
+class Woff2Loading implements ISetupCheck {
+ use CheckServerResponseTrait;
+
+ public function __construct(
+ protected IL10N $l10n,
+ protected IConfig $config,
+ protected IURLGenerator $urlGenerator,
+ protected IClientService $clientService,
+ protected LoggerInterface $logger,
+ ) {
+ }
+
+ public function getCategory(): string {
+ return 'network';
+ }
+
+ public function getName(): string {
+ return $this->l10n->t('WOFF2 file loading');
+ }
+
+ public function run(): SetupResult {
+ $url = $this->urlGenerator->linkTo('', 'core/fonts/NotoSans-Regular-latin.woff2');
+ $noResponse = true;
+ $responses = $this->runHEAD($url);
+ foreach ($responses as $response) {
+ $noResponse = false;
+ if ($response->getStatusCode() === 200) {
+ return SetupResult::success();
+ }
+ }
+
+ 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(),
+ $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.'),
+ $this->urlGenerator->linkToDocs('admin-nginx'),
+ );
+
+ }
+}
diff --git a/apps/settings/src/admin.js b/apps/settings/src/admin.js
index 35f5266acba..842f79a9f0e 100644
--- a/apps/settings/src/admin.js
+++ b/apps/settings/src/admin.js
@@ -110,10 +110,9 @@ window.addEventListener('DOMContentLoaded', () => {
OC.SetupChecks.checkProviderUrl(OC.getRootPath() + '/ocs-provider/', OC.theme.docPlaceholderUrl, $('#postsetupchecks').data('check-wellknown') === true),
OC.SetupChecks.checkSetup(),
OC.SetupChecks.checkGeneric(),
- OC.SetupChecks.checkWOFF2Loading(OC.filePath('core', '', 'fonts/NotoSans-Regular-latin.woff2'), OC.theme.docPlaceholderUrl),
OC.SetupChecks.checkDataProtected(),
- ).then((check1, check2, check3, check4, check5, check6, check7, check8, check9, check10, check11) => {
- const messages = [].concat(check1, check2, check3, check4, check5, check6, check7, check8, check9, check10, check11)
+ ).then((check1, check2, check3, check4, check5, check6, check7, check8, check9, check10) => {
+ const messages = [].concat(check1, check2, check3, check4, check5, check6, check7, check8, check9, check10)
const $el = $('#postsetupchecks')
$('#security-warning-state-loading').addClass('hidden')
diff --git a/core/js/setupchecks.js b/core/js/setupchecks.js
index fe6ab1105a2..be6dc747540 100644
--- a/core/js/setupchecks.js
+++ b/core/js/setupchecks.js
@@ -136,40 +136,6 @@
return deferred.promise();
},
-
- /**
- * Check whether the WOFF2 URLs works.
- *
- * @param url the URL to test
- * @param placeholderUrl the placeholder URL - can be found at OC.theme.docPlaceholderUrl
- * @return $.Deferred object resolved with an array of error messages
- */
- checkWOFF2Loading: function(url, placeholderUrl) {
- var deferred = $.Deferred();
-
- var afterCall = function(xhr) {
- var messages = [];
- if (xhr.status !== 200) {
- var docUrl = placeholderUrl.replace('PLACEHOLDER', 'admin-nginx');
- messages.push({
- msg: t('core', '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 {linkstart}documentation ↗{linkend}.', { docLink: docUrl, url: url })
- .replace('{linkstart}', '<a target="_blank" rel="noreferrer noopener" class="external" href="' + docUrl + '">')
- .replace('{linkend}', '</a>'),
- type: OC.SetupChecks.MESSAGE_TYPE_WARNING
- });
- }
- deferred.resolve(messages);
- };
-
- $.ajax({
- type: 'GET',
- url: url,
- complete: afterCall,
- allowAuthErrors: true
- });
- return deferred.promise();
- },
-
/**
* Runs setup checks on the server side
*
diff --git a/core/js/tests/specs/setupchecksSpec.js b/core/js/tests/specs/setupchecksSpec.js
index 9ac31ce8acb..378bd4d7f39 100644
--- a/core/js/tests/specs/setupchecksSpec.js
+++ b/core/js/tests/specs/setupchecksSpec.js
@@ -143,33 +143,6 @@ describe('OC.SetupChecks tests', function() {
});
});
- describe('checkWOFF2Loading', function() {
- it('should fail with another response status code than the expected one', function(done) {
- var async = OC.SetupChecks.checkWOFF2Loading(OC.filePath('core', '', 'fonts/NotoSans-Regular-latin.woff2'), 'http://example.org/PLACEHOLDER');
-
- suite.server.requests[0].respond(302);
-
- async.done(function( data, s, x ){
- expect(data).toEqual([{
- msg: '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 <a target="_blank" rel="noreferrer noopener" class="external" href="http://example.org/admin-nginx">documentation ↗</a>.',
- type: OC.SetupChecks.MESSAGE_TYPE_WARNING
- }]);
- done();
- });
- });
-
- it('should return no error with the expected response status code', function(done) {
- var async = OC.SetupChecks.checkWOFF2Loading(OC.filePath('core', '', 'fonts/NotoSans-Regular-latin.woff2'), 'http://example.org/PLACEHOLDER');
-
- suite.server.requests[0].respond(200);
-
- async.done(function( data, s, x ){
- expect(data).toEqual([]);
- done();
- });
- });
- });
-
describe('checkDataProtected', function() {
oc_dataURL = "data";