From 4a7f465f100cfc2f40c1689eb3b94cca32677b4c Mon Sep 17 00:00:00 2001 From: Tom Greenfield Date: Wed, 14 Aug 2019 11:09:31 +0100 Subject: [PATCH 1/5] Pass command line arguments to server script --- lib/application.js | 15 +++++++-------- server.js | 7 ++++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/application.js b/lib/application.js index 039b277451..c868c28073 100644 --- a/lib/application.js +++ b/lib/application.js @@ -328,14 +328,13 @@ Origin.prototype.createServer = function (options, cb) { Origin.prototype.startServer = function (options) { var app = this; - // Ensure that the options object is set. - if(typeof options === 'undefined') { - options = { - skipDependencyCheck: false, - skipVersionCheck: false, - skipStartLog: false - }; - } + + options = { ...{ + skipDependencyCheck: false, + skipVersionCheck: false, + skipStartLog: false + }, ...options }; + checkPrerequisites(options, function(err, result) { if(err) { logger.log('error', chalk.red(err.message)); diff --git a/server.js b/server.js index b9cb5f5099..1433d60580 100644 --- a/server.js +++ b/server.js @@ -1,3 +1,4 @@ -// LICENCE https://github.com/adaptlearning/adapt_authoring/blob/master/LICENSE -var app = require('./lib/application')(); -app.run(); +const app = require('./lib/application')(); +const argv = require('optimist').argv; + +app.run(argv); From e2c5b8a786e9fe3297b05ddb4f38e316bf12b006 Mon Sep 17 00:00:00 2001 From: Tom Greenfield Date: Fri, 6 Sep 2019 16:42:44 +0100 Subject: [PATCH 2/5] Process symlinks in Handlebars and Less tasks --- Gruntfile.js | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index cf3cd18a2d..d72ccfd99a 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -87,13 +87,17 @@ module.exports = function(grunt) { partialRegex: /^part_/, partialsPathRegex: /\/partials\// }, - files: { - "frontend/src/templates/templates.js": [ - "frontend/src/core/**/*.hbs", - "frontend/src/modules/**/*.hbs", - "frontend/src/plugins/**/*.hbs" - ] - } + files: [ + { + follow: true, + src: [ + 'frontend/src/core/**/*.hbs', + 'frontend/src/modules/**/*.hbs', + 'frontend/src/plugins/**/*.hbs' + ], + dest: 'frontend/src/templates/templates.js' + } + ] } }, requirejs: { @@ -217,7 +221,10 @@ module.exports = function(grunt) { var ret = ''; for (var i = 0, l = src.length; i < l; i++) { - grunt.file.expand({ filter: options.filter }, src[i]).forEach(function(lessPath) { + grunt.file.expand({ + filter: options.filter, + follow: true + }, src[i]).forEach(function(lessPath) { ret += '@import \'' + path.normalize(lessPath) + '\';\n'; }); } From 5db37863db6ac173b93d194e478e657738aeee26 Mon Sep 17 00:00:00 2001 From: nicola Date: Tue, 15 Oct 2019 11:09:49 +0100 Subject: [PATCH 3/5] Display error information on plugin upload modal --- frontend/src/core/helpers.js | 6 ----- .../views/pluginManagementUploadView.js | 2 +- plugins/content/bower/index.js | 23 +++++++++++-------- routes/lang/en-application.json | 6 +++++ 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/frontend/src/core/helpers.js b/frontend/src/core/helpers.js index 619de89ed7..ce29008315 100644 --- a/frontend/src/core/helpers.js +++ b/frontend/src/core/helpers.js @@ -172,12 +172,6 @@ define(function(require){ return new Handlebars.SafeString(html + ''); }, - decodeHTML: function(html) { - var el = document.createElement('div'); - el.innerHTML = html; - return el.childNodes.length === 0 ? "" : el.childNodes[0].nodeValue; - }, - ifHasPermissions: function(permissions, block) { var hasPermission = Origin.permissions.hasPermissions(permissions.split(',')); return hasPermission ? block.fn(this) : block.inverse(this); diff --git a/frontend/src/modules/pluginManagement/views/pluginManagementUploadView.js b/frontend/src/modules/pluginManagement/views/pluginManagementUploadView.js index 31f6265d2f..de940f5549 100644 --- a/frontend/src/modules/pluginManagement/views/pluginManagementUploadView.js +++ b/frontend/src/modules/pluginManagement/views/pluginManagementUploadView.js @@ -61,7 +61,7 @@ define(function(require){ Origin.Notify.alert({ type: 'error', title: Origin.l10n.t('app.uploadpluginerror'), - text: Helpers.decodeHTML(message) + text: message }); Origin.router.navigateTo('pluginManagement/upload'); }, diff --git a/plugins/content/bower/index.js b/plugins/content/bower/index.js index 4f8cc970b8..a7fd7cd326 100644 --- a/plugins/content/bower/index.js +++ b/plugins/content/bower/index.js @@ -813,7 +813,7 @@ function addPackage (plugin, packageInfo, options, cb) { if (results && 0 !== results.length) { // don't add duplicate if (options.strict) { - return addCb(new PluginPackageError("Can't add plugin: plugin already exists!")); + return addCb(new PluginPackageError(app.polyglot.t('app.versionexists'))); } return addCb(null); } @@ -1058,7 +1058,7 @@ function handleUploadedPlugin (req, res, next) { var file = files.file; if (!file || !file.path) { - return next(new PluginPackageError('File upload failed!')); + return next(new PluginPackageError(app.polyglot.t('app.fileuploaderror'))); } // try unzipping @@ -1104,17 +1104,19 @@ function handleUploadedPlugin (req, res, next) { }, function(hasResults) { if (!hasResults) { - return next(new PluginPackageError('Cannot find expected bower.json file in the plugin root, please check the structure of your zip file and try again.')); + return next(app.polyglot.t('app.cannotfindbower')); } if (!packageJson) { - return next(new PluginPackageError('Unrecognized plugin - a plugin should have a bower.json file')); + return next(app.polyglot.t('app.unrecognisedplugin')); } // extract the plugin type from the package var pluginType = extractPluginType(packageJson); if (!pluginType) { - return next(new PluginPackageError('Unrecognized plugin type for package ' + packageJson.name)); + return next(new PluginPackageError(app.polyglot.t('app.unrecognisedpluginforpackage', { + package: packageJson.name + }))); } // mark as a locally installed package @@ -1132,7 +1134,9 @@ function handleUploadedPlugin (req, res, next) { } // Check if the framework has been defined on the plugin and that it's not compatible if (packageInfo.pkgMeta.framework && !semver.satisfies(semver.clean(frameworkVersion), packageInfo.pkgMeta.framework, { includePrerelease: true })) { - return next(new PluginPackageError('This plugin is incompatible with version ' + frameworkVersion + ' of the Adapt framework')); + return next(new PluginPackageError(app.polyglot.t('app.incompatibleframework', { + framework: frameworkVersion + }))); } app.contentmanager.getContentPlugin(pluginType, function (error, contentPlugin) { if (error) { @@ -1145,10 +1149,9 @@ function handleUploadedPlugin (req, res, next) { function sendResponse() { res.statusCode = 200; - return res.json({ - success: true, - pluginType: pluginType, - message: 'successfully added new plugin' + return res.json({ + success: true, + pluginType: pluginType }); } diff --git a/routes/lang/en-application.json b/routes/lang/en-application.json index dc5608859f..5ed621b262 100644 --- a/routes/lang/en-application.json +++ b/routes/lang/en-application.json @@ -410,5 +410,11 @@ "app.searchByMail": "Search by email", "app.maxfileuploadsize": "Maximum upload file size: %{size}.", "app.uploadsizeerror": "File size limit exceeded. Expected no more than %{max}, received %{size}.", + "app.fileuploaderror": "File upload failed.", + "app.cannotfindbower": "Cannot find expected bower.json file in the plugin root, please check the structure of your zip file and try again.", + "app.unrecognisedplugin": "Unrecognized plugin - a plugin should have a bower.json file.", + "app.unrecognisedpluginforpackage": "Unrecognized plugin type for package %{package}.", + "app.incompatibleframework": "This plugin is incompatible with version %{framework} of the Adapt framework.", + "app.versionexists": "You already have this version of the plugin installed.", "app.unknownuser": "Unknown User" } From e543db4accc4437abb253613072c404bd3c3b874 Mon Sep 17 00:00:00 2001 From: canstudios-nicolaw Date: Tue, 15 Oct 2019 13:02:03 +0100 Subject: [PATCH 4/5] Update routes/lang/en-application.json Co-Authored-By: Tom Taylor --- routes/lang/en-application.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/lang/en-application.json b/routes/lang/en-application.json index 5ed621b262..12ed15ce70 100644 --- a/routes/lang/en-application.json +++ b/routes/lang/en-application.json @@ -413,7 +413,7 @@ "app.fileuploaderror": "File upload failed.", "app.cannotfindbower": "Cannot find expected bower.json file in the plugin root, please check the structure of your zip file and try again.", "app.unrecognisedplugin": "Unrecognized plugin - a plugin should have a bower.json file.", - "app.unrecognisedpluginforpackage": "Unrecognized plugin type for package %{package}.", + "app.unrecognisedpluginforpackage": "Unrecognised plugin type for package %{package}.", "app.incompatibleframework": "This plugin is incompatible with version %{framework} of the Adapt framework.", "app.versionexists": "You already have this version of the plugin installed.", "app.unknownuser": "Unknown User" From 972a4c8efc7dc4819394dc6f80f5d87be103a0f6 Mon Sep 17 00:00:00 2001 From: canstudios-nicolaw Date: Tue, 15 Oct 2019 13:02:12 +0100 Subject: [PATCH 5/5] Update routes/lang/en-application.json Co-Authored-By: Tom Taylor --- routes/lang/en-application.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/lang/en-application.json b/routes/lang/en-application.json index 12ed15ce70..41a9899f13 100644 --- a/routes/lang/en-application.json +++ b/routes/lang/en-application.json @@ -412,7 +412,7 @@ "app.uploadsizeerror": "File size limit exceeded. Expected no more than %{max}, received %{size}.", "app.fileuploaderror": "File upload failed.", "app.cannotfindbower": "Cannot find expected bower.json file in the plugin root, please check the structure of your zip file and try again.", - "app.unrecognisedplugin": "Unrecognized plugin - a plugin should have a bower.json file.", + "app.unrecognisedplugin": "Unrecognised plugin - a plugin should have a bower.json file.", "app.unrecognisedpluginforpackage": "Unrecognised plugin type for package %{package}.", "app.incompatibleframework": "This plugin is incompatible with version %{framework} of the Adapt framework.", "app.versionexists": "You already have this version of the plugin installed.",