client/gulpfile.js
author cavaliet
Thu, 09 Oct 2014 14:34:14 +0200
changeset 5 90a7c431b979
parent 4 9c70d81e9062
child 13 435d5c15275a
permissions -rw-r--r--
first step of working annotation real annotation client
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');
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
     2
var gutil = require('gulp-util')
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
     3
var plugins = require("gulp-load-plugins")({lazy:false});
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
     4
//var flatten = require('gulp-flatten');
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
     5
//var uglify = require('gulp-uglify');
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
     6
//var clean = require('gulp-clean');
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
     7
//var rename = require('gulp-rename');
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
     8
//var filesize = require('gulp-filesize');
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
     9
//var cssmin  = require('gulp-cssmin');
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    10
4
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
    11
var templateFolder = '../annot-server/templates/';
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
    12
var templateFileDest = '../annot-server/templates/annotationclient.html';
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
    13
var staticFolder = '../annot-server/static';
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
    14
1
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    15
gulp.task('clean', function () {
4
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
    16
  gulp.src(templateFileDest, {read: false}).pipe(clean());
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
    17
  gulp.src(staticFolder, {read: false}).pipe(clean());
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'))
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    28
        .pipe(plugins.concat('app.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())
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    32
        .pipe(plugins.rename('app.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
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
    39
//gulp.task('templates',function(){
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
    40
//    //combine all template files of the app into a js file
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
    41
//    gulp.src(['!./app/index.html',
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
    42
//        './app/**/*.html'])
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
    43
//        .pipe(plugins.angularTemplatecache('templates.js',{standalone:true}))
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
    44
//        .pipe(gulp.dest(staticFolder+'/js'));
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
    45
//});
1
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    46
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    47
gulp.task('css', function(){
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    48
    gulp.src('./app/**/*.css')
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    49
//        .pipe(plugins.csslint())
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    50
//        .pipe(plugins.csslint.reporter())
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    51
        .pipe(plugins.concat('app.css'))
4
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
    52
        .pipe(gulp.dest(staticFolder+'/css'))
1
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    53
        .pipe(plugins.filesize())
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    54
        .pipe(plugins.minifyCss({keepBreaks:true}))
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    55
        .pipe(plugins.rename('app.min.css'))
4
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
    56
        .pipe(gulp.dest(staticFolder+'/css'))
1
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    57
        .pipe(plugins.filesize());
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    58
});
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    59
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    60
var vendorJSsrc = [
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    61
  '!./bower_components/**/*.min.js',
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    62
  '!./bower_components/bootstrap/Gruntfile.js',
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    63
  '!./bower_components/bootstrap/grunt/*',
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    64
  '!./bower_components/bootstrap/js/*',
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    65
  '!./bower_components/jquery/src/**/*',
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    66
  '!./bower_components/angular-bootstrap/ui-bootstrap.js',
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    67
  './bower_components/jquery/dist/jquery.js',
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    68
  './bower_components/**/*.js'
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    69
];
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    70
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    71
gulp.task('vendorJS', function(){
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    72
    //concatenate vendor JS files
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    73
    gulp.src(vendorJSsrc)
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    74
        .pipe(plugins.concat('lib.js'))
4
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
    75
        .pipe(gulp.dest(staticFolder+'/js'))
1
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    76
        .pipe(plugins.filesize())
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    77
        .pipe(plugins.uglify())
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    78
        .pipe(plugins.rename('lib.min.js'))
4
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
    79
        .pipe(gulp.dest(staticFolder+'/js'))
1
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    80
        .pipe(plugins.filesize())
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    81
        .on('error', gutil.log);
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    82
});
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    83
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    84
gulp.task('vendorCSS', function(){
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    85
    //concatenate vendor CSS files
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    86
    gulp.src(['!./bower_components/**/*.min.css',
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    87
        './bower_components/**/*.css'])
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    88
        .pipe(plugins.concat('lib.css'))
4
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
    89
        .pipe(gulp.dest(staticFolder+'/css'))
1
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    90
        .pipe(plugins.filesize())
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    91
        .pipe(plugins.minifyCss({keepBreaks:true}))
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    92
        .pipe(plugins.rename('lib.min.css'))
4
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
    93
        .pipe(gulp.dest(staticFolder+'/css'))
1
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    94
        .pipe(plugins.filesize());
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    95
});
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    96
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    97
gulp.task('vendorFonts', function(){
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    98
    gulp.src(['./bower_components/**/fonts/*'])
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
    99
        .pipe(plugins.flatten())
4
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
   100
        .pipe(gulp.dest(staticFolder+'/css/fonts'));
1
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   101
});
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   102
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   103
gulp.task('copy-index', function() {
4
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
   104
    gulp.src('./app/annotationclient.html')
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
   105
        .pipe(gulp.dest(templateFolder));
1
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   106
});
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   107
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   108
gulp.task('copy-data', function() {
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   109
    gulp.src('./data/**/*')
4
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
   110
        .pipe(gulp.dest(staticFolder+'/data'));
1
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   111
});
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   112
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   113
gulp.task('copy-img', function() {
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   114
    gulp.src('./img/**/*')
4
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
   115
        .pipe(gulp.dest(staticFolder+'/img'));
1
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   116
});
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   117
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   118
gulp.task('watch',function(){
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   119
    gulp.watch([
4
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
   120
        templateFolder+'/**/*.html',
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
   121
        staticFolder+'/**/*.js',
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
   122
        staticFolder+'/**/*.css'
1
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   123
    ], function(event) {
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   124
        return gulp.src(event.path)
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   125
            .pipe(plugins.connect.reload());
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   126
    });
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   127
    gulp.watch(['./app/**/*.js','!./app/**/*test.js'],['scripts']);
4
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
   128
    //gulp.watch(['!./app/index.html','./app/**/*.html'],['templates']);
1
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   129
    gulp.watch('./app/**/*.css',['css']);
4
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
   130
    gulp.watch('./app/annotationclient.html',['copy-index']);
1
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   131
    gulp.watch('./data/**/*',['copy-data']);
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   132
    gulp.watch('./img/**/*',['copy-img']);
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   133
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   134
});
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   135
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   136
gulp.task('connect', plugins.connect.server({
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   137
    root: ['build'],
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   138
    port: 9000,
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   139
    livereload: true
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   140
}));
1cdebfeb77f9 add client folder and update hgignore
cavaliet
parents:
diff changeset
   141
4
9c70d81e9062 update gulpfile for template to work with twistd/flask
cavaliet
parents: 1
diff changeset
   142
//gulp.task('default',['connect','scripts','templates','css','copy-index','copy-data','copy-img','vendorJS','vendorCSS','vendorFonts','watch']);
5
90a7c431b979 first step of working annotation real annotation client
cavaliet
parents: 4
diff changeset
   143
gulp.task('default',['scripts','css','copy-index','copy-data','copy-img','vendorJS','vendorCSS','vendorFonts','watch']);