diff --git a/html5/verto/verto_communicator/.gitignore b/html5/verto/verto_communicator/.gitignore new file mode 100644 index 0000000000..7274d6169c --- /dev/null +++ b/html5/verto/verto_communicator/.gitignore @@ -0,0 +1,4 @@ +dist/ +.tmp/ +bower_components/ +node_modules/ diff --git a/html5/verto/verto_communicator/.jshintrc b/html5/verto/verto_communicator/.jshintrc new file mode 100644 index 0000000000..bea9497bb7 --- /dev/null +++ b/html5/verto/verto_communicator/.jshintrc @@ -0,0 +1,18 @@ +{ + "bitwise": true, + "browser": true, + "curly": true, + "eqeqeq": true, + "esnext": true, + "latedef": true, + "noarg": true, + "node": true, + "strict": true, + "undef": true, + "unused": true, + "globals": { + "angular": false, + "jQuery": false, + "$": false + } +} \ No newline at end of file diff --git a/html5/verto/verto_communicator/Gruntfile.js b/html5/verto/verto_communicator/Gruntfile.js index d956edc06a..0cbf3d4475 100644 --- a/html5/verto/verto_communicator/Gruntfile.js +++ b/html5/verto/verto_communicator/Gruntfile.js @@ -1,68 +1,313 @@ /*jslint node: true */ 'use strict'; -var pkg = require('./package.json'); +// var pkg = require('./package.json'); module.exports = function (grunt) { + // Time how long tasks take. Can help when optimizing build times + require('time-grunt')(grunt); + // load all grunt tasks - require('load-grunt-tasks')(grunt); + require('jit-grunt')(grunt, { + includereplace: 'grunt-include-replace', + useminPrepare: 'grunt-usemin' + }); + + // Configurable paths + var config = { + app: '.', + dist: 'dist' + }; + + var ip = grunt.option('ip') || 'localhost'; // Project configuration. grunt.initConfig({ + // Project settings + config: config, + + // Watch things watch: { + bower: { + files: ['bower.json'], + tasks: ['wiredep'] + }, js: { - files: ['js/{,*/}*.js'], - tasks: ['newer:jshint:all'], - options: { - livereload: true - } + files: ['js/verto-service.js'], + tasks: ['includereplace:dev'] + }, + styles: { + files: ['<%= config.app %>/css/{,*/}*.css'], + tasks: ['newer:copy:styles', 'postcss'] }, gruntfile: { files: ['Gruntfile.js'] - }, - livereload: { - options: { - livereload: true - }, - files: [ - 'index.html', - 'partials/{,*/}*.html', - 'js/{,*/}*.js', - 'images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}' - ] } }, + + // Replace so we can have it properly passed from dev + includereplace: { + dev: { + options: { + globals: { + ip: ip + }, + }, + src: 'js/verto-service.js', + dest: '.tmp/js/verto-service.js' + }, + prod: { + options: { + globals: { + ip: ip + }, + }, + src: 'js/verto-service.js', + dest: 'dist/js/' + } + }, wiredep: { app: { src: ['index.html'], ignorePath: /\.\.\// } }, - connect: { + + postcss: { options: { - port: 9001, - // Change this to '0.0.0.0' to access the server from outside. - hostname: 'localhost', - livereload: 35729, - protocol: 'https' + map: true, + processors: [ + // Add vendor prefixed styles + require('autoprefixer-core')({ + browsers: ['> 1%', 'last 2 versions', 'Firefox ESR', 'Opera 12.1'] + }) + ] + }, + dist: { + files: [{ + expand: true, + cwd: '.tmp/styles/', + src: '{,*/}*.css', + dest: '.tmp/styles/' + }] + } + }, + + browserSync: { + options: { + notify: false, + background: true, + https: true, + open: false }, livereload: { options: { - open: false, - middleware: function (connect) { - return [ - connect().use( - '/js/src', - connect.static('../js/src') - ), - connect.static('.') - ]; + files: [ + '<%= config.app %>/{,*/}*.html', + '.tmp/styles/{,*/}*.css', + '<%= config.app %>/images/{,*/}*', + '.tmp/js/{,*/}*.js', + '<%= config.app %>/js/**/*.js' + ], + port: 9001, + server: { + baseDir: ['.tmp', '../js/src/', config.app], + routes: { + '/bower_components': './bower_components', + '/js/src': '../js/src' + } } } }, }, + + jshint: { + options: { + jshintrc: '.jshintrc', + reporter: require('jshint-stylish'), + ignores: ['js/3rd-party/**/*.js'], + force: true // TODO: Remove this once we get files linted correctly!!! + }, + all: { + src: [ + 'Gruntfile.js', + 'js/{,*/}*.js' + ] + } + }, + clean: { + dist: { + files: [{ + dot: true, + src: [ + '.tmp', + 'dist/{,*/}*', + '!dist/.git{,*/}*' + ] + }] + }, + server: '.tmp' + }, + // Renames files for browser caching purposes + filerev: { + dist: { + src: [ + 'dist/scripts/{,*/}*.js', + 'dist/css/{,*/}*.css', + 'dist/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}', + 'dist/css/fonts/*' + ] + } + }, + // Reads HTML for usemin blocks to enable smart builds that automatically + // concat, minify and revision files. Creates configurations in memory so + // additional tasks can operate on them + useminPrepare: { + options: { + dest: '<%= config.dist %>' + }, + html: '<%= config.app %>/index.html' + }, + + // Performs rewrites based on rev and the useminPrepare configuration + usemin: { + options: { + assetsDirs: [ + '<%= config.dist %>', + '<%= config.dist %>/images', + '<%= config.dist %>/styles' + ] + }, + html: ['<%= config.dist %>/{,*/}*.html'], + css: ['<%= config.dist %>/styles/{,*/}*.css'] + }, + + // The following *-min tasks produce minified files in the dist folder + imagemin: { + dist: { + files: [{ + expand: true, + cwd: '<%= config.app %>/images', + src: '{,*/}*.{gif,jpeg,jpg,png}', + dest: '<%= config.dist %>/images' + }] + } + }, + + svgmin: { + dist: { + files: [{ + expand: true, + cwd: '<%= config.app %>/images', + src: '{,*/}*.svg', + dest: '<%= config.dist %>/images' + }] + } + }, + + htmlmin: { + dist: { + options: { + collapseBooleanAttributes: true, + collapseWhitespace: true, + conservativeCollapse: true, + removeAttributeQuotes: true, + removeCommentsFromCDATA: true, + removeEmptyAttributes: true, + removeOptionalTags: true, + // true would impact styles with attribute selectors + removeRedundantAttributes: false, + useShortDoctype: true + }, + files: [{ + expand: true, + cwd: '<%= config.dist %>', + src: '{,*/}*.html', + dest: '<%= config.dist %>' + }] + } + }, + // ng-annotate tries to make the code safe for minification automatically + // by using the Angular long form for dependency injection. + ngAnnotate: { + dist: { + files: [{ + expand: true, + cwd: '.tmp/concat/scripts', + src: '*.js', + dest: '.tmp/concat/scripts' + }] + } + }, + // Copies remaining files to places other tasks can use + copy: { + dist: { + files: [{ + expand: true, + dot: true, + cwd: '', + dest: 'dist', + src: [ + '*.{ico,png,txt}', + '*.html', + 'images/{,*/}*.{webp}', + 'css/fonts/{,*/}*.*' + ] + }, { + expand: true, + cwd: '.tmp/images', + dest: 'dist/images', + src: ['generated/*'] + }, { + expand: true, + cwd: 'bower_components/bootstrap/dist', + src: 'fonts/*', + dest: 'dist' + }] + }, + styles: { + expand: true, + cwd: '/css', + dest: '.tmp/css/', + src: '{,*/}*.css' + } + }, + // Run some tasks in parallel to speed up the build process + concurrent: { + server: [ + 'copy:styles' + ], + dist: [ + 'copy:styles', + 'imagemin', + 'svgmin' + ] + }, }); - grunt.registerTask('serve', ['wiredep', 'connect:livereload', 'watch']); + grunt.registerTask('serve', ['clean:server', + 'wiredep', + 'concurrent:server', + 'postcss', + 'includereplace:dev', + 'browserSync:livereload', + 'watch']); + + grunt.registerTask('build', [ + 'clean:dist', + 'wiredep', + 'useminPrepare', + 'concurrent:dist', + 'postcss', + 'concat', + 'cssmin', + 'ngAnnotate', + 'uglify', + 'copy:dist', + 'filerev', + 'usemin', + 'htmlmin' + ]); + }; diff --git a/html5/verto/verto_communicator/README.md b/html5/verto/verto_communicator/README.md new file mode 100644 index 0000000000..707783501f --- /dev/null +++ b/html5/verto/verto_communicator/README.md @@ -0,0 +1,8 @@ +brew install npm + +npm install -g grunt grunt-cli bower + +cd verto_communicator +npm install +bower install +grunt serve \ No newline at end of file diff --git a/html5/verto/verto_communicator/bower.json b/html5/verto/verto_communicator/bower.json index bc8395cafc..623a51d1cc 100644 --- a/html5/verto/verto_communicator/bower.json +++ b/html5/verto/verto_communicator/bower.json @@ -25,7 +25,7 @@ ], "dependencies": { "angular-gravatar": "~0.4.1", - "bootstrap": "~3.3.5", + "bootstrap": "~3.3.4", "angular-toastr": "~1.4.1", "angular": "~1.3.15", "angular-route": "~1.3.15", @@ -44,17 +44,17 @@ "bootstrap-material-design": "~0.3.0" }, "resolutions": { - "angular": "~1.3.15" + "angular": "~1.3.15", + "angular-bootstrap": "~0.13.3" }, - "overrides":{ - "bootstrap" : { + "overrides": { + "bootstrap": { "main": [ - "less/bootstrap.less", "dist/css/bootstrap.css", "dist/js/bootstrap.js" ] }, - "jquery-json" : { + "jquery-json": { "main": [ "src/jquery.json.js" ] diff --git a/html5/verto/verto_communicator/index.html b/html5/verto/verto_communicator/index.html index cddd8c4ad8..c284bd4bb7 100644 --- a/html5/verto/verto_communicator/index.html +++ b/html5/verto/verto_communicator/index.html @@ -11,6 +11,7 @@