Skip to content

Commit

Permalink
Merge branch 'refs/heads/develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
taylortom committed Sep 25, 2018
2 parents b434763 + 33696d8 commit 03345a2
Show file tree
Hide file tree
Showing 124 changed files with 9,229 additions and 3,400 deletions.
29 changes: 0 additions & 29 deletions .jscsrc

This file was deleted.

34 changes: 33 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,37 @@ All notable changes to the Adapt authoring tool are documented in this file.
**IMPORTANT**: For information on how to **correctly and safely** update your installation, please consult **INSTALL.md**.<br/>
_Note that we adhere to the [semantic versioning](http://semver.org/) scheme for release numbering._

## [0.6.0] - 2018-09-25

Release to tidy up the core 'scaffold' code which is used to render the edit forms in the application.

**Main headlines**:
* All editors given a spring clean for readability and code consistency
* Backbone 'overrides' using hard-coded strings have been refactored into Handlebars templates where appropriate
* Switched to Selectize library for tags
* Fields from the properties schema are now properly passed through to Backbone Forms. This includes:
`confirmDelete`, `default`, `editorAttrs`, `editorClass`, `fieldAttrs`, `fieldClass`, `help`, `inputType`, `legend`, `title`, `titleHTML`, `validators`
* Tooltips displaying help text have been added, as well as the underlying attribute name to align with documentation, and to aid troubleshooting
* A reset button has been added to revert a field to its default state
* The custom Question Button editor has been replaced with the standard Text editor out since this was only compatible with version 1 of the framework
* The custom Boolean true/false dropdown has been replaced with the Checkbox editor for consistency. All core plugin schemas have already been switched over
* The undocumented & unused custom `TextArea:blank` editor has been retired

### Added
- Theme and menu settings can now be exposed via the `properties.schema` ([\#1116](https://github.com/adaptlearning/adapt_authoring/issues/1116), [\#1495](https://github.com/adaptlearning/adapt_authoring/issues/1495))

### Changed
- The colour picker widget has been changed to [Spectrum](http://bgrins.github.io/spectrum/) ([\#2014](https://github.com/adaptlearning/adapt_authoring/issues/2014))
- Form fieldset labels are now localised ([\#1376](https://github.com/adaptlearning/adapt_authoring/issues/1376))
- List items can now be rearranged via drag and drop ([\#1430](https://github.com/adaptlearning/adapt_authoring/issues/1430))
- CKEditor's `allowedContent` can now be specified using `ckEditorExtraAllowedContent` in `config.json` to control what's filtered from CK's output ([\#1619](https://github.com/adaptlearning/adapt_authoring/issues/1619))

### Removed
- The `Gruntfile.js` has been tidied up, and any unused code removed ([\#1993](https://github.com/adaptlearning/adapt_authoring/issues/1993))

### Fixed
- A Select input's default value is now configurable via the `properties.schema` ([\#1539](https://github.com/adaptlearning/adapt_authoring/issues/1539))

## [0.5.0] - 2018-06-26

Release which adds the ability to import courses created in the framework, as well as exports from other authoring tool installs.
Expand All @@ -26,7 +57,7 @@ We're also switching our Node.js support strategy to only include the current **
- Custom SMTP servers can now be used with mailer ([\#1447](https://github.com/adaptlearning/adapt_authoring/issues/1447))

### Changed
- Bumped archive module dependency version ([\#1930](https://github.com/adaptlearning/adapt_authoring/issues/1930))
- Bumped archive module dependency version ([\#1930](https://github.com/adaptlearning/adapt_authoring/issues/1930))
- Core front-end modules are now loaded before any front-end plugins ([\#1913](https://github.com/adaptlearning/adapt_authoring/issues/1913))
- `Database#addModel` now catches and logs errors ([\#1855](https://github.com/adaptlearning/adapt_authoring/issues/1855))
- Server now logs more appropriate message if error is caught when loading a route ([\#1853](https://github.com/adaptlearning/adapt_authoring/issues/1853))
Expand Down Expand Up @@ -434,6 +465,7 @@ Initial release.
- Loading screen of death
- Session cookie security issues

[0.6.0]: https://github.com/adaptlearning/adapt_authoring/compare/v0.5.0...v0.6.0
[0.5.0]: https://github.com/adaptlearning/adapt_authoring/compare/v0.4.1...v0.5.0
[0.4.1]: https://github.com/adaptlearning/adapt_authoring/compare/v0.4.0...v0.4.1
[0.4.0]: https://github.com/adaptlearning/adapt_authoring/compare/v0.3.0...v0.4.0
Expand Down
155 changes: 25 additions & 130 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,68 +96,6 @@ module.exports = function(grunt) {
}
}
},
jscs: {
src: [
'frontend/src/core/**/*.js',
'frontend/src/modules/**/*.js',
'!frontend/src/libraries/**/*.js',
'lib/**/*.js',
'plugins/**/*.js',
'!plugins/content/**',
'routes/**/*.js',
'!**/node_modules/**'
],
options: {
config: ".jscsrc",
reporter: "unix",
fix: true
}
},
jshint: {
options: {
reporter: require('jshint-stylish'),
curly: true,
undef: true,
asi: true,
eqnull: false,
sub: true
},
frontend: {
options: {
browser: true,
es3: true,
jquery: true,
globals: {
Backbone: false,
Handlebars: false,
_: false,
define: false,
require: false
}
},
files: {
src: [
'frontend/src/core/**/*.js',
'frontend/src/modules/**/*.js',
'!frontend/src/libraries/**/*.js'
]
}
},
backend: {
options: {
node: true
},
files: {
src: [
'lib/**/*.js',
'plugins/**/*.js',
'!plugins/content/**',
'routes/**/*.js',
'!**/node_modules/**'
]
}
}
},
requirejs: {
dev: {
options: {
Expand All @@ -180,41 +118,13 @@ module.exports = function(grunt) {
}
}
},
watch: {
handlebars: {
files: ['frontend/src/**/*.hbs'],
tasks: ['handlebars']
},
less: {
files: ['frontend/src/**/*.less'],
tasks: ['less:dev']
},
routes: {
files: ['routes/**/*.*'],
tasks: ['handlebars']
},
lang: {
files: ['routes/lang/*.json'],
tasks: ['merge-json']
}
},
mochaTest: {
src: ['test/*.js'],
options: {
reporter: 'spec',
timeout: 3500
}
},
open: {
server: {
path: 'http://localhost:<%= server.options.port %>/'
}
},
server: {
options: {
port: getHttpPort() || process.env.PORT
}
},
requireBundle: {
modules: {
src: 'frontend/src/modules/*',
Expand All @@ -227,68 +137,29 @@ module.exports = function(grunt) {
}
});

function getHttpPort() {
if (!grunt.file.exists(__dirname + "/conf/config.json")) {
return false;
}
var config = require(__dirname + "/conf/config.json");
return config.serverPort;
};

grunt.registerTask('migration-conf', 'Creating migration Conf', function() {
var config = grunt.file.readJSON('conf/config.json');
var connectionString = '';

// Construct the authentication part of the connection string.
var authenticationString = config.dbUser && config.dbPass ? config.dbUser + ':' + config.dbPass + '@' : '';

// Check if a MongoDB replicaset array has been specified.
if (config.dbReplicaset && Array.isArray(config.dbReplicaset) && config.dbReplicaset.length !== 0) {
// The replicaset should contain an array of hosts and ports
connectionString = 'mongodb://' + authenticationString + config.dbReplicaset.join(',') + '/' + config.dbName
} else {
// Get the host and port number from the configuration.

var portString = config.dbPort ? ':' + config.dbPort : '';

connectionString = 'mongodb://' + authenticationString + config.dbHost + portString + '/' + config.dbName;
}
if(typeof config.authSource === 'string' && config.authSource !== '' ){
connectionString += '?authSource=' + config.authSource
}

var migrateConf = {
migrationsDir : 'migrations/lib',
es6 : false,
dbConnectionUri: connectionString
};

grunt.file.write('conf/migrate.json', JSON.stringify(migrateConf, null, 2));

});

/**
* Accepts 'build' and 'prod' params
* e.g. grunt build:prod
*/
grunt.registerTask('build', 'Running build', function(mode) {
var configFile = 'conf/config.json';

if (!grunt.file.exists(configFile)) {
return grunt.task.run(['requireBundle', 'copy', 'less:dev', 'handlebars', 'requirejs:dev']);
}
var config = grunt.file.readJSON(configFile);
// Check if we're in 'production' mode
config.isProduction = (mode === 'prod') ? true : false;
// Save the configuration
grunt.file.write(configFile, JSON.stringify(config, null, 2));
// run the tasks
var compilation = (config.isProduction) ? 'compile' : 'dev';
grunt.task.run(['migration-conf', 'requireBundle', 'merge-json', 'copy', 'less:' + compilation, 'handlebars', 'requirejs:'+ compilation]);
});

grunt.registerTask('server', "Running Server", function() {
grunt.task.run(['requireBundle', 'copy', 'less:dev', 'handlebars', 'open:server', 'watch']);
});

// Compiles frontend plugins
Expand Down Expand Up @@ -378,6 +249,30 @@ module.exports = function(grunt) {
}
});

grunt.registerTask('default', ['build:dev']);
grunt.registerTask('test', ['mochaTest']);
grunt.registerTask('default', ['merge-json', 'requireBundle', 'less:dev', 'handlebars', 'watch']);

/**
* Accepts 'build' and 'prod' params
* e.g. grunt build:prod
*/
grunt.registerTask('build', 'Running build', function(mode) {
grunt.log.subhead(`Building application in ${mode === 'prod' ? 'production' : 'dev'} mode`);

var isProduction = mode === 'prod' ? true : false;
var compilation = isProduction ? 'compile' : 'dev';

try {
// add flag to config
var configFile = 'conf/config.json';
var config = grunt.file.readJSON(configFile);
config.isProduction = isProduction;
grunt.file.write(configFile, JSON.stringify(config, null, 2));
// run the task
grunt.task.run(['migration-conf', 'requireBundle', 'merge-json', 'copy', 'less:' + compilation, 'handlebars', 'requirejs:'+ compilation]);

} catch(e) {
grunt.task.run(['requireBundle', 'copy', 'less:' + compilation, 'handlebars', 'requirejs:' + compilation]);
}
});
};
1 change: 1 addition & 0 deletions frontend/src/core/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
'jqueryUI',
'mediaelement',
'scrollTo',
'selectize',
'sweetalert',
'velocity'
], function() {
Expand Down
9 changes: 5 additions & 4 deletions frontend/src/core/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ require.config({
backbone: 'libraries/backbone',
'backbone-forms': 'libraries/backbone-forms',
'backbone-forms-lists': 'libraries/backbone-forms-lists',
colorPicker: 'libraries/colorPicker/js/colorpicker',
handlebars: 'libraries/handlebars',
imageReady: 'libraries/imageReady',
inview: 'libraries/inview',
Expand All @@ -19,6 +18,7 @@ require.config({
pikaday: 'libraries/pikaday/js/pikaday',
polyglot: 'libraries/polyglot.min',
scrollTo: 'libraries/scrollTo',
selectize: 'libraries/selectize/js/selectize',
sweetalert: 'libraries/sweetalert.min',
typeahead: 'libraries/typeahead',
underscore: 'libraries/underscore',
Expand All @@ -39,9 +39,6 @@ require.config({
'backbone-forms-lists': {
deps: ['backbone-forms']
},
colorPicker: {
deps: ['jquery'],
},
handlebars: {
exports: 'Handlebars'
},
Expand Down Expand Up @@ -79,6 +76,10 @@ require.config({
deps: ['jquery'],
exports: 'scrollTo'
},
selectize: {
deps: ['jquery'],
exports: "$"
},
sweetalert: {
deps: ['jquery'],
exports: 'sweetAlert'
Expand Down
10 changes: 7 additions & 3 deletions frontend/src/core/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,13 @@ define(function(require){

keyToTitleString: function(key) {
if (!key) return;
// Take in key value and remove all _'s and capitalise
var string = key.replace(/_/g, "").toLowerCase();
return this.capitalise(string);
// check translatable strings first
var l10nKey = 'app.scaffold.' + key;
if(Origin.l10n.has(l10nKey)) {
return Origin.l10n.t(l10nKey);
}
// fall-back: remove all _ and capitalise
return this.capitalise(key.replace(/_/g, "").toLowerCase());
},

momentFormat: function(date, format) {
Expand Down
9 changes: 9 additions & 0 deletions frontend/src/core/l10n.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ define(['require', 'jquery', 'polyglot', 'core/origin'], function(require, $, Po
return string;
}
return polyglot.t.apply(polyglot, arguments);
},
has: function() {
if(!polyglot || !polyglot.has) {
return false;
}
return polyglot.has.apply(polyglot, arguments);
}
};
/**
Expand All @@ -16,11 +22,14 @@ define(['require', 'jquery', 'polyglot', 'core/origin'], function(require, $, Po
var locale = localStorage.getItem('lang') || 'en';
$.getJSON('lang/' + locale, function(data) {
polyglot = new Polyglot({
locale: locale,
phrases: data,
warn: function(message) {
if(Origin.debug) console.warn('l10n:', message);
}
});
Origin.trigger('l10n:loaded');
}).fail(function(jqXHR, textStatus, error) {
Origin.trigger('l10n:loaded');
});
});
Loading

0 comments on commit 03345a2

Please sign in to comment.