client/annot-client/gulpfile.js
author rougeronj
Thu, 22 Jan 2015 09:26:43 +0100
changeset 111 a7b72620d227
parent 81 a6bbf198bd24
child 158 c7e0e3212b4c
permissions -rw-r--r--
Add variable "wait". When this variable set, the annotsroll wait ignore some annotations, and wait before printing an otherone so there is no superposition. Can be passed as an options
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
     1
var gulp = require('gulp');
13
435d5c15275a clean client npm and gulp config, change flask root url, reference static url in template, change config management to follow flask convention
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
     2
var del = require('del');
1
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
     3
var gutil = require('gulp-util')
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
     4
var plugins = require("gulp-load-plugins")({lazy:false});
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
     5
81
a6bbf198bd24 change info for annot-client
ymh <ymh.work@gmail.com>
parents: 80
diff changeset
     6
var templateFolder = '../../annot-server/webapp/templates/';
a6bbf198bd24 change info for annot-client
ymh <ymh.work@gmail.com>
parents: 80
diff changeset
     7
var staticFolder = '../../annot-server/static';
4
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
     8
13
435d5c15275a clean client npm and gulp config, change flask root url, reference static url in template, change config management to follow flask convention
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
     9
var clientBaseName = 'app';
435d5c15275a clean client npm and gulp config, change flask root url, reference static url in template, change config management to follow flask convention
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    10
var vendorBaseName = 'lib';
435d5c15275a clean client npm and gulp config, change flask root url, reference static url in template, change config management to follow flask convention
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    11
435d5c15275a clean client npm and gulp config, change flask root url, reference static url in template, change config management to follow flask convention
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    12
gulp.task('clean', function (cb) {
435d5c15275a clean client npm and gulp config, change flask root url, reference static url in template, change config management to follow flask convention
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    13
    del([
435d5c15275a clean client npm and gulp config, change flask root url, reference static url in template, change config management to follow flask convention
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    14
        staticFolder + "/css/app*",
435d5c15275a clean client npm and gulp config, change flask root url, reference static url in template, change config management to follow flask convention
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    15
        staticFolder + "/js/app*",
435d5c15275a clean client npm and gulp config, change flask root url, reference static url in template, change config management to follow flask convention
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    16
        staticFolder + "/data/categories.json",
435d5c15275a clean client npm and gulp config, change flask root url, reference static url in template, change config management to follow flask convention
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    17
    ],{'force':true}, cb);
1
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    18
});
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    19
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    20
var scriptsSrc = ['!./app/**/*_test.js','./app/**/*.js'];
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    21
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    22
gulp.task('scripts', function(){
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    23
    //combine all js files of the app
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    24
    gulp.src(scriptsSrc)
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    25
        .pipe(plugins.jshint())
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    26
        .pipe(plugins.jshint.reporter('default'))
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    27
        .pipe(plugins.jshint.reporter('fail'))
13
435d5c15275a clean client npm and gulp config, change flask root url, reference static url in template, change config management to follow flask convention
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    28
        .pipe(plugins.concat(clientBaseName+'.js'))
4
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
    29
        .pipe(gulp.dest(staticFolder+'/js'))
1
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    30
        .pipe(plugins.filesize())
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    31
        .pipe(plugins.uglify())
13
435d5c15275a clean client npm and gulp config, change flask root url, reference static url in template, change config management to follow flask convention
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    32
        .pipe(plugins.rename(clientBaseName+'.min.js'))
4
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
    33
        .pipe(gulp.dest(staticFolder+'/js'))
1
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    34
        .pipe(plugins.filesize())
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    35
        .on('error', gutil.log);
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    36
});
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    37
4
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
    38
1
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    39
gulp.task('css', function(){
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    40
    gulp.src('./app/**/*.css')
13
435d5c15275a clean client npm and gulp config, change flask root url, reference static url in template, change config management to follow flask convention
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    41
        .pipe(plugins.csslint({ 'box-sizing': false }))
435d5c15275a clean client npm and gulp config, change flask root url, reference static url in template, change config management to follow flask convention
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    42
        .pipe(plugins.csslint.reporter())
435d5c15275a clean client npm and gulp config, change flask root url, reference static url in template, change config management to follow flask convention
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    43
        .pipe(plugins.concat(clientBaseName+'.css'))
4
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
    44
        .pipe(gulp.dest(staticFolder+'/css'))
1
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    45
        .pipe(plugins.filesize())
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    46
        .pipe(plugins.minifyCss({keepBreaks:true}))
13
435d5c15275a clean client npm and gulp config, change flask root url, reference static url in template, change config management to follow flask convention
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    47
        .pipe(plugins.rename(clientBaseName+'.min.css'))
4
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
    48
        .pipe(gulp.dest(staticFolder+'/css'))
1
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    49
        .pipe(plugins.filesize());
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    50
});
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    51
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    52
var vendorJSsrc = [
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    53
  '!./bower_components/**/*.min.js',
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    54
  '!./bower_components/bootstrap/Gruntfile.js',
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    55
  '!./bower_components/bootstrap/grunt/*',
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    56
  '!./bower_components/bootstrap/js/*',
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    57
  '!./bower_components/jquery/src/**/*',
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    58
  '!./bower_components/angular-bootstrap/ui-bootstrap.js',
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    59
  './bower_components/jquery/dist/jquery.js',
66
658561ea9e65 export sync code in utils, and add button to synchronize annotation on eventsessionview
ymh <ymh.work@gmail.com>
parents: 22
diff changeset
    60
  './bower_components/angular/angular.js',
1
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    61
  './bower_components/**/*.js'
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    62
];
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    63
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    64
gulp.task('vendorJS', function(){
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    65
    //concatenate vendor JS files
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    66
    gulp.src(vendorJSsrc)
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    67
        .pipe(plugins.concat('lib.js'))
4
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
    68
        .pipe(gulp.dest(staticFolder+'/js'))
1
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    69
        .pipe(plugins.filesize())
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    70
        .pipe(plugins.uglify())
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    71
        .pipe(plugins.rename('lib.min.js'))
4
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
    72
        .pipe(gulp.dest(staticFolder+'/js'))
1
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    73
        .pipe(plugins.filesize())
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    74
        .on('error', gutil.log);
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    75
});
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    76
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    77
gulp.task('vendorCSS', function(){
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    78
    //concatenate vendor CSS files
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    79
    gulp.src(['!./bower_components/**/*.min.css',
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    80
        './bower_components/**/*.css'])
13
435d5c15275a clean client npm and gulp config, change flask root url, reference static url in template, change config management to follow flask convention
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    81
        .pipe(plugins.concat(vendorBaseName+'.css'))
4
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
    82
        .pipe(gulp.dest(staticFolder+'/css'))
1
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    83
        .pipe(plugins.filesize())
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    84
        .pipe(plugins.minifyCss({keepBreaks:true}))
13
435d5c15275a clean client npm and gulp config, change flask root url, reference static url in template, change config management to follow flask convention
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    85
        .pipe(plugins.rename(vendorBaseName+'.min.css'))
4
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
    86
        .pipe(gulp.dest(staticFolder+'/css'))
1
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    87
        .pipe(plugins.filesize());
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    88
});
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    89
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    90
gulp.task('vendorFonts', function(){
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    91
    gulp.src(['./bower_components/**/fonts/*'])
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    92
        .pipe(plugins.flatten())
4
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
    93
        .pipe(gulp.dest(staticFolder+'/css/fonts'));
1
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    94
});
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    95
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    96
gulp.task('copy-index', function() {
4
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
    97
    gulp.src('./app/annotationclient.html')
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
    98
        .pipe(gulp.dest(templateFolder));
1
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    99
});
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   100
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   101
gulp.task('copy-data', function() {
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   102
    gulp.src('./data/**/*')
4
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
   103
        .pipe(gulp.dest(staticFolder+'/data'));
1
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   104
});
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   105
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   106
gulp.task('copy-img', function() {
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   107
    gulp.src('./img/**/*')
4
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
   108
        .pipe(gulp.dest(staticFolder+'/img'));
1
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   109
});
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   110
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   111
gulp.task('watch',function(){
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   112
    gulp.watch([
4
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
   113
        templateFolder+'/**/*.html',
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
   114
        staticFolder+'/**/*.js',
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
   115
        staticFolder+'/**/*.css'
1
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   116
    ], function(event) {
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   117
        return gulp.src(event.path)
13
435d5c15275a clean client npm and gulp config, change flask root url, reference static url in template, change config management to follow flask convention
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   118
            .pipe(plugins.webserver.reload());
1
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   119
    });
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   120
    gulp.watch(['./app/**/*.js','!./app/**/*test.js'],['scripts']);
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   121
    gulp.watch('./app/**/*.css',['css']);
4
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
   122
    gulp.watch('./app/annotationclient.html',['copy-index']);
1
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   123
    gulp.watch('./data/**/*',['copy-data']);
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   124
    gulp.watch('./img/**/*',['copy-img']);
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   125
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   126
});
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   127
13
435d5c15275a clean client npm and gulp config, change flask root url, reference static url in template, change config management to follow flask convention
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   128
gulp.task('connect', function() {
435d5c15275a clean client npm and gulp config, change flask root url, reference static url in template, change config management to follow flask convention
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   129
    gulp.src('build').pipe(
435d5c15275a clean client npm and gulp config, change flask root url, reference static url in template, change config management to follow flask convention
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   130
        plugins.webserver({
435d5c15275a clean client npm and gulp config, change flask root url, reference static url in template, change config management to follow flask convention
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   131
            port: 9000,
435d5c15275a clean client npm and gulp config, change flask root url, reference static url in template, change config management to follow flask convention
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   132
            livereload: true
435d5c15275a clean client npm and gulp config, change flask root url, reference static url in template, change config management to follow flask convention
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   133
        })
435d5c15275a clean client npm and gulp config, change flask root url, reference static url in template, change config management to follow flask convention
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   134
    );
435d5c15275a clean client npm and gulp config, change flask root url, reference static url in template, change config management to follow flask convention
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   135
});
1
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   136
13
435d5c15275a clean client npm and gulp config, change flask root url, reference static url in template, change config management to follow flask convention
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   137
gulp.task('default',['scripts','css','copy-index','copy-data','copy-img','vendorJS','vendorCSS','vendorFonts']);