client/gulpfile.js
author rougeronj
Wed, 08 Apr 2015 00:36:37 +0200
changeset 77 ee963d1c409b
parent 49 88cd0bb61c12
child 78 aaffa46a2b79
permissions -rw-r--r--
Add new serializer for the data send by Orpheo. We receive XML so we parse it to json. Then we parse some html to get the proper data of each attribute. Add xmlToJson parser module to requirements.txt
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
var gulp = require('gulp');
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
var gutil = require('gulp-util')
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
var plugins = require("gulp-load-plugins")({lazy:false});
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
//var flatten = require('gulp-flatten');
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
//var uglify = require('gulp-uglify');
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
//var clean = require('gulp-clean');
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
//var rename = require('gulp-rename');
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
//var filesize = require('gulp-filesize');
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
//var cssmin  = require('gulp-cssmin');
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
gulp.task('clean', function () {
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
  return gulp.src('build', {read: false})
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
    .pipe(clean());
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
});
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
var scriptsSrc = ['!./app/**/*_test.js','./app/**/*.js'];
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    17
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
gulp.task('scripts', function(){
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
    //combine all js files of the app
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
    gulp.src(scriptsSrc)
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    21
        .pipe(plugins.jshint())
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
        .pipe(plugins.jshint.reporter('default'))
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
        .pipe(plugins.jshint.reporter('fail'))
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
        .pipe(plugins.concat('app.js'))
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    25
        .pipe(gulp.dest('./build'))
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    26
        .pipe(plugins.filesize())
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    27
        .pipe(plugins.uglify())
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    28
        .pipe(plugins.rename('app.min.js'))
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    29
        .pipe(gulp.dest('./build'))
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    30
        .pipe(plugins.filesize())
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    31
        .on('error', gutil.log);
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    32
});
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    33
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    34
gulp.task('templates',function(){
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    35
    //combine all template files of the app into a js file
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    36
    gulp.src(['!./app/index.html',
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    37
        './app/**/*.html'])
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    38
        .pipe(plugins.angularTemplatecache('templates.js',{standalone:true}))
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    39
        .pipe(gulp.dest('./build'));
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    40
});
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    41
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    42
gulp.task('css', function(){
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    43
    gulp.src('./app/**/*.css')
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    44
//        .pipe(plugins.csslint())
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    45
//        .pipe(plugins.csslint.reporter())
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    46
        .pipe(plugins.concat('app.css'))
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    47
        .pipe(gulp.dest('./build'))
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    48
        .pipe(plugins.filesize())
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    49
        .pipe(plugins.minifyCss({keepBreaks:true}))
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    50
        .pipe(plugins.rename('app.min.css'))
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    51
        .pipe(gulp.dest('./build'))
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    52
        .pipe(plugins.filesize());
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    53
});
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    54
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    55
var vendorJSsrc = [
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    56
  '!./bower_components/**/*.min.js',
44
5eab9718182b FIX and update the client dev environment - update bootstrap - ignore index.js files and every file from bootstrap beside the css
rougeronj
parents: 0
diff changeset
    57
  '!./bower_components/bootstrap/**/*',
0
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    58
  '!./bower_components/jquery/src/**/*',
49
88cd0bb61c12 add ui-sortble lib to be able to sort the list of the slide in the book view - it sends a post request to the server to update the slides' order
rougeronj
parents: 44
diff changeset
    59
  '!./bower_components/jquery-ui/themes/**',
88cd0bb61c12 add ui-sortble lib to be able to sort the list of the slide in the book view - it sends a post request to the server to update the slides' order
rougeronj
parents: 44
diff changeset
    60
  '!./bower_components/jquery-ui/ui/**',
88cd0bb61c12 add ui-sortble lib to be able to sort the list of the slide in the book view - it sends a post request to the server to update the slides' order
rougeronj
parents: 44
diff changeset
    61
  '!./bower_components/jquery-ui/ui/*.js',
44
5eab9718182b FIX and update the client dev environment - update bootstrap - ignore index.js files and every file from bootstrap beside the css
rougeronj
parents: 0
diff changeset
    62
  '!./bower_components/**/index.js',
5eab9718182b FIX and update the client dev environment - update bootstrap - ignore index.js files and every file from bootstrap beside the css
rougeronj
parents: 0
diff changeset
    63
  './bower_components/bootstrap/dist/css/*',
0
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    64
  './bower_components/jquery/dist/jquery.js',
44
5eab9718182b FIX and update the client dev environment - update bootstrap - ignore index.js files and every file from bootstrap beside the css
rougeronj
parents: 0
diff changeset
    65
  './bower_components/angular/angular.js',
5eab9718182b FIX and update the client dev environment - update bootstrap - ignore index.js files and every file from bootstrap beside the css
rougeronj
parents: 0
diff changeset
    66
  './bower_components/angular-route/angular-route.js',
5eab9718182b FIX and update the client dev environment - update bootstrap - ignore index.js files and every file from bootstrap beside the css
rougeronj
parents: 0
diff changeset
    67
  './bower_components/angular-resource/angular-resource.js',
5eab9718182b FIX and update the client dev environment - update bootstrap - ignore index.js files and every file from bootstrap beside the css
rougeronj
parents: 0
diff changeset
    68
  './bower_components/angular-bootstrap/ui-bootstrap.js',
0
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    69
  './bower_components/**/*.js'
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    70
];
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    71
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    72
gulp.task('vendorJS', function(){
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    73
    //concatenate vendor JS files
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    74
    gulp.src(vendorJSsrc)
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    75
        .pipe(plugins.concat('lib.js'))
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    76
        .pipe(gulp.dest('./build'))
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    77
        .pipe(plugins.filesize())
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    78
        .pipe(plugins.uglify())
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    79
        .pipe(plugins.rename('lib.min.js'))
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    80
        .pipe(gulp.dest('./build'))
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    81
        .pipe(plugins.filesize())
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    82
        .on('error', gutil.log);
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    83
});
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    84
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    85
gulp.task('vendorCSS', function(){
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    86
    //concatenate vendor CSS files
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    87
    gulp.src(['!./bower_components/**/*.min.css',
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    88
        './bower_components/**/*.css'])
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    89
        .pipe(plugins.concat('lib.css'))
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    90
        .pipe(gulp.dest('./build'))
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    91
        .pipe(plugins.filesize())
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    92
        .pipe(plugins.minifyCss({keepBreaks:true}))
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    93
        .pipe(plugins.rename('lib.min.css'))
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    94
        .pipe(gulp.dest('./build'))
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    95
        .pipe(plugins.filesize());
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    96
});
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    97
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    98
gulp.task('vendorFonts', function(){
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    99
    gulp.src(['./bower_components/**/fonts/*'])
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
   100
        .pipe(plugins.flatten())
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
   101
        .pipe(gulp.dest('./build/fonts'));
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
   102
});
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
   103
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
   104
gulp.task('copy-index', function() {
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
   105
    gulp.src('./app/index.html')
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
   106
        .pipe(gulp.dest('./build'));
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
   107
});
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
   108
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
   109
gulp.task('copy-data', function() {
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
   110
    gulp.src('./data/**/*')
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
   111
        .pipe(gulp.dest('./build/data'));
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
   112
});
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
   113
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
   114
gulp.task('copy-img', function() {
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
   115
    gulp.src('./img/**/*')
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
   116
        .pipe(gulp.dest('./build/img'));
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
   117
});
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
   118
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
   119
gulp.task('watch',function(){
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
   120
    gulp.watch([
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
   121
        'build/**/*.html',
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
   122
        'build/**/*.js',
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
   123
        'build/**/*.css'
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
   124
    ], function(event) {
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
   125
        return gulp.src(event.path)
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
   126
            .pipe(plugins.connect.reload());
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
   127
    });
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
   128
    gulp.watch(['./app/**/*.js','!./app/**/*test.js'],['scripts']);
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
   129
    gulp.watch(['!./app/index.html','./app/**/*.html'],['templates']);
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
   130
    gulp.watch('./app/**/*.css',['css']);
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
   131
    gulp.watch('./app/index.html',['copy-index']);
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
   132
    gulp.watch('./data/**/*',['copy-data']);
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
   133
    gulp.watch('./img/**/*',['copy-img']);
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
   134
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
   135
});
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
   136
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
   137
gulp.task('connect', plugins.connect.server({
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
   138
    root: ['build'],
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
   139
    port: 9000,
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
   140
    livereload: true
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
   141
}));
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
   142
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
   143
gulp.task('default',['connect','scripts','templates','css','copy-index','copy-data','copy-img','vendorJS','vendorCSS','vendorFonts','watch']);