Skip to content

Commit e78254e

Browse files
committed
Merge branch 'release/bugpatch' into issue/2433
2 parents b0cba9e + 6ef2f81 commit e78254e

7 files changed

Lines changed: 46 additions & 36 deletions

File tree

Gruntfile.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,17 @@ module.exports = function(grunt) {
8787
partialRegex: /^part_/,
8888
partialsPathRegex: /\/partials\//
8989
},
90-
files: {
91-
"frontend/src/templates/templates.js": [
92-
"frontend/src/core/**/*.hbs",
93-
"frontend/src/modules/**/*.hbs",
94-
"frontend/src/plugins/**/*.hbs"
95-
]
96-
}
90+
files: [
91+
{
92+
follow: true,
93+
src: [
94+
'frontend/src/core/**/*.hbs',
95+
'frontend/src/modules/**/*.hbs',
96+
'frontend/src/plugins/**/*.hbs'
97+
],
98+
dest: 'frontend/src/templates/templates.js'
99+
}
100+
]
97101
}
98102
},
99103
requirejs: {
@@ -217,7 +221,10 @@ module.exports = function(grunt) {
217221
var ret = '';
218222

219223
for (var i = 0, l = src.length; i < l; i++) {
220-
grunt.file.expand({ filter: options.filter }, src[i]).forEach(function(lessPath) {
224+
grunt.file.expand({
225+
filter: options.filter,
226+
follow: true
227+
}, src[i]).forEach(function(lessPath) {
221228
ret += '@import \'' + path.normalize(lessPath) + '\';\n';
222229
});
223230
}

frontend/src/core/helpers.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,6 @@ define(function(require){
172172
return new Handlebars.SafeString(html + '</ul>');
173173
},
174174

175-
decodeHTML: function(html) {
176-
var el = document.createElement('div');
177-
el.innerHTML = html;
178-
return el.childNodes.length === 0 ? "" : el.childNodes[0].nodeValue;
179-
},
180-
181175
ifHasPermissions: function(permissions, block) {
182176
var hasPermission = Origin.permissions.hasPermissions(permissions.split(','));
183177
return hasPermission ? block.fn(this) : block.inverse(this);

frontend/src/modules/pluginManagement/views/pluginManagementUploadView.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ define(function(require){
6161
Origin.Notify.alert({
6262
type: 'error',
6363
title: Origin.l10n.t('app.uploadpluginerror'),
64-
text: Helpers.decodeHTML(message)
64+
text: message
6565
});
6666
Origin.router.navigateTo('pluginManagement/upload');
6767
},

lib/application.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -328,14 +328,13 @@ Origin.prototype.createServer = function (options, cb) {
328328

329329
Origin.prototype.startServer = function (options) {
330330
var app = this;
331-
// Ensure that the options object is set.
332-
if(typeof options === 'undefined') {
333-
options = {
334-
skipDependencyCheck: false,
335-
skipVersionCheck: false,
336-
skipStartLog: false
337-
};
338-
}
331+
332+
options = { ...{
333+
skipDependencyCheck: false,
334+
skipVersionCheck: false,
335+
skipStartLog: false
336+
}, ...options };
337+
339338
checkPrerequisites(options, function(err, result) {
340339
if(err) {
341340
logger.log('error', chalk.red(err.message));

plugins/content/bower/index.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,7 @@ function addPackage (plugin, packageInfo, options, cb) {
831831
if (results && 0 !== results.length) {
832832
// don't add duplicate
833833
if (options.strict) {
834-
return addCb(new PluginPackageError("Can't add plugin: plugin already exists!"));
834+
return addCb(new PluginPackageError(app.polyglot.t('app.versionexists')));
835835
}
836836
return addCb(null);
837837
}
@@ -1077,7 +1077,7 @@ function handleUploadedPlugin (req, res, next) {
10771077

10781078
var file = files.file;
10791079
if (!file || !file.path) {
1080-
return next(new PluginPackageError('File upload failed!'));
1080+
return next(new PluginPackageError(app.polyglot.t('app.fileuploaderror')));
10811081
}
10821082

10831083
// try unzipping
@@ -1123,17 +1123,19 @@ function handleUploadedPlugin (req, res, next) {
11231123

11241124
}, function(hasResults) {
11251125
if (!hasResults) {
1126-
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.'));
1126+
return next(app.polyglot.t('app.cannotfindbower'));
11271127
}
11281128

11291129
if (!packageJson) {
1130-
return next(new PluginPackageError('Unrecognized plugin - a plugin should have a bower.json file'));
1130+
return next(app.polyglot.t('app.unrecognisedplugin'));
11311131
}
11321132

11331133
// extract the plugin type from the package
11341134
var pluginType = extractPluginType(packageJson);
11351135
if (!pluginType) {
1136-
return next(new PluginPackageError('Unrecognized plugin type for package ' + packageJson.name));
1136+
return next(new PluginPackageError(app.polyglot.t('app.unrecognisedpluginforpackage', {
1137+
package: packageJson.name
1138+
})));
11371139
}
11381140

11391141
// mark as a locally installed package
@@ -1151,7 +1153,9 @@ function handleUploadedPlugin (req, res, next) {
11511153
}
11521154
// Check if the framework has been defined on the plugin and that it's not compatible
11531155
if (packageInfo.pkgMeta.framework && !semver.satisfies(semver.clean(frameworkVersion), packageInfo.pkgMeta.framework, { includePrerelease: true })) {
1154-
return next(new PluginPackageError('This plugin is incompatible with version ' + frameworkVersion + ' of the Adapt framework'));
1156+
return next(new PluginPackageError(app.polyglot.t('app.incompatibleframework', {
1157+
framework: frameworkVersion
1158+
})));
11551159
}
11561160
app.contentmanager.getContentPlugin(pluginType, function (error, contentPlugin) {
11571161
if (error) {
@@ -1164,10 +1168,9 @@ function handleUploadedPlugin (req, res, next) {
11641168

11651169
function sendResponse() {
11661170
res.statusCode = 200;
1167-
return res.json({
1168-
success: true,
1169-
pluginType: pluginType,
1170-
message: 'successfully added new plugin'
1171+
return res.json({
1172+
success: true,
1173+
pluginType: pluginType
11711174
});
11721175
}
11731176

routes/lang/en-application.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,5 +410,11 @@
410410
"app.searchByMail": "Search by email",
411411
"app.maxfileuploadsize": "Maximum upload file size: %{size}.",
412412
"app.uploadsizeerror": "File size limit exceeded. Expected no more than %{max}, received %{size}.",
413+
"app.fileuploaderror": "File upload failed.",
414+
"app.cannotfindbower": "Cannot find expected bower.json file in the plugin root, please check the structure of your zip file and try again.",
415+
"app.unrecognisedplugin": "Unrecognised plugin - a plugin should have a bower.json file.",
416+
"app.unrecognisedpluginforpackage": "Unrecognised plugin type for package %{package}.",
417+
"app.incompatibleframework": "This plugin is incompatible with version %{framework} of the Adapt framework.",
418+
"app.versionexists": "You already have this version of the plugin installed.",
413419
"app.unknownuser": "Unknown User"
414420
}

server.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
// LICENCE https://github.com/adaptlearning/adapt_authoring/blob/master/LICENSE
2-
var app = require('./lib/application')();
3-
app.run();
1+
const app = require('./lib/application')();
2+
const argv = require('optimist').argv;
3+
4+
app.run(argv);

0 commit comments

Comments
 (0)