Skip to content

Commit

Permalink
Issue #000 merge: Merge pull request #1 from project-sunbird/webpack-…
Browse files Browse the repository at this point in the history
…coreplugins-plugins

Webpack coreplugins plugins
  • Loading branch information
pallakartheekreddy authored Jul 29, 2018
2 parents 78fd0ae + c3bfc69 commit e0080a9
Show file tree
Hide file tree
Showing 10 changed files with 669 additions and 68 deletions.
3 changes: 2 additions & 1 deletion app/bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"bootstrap": "^3.2.0",
"font-awesome": "~4.5.0",
"fabric": "1.7.3",
"fingerprintjs2": "^1.5.1",
"lodash": "~4.0.0",
"x2js": "./libs/xml2json.js",
"eventbus": "./libs/eventbus.min.js",
Expand Down Expand Up @@ -38,4 +39,4 @@
"devDependencies": {
"jasmine-jquery": "^2.1.1"
}
}
}
26 changes: 17 additions & 9 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<link rel="stylesheet" href="bower_components/ng-dialog/css/ngDialog.min.css">
<link rel="stylesheet" href="bower_components/ng-dialog/css/ngDialog-theme-plain.min.css">
<link rel="stylesheet" href="bower_components/ng-dialog/css/ngDialog-theme-default.min.css">
<link rel="stylesheet" href="bower_components/izitoast/dist/css/iziToast.min.css"/>
<link rel="stylesheet" href="bower_components/izitoast/dist/css/iziToast.min.css" />
<link rel="stylesheet" type="text/css" href="styles/iconfont.css">
<link rel="stylesheet" type="text/css" href="styles/noto.css">
<link rel="stylesheet" type="text/css" href="libs/spinkit.css">
Expand Down Expand Up @@ -63,20 +63,28 @@
<script src="scripts/genericeditor/genericeditor-config.js"></script>
<script src="scripts/genericeditor/genericeditor-api.js"></script>
<script src="scripts/genericeditor/genericeditor-base-plugin.js"></script>
<script src="scripts/genericeditor/manager/container-manager.js"></script>
<script src="scripts/genericeditor/manager/canvas-manager.js"></script>
<script src="scripts/genericeditor/manager/container-manager.js"></script>
<script src="scripts/genericeditor/manager/canvas-manager.js"></script>
<script src="scripts/genericeditor/md5.js"></script>

<!-- Load Angular Controllers -->
<script src="scripts/angular/controller/main.js"></script>
<script src="scripts/angular/directive/template-compiler-directive.js"></script>
<!-- endinject -->
<script type="text/javascript">
window.loading_screen = window.pleaseWait({
logo: !ecEditor._.isUndefined(ecEditor.getConfig('loadingImage')) ? ecEditor.getConfig('loadingImage') : '',
backgroundColor: '#bbbbbb',
loadingHtml: "<div class='sk-cube-grid'> <div class='sk-cube sk-cube1'></div> <div class='sk-cube sk-cube2'></div> <div class='sk-cube sk-cube3'></div> <div class='sk-cube sk-cube4'></div> <div class='sk-cube sk-cube5'></div> <div class='sk-cube sk-cube6'></div> <div class='sk-cube sk-cube7'></div> <div class='sk-cube sk-cube8'></div> <div class='sk-cube sk-cube9'></div> </div><p class='loading-message'>Loading Editor...</p>"
});
// Currently, Webpack is bundling window object `pleaseWait` into nested format.
// Ex: window.pleaseWait.pleaseWait ==> window.pleaseWait
if (typeof window.pleaseWait !== 'function') {
if (typeof window.pleaseWait.pleaseWait === 'function') {
window.pleaseWait = window.pleaseWait.pleaseWait;
}
};
window.loading_screen = window.pleaseWait({
logo: !ecEditor._.isUndefined(ecEditor.getConfig('loadingImage')) ? ecEditor.getConfig('loadingImage') : '',
backgroundColor: '#bbbbbb',
loadingHtml: "<div class='sk-cube-grid'> <div class='sk-cube sk-cube1'></div> <div class='sk-cube sk-cube2'></div> <div class='sk-cube sk-cube3'></div> <div class='sk-cube sk-cube4'></div> <div class='sk-cube sk-cube5'></div> <div class='sk-cube sk-cube6'></div> <div class='sk-cube sk-cube7'></div> <div class='sk-cube sk-cube8'></div> <div class='sk-cube sk-cube9'></div> </div><p class='loading-message'>Loading Editor...</p>"
});
</script>
</body>
</html>

</html>
51 changes: 30 additions & 21 deletions app/scripts/angular/controller/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

angular.module('editorApp', ['ngDialog', 'oc.lazyLoad', 'Scope.safeApply']).factory('cacheBustInterceptor', ['$templateCache', function($templateCache) {
return {
request : function(config) {
request: function(config) {
config.alreadyCached = $templateCache.get(config.url);
if (!config.alreadyCached) {
config.url = config.url + '?' + ecEditor.getConfig('build_number');
Expand All @@ -20,12 +20,22 @@ angular.module('editorApp', ['ngDialog', 'oc.lazyLoad', 'Scope.safeApply']).fact
});
$httpProvider.interceptors.push('cacheBustInterceptor');
}]);
angular.module('editorApp').controller('popupController', ['ngDialog', '$ocLazyLoad', function(ngDialog, $ocLazyLoad) {
function loadNgModules(templatePath, controllerPath) {
return $ocLazyLoad.load([
{ type: 'html', path: templatePath },
{ type: 'js', path: controllerPath + '?' + ecEditor.getConfig('build_number')}
]);
angular.module('editorApp').controller('popupController', ['ngDialog', '$ocLazyLoad', '$templateCache', function(ngDialog, $ocLazyLoad, $templateCache) {
function loadNgModules(templatePath, controllerPath, allowTemplateCache) {
if (!allowTemplateCache) {
return $ocLazyLoad.load([
{ type: 'html', path: templatePath },
{ type: 'js', path: controllerPath + '?' + ecEditor.getConfig('build_number') }
]);
} else {
if (angular.isString(templatePath) && templatePath.length > 0) {
angular.forEach(angular.element(templatePath), function(node) {
if (node.nodeName === "SCRIPT" && node.type === "text/ng-template") {
$templateCache.put(node.id, node.innerHTML);
}
});
}
}
};

function openModal(config, callback) {
Expand All @@ -35,24 +45,23 @@ angular.module('editorApp').controller('popupController', ['ngDialog', '$ocLazyL
org.ekstep.contenteditor.api.getService('popup').initService(loadNgModules, openModal);
}]);
angular.module('editorApp').controller('MainCtrl', ['$scope', '$ocLazyLoad', '$location',
function($scope, $ocLazyLoad, $location) {

function($scope, $ocLazyLoad, $location) {
$scope.loadNgModules = function(templatePath, controllerPath) {
var files = [];
if (templatePath) files.push({ type: 'html', path: templatePath });
if (controllerPath) files.push({ type: 'js', path: controllerPath + '?' + ecEditor.getConfig('build_number') });
if (files.length) return $ocLazyLoad.load(files)
};

org.ekstep.contenteditor.containerManager.initialize({loadNgModules: $scope.loadNgModules, scope: $scope });
};
org.ekstep.contenteditor.containerManager.initialize({ loadNgModules: $scope.loadNgModules, scope: $scope });

// container scope starts
$scope.editorContainer = undefined;
$scope.addToContainer = function(container) {
$scope.editorContainer = container;
$scope.$safeApply();
}
// container scope ends
$scope.editorContainer = container;
$scope.$safeApply();
}
// container scope ends

document.title = 'Generic-Editor';

Expand All @@ -63,17 +72,17 @@ angular.module('editorApp').controller('MainCtrl', ['$scope', '$ocLazyLoad', '$l
context.etags.app = context.app || context.etags.app || [];
context.etags.partner = context.partner || context.etags.partner || [];
context.etags.dims = context.dims || context.etags.dims || [];

var config = org.ekstep.contenteditor.getWindowConfig();
config.absURL = $location.protocol() + '://' + $location.host() + ':' + $location.port() // Required

config.genericeditorPlugins = config.plugins || org.ekstep.contenteditor.config.plugins;
config.plugins = [
config.plugins = [
{ "id": "org.ekstep.genericeditor", "ver": "1.1", "type": "plugin" }
]
org.ekstep.contenteditor.init(context, config, $scope, undefined, function() {
$scope.contentService = org.ekstep.contenteditor.api.getService(ServiceConstants.CONTENT_SERVICE);
$scope.popupService = org.ekstep.contenteditor.api.getService(ServiceConstants.POPUP_SERVICE);
});
$scope.contentService = org.ekstep.contenteditor.api.getService(ServiceConstants.CONTENT_SERVICE);
$scope.popupService = org.ekstep.contenteditor.api.getService(ServiceConstants.POPUP_SERVICE);
});
}
]);
]);
35 changes: 19 additions & 16 deletions app/scripts/coreplugins.js

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions deploy/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var rename = require("gulp-rename");

var cachebust = new CacheBuster();
gulp.task('renameminifiedfiles', function() {
var js = gulp.src('scripts/*.min.js').pipe(cachebust.resources()).pipe(gulp.dest('scripts/'));
var js = gulp.src('scripts/*.min.js').pipe(cachebust.resources()).pipe(gulp.dest('scripts/'));
var css = gulp.src('styles/*.min.css').pipe(cachebust.resources()).pipe(gulp.dest('styles/'));
return mergeStream(js, css);
});
Expand All @@ -26,23 +26,23 @@ gulp.task('bower-package', function() {
return gulp.src(['**', '!node_modules', '!node_modules/**', '!scripts/contenteditor.min.js', '!scripts/plugin-framework.min.js', '!scripts/contenteditor.min.js', '!gulpfile.js', '!package.json']).pipe(gulp.dest('build/'));
});

gulp.task('package', ['iframe-package', 'embed-package', 'coreplugins-package']);
gulp.task('package', ['renameminifiedfiles', 'injectrenamedfiles', 'iframe-package', 'embed-package', 'coreplugins-package']);

gulp.task('iframe-package', ['bower-package'], function() {
var package_id = packageJson['name'] + '-' + 'iframe' + '-' + packageJson['version'];
return mergeStream(gulp.src('build/**').pipe(zip(package_id + '.zip')).pipe(gulp.dest('dist/editor/')),
gulp.src('build/**').pipe(zip(packageJson['name'] + '-iframe-latest' + '.zip')).pipe(gulp.dest('dist/editor/')));
return mergeStream(gulp.src('build/**').pipe(zip(package_id + '.zip')).pipe(gulp.dest('dist/editor/')),
gulp.src('build/**').pipe(zip(packageJson['name'] + '-iframe-latest' + '.zip')).pipe(gulp.dest('dist/editor/')));
});

gulp.task('bower-package-transform', ['iframe-package'], function() {
return mergeStream(gulp.src('build/index.html').pipe(replace('href="styles', 'href="content-editor-embed/styles')).pipe(replace('src="scripts', 'src="content-editor-embed/scripts')).pipe(replace("'templates", "'content-editor-embed/templates")).pipe(gulp.dest('build/')),
gulp.src('build/scripts/script.min.js').pipe(replace("src='scripts", "src='content-editor-embed/scripts")).pipe(gulp.dest('build/scripts/')));
gulp.src('build/scripts/script.min.js').pipe(replace("src='scripts", "src='content-editor-embed/scripts")).pipe(gulp.dest('build/scripts/')));
});

gulp.task('embed-package', ['bower-package-transform'], function() {
var package_id = packageJson['name'] + '-' + 'embed' + '-' + packageJson['version'];
return mergeStream(gulp.src('build/**').pipe(zip(package_id + '.zip')).pipe(gulp.dest('dist/editor/')),
gulp.src('build/**').pipe(zip(packageJson['name'] + '-embed-latest' + '.zip')).pipe(gulp.dest('dist/editor/')));
gulp.src('build/**').pipe(zip(packageJson['name'] + '-embed-latest' + '.zip')).pipe(gulp.dest('dist/editor/')));
});

gulp.task('rename-coreplugins', ['embed-package'], function() {
Expand Down
3 changes: 1 addition & 2 deletions deploy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
},
"author": "Kartheek Palla",
"license": "ISC",
"dependencies": {
},
"dependencies": {},
"devDependencies": {
"gulp": "^3.9.1",
"gulp-zip": "^3.2.0",
Expand Down
13 changes: 5 additions & 8 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var uglify = require('gulp-uglify');
var versionNumber = process.env.version_number;
var buildNumber = process.env.build_number;

if(!versionNumber && !versionNumber) {
if (!versionNumber && !versionNumber) {
console.error('Error!!! Cannot find verion_number and build_number env variables');
return process.exit(1);
}
Expand Down Expand Up @@ -60,7 +60,7 @@ var scriptfiles = [
"app/scripts/genericeditor/genericeditor-config.js",
"app/scripts/genericeditor/genericeditor-api.js",
"app/scripts/genericeditor/genericeditor-base-plugin.js",
"app/scripts/genericeditor/manager/container-manager.js",
"app/scripts/genericeditor/manager/container-manager.js",
"app/scripts/genericeditor/manager/canvas-manager.js",
"app/scripts/angular/controller/main.js",
"app/scripts/angular/directive/template-compiler-directive.js",
Expand Down Expand Up @@ -185,7 +185,7 @@ gulp.task('copydeploydependencies', function() {
.pipe(gulp.dest('generic-editor'));
});

gulp.task('minify', ['minifyCE', 'minifyCSS', 'minifyJsBower', 'minifyCssBower', 'copycommonfonts', 'copyfontawesomefonts', 'copyFiles','copydeploydependencies']);
gulp.task('minify', ['minifyCE', 'minifyCSS', 'minifyJsBower', 'minifyCssBower', 'copycommonfonts', 'copyfontawesomefonts', 'copyFiles', 'copydeploydependencies']);

gulp.task('inject', ['minify'], function() {
var target = gulp.src('generic-editor/index.html');
Expand Down Expand Up @@ -213,13 +213,10 @@ gulp.task('zip', ['minify', 'inject', 'replace', 'packageCorePlugins'], function
.pipe(gulp.dest(''));
});

gulp.task('build', ['minify','inject', 'replace', 'packageCorePlugins', 'zip']);
gulp.task('build', ['minify', 'inject', 'replace', 'packageCorePlugins', 'zip']);

var corePlugins = [
"org.ekstep.conceptselector-1.1",
"org.ekstep.assetbrowser-1.2",
"org.ekstep.uploadcontent-1.2",
"org.ekstep.contenteditorfunctions-1.2"
]

gulp.task('minifyCorePlugins', function() {
Expand Down Expand Up @@ -296,4 +293,4 @@ gulp.task('packageCorePlugins', ['minify', "minifyCorePlugins"], function() {
return gulp.src('plugins/**/plugin.min.js', {
read: false
}).pipe(clean());
});
});
41 changes: 36 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "at",
"name": "sunbird-generic-editor",
"version": "1.0.0",
"description": "",
"description": "Basic editor for all uploaded (non-ecml & non-collection) content",
"main": "Gruntfile.js",
"dependencies": {
"body-parser": "*",
Expand All @@ -13,7 +13,14 @@
"xmlbuilder": "*"
},
"devDependencies": {
"ajv": "^6.5.2",
"bluebird": "^3.4.6",
"clean-webpack-plugin": "^0.1.19",
"copy-webpack-plugin": "4.5.2",
"css-loader": "^1.0.0",
"expose-loader": "^0.7.5",
"express-http-proxy": "^1.2.0",
"file-loader": "1.1.11",
"grunt": ">=0.4.0 <1.0.0",
"grunt-aws-s3": "^0.14.5",
"grunt-contrib-compress": "^1.3.0",
Expand All @@ -36,10 +43,16 @@
"gulp-strip-debug": "^1.1.0",
"gulp-uglify": "^3.0.0",
"gulp-zip": "^3.2.0",
"html-loader": "^0.5.5",
"html-minifier": "*",
"html-minifier-loader": "*",
"html-webpack-plugin": "^3.2.0",
"imagemin-webpack-plugin": "^2.1.5",
"imports-loader": "*",
"jasmine": "2.5.2",
"jasmine-core": "2.5.2",
"jasmine-expect": "3.7.0",
"jquery": "3.1.1",
"jquery": "^3.1.1",
"jsdoc": "3.4.3",
"karma": "1.3.0",
"karma-chrome-launcher": "2.0.0",
Expand All @@ -49,14 +62,32 @@
"karma-mocha-reporter": "^2.2.3",
"karma-phantomjs-launcher": "1.0.2",
"merge-stream": "1.0.1",
"phantomjs": "2.1.7"
"mini-css-extract-plugin": "^0.4.1",
"node-sass": "^4.9.2",
"optimize-css-assets-webpack-plugin": "^4.0.3",
"phantomjs": "2.1.7",
"postcss-cli": "*",
"purify-css": "*",
"purifycss-webpack": "*",
"sass-loader": "^7.0.3",
"string-replace-loader": "2.1",
"svg-inline-loader": "*",
"uglify-js": "^3.4.5",
"uglifyjs-webpack-plugin": "1.2.7",
"url-loader": "^1.0.1",
"webpack": "^4.14.0",
"webpack-cli": "^2.1.5",
"webpack-entry-plus": "1.0.12",
"zip-webpack-plugin": "^3.0.0"
},
"scripts": {
"build": "webpack",
"plugin-build": "webpack --config webpack.plugin.config.js",
"test": "karma start karmaconf.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/ekstep/Collection-Editor.git"
"url": "git+https://github.com/project-sunbird/sunbird-generic-editor"
},
"author": "",
"license": "CC"
Expand Down
Loading

0 comments on commit e0080a9

Please sign in to comment.