Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules/
bower_components/
.idea/
.project/
deploy/
153 changes: 153 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
/*
* Copyright (c) 2012-2015 S-Core Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';
module.exports = function (grunt) {
grunt.initConfig({
// for jshint check based on .jshintrc
// package.json doesn't have jshint-stylish and grunt-contrib-jshint plugins.
// Therefore, users of jshint must install these plugins by using npm install ...
jshint : {
options: {
jshintrc: '.jshintrc',
reporter: require('jshint-stylish')
},
files: {
expand: true,
cwd: './',
src: ['js/*.js', 'js/**/*.js',
'!**/lib/**', '!**/Gruntfile.js', // ignore lib and Gruntfile
'!**/*.min.js', '!**/*.back.js'] // ignore min/back.js files
}
},
bower: {
install: {
// just run grunt bower install
},
options: {
copy: false
}
},
copy: {
all: {
files: [
{
expand: true,
cwd: './',
src: ['**'],
dest: 'deploy/'
}
]
},
uncompressed: {
files: [
{
expand: true,
cwd: './',
src: ['**/*.js', '**/lib/**', '!node_modules/**', '!deploy/**'],
dest: 'deploy/',
rename: function (dest, src) {
return dest + src.substring(0, src.lastIndexOf('.js')) + '.uncompressed.js';
}
}
]
}
},
uglify: {
debug: {
options: {
mangle: true,
compress: true,
preserveComments: false,
sourceMap: function(path) {
return path + '.map';
},
sourceMappingURL: function(path) {
return path.substring(path.lastIndexOf('/') + 1) + '.map';
}
},
files: [
{
expand: true,
cwd: 'deploy/',
src: ['**/*.js', '!node_modules/*.js', '!node_modules/**/*.js', '!**/lib/**', '!*.uncompressed.js', '!**/*.uncompressed.js', , '!bower_components/**/*.js'],
dest: 'deploy/'
}
]
},
release: {
options: {
mangle: true,
compress: true,
preserveCommnets: false
},
files: [
{
expand: true,
cwd: 'deploy/',
src: ['**/*.js', '!node_modules/**/*.js', '!node_modules/*.js', '!**/lib/**', '!bower_components/**/*.js'],
dest: 'deploy/'
}
]
}
},
clean: {
all: ['deploy'],
unnecessary: ['deploy/Gruntfile.js', 'deploy/node_modules']
},
fix_source_maps: {
files: {
expand: true,
cwd: 'deploy/',
src: ['*.map', '**/*.map'],
dest: 'deploy'
}
}
});
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-bower-task');

grunt.registerMultiTask('fix_source_maps', 'Fixes uglified source maps', function() {
this.files.forEach(function(f) {
var json, src;
src = f.src.filter(function(filepath) {
if (!grunt.file.exists(filepath)) {
grunt.log.warn('Source file "' + filepath + '" not found.');
return false;
} else {
return true;
}
});
json = grunt.file.readJSON(src);
var length = json.sources.length;
for(var i = 0; i < length; i++) {
json.sources[i] = json.sources[i].substring(json.sources[i].lastIndexOf('/') + 1);
json.sources[i] = json.sources[i].substring(0, json.sources[i].lastIndexOf('.js')) + '.uncompressed.js';
}
json.file= json.file.substring(json.file.lastIndexOf('/') + 1);
grunt.file.write(f.dest, JSON.stringify(json));
grunt.log.writeln('Source map in ' + src + ' fixed');
});
});

grunt.registerTask('default', ['clean:all', 'bower', 'copy:all'/*, 'copy:uncompressed', 'clean:unnecessary', 'uglify:debug', 'fix_source_maps'*/]);
grunt.registerTask('release', ['clean:all', 'bower', 'copy:all', 'clean:unnecessary', 'uglify:release']);
grunt.registerTask('convention', ['jshint']);
};

3 changes: 2 additions & 1 deletion js/app-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ define([
clientId: 'DASHBOARD_CLIENT_ID',
signUpEnable: !!serverConf.featureEnables.signUp,
guestMode: !!serverConf.featureEnables.guestMode,
redirectUrl: serverConf.systemApps[APP_ID].baseUrl + '/pages/auth.html'
redirectUrl: serverConf.systemApps[APP_ID].baseUrl + '/pages/auth.html',
ideBaseUrl: serverConf.systemApps['webida-client'].baseUrl
};
});
9 changes: 4 additions & 5 deletions js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ require([
'ModalFactory',
'notify',
'services/Auth',
'services/FS',
'webida',
], function (appConfig, guest, ModalFactory, notify, Auth, FS, webida) {
'services/FS'
], function (appConfig, guest, ModalFactory, notify, Auth, FS) {
'use strict';

jQuery.fn.closeModal = function () {
Expand All @@ -48,8 +47,8 @@ require([
Auth.getMyInfo(true).then(function (info) {
if (info.isGuest) {
FS.getFSId().then(function (fsid) {
location.href = '//ide.' + webida.conf.webidaHost +
'/apps/ide/src/index.html?workspace=' + fsid + '/guest';
location.href = appConfig.ideBaseUrl + '/apps/ide/src/index.html?workspace=' +
fsid + '/guest';
}).fail(function (e) {
console.log('getFSId fail', e);
});
Expand Down
7 changes: 3 additions & 4 deletions js/services/WorkspaceManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ define([
'app-config',
'lodash',
'services/App',
'services/FS',
'webida',
], function (appConfig, _, App, FS, webida) {
'services/FS'
], function (appConfig, _, App, FS) {
'use strict';

var WorkspaceManager = function () {
Expand Down Expand Up @@ -142,7 +141,7 @@ define([
},

getWorkspaceOpenUrl: function (wsName) {
return '//ide.' + webida.conf.webidaHost + '/apps/ide/src/index.html?workspace=' + fsid + '/' + wsName;
return appConfig.ideBaseUrl + '/apps/ide/src/index.html?workspace=' + fsid + '/' + wsName;
},

createWorkspace: function (name /*, desc*/ ) {
Expand Down
25 changes: 25 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"appid": "app-dashboard",
"apptype": "html",
"name": "webida-dashboard",
"desc": "dashboard",
"version": "1.2.0",
"devDependencies": {
"grunt": "~0.4.2",
"grunt-bower-task": "^0.4.0",
"grunt-contrib-copy": "~0.5.0",
"grunt-contrib-uglify": "~0.4.0",
"grunt-contrib-cssmin": "~0.9.0",
"grunt-contrib-clean": "~0.5.0",
"grunt-contrib-jshint": "^0.10.0",
"grunt-exec": "~0.4.5",
"grunt-dom-munger": "~3.4.0",
"jshint-stylish": "^1.0.0",
"grunt-contrib-clean": "~0.4.0",
"grunt-prettify": "~0.3.4"
},
"scripts": {
"prepublish": "echo 'prepublish'; if [ -z $RELEASE_BUILD ]; then grunt; else grunt release; fi"
},
"build-dir": "deploy"
}