Skip to content

Commit 630d44c

Browse files
authored
Merge pull request #1973 from moodlehq/integration
Integration
2 parents 13a9dab + e9d0d73 commit 630d44c

File tree

520 files changed

+12389
-3683
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

520 files changed

+12389
-3683
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ dist: xenial
33
group: edge
44

55
language: node_js
6-
node_js: stable
6+
node_js: 11
77

88
before_cache:
99
- rm -rf $HOME/.cache/electron-builder/wine
1010

1111
cache:
1212
directories:
13-
- node_modules
13+
- $HOME/.npm
1414
- $HOME/.cache/electron
1515
- $HOME/.cache/electron-builder
1616

Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ EXPOSE 35729
1111
# Port 53703 is the Chrome dev logger port.
1212
EXPOSE 53703
1313

14-
# MoodleMobile uses Cordova, Ionic, and Gulp.
15-
RUN npm install -g cordova ionic gulp && rm -rf /root/.npm
14+
# MoodleMobile uses Ionic and Gulp.
15+
RUN npm i -g ionic gulp && rm -rf /root/.npm
1616

1717
WORKDIR /app
1818

1919
COPY . /app
2020

21-
# The setup script will handle npm installation, cordova setup, and gulp setup.
22-
RUN npm run setup && rm -rf /root/.npm
21+
# Install npm libraries and run gulp to initialize the project.
22+
RUN npm install && gulp && rm -rf /root/.npm
2323

2424
# Provide a Healthcheck command for easier use in CI.
2525
HEALTHCHECK --interval=10s --timeout=3s --start-period=30s CMD curl -f http://localhost:8100 || exit 1

config.xml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version='1.0' encoding='utf-8'?>
2-
<widget id="com.moodle.moodlemobile" version="3.6.1" xmlns="http://www.w3.org/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cdv="http://cordova.apache.org/ns/1.0">
2+
<widget id="com.moodle.moodlemobile" version="3.7.0" xmlns="http://www.w3.org/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cdv="http://cordova.apache.org/ns/1.0">
33
<name>Moodle</name>
44
<description>Moodle official app</description>
55
<author email="[email protected]" href="http://moodle.com">Moodle Mobile team</author>
@@ -37,6 +37,7 @@
3737
<preference name="SplashMaintainAspectRatio" value="true" />
3838
<preference name="SplashShowOnlyFirstTime" value="false" />
3939
<preference name="LoadUrlTimeoutValue" value="60000" />
40+
<preference name="CustomURLSchemePluginClearsAndroidIntent" value="true" />
4041
<feature name="StatusBar">
4142
<param name="ios-package" onload="true" value="CDVStatusBar" />
4243
</feature>
@@ -112,14 +113,14 @@
112113
<icon height="1024" src="resources/ios/icon/icon-1024.png" width="1024" />
113114
<splash height="2732" src="resources/ios/splash/Default@2x~universal~anyany.png" width="2732" />
114115
</platform>
115-
<plugin name="com-darryncampbell-cordova-plugin-intent" spec="1.1.5" />
116-
<plugin name="cordova-android-support-gradle-release" spec="2.0.1">
116+
<plugin name="com-darryncampbell-cordova-plugin-intent" spec="1.1.7" />
117+
<plugin name="cordova-android-support-gradle-release" spec="3.0.0">
117118
<variable name="ANDROID_SUPPORT_VERSION" value="27.1.0" />
118119
</plugin>
119120
<plugin name="cordova-clipboard" spec="1.2.1" />
120121
<plugin name="cordova-plugin-badge" spec="0.8.8" />
121122
<plugin name="cordova-plugin-camera" spec="4.0.3" />
122-
<plugin name="cordova-plugin-customurlscheme" spec="4.3.0">
123+
<plugin name="cordova-plugin-customurlscheme" spec="4.4.0">
123124
<variable name="URL_SCHEME" value="moodlemobile" />
124125
</plugin>
125126
<plugin name="cordova-plugin-device" spec="2.0.2" />
@@ -129,7 +130,7 @@
129130
<plugin name="cordova-plugin-globalization" spec="1.11.0" />
130131
<plugin name="cordova-plugin-inappbrowser" spec="3.0.0" />
131132
<plugin name="cordova-plugin-ionic-keyboard" spec="2.1.3" />
132-
<plugin name="cordova-plugin-local-notification" spec="0.9.0-beta.3" />
133+
<plugin name="cordova-plugin-local-notification" spec="https://github.com/moodlemobile/cordova-plugin-local-notification.git#moodle" />
133134
<plugin name="cordova-plugin-media-capture" spec="3.0.2" />
134135
<plugin name="cordova-plugin-network-information" spec="2.0.1" />
135136
<plugin name="cordova-plugin-screen-orientation" spec="3.0.1" />
@@ -139,13 +140,19 @@
139140
<plugin name="cordova-plugin-zip" spec="3.1.0" />
140141
<plugin name="cordova-sqlite-storage" spec="2.6.0" />
141142
<plugin name="nl.kingsquare.cordova.background-audio" spec="1.0.1" />
142-
<plugin name="phonegap-plugin-push" spec="https://github.com/moodlemobile/phonegap-plugin-push.git#moodle-v2">
143+
<plugin name="phonegap-plugin-push" spec="https://github.com/moodlemobile/phonegap-plugin-push.git#moodle-v3">
143144
<variable name="ANDROID_SUPPORT_V13_VERSION" value="27.+" />
144-
<variable name="FCM_VERSION" value="17.0.+" />
145+
<variable name="FCM_VERSION" value="17.5.+" />
145146
</plugin>
146147
<edit-config file="AndroidManifest.xml" mode="merge" target="/manifest/application/activity[@android:name='MainActivity']">
147148
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|screenLayout|smallestScreenSize" android:debuggable="true" />
148149
</edit-config>
150+
<config-file parent="/manifest/application" target="AndroidManifest.xml">
151+
<meta-data android:name="firebase_analytics_collection_deactivated" android:value="true" />
152+
</config-file>
153+
<config-file parent="FIREBASE_ANALYTICS_COLLECTION_DEACTIVATED" target="*-Info.plist">
154+
<string>YES</string>
155+
</config-file>
149156
<engine name="android" spec="7.1.2" />
150157
<engine name="ios" spec="4.5.5" />
151158
</widget>

desktop/assets/windows/AppXManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<Identity Name="3312ADB7.MoodleDesktop"
77
ProcessorArchitecture="x64"
88
Publisher="CN=33CDCDF6-1EB5-4827-9897-ED25C91A32F6"
9-
Version="3.6.1.0" />
9+
Version="3.7.0.0" />
1010
<Properties>
1111
<DisplayName>Moodle Desktop</DisplayName>
1212
<PublisherDisplayName>Moodle Pty Ltd.</PublisherDisplayName>

desktop/electron.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const url = require('url');
66
const fs = require('fs');
77
const os = require('os');
88
const userAgent = 'MoodleMobile';
9+
const isMac = os.platform().indexOf('darwin') != -1;
910

1011
// Keep a global reference of the window object, if you don't, the window will
1112
// be closed automatically when the JavaScript object is garbage collected.
@@ -68,14 +69,22 @@ function createWindow() {
6869

6970
// Append some text to the user agent.
7071
mainWindow.webContents.setUserAgent(mainWindow.webContents.getUserAgent() + ' ' + userAgent);
72+
73+
// Add shortcut to open dev tools: Cmd + Option + I in MacOS, Ctrl + Shift + I in Windows/Linux.
74+
mainWindow.webContents.on('before-input-event', function(e, input) {
75+
if (input.type == 'keyDown' && !input.isAutoRepeat && input.code == 'KeyI' &&
76+
((isMac && input.alt && input.meta) || (!isMac && input.shift && input.control))) {
77+
mainWindow.webContents.toggleDevTools();
78+
}
79+
}, true)
7180
}
7281

7382
// Make sure that only a single instance of the app is running.
7483
// For some reason, gotTheLock is always false in signed Mac apps so we should ingore it.
7584
// See https://github.com/electron/electron/issues/15958
7685
var gotTheLock = app.requestSingleInstanceLock();
7786

78-
if (!gotTheLock && os.platform().indexOf('darwin') == -1) {
87+
if (!gotTheLock && !isMac) {
7988
// It's not the main instance of the app, kill it.
8089
app.exit();
8190
return;
@@ -221,22 +230,18 @@ function setAppMenu() {
221230
submenu: [
222231
{
223232
label: 'Cut',
224-
accelerator: 'CmdOrCtrl+X',
225233
role: 'cut'
226234
},
227235
{
228236
label: 'Copy',
229-
accelerator: 'CmdOrCtrl+C',
230237
role: 'copy'
231238
},
232239
{
233240
label: 'Paste',
234-
accelerator: 'CmdOrCtrl+V',
235241
role: 'paste'
236242
},
237243
{
238244
label: 'Select All',
239-
accelerator: 'CmdOrCtrl+A',
240245
role: 'selectall'
241246
}
242247
]

gulpfile.js

Lines changed: 130 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ var gulp = require('gulp'),
88
gutil = require('gulp-util'),
99
flatten = require('gulp-flatten'),
1010
npmPath = require('path'),
11+
concat = require('gulp-concat'),
12+
bufferFrom = require('buffer-from')
1113
File = gutil.File,
1214
exec = require('child_process').exec,
1315
license = '' +
@@ -113,7 +115,7 @@ function treatMergedData(data) {
113115
mergedOrdered[k] = merged[k];
114116
});
115117

116-
return new Buffer(JSON.stringify(mergedOrdered, null, 4));
118+
return bufferFrom(JSON.stringify(mergedOrdered, null, 4));
117119
}
118120

119121
/**
@@ -257,7 +259,7 @@ gulp.task('config', function(done) {
257259

258260
contents += '}\n';
259261

260-
file.contents = new Buffer(contents);
262+
file.contents = bufferFrom(contents);
261263
this.emit('data', file);
262264
}))
263265
.pipe(rename('configconstants.ts'))
@@ -296,3 +298,129 @@ gulp.task('copy-component-templates', function(done) {
296298
.on('end', done);
297299
});
298300

301+
/**
302+
* Finds the file and returns its content.
303+
*
304+
* @param {string} capture Import file path.
305+
* @param {string} baseDir Directory where the file was found.
306+
* @param {string} paths Alternative paths where to find the imports.
307+
* @param {Array} parsedFiles Yet parsed files to reduce size of the result.
308+
* @return {string} Partially combined scss.
309+
*/
310+
function getReplace(capture, baseDir, paths, parsedFiles) {
311+
var parse = path.parse(path.resolve(baseDir, capture + '.scss'));
312+
var file = parse.dir + '/' + parse.name;
313+
314+
315+
if (!fs.existsSync(file + '.scss')) {
316+
// File not found, might be a partial file.
317+
file = parse.dir + '/_' + parse.name;
318+
}
319+
320+
// If file still not found, try to find the file in the alternative paths.
321+
var x = 0;
322+
while (!fs.existsSync(file + '.scss') && paths.length > x) {
323+
parse = path.parse(path.resolve(paths[x], capture + '.scss'));
324+
file = parse.dir + '/' + parse.name;
325+
326+
x++;
327+
}
328+
329+
file = file + '.scss';
330+
331+
if (!fs.existsSync(file)) {
332+
// File not found. Leave the import there.
333+
console.log('File "' + capture + '" not found');
334+
return '@import "' + capture + '";';
335+
}
336+
337+
if (parsedFiles.indexOf(file) >= 0) {
338+
console.log('File "' + capture + '" already parsed');
339+
// File was already parsed, leave the import commented.
340+
return '// @import "' + capture + '";';
341+
}
342+
343+
parsedFiles.push(file);
344+
var text = fs.readFileSync(file);
345+
346+
// Recursive call.
347+
return scssCombine(text, parse.dir, paths, parsedFiles);
348+
}
349+
350+
/**
351+
* Combine scss files with its imports
352+
*
353+
* @param {string} content Scss string to read.
354+
* @param {string} baseDir Directory where the file was found.
355+
* @param {string} paths Alternative paths where to find the imports.
356+
* @param {Array} parsedFiles Yet parsed files to reduce size of the result.
357+
* @return {string} Scss string with the replaces done.
358+
*/
359+
function scssCombine(content, baseDir, paths, parsedFiles) {
360+
361+
// Content is a Buffer, convert to string.
362+
if (typeof content != "string") {
363+
content = content.toString();
364+
}
365+
366+
// Search of single imports.
367+
var regex = /@import[ ]*['"](.*)['"][ ]*;/g;
368+
369+
if (regex.test(content)) {
370+
return content.replace(regex, function(m, capture) {
371+
if (capture == "bmma") {
372+
return m;
373+
}
374+
375+
return getReplace(capture, baseDir, paths, parsedFiles);
376+
});
377+
}
378+
379+
// Search of multiple imports.
380+
regex = /@import(?:[ \n]+['"](.*)['"][,]?[ \n]*)+;/gm;
381+
if (regex.test(content)) {
382+
return content.replace(regex, function(m, capture) {
383+
var text = "";
384+
385+
// Divide the import into multiple files.
386+
regex = /['"]([^'"]*)['"]/g;
387+
var captures = m.match(regex);
388+
for (var x in captures) {
389+
text += getReplace(captures[x].replace(/['"]+/g, ''), baseDir, paths, parsedFiles) + "\n";
390+
}
391+
392+
return text;
393+
});
394+
}
395+
396+
return content;
397+
}
398+
399+
gulp.task('combine-scss', function(done) {
400+
var paths = [
401+
'node_modules/ionic-angular/themes/',
402+
'node_modules/font-awesome/scss/',
403+
'node_modules/ionicons/dist/scss/'
404+
];
405+
406+
var parsedFiles = [];
407+
408+
gulp.src([
409+
'./src/theme/variables.scss',
410+
'./node_modules/ionic-angular/themes/ionic.globals.*.scss',
411+
'./node_modules/ionic-angular/themes/ionic.components.scss',
412+
'./src/**/*.scss']) // define a source files
413+
.pipe(through(function(file, encoding, callback) {
414+
if (file.isNull()) {
415+
return;
416+
}
417+
418+
parsedFiles.push(file);
419+
file.contents = bufferFrom(scssCombine(file.contents, path.dirname(file.path), paths, parsedFiles));
420+
421+
this.emit('data', file);
422+
})) // combine them based on @import and save it to stream
423+
.pipe(concat('combined.scss')) // concat the stream output in single file
424+
.pipe(gulp.dest('.')) // save file to destination.
425+
.on('end', done);
426+
});

0 commit comments

Comments
 (0)