Skip to content

Commit

Permalink
Merge branch 'release/bugpatch' into issue/2433
Browse files Browse the repository at this point in the history
  • Loading branch information
tomgreenfield committed Oct 16, 2019
2 parents b0cba9e + 6ef2f81 commit e78254e
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 36 deletions.
23 changes: 15 additions & 8 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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';
});
}
Expand Down
6 changes: 0 additions & 6 deletions frontend/src/core/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,6 @@ define(function(require){
return new Handlebars.SafeString(html + '</ul>');
},

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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
},
Expand Down
15 changes: 7 additions & 8 deletions lib/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
23 changes: 13 additions & 10 deletions plugins/content/bower/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,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);
}
Expand Down Expand Up @@ -1077,7 +1077,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
Expand Down Expand Up @@ -1123,17 +1123,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
Expand All @@ -1151,7 +1153,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) {
Expand All @@ -1164,10 +1168,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
});
}

Expand Down
6 changes: 6 additions & 0 deletions routes/lang/en-application.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "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.",
"app.unknownuser": "Unknown User"
}
7 changes: 4 additions & 3 deletions server.js
Original file line number Diff line number Diff line change
@@ -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);

0 comments on commit e78254e

Please sign in to comment.