summaryrefslogtreecommitdiffstats
path: root/core/js
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2018-11-29 19:36:56 +0100
committerGitHub <noreply@github.com>2018-11-29 19:36:56 +0100
commita915594b03757a9e7f3f0a266dd29003ac6dd7d0 (patch)
tree64373e9bcbb935c5120420e3b34a5ca748c31805 /core/js
parent3b53c1077402bd79dcc4243ab0395bf2494595bb (diff)
parentf5894b653d0d85662916454cf825c1a024c27d2a (diff)
downloadnextcloud-server-a915594b03757a9e7f3f0a266dd29003ac6dd7d0.tar.gz
nextcloud-server-a915594b03757a9e7f3f0a266dd29003ac6dd7d0.zip
Merge pull request #12734 from nextcloud/feature/noid/check-nginx-woff2
Add check for missing .woff2 rule in Nginx via setup check
Diffstat (limited to 'core/js')
-rw-r--r--core/js/setupchecks.js31
-rw-r--r--core/js/tests/specs/setupchecksSpec.js27
2 files changed, 58 insertions, 0 deletions
diff --git a/core/js/setupchecks.js b/core/js/setupchecks.js
index ca7d979f5f3..c50781f1485 100644
--- a/core/js/setupchecks.js
+++ b/core/js/setupchecks.js
@@ -88,6 +88,37 @@
},
/**
+ * Check whether the WOFF2 URLs works.
+ *
+ * @param url the URL to test
+ * @param placeholderUrl the placeholder URL - can be found at oc_defaults.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 <a target="_blank" rel="noreferrer noopener" href="{docLink}">documentation</a>.', { docLink: docUrl, url: url }),
+ 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
*
* @return $.Deferred object resolved with an array of error messages
diff --git a/core/js/tests/specs/setupchecksSpec.js b/core/js/tests/specs/setupchecksSpec.js
index 47443e5e727..b8a2164de54 100644
--- a/core/js/tests/specs/setupchecksSpec.js
+++ b/core/js/tests/specs/setupchecksSpec.js
@@ -107,6 +107,33 @@ 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/Nunito-Regular.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 href="http://example.org/admin-nginx" rel="noreferrer noopener">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/Nunito-Regular.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";