MOBILE-3645 build: Add script to copy some files to www

main
Dani Palou 2021-03-15 13:01:25 +01:00
parent e44212bf19
commit 5edc8de380
9 changed files with 83 additions and 16 deletions

1
.gitignore vendored
View File

@ -28,6 +28,7 @@ npm-debug.log*
/platforms /platforms
/plugins /plugins
/www /www
/src/assets/lib
/moodle.*.config.json /moodle.*.config.json
!/moodle.example.config.json !/moodle.example.config.json

View File

@ -3,5 +3,9 @@
"integrations": { "integrations": {
"cordova": {} "cordova": {}
}, },
"type": "angular" "type": "angular",
} "hooks": {
"build:before": "./scripts/copy-assets.js",
"serve:before": "./scripts/copy-assets.js"
}
}

27
package-lock.json generated
View File

@ -10531,14 +10531,14 @@
"optional": true "optional": true
}, },
"fs-extra": { "fs-extra": {
"version": "9.0.1", "version": "9.1.0",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.0.1.tgz", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.1.0.tgz",
"integrity": "sha512-h2iAoN838FqAFJY2/qVpzFXy+EBxfVE220PalAqQLDVsFOHLJrZvut5puAbCdNv6WJk+B8ihI+k0c7JK5erwqQ==", "integrity": "sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==",
"requires": { "requires": {
"at-least-node": "^1.0.0", "at-least-node": "^1.0.0",
"graceful-fs": "^4.2.0", "graceful-fs": "^4.2.0",
"jsonfile": "^6.0.1", "jsonfile": "^6.0.1",
"universalify": "^1.0.0" "universalify": "^2.0.0"
} }
}, },
"fs-minipass": { "fs-minipass": {
@ -14192,12 +14192,12 @@
"dev": true "dev": true
}, },
"jsonfile": { "jsonfile": {
"version": "6.0.1", "version": "6.1.0",
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.0.1.tgz", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz",
"integrity": "sha512-jR2b5v7d2vIOust+w3wtFKZIfpC2pnRmFAhAC/BuweZFQR8qZzxH1OyrQ10HmdVYiXWkYUqPVsz91cG7EL2FBg==", "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==",
"requires": { "requires": {
"graceful-fs": "^4.1.6", "graceful-fs": "^4.1.6",
"universalify": "^1.0.0" "universalify": "^2.0.0"
} }
}, },
"jsonparse": { "jsonparse": {
@ -15061,6 +15061,11 @@
} }
} }
}, },
"mathjax": {
"version": "2.7.7",
"resolved": "https://registry.npmjs.org/mathjax/-/mathjax-2.7.7.tgz",
"integrity": "sha512-OOl0B2/0tSJAtAZarXnQuLDBLgTNRqiI9VqHTQzPsxf4okT2iIpDrvaklK9x2QEMD1sDj4yRn11Ygci41DxMAQ=="
},
"md5-file": { "md5-file": {
"version": "5.0.0", "version": "5.0.0",
"resolved": "https://registry.npmjs.org/md5-file/-/md5-file-5.0.0.tgz", "resolved": "https://registry.npmjs.org/md5-file/-/md5-file-5.0.0.tgz",
@ -21796,9 +21801,9 @@
} }
}, },
"universalify": { "universalify": {
"version": "1.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/universalify/-/universalify-1.0.0.tgz", "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz",
"integrity": "sha512-rb6X1W158d7pRQBg5gkR8uPaSfiids68LTJQYOtEUhoJUWBdaQHsuT/EUduxXYxcrt4r5PJ4fuHW1MHT6p0qug==" "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ=="
}, },
"unorm": { "unorm": {
"version": "1.6.0", "version": "1.6.0",

View File

@ -110,6 +110,7 @@
"core-js": "^3.9.1", "core-js": "^3.9.1",
"es6-promise-plugin": "^4.2.2", "es6-promise-plugin": "^4.2.2",
"jszip": "^3.5.0", "jszip": "^3.5.0",
"mathjax": "2.7.7",
"moment": "^2.29.0", "moment": "^2.29.0",
"nl.kingsquare.cordova.background-audio": "^1.0.1", "nl.kingsquare.cordova.background-audio": "^1.0.1",
"phonegap-plugin-multidex": "^1.0.0", "phonegap-plugin-multidex": "^1.0.0",
@ -149,6 +150,7 @@
"eslint-plugin-prefer-arrow": "^1.2.2", "eslint-plugin-prefer-arrow": "^1.2.2",
"eslint-plugin-promise": "^4.2.1", "eslint-plugin-promise": "^4.2.1",
"faker": "^5.1.0", "faker": "^5.1.0",
"fs-extra": "^9.1.0",
"gulp": "4.0.2", "gulp": "4.0.2",
"gulp-clip-empty-files": "^0.1.2", "gulp-clip-empty-files": "^0.1.2",
"gulp-concat": "^2.6.1", "gulp-concat": "^2.6.1",

View File

@ -0,0 +1,39 @@
// (C) Copyright 2015 Moodle Pty Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
* Script to copy some files to the www folder.
*/
const fse = require('fs-extra');
const path = require('path');
// Assets to copy.
const ASSETS = {
'/node_modules/mathjax/MathJax.js': '/lib/mathjax/MathJax.js',
'/node_modules/mathjax/extensions': '/lib/mathjax/extensions',
'/node_modules/mathjax/jax/element': '/lib/mathjax/jax/element',
'/node_modules/mathjax/jax/input': '/lib/mathjax/jax/input',
'/node_modules/mathjax/jax/output/SVG': '/lib/mathjax/jax/output/SVG',
'/node_modules/mathjax/jax/output/PreviewHTML': '/lib/mathjax/jax/output/PreviewHTML',
'/node_modules/mathjax/localization': '/lib/mathjax/localization',
'/src/core/features/h5p/assets': '/lib/h5p',
};
module.exports = function(ctx) {
const assetsPath = ctx.project.srcDir + '/assets';
for (const src in ASSETS) {
fse.copySync(ctx.project.dir + src, assetsPath + ASSETS[src], { overwrite: true });
}
};

View File

@ -245,7 +245,7 @@ export class AddonFilterMathJaxLoaderHandlerService extends CoreFilterDefaultHan
const equations = Array.from(container.querySelectorAll('.filter_mathjaxloader_equation')); const equations = Array.from(container.querySelectorAll('.filter_mathjaxloader_equation'));
equations.forEach((node) => { equations.forEach((node) => {
that.window.MathJax.Hub.Queue(['Typeset', that.window.MathJax.Hub, node]); that.window.MathJax.Hub.Queue(['Typeset', that.window.MathJax.Hub, node], [that.fixUseUrls, node]);
}); });
// Set the delay back to normal after processing. // Set the delay back to normal after processing.
@ -255,6 +255,20 @@ export class AddonFilterMathJaxLoaderHandlerService extends CoreFilterDefaultHan
}; };
} }
/**
* Fix URLs in <use> elements.
* This is needed because MathJax stores the location.href when it's loaded, and then sets that URL to all the <use>
* elements href. Since the app URL changes when navigating, the SVGs can use a URL that isn't the current page.
* When that happens, the request returns a 404 error and the SVG isn't displayed.
*
* @param node Element that can contain equations.
*/
protected fixUseUrls(node: Element): void {
Array.from(node.querySelectorAll('use')).forEach((useElem) => {
useElem.setAttribute('href', useElem.href.baseVal.substr(useElem.href.baseVal.indexOf('#')));
});
}
/** /**
* Perform a mapping of the app language code to the equivalent for MathJax. * Perform a mapping of the app language code to the equivalent for MathJax.
* *

View File

@ -376,7 +376,7 @@ export class CoreH5PFileStorage {
* @return Folder path. * @return Folder path.
*/ */
getCoreH5PPath(): string { getCoreH5PPath(): string {
return CoreTextUtils.concatenatePaths(CoreFile.getWWWPath(), '/h5p/'); return CoreTextUtils.concatenatePaths(CoreFile.getWWWPath(), '/assets/lib/h5p/');
} }
/** /**

View File

@ -48,7 +48,7 @@ export class CoreUpdateManagerProvider {
const versionApplied = await CoreConfig.get<number>(VERSION_APPLIED, 0); const versionApplied = await CoreConfig.get<number>(VERSION_APPLIED, 0);
if (versionCode >= 3900 && versionApplied < 3900 && versionApplied > 0) { if (versionCode >= 3950 && versionApplied < 3950 && versionApplied > 0) {
promises.push(CoreH5P.h5pPlayer.deleteAllContentIndexes()); promises.push(CoreH5P.h5pPlayer.deleteAllContentIndexes());
} }

View File

@ -17,6 +17,8 @@
<!-- add to homescreen for ios --> <!-- add to homescreen for ios -->
<meta name="apple-mobile-web-app-capable" content="yes" /> <meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" /> <meta name="apple-mobile-web-app-status-bar-style" content="black" />
<script src="assets/lib/mathjax/MathJax.js?delayStartupUntil=configured"></script>
</head> </head>
<body> <body>