Add gulp build of commonFramework
This commit is contained in:
@ -1,24 +1,25 @@
|
|||||||
window.common = (function(global) {
|
window.common = (function(global) {
|
||||||
const {
|
const {
|
||||||
|
Rx: { Subject, Observable },
|
||||||
CodeMirror,
|
CodeMirror,
|
||||||
emmetCodeMirror,
|
emmetCodeMirror,
|
||||||
common = { init: [] }
|
common = { init: [] }
|
||||||
} = global;
|
} = global;
|
||||||
|
|
||||||
const { challengeType = '0' } = common;
|
const { challengeType = '0', challengeTypes } = common;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!CodeMirror ||
|
!CodeMirror ||
|
||||||
challengeType === '0' ||
|
challengeType === challengeTypes.BONFIRE ||
|
||||||
challengeType === '7'
|
challengeType === challengeTypes.ZIPLINE ||
|
||||||
|
challengeType === challengeTypes.VIDEO ||
|
||||||
|
challengeType === challengeTypes.STEP ||
|
||||||
|
challengeType === challengeTypes.HIKES
|
||||||
) {
|
) {
|
||||||
common.editor = {};
|
common.editor = {};
|
||||||
return common;
|
return common;
|
||||||
}
|
}
|
||||||
|
|
||||||
var delay;
|
|
||||||
var codeStorageFactory = common.codeStorageFactory;
|
|
||||||
|
|
||||||
var editor = CodeMirror.fromTextArea(
|
var editor = CodeMirror.fromTextArea(
|
||||||
document.getElementById('codeEditor'),
|
document.getElementById('codeEditor'),
|
||||||
{
|
{
|
||||||
@ -37,22 +38,12 @@ window.common = (function(global) {
|
|||||||
|
|
||||||
editor.setSize('100%', 'auto');
|
editor.setSize('100%', 'auto');
|
||||||
|
|
||||||
var codeStorage = common.codeStorage =
|
common.editorKeyUp$ = Observable.fromEventPattern(
|
||||||
codeStorageFactory(editor, common.challengeName);
|
() => editor.on('keyup'),
|
||||||
|
() => editor.off('keyup')
|
||||||
editor.on('keyup', function() {
|
|
||||||
clearTimeout(codeStorage.updateTimeoutId);
|
|
||||||
codeStorage.updateTimeoutId = setTimeout(
|
|
||||||
codeStorage.updateStorage.bind(codeStorage),
|
|
||||||
codeStorage.updateWait
|
|
||||||
);
|
);
|
||||||
});
|
|
||||||
|
|
||||||
// Initialize CodeMirror editor with a nice html5 canvas demo.
|
common.editorExecute$ = new Subject();
|
||||||
editor.on('keyup', function() {
|
|
||||||
clearTimeout(delay);
|
|
||||||
delay = setTimeout(common.updatePreview, 300);
|
|
||||||
});
|
|
||||||
|
|
||||||
editor.setOption('extraKeys', {
|
editor.setOption('extraKeys', {
|
||||||
Tab: function(cm) {
|
Tab: function(cm) {
|
||||||
@ -72,11 +63,11 @@ window.common = (function(global) {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
'Ctrl-Enter': function() {
|
'Ctrl-Enter': function() {
|
||||||
common.executeChallenge(true);
|
common.editorExecute$.onNext();
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
'Cmd-Enter': function() {
|
'Cmd-Enter': function() {
|
||||||
common.executeChallenge(true);
|
common.editorExecute$.onNext();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -104,12 +95,12 @@ window.common = (function(global) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
common.init.push(function() {
|
common.init.push(function() {
|
||||||
var editorValue;
|
let editorValue;
|
||||||
if (common.codeUri.isAlive()) {
|
if (common.codeUri.isAlive()) {
|
||||||
editorValue = common.codeUri.parse();
|
editorValue = common.codeUri.parse();
|
||||||
} else {
|
} else {
|
||||||
editorValue = codeStorage.isAlive() ?
|
editorValue = common.codeStorage.isAlive() ?
|
||||||
codeStorage.getStoredValue() :
|
common.codeStorage.getStoredValue() :
|
||||||
common.seed;
|
common.seed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,5 +85,4 @@ window.common = (function(global) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return common;
|
return common;
|
||||||
})();
|
})(window);
|
||||||
|
|
||||||
|
@ -129,4 +129,4 @@ window.common = (function({ common = { init: [] }}) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
return common;
|
return common;
|
||||||
}());
|
}(window));
|
||||||
|
32
gulpfile.js
32
gulpfile.js
@ -106,8 +106,22 @@ var paths = {
|
|||||||
'client/plugin.js'
|
'client/plugin.js'
|
||||||
],
|
],
|
||||||
|
|
||||||
dependents: [
|
commonFramework: [
|
||||||
'client/commonFramework.js'
|
'init',
|
||||||
|
'code-storage',
|
||||||
|
'code-uri',
|
||||||
|
'create-editor',
|
||||||
|
'detect-loops-stream',
|
||||||
|
'display-test-results',
|
||||||
|
'execute-challenge-stream',
|
||||||
|
'out-display',
|
||||||
|
'phone-scroll-lock',
|
||||||
|
'report-issue',
|
||||||
|
'run-tests-stream',
|
||||||
|
'show-completion',
|
||||||
|
'step-challenge',
|
||||||
|
'test-script-stream',
|
||||||
|
'update-preview'
|
||||||
],
|
],
|
||||||
|
|
||||||
less: './client/less/main.less',
|
less: './client/less/main.less',
|
||||||
@ -133,6 +147,12 @@ var webpackOptions = {
|
|||||||
devtool: 'inline-source-map'
|
devtool: 'inline-source-map'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function formatCommonFrameworkPaths() {
|
||||||
|
return this.map(function(script) {
|
||||||
|
return 'client/commonFramework/' + script + '.js';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function errorHandler() {
|
function errorHandler() {
|
||||||
var args = Array.prototype.slice.call(arguments);
|
var args = Array.prototype.slice.call(arguments);
|
||||||
|
|
||||||
@ -405,9 +425,10 @@ gulp.task('dependents', ['js'], function() {
|
|||||||
path.join(__dirname, paths.manifest, 'js-manifest.json')
|
path.join(__dirname, paths.manifest, 'js-manifest.json')
|
||||||
);
|
);
|
||||||
|
|
||||||
return gulp.src(paths.dependents)
|
return gulp.src(formatCommonFrameworkPaths.call(paths.commonFramework))
|
||||||
.pipe(plumber({ errorHandler: errorHandler }))
|
.pipe(plumber({ errorHandler: errorHandler }))
|
||||||
.pipe(babel())
|
.pipe(babel())
|
||||||
|
.pipe(concat('commonFramework.js'))
|
||||||
.pipe(__DEV__ ? gutil.noop() : uglify())
|
.pipe(__DEV__ ? gutil.noop() : uglify())
|
||||||
.pipe(revReplace({ manifest: manifest }))
|
.pipe(revReplace({ manifest: manifest }))
|
||||||
.pipe(gulp.dest(dest))
|
.pipe(gulp.dest(dest))
|
||||||
@ -474,7 +495,10 @@ gulp.task('watch', watchDependents, function() {
|
|||||||
gulp.watch(paths.js, ['js']);
|
gulp.watch(paths.js, ['js']);
|
||||||
gulp.watch(paths.challenges, ['test-challenges', 'reload']);
|
gulp.watch(paths.challenges, ['test-challenges', 'reload']);
|
||||||
gulp.watch(paths.js, ['js', 'dependents']);
|
gulp.watch(paths.js, ['js', 'dependents']);
|
||||||
gulp.watch(paths.dependents, ['dependents']);
|
gulp.watch(
|
||||||
|
formatCommonFrameworkPaths.call(paths.commonFramework),
|
||||||
|
['dependents']
|
||||||
|
);
|
||||||
gulp.watch(paths.manifest + '/*.json', ['build-manifest-watch']);
|
gulp.watch(paths.manifest + '/*.json', ['build-manifest-watch']);
|
||||||
gulp.watch(webpackConfig.output.path + '/bundle.js', ['pack-watch-manifest']);
|
gulp.watch(webpackConfig.output.path + '/bundle.js', ['pack-watch-manifest']);
|
||||||
});
|
});
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
extends ../layout-wide
|
extends ../layout-wide
|
||||||
block content
|
block content
|
||||||
link(rel='stylesheet', href='/js/lib/codemirror/lib/codemirror.css')
|
link(rel='stylesheet', href='/bower_components/CodeMirror/lib/codemirror.css')
|
||||||
link(rel='stylesheet', href='/js/lib/codemirror/addon/lint/lint.css')
|
link(rel='stylesheet', href='/bower_components/CodeMirror/addon/lint/lint.css')
|
||||||
link(rel='stylesheet', href='/js/lib/codemirror/theme/monokai.css')
|
link(rel='stylesheet', href='/bower_components/Codemirror/theme/monokai.css')
|
||||||
link(rel='stylesheet', href='/css/ubuntu.css')
|
link(rel='stylesheet', href='/css/ubuntu.css')
|
||||||
.row.courseware-height
|
.row.courseware-height
|
||||||
.col-md-3.col-lg-3
|
.col-md-3.col-lg-3
|
||||||
@ -87,6 +87,10 @@ block content
|
|||||||
common.dashedName = !{JSON.stringify(dashedName)};
|
common.dashedName = !{JSON.stringify(dashedName)};
|
||||||
|
|
||||||
common.started = Math.floor(Date.now());
|
common.started = Math.floor(Date.now());
|
||||||
|
common.init.push(function() {
|
||||||
|
common.editor.setOption('lint', false);
|
||||||
|
common.editor.setOption('mode', 'text/html');
|
||||||
|
});
|
||||||
|
|
||||||
include ../partials/challenge-footer
|
include ../partials/challenge-footer
|
||||||
script.
|
script.
|
||||||
@ -96,5 +100,3 @@ block content
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
editor.setOption('lint', false);
|
|
||||||
editor.setOption("mode", "text/html");
|
|
||||||
|
Reference in New Issue
Block a user