<commit_before>/*global module: false*/
/*jslint indent: 2*/

module.exports = function (grunt) {

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),

        meta: {
            name: 'skinswitcher',
            banner: '/**\n' +
                ' * <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
                '<%= grunt.template.today("yyyy-mm-dd") %>\n' +
                ' * <%= pkg.homepage %>\n' +
                ' *\n' +
                ' * <%= pkg.description %>\n' +
                ' *\n' +
                ' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
                ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %>\n' +
                ' */\n' +
                '\n'
        },

        concat: {
            options: {
                banner: '<%= meta.banner %>',
                stripBanners: true
            },
            js: {
                src: ['jquery.<%= meta.name %>.js'],
                dest: 'dist/jquery.<%= meta.name %>.js'
            },
            css: {
                src: ['jquery.<%= meta.name %>.css'],
                dest: 'dist/jquery.<%= meta.name %>.css'
            },
            misc: {
                files: {
                    'dist/LICENSE-GPL': 'LICENSE-GPL',
                    'dist/LICENSE-MIT': 'LICENSE-MIT',
                    'dist/README.md': 'README.md',
                    'dist/CHANGELOG': 'CHANGELOG',
                    'dist/AUTHORS': 'AUTHORS'
                }
            },
            plugin: {
                options: {
                    banner: '',
                    stripBanners: true
                },
                files: {
                    '<%= pkg.name %>.jquery.json': ['package.json']
                }
            }
        },

        uglify: {
            options: {
                banner: '<%= meta.banner %>'
            },
            dist: {
                files: {
                    'dist/jquery.<%= meta.name %>.min.js': ['<%= concat.js.dest %>']
                }
            }
        },

        cssmin: {
            options: {
                banner: '<%= meta.banner %>'
            },
            dist: {
                src: ['<%= concat.css.dest %>'],
                dest: 'dist/jquery.<%= meta.name %>.min.css'
            }
        },

        jshint: {
            options: {
                bitwise: true,
                curly: true,
                eqeqeq: true,
                forin: true,
                immed: true,
                sub: true,
                boss: true,
                eqnull: true,
                indent: 4,
                latedef: true,
                newcap: true,
                noarg: true,
                noempty: true,
                nonew: true,
                plusplus: true,
                quotmark: true,
                regexp: true,
                undef: true,
                unused: true,
                trailing: true,
                // relaxing options
                evil: false,
                regexdash: true,
                white: false,
                // environments
                browser: true,
                jquery: true,
                console: true
            },
            dist: {
                options: {
                    globals: {
                        jQuery: false,
                        LazyLoad: false,
                        console: true
                    }
                },
                files: {
                    src: ['Gruntfile.js', 'package.json', 'jquery.<%= meta.name %>.js']
                }
            },
            test: {
                options: {
                    globals: {
                        jQuery: false,
                        LazyLoad: false,
                        ok: false,
                        console: true
                    }
                },
                files: {
                    src: ['test/test.js']
                }
            }
        },

        csslint: {
            dist: {
                src: ['jquery.<%= meta.name %>.css'],
                options: {
                    'box-model': false
                }
            }
        },

        copy: {
            legacy: {
                files: [
                    {
                        expand: true,
                        cwd: 'dist/',
                        src: ['jquery.<%= meta.name %>.min.js', 'jquery.<%= meta.name %>.min.css'],
                        dest: '.'
                    }
                ]
            }
        },

        compress: {
            zip: {
                options: {
                    archive: 'builds/<%= pkg.name %>-<%= pkg.version %>.zip'
                },
                files: [
                    {expand: true, cwd: 'dist/', src: ['*']}
                ]
            }
        },

        qunit: {
            all: {
                options: {
                    urls: [
                        'http://localhost:8000/test/index.html?jquery=1.8.3',
                        'http://localhost:8000/test/index.html?jquery=1.9.0',
                        'http://localhost:8000/test/index.html?jquery=1.9.1',
                        'http://localhost:8000/test/index.html?jquery=1.10.1',
                        'http://localhost:8000/test/index.html?jquery=1.10.2',
                        'http://localhost:8000/test/index.html?jquery=2.0.0',
                        'http://localhost:8000/test/index.html?jquery=2.0.1',
                        'http://localhost:8000/test/index.html?jquery=2.0.2',
                        'http://localhost:8000/test/index.html?jquery=2.0.3'
                    ]
                }
            }
        },

        connect: {
            'default': {}
        },

        clean: ['dist/']
    });

    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-contrib-csslint');
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-cssmin');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-contrib-compress');
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-contrib-connect');
    grunt.loadNpmTasks('grunt-contrib-qunit');

    grunt.registerTask('lint', ['jshint', 'csslint']);
    grunt.registerTask('min', ['uglify', 'cssmin']);
    grunt.registerTask('build', ['copy:legacy', 'compress']);
    grunt.registerTask('default', ['lint', 'concat', 'min', 'build', 'clean']);
    grunt.registerTask('test', ['default', 'connect', 'qunit']);

};
<commit_msg>Improved console.log support during tests<commit_after>/*global module: false*/
/*jslint indent: 2*/

module.exports = function(grunt) {

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),

    meta: {
      name: 'skinswitcher',
      banner: '/**\n' +
        ' * <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
        '<%= grunt.template.today("yyyy-mm-dd") %>\n' +
        ' * <%= pkg.homepage %>\n' +
        ' *\n' +
        ' * <%= pkg.description %>\n' +
        ' *\n' +
        ' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
        ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %>\n' +
        ' */\n' +
        '\n'
    },

    concat: {
      options: {
        banner: '<%= meta.banner %>',
        stripBanners: true
      },
      js: {
        src: ['jquery.<%= meta.name %>.js'],
        dest: 'dist/jquery.<%= meta.name %>.js'
      },
      css: {
        src: ['jquery.<%= meta.name %>.css'],
        dest: 'dist/jquery.<%= meta.name %>.css'
      },
      misc: {
        files: {
          'dist/LICENSE-GPL': 'LICENSE-GPL',
          'dist/LICENSE-MIT': 'LICENSE-MIT',
          'dist/README.md': 'README.md',
          'dist/CHANGELOG': 'CHANGELOG',
          'dist/AUTHORS': 'AUTHORS'
        }
      },
      plugin: {
        options: {
          banner: '',
          stripBanners: true
        },
        files: {
          '<%= pkg.name %>.jquery.json': ['package.json']
        }
      }
    },

    uglify: {
      options: {
        banner: '<%= meta.banner %>'
      },
      dist: {
        files: {
          'dist/jquery.<%= meta.name %>.min.js': ['<%= concat.js.dest %>']
        }
      }
    },

    cssmin: {
      options: {
        banner: '<%= meta.banner %>'
      },
      dist: {
        src: ['<%= concat.css.dest %>'],
        dest: 'dist/jquery.<%= meta.name %>.min.css'
      }
    },

    jshint: {
      options: {
        bitwise: true,
        curly: true,
        eqeqeq: true,
        forin: true,
        immed: true,
        sub: true,
        boss: true,
        eqnull: true,
        indent: 4,
        latedef: true,
        newcap: true,
        noarg: true,
        noempty: true,
        nonew: true,
        plusplus: true,
        quotmark: true,
        regexp: true,
        undef: true,
        unused: true,
        trailing: true,
        // relaxing options
        evil: false,
        regexdash: true,
        white: false,
        // environments
        browser: true,
        jquery: true,
        globals: {
            console: true
        }
      },
      dist: {
        options: {
          globals: {
            jQuery: false,
            LazyLoad: false,
              console: true
          }
        },
        files: {
          src: ['Gruntfile.js', 'package.json', 'jquery.<%= meta.name %>.js']
        }
      },
      test: {
        options: {
          globals: {
            jQuery: false,
            LazyLoad: false,
            ok: false,
            console: true
          }
        },
        files: {
          src: ['test/test.js']
        }
      }
    },

    csslint: {
      dist: {
        src: ['jquery.<%= meta.name %>.css'],
        options: {
          'box-model': false
        }
      }
    },

    copy: {
      legacy: {
        files: [
          {
            expand: true,
            cwd: 'dist/',
            src: ['jquery.<%= meta.name %>.min.js', 'jquery.<%= meta.name %>.min.css'],
            dest: '.'
          }
        ]
      }
    },

    compress: {
      zip: {
        options: {
          archive: 'builds/<%= pkg.name %>-<%= pkg.version %>.zip'
        },
        files: [{expand: true, cwd: 'dist/', src: ['*']}]
      }
    },

    qunit: {
      all: {
        options: {
          urls: [
            'http://localhost:8000/test/index.html?jquery=1.8.3',
            'http://localhost:8000/test/index.html?jquery=1.9.0',
            'http://localhost:8000/test/index.html?jquery=1.9.1',
            'http://localhost:8000/test/index.html?jquery=1.10.1',
            'http://localhost:8000/test/index.html?jquery=1.10.2',
            'http://localhost:8000/test/index.html?jquery=2.0.0',
            'http://localhost:8000/test/index.html?jquery=2.0.1',
            'http://localhost:8000/test/index.html?jquery=2.0.2',
            'http://localhost:8000/test/index.html?jquery=2.0.3'
          ]
        }
      }
    },

    connect: {
      'default': {}
    },

    clean: ['dist/']
  });

  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-csslint');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-cssmin');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-contrib-compress');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-connect');
  grunt.loadNpmTasks('grunt-contrib-qunit');

  grunt.registerTask('lint', ['jshint', 'csslint']);
  grunt.registerTask('min', ['uglify', 'cssmin']);
  grunt.registerTask('build', ['copy:legacy', 'compress']);
  grunt.registerTask('default', ['lint', 'concat', 'min', 'build', 'clean']);
  grunt.registerTask('test', ['default', 'connect', 'qunit']);

};
<|endoftext|>


<commit_before>// Generated on 2013-12-12 using generator-angular 0.6.0-rc.1
'use strict';

// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to recursively match all subfolders:
// 'test/spec/**/*.js'

module.exports = function (grunt) {
    require('load-grunt-tasks')(grunt);
    require('time-grunt')(grunt);

    // load all grunt tasks
    require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

    grunt.initConfig({
                         yeoman: {
                             // configurable paths
                             jekyll: 'app',
                             app: '_site',
                             dist: 'dist'
                         },
                         watch: {
                             styles: {
                                 files: ['<%= yeoman.app %>/styles/{,*/}*.less'],
                                 tasks: ['less', 'copy:styles', 'autoprefixer']
                             },
                             jekyllSources: {
                                 files: [
                                     // capture all except css
                                     '<%= yeoman.jekyll %>/{,**/}*.html','!**/bower_components/**',
                                     '<%= yeoman.jekyll %>/{,*/}*.less',
                                     '.tmp/styles/{,*/}*.css',
                                     '{.tmp,<%= yeoman.jekyll %>}/scripts/{,*/}*.js',
                                     '<%= yeoman.jekyll %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
                                 ],
                                 tasks: ['shell:jekyll', 'copy:bower']
                             },
                             livereload: {
                                 options: {
                                     livereload: '<%= connect.options.livereload %>'
                                 },
                                 files: [
                                     '<%= yeoman.app %>/{,**/}*.html','!**/bower_components/**',
                                     '.tmp/styles/{,*/}*.css',
                                     '{.tmp,<%= yeoman.app %>}/scripts/{,*/}*.js',
                                     '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
                                 ]
                             }
                         },
                         autoprefixer: {
                             options: ['last 1 version'],
                             dist: {
                                 files: [
                                     {
                                         expand: true,
                                         cwd: '.tmp/styles/',
                                         src: '{,*/}*.css',
                                         dest: '.tmp/styles/'
                                     }
                                 ]
                             }
                         },
                         connect: {
                             options: {
                                 port: 9002,
                                 // Change this to '0.0.0.0' to access the server from outside.
                                 hostname: 'localhost',
                                 livereload: 35729
                             },
                             livereload: {
                                 options: {
                                     open: true,
                                     base: [
                                         '.tmp',
                                         '<%= yeoman.app %>'
                                     ]
                                 }
                             },
                             test: {
                                 options: {
                                     port: 9001,
                                     base: [
                                         '.tmp',
                                         'test',
                                         '<%= yeoman.app %>'
                                     ]
                                 }
                             },
                             dist: {
                                 options: {
                                     base: '<%= yeoman.dist %>'
                                 }
                             }
                         },
                         clean: {
                             dist: {
                                 files: [
                                     {
                                         dot: true,
                                         src: [
                                             '.tmp',
                                             '<%= yeoman.dist %>/*',
                                             '!<%= yeoman.dist %>/.git*'
                                         ]
                                     }
                                 ]
                             },
                             server: '.tmp'
                         },
                         jshint: {
                             options: {
                                 jshintrc: '.jshintrc',
                                 reporter: require('jshint-stylish')
                             },
                             all: [
                                 'Gruntfile.js',
                                 '<%= yeoman.app %>/scripts/{,*/}*.js'
                             ]
                         },
                         // not used since Uglify task does concat,
                         // but still available if needed
                         /*concat: {
                          dist: {}
                          },*/
                         rev: {
                             dist: {
                                 files: {
                                     src: [
                                         '<%= yeoman.dist %>/scripts/{,*/}*.js',
                                         '<%= yeoman.dist %>/styles/{,*/}*.css',
					                    // '<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
                                         '<%= yeoman.dist %>/styles/fonts/*'
                                     ]
                                 }
                             }
                         },
                         useminPrepare: {
                             html: ['<%= yeoman.app %>/{,**/}*.html','!**/bower_components/**'],
                             options: {
                                 dest: '<%= yeoman.dist %>'
                             }
                         },
                         usemin: {
                             html: ['<%= yeoman.dist %>/{,**/}*.html','!**/bower_components/**'],
                             css: ['<%= yeoman.dist %>/styles/{,*/}*.css'],
                             options: {
                                 assetsDirs: ['<%= yeoman.dist %>'],
                             }
                         },
                         imagemin: {
                             dist: {
                                 files: [
                                     {
                                         expand: true,
                                         cwd: '<%= yeoman.app %>/images',
                                         src: '{,*/}*.{png,jpg,jpeg}',
                                         dest: '<%= yeoman.dist %>/images'
                                     }
                                 ]
                             }
                         },
                         svgmin: {
                             dist: {
                                 files: [
                                     {
                                         expand: true,
                                         cwd: '<%= yeoman.app %>/images',
                                         src: '{,*/}*.svg',
                                         dest: '<%= yeoman.dist %>/images'
                                     }
                                 ]
                             }
                         },
                         cssmin: {
                             // By default, your `index.html` <!-- Usemin Block --> will take care of
                             // minification. This option is pre-configured if you do not wish to use
                             // Usemin blocks.
                             // dist: {
                             //   files: {
                             //     '<%= yeoman.dist %>/styles/main.css': [
                             //       '.tmp/styles/{,*/}*.css',
                             //       '<%= yeoman.app %>/styles/{,*/}*.css'
                             //     ]
                             //   }
                             // }
                         },
                         htmlmin: {
                             dist: {
                                 options: {
                                 },
                                 files: [
                                     {
                                         expand: true,
                                         cwd: '<%= yeoman.app %>',
                                         src: ['{,**/}*.html','!**/bower_components/**'],
                                         dest: '<%= yeoman.dist %>',
                                     }
                                 ]
                             },
                             final:{
                                 options:{
                                     removeCommentsFromCDATA: true,
                                      removeComments: true,
                                      collapseWhitespace: false,
                                      collapseBooleanAttributes: true,
                                      removeAttributeQuotes: true,
                                      removeRedundantAttributes: true,
                                      useShortDoctype: true,
                                      removeEmptyAttributes: true,
                                      removeOptionalTags: true
                                 },
                                 files: [{
                                     expand: true,
                                     cwd: '<%= yeoman.dist %>',
                                     src: ['{,**/}*.html','!**/bower_components/**'],
                                     dest: '<%= yeoman.dist %>'
                                 }]
                             }
                         },
                         // Put files not handled in other tasks here
                         copy: {
                             dist: {
                                 files: [
                                     {
                                         expand: true,
                                         dot: true,
                                         cwd: '<%= yeoman.app %>',
                                         dest: '<%= yeoman.dist %>',
                                         src: [
                                             '*.{ico,png,txt}',
                                             '.htaccess',
                                             'bower_components/**/*',
                                             '_config.yml',
                                             'CNAME',
                                             '.gitignore',
                                             'images/{,*/}*.{gif,webp}',
                                             'fonts/*',
                                             'data/*.json'
                                         ]
                                     },
                                     {
                                         expand: true,
                                         cwd: '.tmp/images',
                                         dest: '<%= yeoman.dist %>/images',
                                         src: [
                                             'generated/*'
                                         ]
                                     },
                                     {
                                         expand: true,
                                         cwd: '<%= yeoman.app %>/bower_components/font-awesome/fonts/',
                                         dest: '<%= yeoman.dist %>/fonts/',
                                         src: ['**']
                                     }
                                 ]
                             },
                             styles: {
                                 expand: true,
                                 cwd: '<%= yeoman.app %>/styles',
                                 dest: '.tmp/styles/',
                                 src: '{,*/}*.css'
                             },
                             bower: {
                                 expand: true,
                                 cwd: '<%= yeoman.jekyll %>',
                                 dest: '<%= yeoman.app %>',
                                 src: ['bower_components/**/*','_config.yml']
                             }
                         },
                         concurrent: {
                             server: [
                                 'copy:styles'
                             ],
                             test: [
                                 'copy:styles'
                             ],
                             dist: [
                                 'copy:styles',
                                 'imagemin',
                                 'svgmin',
                                 'htmlmin:dist'
                             ]
                         },
                         cdnify: {
                             dist: {
                                 html: ['<%= yeoman.dist %>/{,**/}*.html','!**/bower_components/**']
                             }
                         },
                         ngmin: {
                             dist: {
                                 files: [
                                     {
                                         expand: true,
                                         cwd: '.tmp/concat/scripts',
                                         src: '*.js',
                                         dest: '.tmp/concat/scripts'
                                     }
                                 ]
                             }
                         },
                         uglify: {
                             dist: {
                                 files: {
                                     '<%= yeoman.dist %>/scripts/scripts.js': [
                                         '<%= yeoman.dist %>/scripts/scripts.js'
                                     ]
                                 }
                             }
                         },
                         less: {
                             development: {
                                 options: {
                                     paths: ["<%= yeoman.app %>/styles"],
                                     yuicompress: true
                                 },
                                 files: {
                                     "<%= yeoman.app %>/styles/style.css": "<%= yeoman.app %>/styles/style.less"
                                 }
                             }
                         },
                         'gh-pages': {
                             options: {
                                 base: 'dist',
                                 push: true,
                                 message: 'Auto-generated commit (cloudbees forge)'
                             },
                             src: ['**']
                         },
                        shell:{
                            jekyll: {
                                command: 'rm -rf <%= yeoman.app %>/*; jekyll build;',
                                stdout: true
                            }
                        },
                         sitemap: {
                             dist: {
                                 siteRoot: '_site/',
                                 homepage: 'www.code-troopers.com'
                             }
                         }
                     });

    grunt.registerTask('server', function (target) {
        if (target === 'dist') {
            return grunt.task.run(['build', 'connect:dist:keepalive']);
        }

        grunt.task.run([   'shell:jekyll',
                           'copy:bower',
                           'less',
                           'clean:server',
                           'concurrent:server',
                           'autoprefixer',
                           'connect:livereload',
                           'watch'
                       ]);
    });

    grunt.registerTask('test', [
        'clean:server',
        'concurrent:test',
        'autoprefixer',
        'connect:test',
        'karma'
    ]);

    grunt.registerTask('build', [
        'shell:jekyll',
        'copy:bower',
        'less',
        'clean:dist',
        'useminPrepare',
        'concurrent:dist',
        'autoprefixer',
        'concat',
        'ngmin',
        'copy:dist',
        'cdnify',
        'cssmin',
        'uglify',
        'rev',
        'usemin',
        'htmlmin:final'
    ]);

    grunt.registerTask('default', [
        'jshint',
        'test',
        'build'
    ]);
};
<commit_msg>fix broken rss link<commit_after>// Generated on 2013-12-12 using generator-angular 0.6.0-rc.1
'use strict';

// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to recursively match all subfolders:
// 'test/spec/**/*.js'

module.exports = function (grunt) {
    require('load-grunt-tasks')(grunt);
    require('time-grunt')(grunt);

    // load all grunt tasks
    require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

    grunt.initConfig({
                         yeoman: {
                             // configurable paths
                             jekyll: 'app',
                             app: '_site',
                             dist: 'dist'
                         },
                         watch: {
                             styles: {
                                 files: ['<%= yeoman.app %>/styles/{,*/}*.less'],
                                 tasks: ['less', 'copy:styles', 'autoprefixer']
                             },
                             jekyllSources: {
                                 files: [
                                     // capture all except css
                                     '<%= yeoman.jekyll %>/{,**/}*.html','!**/bower_components/**',
                                     '<%= yeoman.jekyll %>/{,*/}*.less',
                                     '.tmp/styles/{,*/}*.css',
                                     '{.tmp,<%= yeoman.jekyll %>}/scripts/{,*/}*.js',
                                     '<%= yeoman.jekyll %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
                                 ],
                                 tasks: ['shell:jekyll', 'copy:bower']
                             },
                             livereload: {
                                 options: {
                                     livereload: '<%= connect.options.livereload %>'
                                 },
                                 files: [
                                     '<%= yeoman.app %>/{,**/}*.html','!**/bower_components/**',
                                     '.tmp/styles/{,*/}*.css',
                                     '{.tmp,<%= yeoman.app %>}/scripts/{,*/}*.js',
                                     '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
                                 ]
                             }
                         },
                         autoprefixer: {
                             options: ['last 1 version'],
                             dist: {
                                 files: [
                                     {
                                         expand: true,
                                         cwd: '.tmp/styles/',
                                         src: '{,*/}*.css',
                                         dest: '.tmp/styles/'
                                     }
                                 ]
                             }
                         },
                         connect: {
                             options: {
                                 port: 9002,
                                 // Change this to '0.0.0.0' to access the server from outside.
                                 hostname: 'localhost',
                                 livereload: 35729
                             },
                             livereload: {
                                 options: {
                                     open: true,
                                     base: [
                                         '.tmp',
                                         '<%= yeoman.app %>'
                                     ]
                                 }
                             },
                             test: {
                                 options: {
                                     port: 9001,
                                     base: [
                                         '.tmp',
                                         'test',
                                         '<%= yeoman.app %>'
                                     ]
                                 }
                             },
                             dist: {
                                 options: {
                                     base: '<%= yeoman.dist %>'
                                 }
                             }
                         },
                         clean: {
                             dist: {
                                 files: [
                                     {
                                         dot: true,
                                         src: [
                                             '.tmp',
                                             '<%= yeoman.dist %>/*',
                                             '!<%= yeoman.dist %>/.git*'
                                         ]
                                     }
                                 ]
                             },
                             server: '.tmp'
                         },
                         jshint: {
                             options: {
                                 jshintrc: '.jshintrc',
                                 reporter: require('jshint-stylish')
                             },
                             all: [
                                 'Gruntfile.js',
                                 '<%= yeoman.app %>/scripts/{,*/}*.js'
                             ]
                         },
                         // not used since Uglify task does concat,
                         // but still available if needed
                         /*concat: {
                          dist: {}
                          },*/
                         rev: {
                             dist: {
                                 files: {
                                     src: [
                                         '<%= yeoman.dist %>/scripts/{,*/}*.js',
                                         '<%= yeoman.dist %>/styles/{,*/}*.css',
					                    // '<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
                                         '<%= yeoman.dist %>/styles/fonts/*'
                                     ]
                                 }
                             }
                         },
                         useminPrepare: {
                             html: ['<%= yeoman.app %>/{,**/}*.html','!**/bower_components/**'],
                             options: {
                                 dest: '<%= yeoman.dist %>'
                             }
                         },
                         usemin: {
                             html: ['<%= yeoman.dist %>/{,**/}*.html','!**/bower_components/**'],
                             css: ['<%= yeoman.dist %>/styles/{,*/}*.css'],
                             options: {
                                 assetsDirs: ['<%= yeoman.dist %>'],
                             }
                         },
                         imagemin: {
                             dist: {
                                 files: [
                                     {
                                         expand: true,
                                         cwd: '<%= yeoman.app %>/images',
                                         src: '{,*/}*.{png,jpg,jpeg}',
                                         dest: '<%= yeoman.dist %>/images'
                                     }
                                 ]
                             }
                         },
                         svgmin: {
                             dist: {
                                 files: [
                                     {
                                         expand: true,
                                         cwd: '<%= yeoman.app %>/images',
                                         src: '{,*/}*.svg',
                                         dest: '<%= yeoman.dist %>/images'
                                     }
                                 ]
                             }
                         },
                         cssmin: {
                             // By default, your `index.html` <!-- Usemin Block --> will take care of
                             // minification. This option is pre-configured if you do not wish to use
                             // Usemin blocks.
                             // dist: {
                             //   files: {
                             //     '<%= yeoman.dist %>/styles/main.css': [
                             //       '.tmp/styles/{,*/}*.css',
                             //       '<%= yeoman.app %>/styles/{,*/}*.css'
                             //     ]
                             //   }
                             // }
                         },
                         htmlmin: {
                             dist: {
                                 options: {
                                 },
                                 files: [
                                     {
                                         expand: true,
                                         cwd: '<%= yeoman.app %>',
                                         src: ['{,**/}*.html','{,**/}*.xml','!**/bower_components/**'],
                                         dest: '<%= yeoman.dist %>',
                                     }
                                 ]
                             },
                             final:{
                                 options:{
                                     removeCommentsFromCDATA: true,
                                      removeComments: true,
                                      collapseWhitespace: false,
                                      collapseBooleanAttributes: true,
                                      removeAttributeQuotes: true,
                                      removeRedundantAttributes: true,
                                      useShortDoctype: true,
                                      removeEmptyAttributes: true,
                                      removeOptionalTags: true
                                 },
                                 files: [{
                                     expand: true,
                                     cwd: '<%= yeoman.dist %>',
                                     src: ['{,**/}*.html','!**/bower_components/**'],
                                     dest: '<%= yeoman.dist %>'
                                 }]
                             }
                         },
                         // Put files not handled in other tasks here
                         copy: {
                             dist: {
                                 files: [
                                     {
                                         expand: true,
                                         dot: true,
                                         cwd: '<%= yeoman.app %>',
                                         dest: '<%= yeoman.dist %>',
                                         src: [
                                             '*.{ico,png,txt}',
                                             '.htaccess',
                                             'bower_components/**/*',
                                             '_config.yml',
                                             'CNAME',
                                             '.gitignore',
                                             'images/{,*/}*.{gif,webp}',
                                             'fonts/*',
                                             'data/*.json'
                                         ]
                                     },
                                     {
                                         expand: true,
                                         cwd: '.tmp/images',
                                         dest: '<%= yeoman.dist %>/images',
                                         src: [
                                             'generated/*'
                                         ]
                                     },
                                     {
                                         expand: true,
                                         cwd: '<%= yeoman.app %>/bower_components/font-awesome/fonts/',
                                         dest: '<%= yeoman.dist %>/fonts/',
                                         src: ['**']
                                     }
                                 ]
                             },
                             styles: {
                                 expand: true,
                                 cwd: '<%= yeoman.app %>/styles',
                                 dest: '.tmp/styles/',
                                 src: '{,*/}*.css'
                             },
                             bower: {
                                 expand: true,
                                 cwd: '<%= yeoman.jekyll %>',
                                 dest: '<%= yeoman.app %>',
                                 src: ['bower_components/**/*','_config.yml']
                             }
                         },
                         concurrent: {
                             server: [
                                 'copy:styles'
                             ],
                             test: [
                                 'copy:styles'
                             ],
                             dist: [
                                 'copy:styles',
                                 'imagemin',
                                 'svgmin',
                                 'htmlmin:dist'
                             ]
                         },
                         cdnify: {
                             dist: {
                                 html: ['<%= yeoman.dist %>/{,**/}*.html','!**/bower_components/**']
                             }
                         },
                         ngmin: {
                             dist: {
                                 files: [
                                     {
                                         expand: true,
                                         cwd: '.tmp/concat/scripts',
                                         src: '*.js',
                                         dest: '.tmp/concat/scripts'
                                     }
                                 ]
                             }
                         },
                         uglify: {
                             dist: {
                                 files: {
                                     '<%= yeoman.dist %>/scripts/scripts.js': [
                                         '<%= yeoman.dist %>/scripts/scripts.js'
                                     ]
                                 }
                             }
                         },
                         less: {
                             development: {
                                 options: {
                                     paths: ["<%= yeoman.app %>/styles"],
                                     yuicompress: true
                                 },
                                 files: {
                                     "<%= yeoman.app %>/styles/style.css": "<%= yeoman.app %>/styles/style.less"
                                 }
                             }
                         },
                         'gh-pages': {
                             options: {
                                 base: 'dist',
                                 push: true,
                                 message: 'Auto-generated commit (cloudbees forge)'
                             },
                             src: ['**']
                         },
                        shell:{
                            jekyll: {
                                command: 'rm -rf <%= yeoman.app %>/*; jekyll build;',
                                stdout: true
                            }
                        },
                         sitemap: {
                             dist: {
                                 siteRoot: '_site/',
                                 homepage: 'www.code-troopers.com'
                             }
                         }
                     });

    grunt.registerTask('server', function (target) {
        if (target === 'dist') {
            return grunt.task.run(['build', 'connect:dist:keepalive']);
        }

        grunt.task.run([   'shell:jekyll',
                           'copy:bower',
                           'less',
                           'clean:server',
                           'concurrent:server',
                           'autoprefixer',
                           'connect:livereload',
                           'watch'
                       ]);
    });

    grunt.registerTask('test', [
        'clean:server',
        'concurrent:test',
        'autoprefixer',
        'connect:test',
        'karma'
    ]);

    grunt.registerTask('build', [
        'shell:jekyll',
        'copy:bower',
        'less',
        'clean:dist',
        'useminPrepare',
        'concurrent:dist',
        'autoprefixer',
        'concat',
        'ngmin',
        'copy:dist',
        'cdnify',
        'cssmin',
        'uglify',
        'rev',
        'usemin',
        'htmlmin:final'
    ]);

    grunt.registerTask('default', [
        'jshint',
        'test',
        'build'
    ]);
};
<|endoftext|>


<commit_before>// var es = require('event-stream');
// var babel = require('gulp-babel');
// var gutil = require('gulp-util');
// var sourcemaps = require('gulp-sourcemaps');
// var buffer = require('vinyl-buffer');
// var _ = require('lodash');
// var gulpif = require('gulp-if');
// var browserSync = require('browser-sync');

var gulp = require('gulp');
var $ = require('gulp-load-plugins')();

var src = {};

var source = require('vinyl-source-stream');
var watchify = require('watchify');
var browserify = require('browserify');
var reactify = require('reactify');
var runSequence = require('run-sequence');
var del = require('del');
var concat = require('gulp-concat');
var inject = require('gulp-inject');
var babelify = require('babelify');
var argv = require('minimist')(process.argv.slice(2));
var connect = require('gulp-connect');
var open = require('gulp-open');

var RELEASE = !!argv.release;

gulp.task('browserify', function() {
  bundleJS(false)
});

gulp.task('browserify-watch', function() {
  bundleJS(true);
});

// Host static files and automatically
// livereload them when they change
gulp.task('connect', function() {
  connect.server({
    root: 'build',
    port: 9090,
    livereload: true
  });
});

function bundleJS(watch) {
  var bundler = browserify({
    entries: ['./src/app.js'], // Just our entry point
    transform: [reactify], // We want to convert JSX to normal javascript
    debug: true, // give us sourcemapping
    cache: {}, packageCache: {}, fullPaths: true // Requirement of watchify
  });

  if (watch) {
    var watcher = watchify(bundler);

    watcher.transform(babelify);

    return watcher
      .on('update', function() {
        var updateStart = Date.now();
        console.log('Let\'s update!');
        var newBundle = watcher.bundle();

        newBundle
          .pipe(source('app.js'))
          .pipe(gulp.dest('./build/'));
        console.log('Updated in ' + (Date.now() - updateStart) + 'ms');
        // rebundle(bundler);
      })
      .bundle() // create the initial bundle when starting the task
      .pipe(source('app.js'))
      .pipe(gulp.dest('./build/'))
      .pipe(connect.reload());

  } else {
    bundler.transform(babelify);
  }

  // else {
  //   bundler
  //    .bundle()
  //    .pipe(source('app.js'))
  //    .pipe(gulp.dest('./build/'));
  // }
  // function rebundle(bundler) {
  //  bundler.transform(babelify);
  //  console.log('ohai');
  //   return bundler.bundle()
  //     .on('error', function(e) {
  //       gutil.log('Browserify Error', e);
  //     })
  //     .pipe(source('app.js'))
  //     .pipe(buffer())
  //     .pipe(sourcemaps.init({loadMaps: true})) // loads map from browserify file
  //     .pipe(sourcemaps.write()) // writes .map file
  //     .pipe(gulp.dest('.tmp/app'))
  //     // .pipe(gulpif(watch, browserSync.reload({
  //       // stream: true,
  //       // once: true
  //     // })));
  // }

  // return rebundle(bro);
}

// Clean build and temp directories
gulp.task('clean', del.bind(
  null, ['.tmp', 'build/*', '!build/.git'], {dot: true}
));

gulp.task('scripts', function(){
  var src = gulp.src('src/**/*.js');
  return src
    .pipe(gulp.dest('build'))
    .pipe(connect.reload());
});

gulp.task('index', function() {
  var target = gulp.src('src/index.html');

  return target
    .pipe(gulp.dest('build'))
    .pipe(connect.reload());
});

// copy libs/*
gulp.task('libs', function() {
  src.assets = [
    'src/libs/**'
  ];

  return gulp.src(src.assets)
    .pipe($.changed('build')) // only changed files
    .pipe(gulp.dest('build/libs')) // pipe them to our destination
    .pipe($.size({title: 'libs'}))
    .pipe(connect.reload()); // display sizes
});

// copy components/*
gulp.task('components', function() {
  src.assets = [
    'src/components/**'
  ];

  return gulp.src(src.assets)
    .pipe($.changed('build')) // only changed files
    .pipe(gulp.dest('build/components')) // pipe them to our destination
    .pipe($.size({title: 'components'})) // display sizes
    .pipe(connect.reload());
});

// copy bower components into /libs/bower_components
gulp.task('bower', function() {
  src.assets = [
    'bower_components/**'
  ];

  return gulp.src(src.assets)
    .pipe($.changed('build')) // only changed files
    .pipe(gulp.dest('build/libs/bower_components')) // pipe them to our destination
    .pipe($.size({title: 'bower'})) // display sizes
    .pipe(connect.reload());
});

// copy static assets
gulp.task('assets', function() {
  src.assets = [
    'src/assets/**'
  ];

  return gulp.src(src.assets)
    .pipe($.changed('build')) // only changed files
    .pipe(gulp.dest('build/assets')) // pipe them to our destination
    .pipe($.size({title: 'assets'})) // display sizes
    .pipe(connect.reload());
});

// SCSS and CSS
gulp.task('css', function() {
  return gulp.src('src/**/*.{css,scss}')
    .pipe($.plumber())
    .pipe($.sass({
      sourceMap: !RELEASE,
      sourceMapBasepath: __dirname
    }))
    .on('error', console.error.bind(console))
    // .pipe($.autoprefixer({browsers: AUTOPREFIXER_BROWSERS}))
    // .pipe($.csscomb())
    // .pipe($.if(RELEASE, $.minifyCss()))
    .pipe(concat('main.css'))
    .pipe(gulp.dest('build/css'))
    .pipe($.size({title: 'styles'}))
    .pipe(connect.reload());
});

// Open the app in a browser
gulp.task('open', function () {
  var options = {
    url: 'http://localhost:9090/'
  };

  return gulp.src('./build/index.html')
    .pipe(open('', options));
});

gulp.task('default', function () {
  return gulp.start('serve');
});

gulp.task('serve', function () {
 	runSequence(['build-watch', 'connect', 'open']);
});

gulp.task('build-watch', ['clean'], function(cb) {
	runSequence(['browserify-watch', 'css', 'assets', 'libs', 'bower', 'components', 'index'], cb);
	gulp.watch('src/**/*.{css,scss}', ['css']);
	gulp.watch('src/assets/**', ['assets']);
	gulp.watch('bower_components/**', ['bower']);
	gulp.watch('src/libs/**', ['libs']);
	gulp.watch('src/components/**', ['components']);
	gulp.watch('src/index.html', ['index']);
});

gulp.task('build', ['clean'], function(cb) {
  runSequence(['browserify', 'css', 'assets', 'libs', 'bower', 'components', 'index'], cb);
});

<commit_msg>fix gulp script error<commit_after>// var es = require('event-stream');
// var babel = require('gulp-babel');
// var gutil = require('gulp-util');
// var sourcemaps = require('gulp-sourcemaps');
// var buffer = require('vinyl-buffer');
// var _ = require('lodash');
// var gulpif = require('gulp-if');
// var browserSync = require('browser-sync');

var gulp = require('gulp');
var $ = require('gulp-load-plugins')();

var src = {};

var source = require('vinyl-source-stream');
var watchify = require('watchify');
var browserify = require('browserify');
var reactify = require('reactify');
var runSequence = require('run-sequence');
var del = require('del');
var concat = require('gulp-concat');
var inject = require('gulp-inject');
var babelify = require('babelify');
var argv = require('minimist')(process.argv.slice(2));
var connect = require('gulp-connect');
var open = require('gulp-open');

var RELEASE = !!argv.release;

gulp.task('browserify', function() {
  bundleJS(false)
});

gulp.task('browserify-watch', function() {
  bundleJS(true);
});

// Host static files and automatically
// livereload them when they change
gulp.task('connect', function() {
  connect.server({
    root: 'build',
    port: 9090,
    livereload: true
  });
});

function bundleJS(watch) {
  var bundler = browserify({
    entries: ['./src/app.js'], // Just our entry point
    transform: [reactify], // We want to convert JSX to normal javascript
    debug: true, // give us sourcemapping
    cache: {}, packageCache: {}, fullPaths: true // Requirement of watchify
  });

  if (watch) {
    var watcher = watchify(bundler);

    watcher.transform(babelify);

    return watcher
      .on('update', function() {
        var updateStart = Date.now();
        console.log('Let\'s update!');
        var newBundle = watcher.bundle();

        newBundle
          .pipe(source('app.js'))
          .pipe(gulp.dest('./build/'));
        console.log('Updated in ' + (Date.now() - updateStart) + 'ms');
        // rebundle(bundler);
      })
      .bundle() // create the initial bundle when starting the task
      .pipe(source('app.js'))
      .pipe(gulp.dest('./build/'))
      .pipe(connect.reload());

  } else {
    bundler.transform(babelify);
  }

  // else {
  //   bundler
  //    .bundle()
  //    .pipe(source('app.js'))
  //    .pipe(gulp.dest('./build/'));
  // }
  // function rebundle(bundler) {
  //  bundler.transform(babelify);
  //  console.log('ohai');
  //   return bundler.bundle()
  //     .on('error', function(e) {
  //       gutil.log('Browserify Error', e);
  //     })
  //     .pipe(source('app.js'))
  //     .pipe(buffer())
  //     .pipe(sourcemaps.init({loadMaps: true})) // loads map from browserify file
  //     .pipe(sourcemaps.write()) // writes .map file
  //     .pipe(gulp.dest('.tmp/app'))
  //     // .pipe(gulpif(watch, browserSync.reload({
  //       // stream: true,
  //       // once: true
  //     // })));
  // }

  // return rebundle(bro);
}

// Clean build and temp directories
gulp.task('clean', del.bind(
  null, ['.tmp', 'build/*', '!build/.git'], {dot: true}
));

gulp.task('scripts', function(){
  var src = gulp.src('src/**/*.js');
  return src
    .pipe(gulp.dest('build'))
    .pipe(connect.reload());
});

gulp.task('index', function() {
  var target = gulp.src('src/index.html');

  return target
    .pipe(gulp.dest('build'))
    .pipe(connect.reload());
});

// copy libs/*
gulp.task('libs', function() {
  src.assets = [
    'src/libs/**'
  ];

  return gulp.src(src.assets)
    .pipe($.changed('build')) // only changed files
    .pipe(gulp.dest('build/libs')) // pipe them to our destination
    .pipe($.size({title: 'libs'}))
    .pipe(connect.reload()); // display sizes
});

// copy components/*
gulp.task('components', function() {
  src.assets = [
    'src/components/**'
  ];

  return gulp.src(src.assets)
    .pipe($.changed('build')) // only changed files
    .pipe(gulp.dest('build/components')) // pipe them to our destination
    .pipe($.size({title: 'components'})) // display sizes
    .pipe(connect.reload());
});

// copy bower components into /libs/bower_components
gulp.task('bower', function() {
  src.assets = [
    'bower_components/**'
  ];

  return gulp.src(src.assets)
    .pipe($.changed('build')) // only changed files
    .pipe(gulp.dest('build/libs/bower_components')) // pipe them to our destination
    .pipe($.size({title: 'bower'})) // display sizes
    .pipe(connect.reload());
});

// copy static assets
gulp.task('assets', function() {
  src.assets = [
    'src/assets/**'
  ];

  return gulp.src(src.assets)
    .pipe($.changed('build')) // only changed files
    .pipe(gulp.dest('build/assets')) // pipe them to our destination
    .pipe($.size({title: 'assets'})) // display sizes
    .pipe(connect.reload());
});

// SCSS and CSS
gulp.task('css', function() {
  return gulp.src('src/**/*.{css,scss}')
    .pipe($.plumber())
    .pipe($.sass({
      sourceMap: !RELEASE,
      sourceMapBasepath: __dirname
    }))
    .on('error', console.error.bind(console))
    // .pipe($.autoprefixer({browsers: AUTOPREFIXER_BROWSERS}))
    // .pipe($.csscomb())
    // .pipe($.if(RELEASE, $.minifyCss()))
    .pipe(concat('main.css'))
    .pipe(gulp.dest('build/css'))
    .pipe($.size({title: 'styles'}))
    .pipe(connect.reload());
});

// Open the app in a browser
gulp.task('open', function () {
  var options = {
    url: 'http://localhost:9090/'
  };

  return gulp.src('./build/index.html')
    .pipe(open('', options));
});

gulp.task('default', function () {
  return gulp.start('serve');
});

gulp.task('serve', ['build-watch', 'connect'], function () {
  runSequence(['open']);
});

gulp.task('build-watch', ['clean'], function(cb) {
  runSequence(['browserify-watch', 'css', 'assets', 'libs', 'bower', 'components', 'index'], cb);
  gulp.watch('src/**/*.{css,scss}', ['css']);
  // gulp.watch('src/assets/**', ['assets']);
  // gulp.watch('bower_components/**', ['bower']);
  // gulp.watch('src/libs/**', ['libs']);
  // gulp.watch('src/components/**', ['components']);
  gulp.watch('src/index.html', ['index']);
});

gulp.task('build', ['clean'], function(cb) {
  runSequence(['browserify', 'css', 'assets', 'libs', 'bower', 'components', 'index'], cb);
});

<|endoftext|>


<commit_before>module.exports = function (grunt) {

    /// Switch between production (prod) and development (dev) environment. E.g. $ grunt --environment=prod
    var production = typeof grunt.option("prod") !== "undefined";

    /// Print the current environment
    grunt.log.writeln((production ? "Production" : "Development").rainbow.bold);

    grunt.initConfig({

        pkg: grunt.file.readJSON("package.json"),

        /// Minify javascript files with UglifyJS
        uglify: {
            options: {
                banner: production ?
                        "/**\n" +
                        " * <%= pkg.description %>\n" +
                        " * @author <%= pkg.author %>\n" +
                        " * @date <%= grunt.template.today('yyyy-mm-dd HH:MM:ss') %>\n" +
                        " */\n"
                        :
                        "console.log('<%= pkg.name %> <%= grunt.template.today(\'yyyy-mm-dd HH:MM:ss\') %>');\n",
                mangle: production,
                beautify: !production
            },
            build: {
                src: [
                    "bower_components/example/example.js",
                    "src/js/**/*.js"
                ],
                dest: "js/<%= pkg.name %>.min.js"
            }
        },

        /// Validate files with JSHint
        jshint: {
            all: ["Gruntfile.js", "src/js/**/*.js"]
        },

        /// Compile Sass to CSS using Compass
        compass: {
            compile: {
                options: {
                    sassDir: "src/sass",
                    cssDir: "css",
                    imagesDir: "images",
                    javascriptsDir: "js",
                    generatedImagesDir: "images/sprites",
                    relativeAssets: true,
                    require: ["compass/import-once/activate", "susy"], /// $ gem install susy
                    environment: production ? "production" : "development",
                    outputStyle: production ? "compressed" : "expanded",
                    noLineComments: production,
                    force: production
                }
            }
        },

        /// Clean files and folders
        clean: ["*.DS_Store", "**/*.DS_Store"],

        /// Run predefined tasks whenever watched file patterns are added, changed or deleted
        watch: {
            default: {
                files: ["Gruntfile.js"],
                tasks: ["default"]
            },
            js: {
                files: "<%= uglify.build.src %>",
                tasks: ["jshint", "uglify"]
            },
            sass: {
                files: ["src/sass/**/*.sass"],
                tasks: ["compass"]
            },
            clean: {
                files: [".DS_Store", "**/.DS_Store"],
                tasks: ["clean"]
            }
        }

    });

    grunt.loadNpmTasks("grunt-contrib-uglify");
    grunt.loadNpmTasks("grunt-contrib-compass");
    grunt.loadNpmTasks("grunt-contrib-clean");
    grunt.loadNpmTasks("grunt-contrib-watch");
    grunt.loadNpmTasks("grunt-contrib-jshint");

    grunt.registerTask("default", ["uglify", "compass", "clean", "watch"]);

};<commit_msg>Added tip comment<commit_after>module.exports = function (grunt) {

    /// Switch between production (prod) and development (dev) environment. For production mode run: grunt --prod
    var production = typeof grunt.option("prod") !== "undefined";

    /// Print the current environment
    grunt.log.writeln((production ? "Production" : "Development").rainbow.bold);

    grunt.initConfig({

        pkg: grunt.file.readJSON("package.json"),

        /// Minify javascript files with UglifyJS
        uglify: {
            options: {
                banner: production ?
                        "/**\n" +
                        " * <%= pkg.description %>\n" +
                        " * @author <%= pkg.author %>\n" +
                        " * @date <%= grunt.template.today('yyyy-mm-dd HH:MM:ss') %>\n" +
                        " */\n"
                        :
                        "console.log('<%= pkg.name %> <%= grunt.template.today(\'yyyy-mm-dd HH:MM:ss\') %>');\n",
                mangle: production,
                beautify: !production
            },
            build: {
                src: [
                    "bower_components/example/example.js",
                    "src/js/**/*.js"
                ],
                dest: "js/<%= pkg.name %>.min.js"
            }
        },

        /// Validate files with JSHint
        jshint: {
            all: ["Gruntfile.js", "src/js/**/*.js"]
        },

        /// Compile Sass to CSS using Compass
        compass: {
            compile: {
                options: {
                    sassDir: "src/sass",
                    cssDir: "css",
                    imagesDir: "images",
                    javascriptsDir: "js",
                    generatedImagesDir: "images/sprites",
                    relativeAssets: true,
                    require: ["compass/import-once/activate", "susy"], /// $ gem install susy
                    environment: production ? "production" : "development",
                    outputStyle: production ? "compressed" : "expanded",
                    noLineComments: production,
                    force: production
                }
            }
        },

        /// Clean files and folders
        clean: ["*.DS_Store", "**/*.DS_Store"],

        /// Run predefined tasks whenever watched file patterns are added, changed or deleted
        watch: {
            default: {
                files: ["Gruntfile.js"],
                tasks: ["default"]
            },
            js: {
                files: "<%= uglify.build.src %>",
                tasks: ["jshint", "uglify"]
            },
            sass: {
                files: ["src/sass/**/*.sass"],
                tasks: ["compass"]
            },
            clean: {
                files: [".DS_Store", "**/.DS_Store"],
                tasks: ["clean"]
            }
        }

    });

    grunt.loadNpmTasks("grunt-contrib-uglify");
    grunt.loadNpmTasks("grunt-contrib-compass");
    grunt.loadNpmTasks("grunt-contrib-clean");
    grunt.loadNpmTasks("grunt-contrib-watch");
    grunt.loadNpmTasks("grunt-contrib-jshint");

    grunt.registerTask("default", ["uglify", "compass", "clean", "watch"]);

};<|endoftext|>


<commit_before>var gulp = require('gulp');
var sass = require('gulp-sass');
var autoprefixer = require('gulp-autoprefixer');
var uglify = require('gulp-uglify');
var pump = require('pump');
var cleanCSS = require('gulp-clean-css');
var imagemin = require('gulp-imagemin');

gulp.task('sass', function() {
    return gulp.src('src/sass/*.scss')
        .pipe(sass())
        .pipe(autoprefixer({ browsers: ['last 3 versions'] }))
        .pipe(cleanCSS())
        .pipe(gulp.dest('build/css'));
});

gulp.task('uglify-js', function() {
    pump([
        gulp.src('src/js/*.js'),
        uglify(),
        gulp.dest('build/js')
    ]);
});

gulp.task('html', function() {
	return gulp.src('src/index.html').pipe(gulp.dest('build'));
});

gulp.task('default', function() {
	gulp.watch('src/sass/*.scss', ['sass']);
	gulp.watch('src/js/*.js', ['uglify-js']);
	gulp.watch('src/index.html', ['html']);
	gulp.src('src/img/*')
        .pipe(imagemin())
        .pipe(gulp.dest('build/img'));
});<commit_msg>Modify .scss files to compile<commit_after>var gulp = require('gulp');
var sass = require('gulp-sass');
var autoprefixer = require('gulp-autoprefixer');
var uglify = require('gulp-uglify');
var pump = require('pump');
var cleanCSS = require('gulp-clean-css');
var imagemin = require('gulp-imagemin');

gulp.task('sass', function() {
    return gulp.src('src/sass/main.scss')
        .pipe(sass())
        .pipe(autoprefixer({ browsers: ['last 3 versions'] }))
        .pipe(cleanCSS())
        .pipe(gulp.dest('build/css'));
});

gulp.task('uglify-js', function() {
    pump([
        gulp.src('src/js/*.js'),
        uglify(),
        gulp.dest('build/js')
    ]);
});

gulp.task('html', function() {
	return gulp.src('src/index.html').pipe(gulp.dest('build'));
});

gulp.task('default', function() {
	gulp.watch('src/sass/*.scss', ['sass']);
	gulp.watch('src/js/*.js', ['uglify-js']);
	gulp.watch('src/index.html', ['html']);
	gulp.src('src/img/*')
        .pipe(imagemin())
        .pipe(gulp.dest('build/img'));
});<|endoftext|>


<commit_before>'use strict';
var lrSnippet = require('grunt-contrib-livereload/lib/utils').livereloadSnippet;
var mountFolder = function (connect, dir) {
    return connect.static(require('path').resolve(dir));
};

module.exports = function (grunt) {
    // load all grunt tasks
    require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

    // configurable paths
    var yeomanConfig = {
        name: 'gmodule',
        src: 'src',
        dist: 'dist',
        example:'example'
    };

    try {
        yeomanConfig.src = require('./component.json').appPath || yeomanConfig.src;
    } catch (e) {}

    grunt.initConfig({
        yeoman: yeomanConfig,
        livereload:{
            port: 35723
        },
        watch: {
            livereload: {
                files: [
                    '<%= yeoman.src %>/{,*/}*.html',
                    '{.tmp,<%= yeoman.src %>}/styles/{,*/}*.css',
                    '{.tmp,<%= yeoman.src %>}/scripts/{,*/}*.js',
                    '<%= yeoman.src %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
                ],
                tasks: ['livereload']
            }
        },
        connect: {
            options: {
                port: 9300,
                // Change this to '0.0.0.0' to access the server from outside.
                hostname: 'localhost'
            },
            livereload: {
                options: {
                    middleware: function (connect) {
                        return [
                            lrSnippet,
                            mountFolder(connect, '.tmp'),
                            mountFolder(connect, yeomanConfig.src)
                        ];
                    }
                }
            },
            test: {
                options: {
                    middleware: function (connect) {
                        return [
                            mountFolder(connect, '.tmp'),
                            mountFolder(connect, 'test')
                        ];
                    }
                }
            },
            dev:{
                options: {}
            }
        },
        open: {
            server: {
                url: 'http://localhost:<%= connect.options.port %>'
            }
        },
        clean: {
            dist: {
                files: [{
                    dot: true,
                    src: [
                        '.tmp',
                        '<%= yeoman.dist %>/*',
                        '!<%= yeoman.dist %>/.git*'
                    ]
                }]
            },
            server: '.tmp'
        },
        jshint: {
            options: {
                jshintrc: '.jshintrc'
            },
            all: [
                'Gruntfile.js',
                '<%= yeoman.src %>/{,*/}*.js'
            ]
        },
        karma: {
            options: {
                configFile: 'karma.conf.js',
                runnerPort: 9339,
                browsers: ['Chrome', 'Firefox']
            },
            unit: {
                reporters: 'dots'
            },
            continuous: {
                singleRun: true,
                browsers: ['PhantomJS']
            },
            ci: {
                singleRun: true,
                browsers: ['PhantomJS']
            }
        },
        concat: {
            dist: {
                files: {
                    '<%= yeoman.dist %>/<%= yeoman.name %>.js': [
                        '.tmp/{,*/}*.js',
                        '<%= yeoman.src %>/{,*/}*.js'
                    ]
                }
            }
        },
        uglify: {
            dist: {
                files: {
                    '<%= yeoman.dist %>/<%= yeoman.name %>.min.js': [
                        '<%= yeoman.dist %>/<%= yeoman.name %>.js'
                    ]
                }
            }
        },
        copy: {
            dist: {
                files: [{
                    expand: true,
                    dot: true,
                    cwd: '<%= yeoman.src %>',
                    dest: '<%= yeoman.dist %>',
                    src: []
                }]
            }
        },
        //https://github.com/vojtajina/grunt-bump
        bump: {
            options: {
                files: ['package.json', 'bower.json', 'component.json'],
                updateConfigs: [],
                commit: true,
                commitMessage: 'Release v%VERSION%',
                commitFiles: ['package.json', 'bower.json', 'component.json'], // '-a' for all files
                createTag: true,
                tagName: 'v%VERSION%',
                tagMessage: 'Version %VERSION%',
                push: true,
                pushTo: 'upstream',
                gitDescribeOptions: '--tags --always --abbrev=1 --dirty=-d' // options to use with '$ git describe'
            }
        }
    });

    grunt.renameTask('regarde', 'watch');

    grunt.registerTask('server', [
        'clean:server',
        'livereload-start',
        'connect:livereload',
        'open',
        'watch'
    ]);

    grunt.registerTask('test', [
        'clean:server',
        'connect:test',
        'karma:ci'
    ]);

    grunt.registerTask('build', [
        'clean:dist',
        'jshint',
        'test',
        'concat',
        'copy',
        'uglify',
    ]);

    grunt.registerTask('default', ['build']);
};
<commit_msg>Release v0.1.1<commit_after>'use strict';
var lrSnippet = require('grunt-contrib-livereload/lib/utils').livereloadSnippet;
var mountFolder = function (connect, dir) {
    return connect.static(require('path').resolve(dir));
};

module.exports = function (grunt) {
    // load all grunt tasks
    require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

    // configurable paths
    var yeomanConfig = {
        name: 'gmodule',
        src: 'src',
        dist: 'dist',
        example:'example'
    };

    try {
        yeomanConfig.src = require('./component.json').appPath || yeomanConfig.src;
    } catch (e) {}

    grunt.initConfig({
        yeoman: yeomanConfig,
        livereload:{
            port: 35723
        },
        watch: {
            livereload: {
                files: [
                    '<%= yeoman.src %>/{,*/}*.html',
                    '{.tmp,<%= yeoman.src %>}/styles/{,*/}*.css',
                    '{.tmp,<%= yeoman.src %>}/scripts/{,*/}*.js',
                    '<%= yeoman.src %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
                ],
                tasks: ['livereload']
            }
        },
        connect: {
            options: {
                port: 9300,
                // Change this to '0.0.0.0' to access the server from outside.
                hostname: 'localhost'
            },
            livereload: {
                options: {
                    middleware: function (connect) {
                        return [
                            lrSnippet,
                            mountFolder(connect, '.tmp'),
                            mountFolder(connect, yeomanConfig.src)
                        ];
                    }
                }
            },
            test: {
                options: {
                    middleware: function (connect) {
                        return [
                            mountFolder(connect, '.tmp'),
                            mountFolder(connect, 'test')
                        ];
                    }
                }
            },
            dev:{
                options: {}
            }
        },
        open: {
            server: {
                url: 'http://localhost:<%= connect.options.port %>'
            }
        },
        clean: {
            dist: {
                files: [{
                    dot: true,
                    src: [
                        '.tmp',
                        '<%= yeoman.dist %>/*',
                        '!<%= yeoman.dist %>/.git*'
                    ]
                }]
            },
            server: '.tmp'
        },
        jshint: {
            options: {
                jshintrc: '.jshintrc'
            },
            all: [
                'Gruntfile.js',
                '<%= yeoman.src %>/{,*/}*.js'
            ]
        },
        karma: {
            options: {
                configFile: 'karma.conf.js',
                runnerPort: 9339,
                browsers: ['Chrome', 'Firefox']
            },
            unit: {
                reporters: 'dots'
            },
            continuous: {
                singleRun: true,
                browsers: ['PhantomJS']
            },
            ci: {
                singleRun: true,
                browsers: ['PhantomJS']
            }
        },
        concat: {
            dist: {
                files: {
                    '<%= yeoman.dist %>/<%= yeoman.name %>.js': [
                        '.tmp/{,*/}*.js',
                        '<%= yeoman.src %>/{,*/}*.js'
                    ]
                }
            }
        },
        uglify: {
            dist: {
                files: {
                    '<%= yeoman.dist %>/<%= yeoman.name %>.min.js': [
                        '<%= yeoman.dist %>/<%= yeoman.name %>.js'
                    ]
                }
            }
        },
        copy: {
            dist: {
                files: [{
                    expand: true,
                    dot: true,
                    cwd: '<%= yeoman.src %>',
                    dest: '<%= yeoman.dist %>',
                    src: []
                }]
            }
        },
        //https://github.com/vojtajina/grunt-bump
        bump: {
            options: {
                files: ['package.json', 'bower.json', 'component.json'],
                updateConfigs: [],
                commit: true,
                commitMessage: 'Release v%VERSION%',
                commitFiles: ['-a'], // '-a' for all files
                createTag: true,
                tagName: 'v%VERSION%',
                tagMessage: 'Version %VERSION%',
                push: true,
                pushTo: 'origin',
                gitDescribeOptions: '--tags --always --abbrev=1 --dirty=-d' // options to use with '$ git describe'
            }
        }
    });

    grunt.renameTask('regarde', 'watch');

    grunt.registerTask('server', [
        'clean:server',
        'livereload-start',
        'connect:livereload',
        'open',
        'watch'
    ]);

    grunt.registerTask('test', [
        'clean:server',
        'connect:test',
        'karma:ci'
    ]);

    grunt.registerTask('build', [
        'clean:dist',
        'jshint',
        'test',
        'concat',
        'copy',
        'uglify',
    ]);

    grunt.registerTask('default', ['build']);
};
<|endoftext|>


<commit_before>/*
 * Copyright (c) 2012-2013. Telecom ParisTech/TSI/MM/GPAC Cyril Concolato
 * License: BSD-3-Clause (see LICENSE file)
 */
var BoxParser = {
	ERR_INVALID_DATA : -1,
	ERR_NOT_ENOUGH_DATA : 0,
	OK : 1,
	boxCodes : [
				 "mdat", "idat", "free", "skip",
				 "avcC", "hvcC", "ftyp", "styp",
				 "payl", "vttC",
				 "rtp ", "sdp ",
				 "btrt", "frma",
				 "trpy", "tpyl", "totl", "tpay", "dmed", "dimm", "drep", "nump", "npck", "maxr", "tmin", "tmax", "dmax", "pmax", "payt",
				 "vmhd", "smhd", "hmhd", // full boxes not yet parsed
				 "idat", "meco",
				 "udta", "strk",
				 "free", "skip"
			   ],
	fullBoxCodes : [ "mvhd", "tkhd", "mdhd", "hdlr", "vmhd", "smhd", "hmhd", "nmhd", "url ", "urn ",
				  "ctts", "cslg", "stco", "co64", "stsc", "stss", "stsz", "stz2", "stts", "stsh",
				  "mehd", "trex", "mfhd", "tfhd", "trun", "tfdt",
				  "esds", "subs",
				  "txtC",
				  "sidx", "emsg", "prft", "pssh",
				  "elst", "dref", "url ", "urn ",
				  "sbgp", "sgpd",
				  "cprt",
				  "iods",
				  "ssix", "tfra", "mfro", "pdin", "tsel",
				  "trep", "leva", "stri", "stsg",
				  "schm",
				  "stvi",
				  "padb", "stdp", "sdtp", "saio", "saiz",
				  "meta", "xml ", "bxml", "iloc", "pitm", "ipro", "iinf", "infe", "iref" , "mere",
				  "kind", "elng",
				  /* missing "stsd", "iref", : special case full box and container */
				],
	containerBoxCodes : [
		[ "moov", [ "trak", "sidx" ] ],
		[ "trak" ],
		[ "edts" ],
		[ "mdia" ],
		[ "minf" ],
		[ "dinf" ],
		[ "stbl", [ "sgpd", "sbgp" ] ],
		[ "mvex", [ "trex" ] ],
		[ "moof", [ "traf" ] ],
		[ "traf", [ "trun", "sgpd", "sbgp" ] ],
		[ "vttc" ],
		[ "tref" ],
		[ "iref" ],
		[ "udta" ],
		[ "mfra" ],
		[ "meco" ],
		[ "hnti" ],
		[ "hinf" ],
		[ "strk" ],
		[ "strd" ],
		[ "sinf" ],
		[ "rinf" ],
		[ "schi" ],
		[ "trgr" ],
		[ "udta", ["kind"] ],
		[ "iprp" ]
	],
	sampleEntryCodes : [
		/* 4CC as registered on http://mp4ra.org/codecs.html */
		{ prefix: "Visual", types: [ "mp4v", "avc1", "avc2", "avc3", "avc4", "avcp", "drac", "encv", "mjp2", "mvc1", "mvc2", "resv", "s263", "svc1", "vc-1", "hvc1", "hev1"  ] },
		{ prefix: "Audio", 	types: [ "mp4a", "ac-3", "alac", "dra1", "dtsc", "dtse", ,"dtsh", "dtsl", "ec-3", "enca", "g719", "g726", "m4ae", "mlpa",  "raw ", "samr", "sawb", "sawp", "sevc", "sqcp", "ssmv", "twos", ".mp3" ] },
		{ prefix: "Hint", 	types: [ "fdp ", "m2ts", "pm2t", "prtp", "rm2t", "rrtp", "rsrp", "rtp ", "sm2t", "srtp" ] },
		{ prefix: "Metadata", types: [ "metx", "mett", "urim" ] },
		{ prefix: "Subtitle", types: [ "stpp", "wvtt", "sbtt", "tx3g", "stxt" ] },
		{ prefix: "System", types: [ "mp4s"] }
	],
	sampleGroupEntryCodes: [
		"roll", "prol", "alst", "rap ", "tele", "avss", "avll", "sync", "tscl", "tsas", "stsa", "scif", "mvif", "scnm", "dtrt", "vipr", "tele", "rash"
	],
	trackGroupTypes: [ "msrc" ],
	initialize: function() {
		var i, j;
		var length;
		BoxParser.FullBox.prototype = new BoxParser.Box();
		BoxParser.ContainerBox.prototype = new BoxParser.Box();
		BoxParser.SampleEntry.prototype = new BoxParser.FullBox();
		BoxParser.TrackGroupTypeBox.prototype = new BoxParser.FullBox();
		/* creating constructors for simple boxes */
		length = BoxParser.boxCodes.length;
		for (i=0; i<length; i++) {
			BoxParser[BoxParser.boxCodes[i]+"Box"] = (function (j) { /* creating a closure around the iterating value of i */
				return function(size) {
					BoxParser.Box.call(this, BoxParser.boxCodes[j], size);
				}
			})(i);
			BoxParser[BoxParser.boxCodes[i]+"Box"].prototype = new BoxParser.Box();
		}
		/* creating constructors for full boxes */
		length = BoxParser.fullBoxCodes.length;
		for (i=0; i<length; i++) {
			BoxParser[BoxParser.fullBoxCodes[i]+"Box"] = (function (j) {
				return function(size) {
					BoxParser.FullBox.call(this, BoxParser.fullBoxCodes[j], size);
				}
			})(i);
			BoxParser[BoxParser.fullBoxCodes[i]+"Box"].prototype = new BoxParser.FullBox();
		}
		/* creating constructors for container boxes */
		length = BoxParser.containerBoxCodes.length;
		for (i=0; i<length; i++) {
			BoxParser[BoxParser.containerBoxCodes[i][0]+"Box"] = (function (j, subBoxNames) {
				return function(size) {
					BoxParser.ContainerBox.call(this, BoxParser.containerBoxCodes[j][0], size);
					if (subBoxNames) {
						this.subBoxNames = subBoxNames;
						var nbSubBoxes = subBoxNames.length;
						for (var k = 0; k<nbSubBoxes; k++) {
							this[subBoxNames[k]+"s"] = [];
						}
					}
				}
			})(i, BoxParser.containerBoxCodes[i][1]);
			BoxParser[BoxParser.containerBoxCodes[i][0]+"Box"].prototype = new BoxParser.ContainerBox();
		}
		/* creating constructors for stsd entries  */
		length = BoxParser.sampleEntryCodes.length;
		for (j = 0; j < length; j++) {
			var prefix = BoxParser.sampleEntryCodes[j].prefix;
			var types = BoxParser.sampleEntryCodes[j].types;
			var nb_types = types.length;
			BoxParser[prefix+"SampleEntry"] = function(type, size) { BoxParser.SampleEntry.call(this, type, size); };
			BoxParser[prefix+"SampleEntry"].prototype = new BoxParser.SampleEntry();
			for (i=0; i<nb_types; i++) {
				BoxParser[types[i]+"SampleEntry"] = (function (k, l) {
					return function(size) {
						BoxParser[BoxParser.sampleEntryCodes[k].prefix+"SampleEntry"].call(this, BoxParser.sampleEntryCodes[k].types[l], size);
					}
				})(j, i);
				BoxParser[types[i]+"SampleEntry"].prototype = new BoxParser[prefix+"SampleEntry"]();
			}
		}
		/* creating constructors for stsd entries  */
		length = BoxParser.sampleGroupEntryCodes.length;
		for (i = 0; i < length; i++) {
			BoxParser[BoxParser.sampleGroupEntryCodes[i]+"SampleGroupEntry"] = (function (j) {
				return function(size) {
					BoxParser.SampleGroupEntry.call(this, BoxParser.sampleGroupEntryCodes[j], size);
				}
			})(i);
			BoxParser[BoxParser.sampleGroupEntryCodes[i]+"SampleGroupEntry"].prototype = new BoxParser.SampleGroupEntry();
		}
		/* creating constructors for track groups  */
		length = BoxParser.trackGroupTypes.length;
		for (i = 0; i < length; i++) {
			BoxParser[BoxParser.trackGroupTypes[i]+"Box"] = (function (j) {
				return function(size) {
					BoxParser.TrackGroupTypeBox.call(this, BoxParser.trackGroupTypes[j], size);
				}
			})(i);
			BoxParser[BoxParser.trackGroupTypes[i]+"Box"].prototype = new BoxParser.TrackGroupTypeBox();
		}
	},
	Box: function(_type, _size) {
		this.type = _type;
		this.size = _size;
	},
	FullBox: function(type, size) {
		BoxParser.Box.call(this, type, size);
		this.flags = 0;
		this.version = 0;
	},
	ContainerBox: function(type, size) {
		BoxParser.Box.call(this, type, size);
		this.boxes = [];
	},
	SampleEntry: function(type, size, hdr_size, start) {
		BoxParser.Box.call(this, type, size);
		this.hdr_size = hdr_size;
		this.start = start;
		this.boxes = [];
	},
	SampleGroupEntry: function(type) {
		this.grouping_type = type;
	},
	TrackGroupTypeBox: function(type, size) {
		BoxParser.FullBox.call(this, type, size);
	}
}

BoxParser.initialize();

BoxParser.TKHD_FLAG_ENABLED    = 0x000001;
BoxParser.TKHD_FLAG_IN_MOVIE   = 0x000002;
BoxParser.TKHD_FLAG_IN_PREVIEW = 0x000004;

BoxParser.TFHD_FLAG_BASE_DATA_OFFSET	= 0x01;
BoxParser.TFHD_FLAG_SAMPLE_DESC			= 0x02;
BoxParser.TFHD_FLAG_SAMPLE_DUR			= 0x08;
BoxParser.TFHD_FLAG_SAMPLE_SIZE			= 0x10;
BoxParser.TFHD_FLAG_SAMPLE_FLAGS		= 0x20;
BoxParser.TFHD_FLAG_DUR_EMPTY			= 0x10000;
BoxParser.TFHD_FLAG_DEFAULT_BASE_IS_MOOF= 0x20000;

BoxParser.TRUN_FLAGS_DATA_OFFSET= 0x01;
BoxParser.TRUN_FLAGS_FIRST_FLAG	= 0x04;
BoxParser.TRUN_FLAGS_DURATION	= 0x100;
BoxParser.TRUN_FLAGS_SIZE		= 0x200;
BoxParser.TRUN_FLAGS_FLAGS		= 0x400;
BoxParser.TRUN_FLAGS_CTS_OFFSET	= 0x800;

if (typeof exports !== "undefined") {
	exports.BoxParser = BoxParser;
}
<commit_msg>add helper functions to add a box and set properties<commit_after>/*
 * Copyright (c) 2012-2013. Telecom ParisTech/TSI/MM/GPAC Cyril Concolato
 * License: BSD-3-Clause (see LICENSE file)
 */
var BoxParser = {
	ERR_INVALID_DATA : -1,
	ERR_NOT_ENOUGH_DATA : 0,
	OK : 1,
	boxCodes : [
				 "mdat", "idat", "free", "skip",
				 "avcC", "hvcC", "ftyp", "styp",
				 "payl", "vttC",
				 "rtp ", "sdp ",
				 "btrt", "frma",
				 "trpy", "tpyl", "totl", "tpay", "dmed", "dimm", "drep", "nump", "npck", "maxr", "tmin", "tmax", "dmax", "pmax", "payt",
				 "vmhd", "smhd", "hmhd", // full boxes not yet parsed
				 "idat", "meco",
				 "udta", "strk",
				 "free", "skip"
			   ],
	fullBoxCodes : [ "mvhd", "tkhd", "mdhd", "hdlr", "vmhd", "smhd", "hmhd", "nmhd", "url ", "urn ",
				  "ctts", "cslg", "stco", "co64", "stsc", "stss", "stsz", "stz2", "stts", "stsh",
				  "mehd", "trex", "mfhd", "tfhd", "trun", "tfdt",
				  "esds", "subs",
				  "txtC",
				  "sidx", "emsg", "prft", "pssh",
				  "elst", "dref", "url ", "urn ",
				  "sbgp", "sgpd",
				  "cprt",
				  "iods",
				  "ssix", "tfra", "mfro", "pdin", "tsel",
				  "trep", "leva", "stri", "stsg",
				  "schm",
				  "stvi",
				  "padb", "stdp", "sdtp", "saio", "saiz",
				  "meta", "xml ", "bxml", "iloc", "pitm", "ipro", "iinf", "infe", "iref" , "mere",
				  "kind", "elng",
				  /* missing "stsd", "iref", : special case full box and container */
				],
	containerBoxCodes : [
		[ "moov", [ "trak", "sidx" ] ],
		[ "trak" ],
		[ "edts" ],
		[ "mdia" ],
		[ "minf" ],
		[ "dinf" ],
		[ "stbl", [ "sgpd", "sbgp" ] ],
		[ "mvex", [ "trex" ] ],
		[ "moof", [ "traf" ] ],
		[ "traf", [ "trun", "sgpd", "sbgp" ] ],
		[ "vttc" ],
		[ "tref" ],
		[ "iref" ],
		[ "udta" ],
		[ "mfra" ],
		[ "meco" ],
		[ "hnti" ],
		[ "hinf" ],
		[ "strk" ],
		[ "strd" ],
		[ "sinf" ],
		[ "rinf" ],
		[ "schi" ],
		[ "trgr" ],
		[ "udta", ["kind"] ],
		[ "iprp" ]
	],
	sampleEntryCodes : [
		/* 4CC as registered on http://mp4ra.org/codecs.html */
		{ prefix: "Visual", types: [ "mp4v", "avc1", "avc2", "avc3", "avc4", "avcp", "drac", "encv", "mjp2", "mvc1", "mvc2", "resv", "s263", "svc1", "vc-1", "hvc1", "hev1"  ] },
		{ prefix: "Audio", 	types: [ "mp4a", "ac-3", "alac", "dra1", "dtsc", "dtse", ,"dtsh", "dtsl", "ec-3", "enca", "g719", "g726", "m4ae", "mlpa",  "raw ", "samr", "sawb", "sawp", "sevc", "sqcp", "ssmv", "twos", ".mp3" ] },
		{ prefix: "Hint", 	types: [ "fdp ", "m2ts", "pm2t", "prtp", "rm2t", "rrtp", "rsrp", "rtp ", "sm2t", "srtp" ] },
		{ prefix: "Metadata", types: [ "metx", "mett", "urim" ] },
		{ prefix: "Subtitle", types: [ "stpp", "wvtt", "sbtt", "tx3g", "stxt" ] },
		{ prefix: "System", types: [ "mp4s"] }
	],
	sampleGroupEntryCodes: [
		"roll", "prol", "alst", "rap ", "tele", "avss", "avll", "sync", "tscl", "tsas", "stsa", "scif", "mvif", "scnm", "dtrt", "vipr", "tele", "rash"
	],
	trackGroupTypes: [ "msrc" ],
	initialize: function() {
		var i, j;
		var length;
		BoxParser.FullBox.prototype = new BoxParser.Box();
		BoxParser.ContainerBox.prototype = new BoxParser.Box();
		BoxParser.SampleEntry.prototype = new BoxParser.FullBox();
		BoxParser.TrackGroupTypeBox.prototype = new BoxParser.FullBox();
		/* creating constructors for simple boxes */
		length = BoxParser.boxCodes.length;
		for (i=0; i<length; i++) {
			BoxParser[BoxParser.boxCodes[i]+"Box"] = (function (j) { /* creating a closure around the iterating value of i */
				return function(size) {
					BoxParser.Box.call(this, BoxParser.boxCodes[j], size);
				}
			})(i);
			BoxParser[BoxParser.boxCodes[i]+"Box"].prototype = new BoxParser.Box();
		}
		/* creating constructors for full boxes */
		length = BoxParser.fullBoxCodes.length;
		for (i=0; i<length; i++) {
			BoxParser[BoxParser.fullBoxCodes[i]+"Box"] = (function (j) {
				return function(size) {
					BoxParser.FullBox.call(this, BoxParser.fullBoxCodes[j], size);
				}
			})(i);
			BoxParser[BoxParser.fullBoxCodes[i]+"Box"].prototype = new BoxParser.FullBox();
		}
		/* creating constructors for container boxes */
		length = BoxParser.containerBoxCodes.length;
		for (i=0; i<length; i++) {
			BoxParser[BoxParser.containerBoxCodes[i][0]+"Box"] = (function (j, subBoxNames) {
				return function(size) {
					BoxParser.ContainerBox.call(this, BoxParser.containerBoxCodes[j][0], size);
					if (subBoxNames) {
						this.subBoxNames = subBoxNames;
						var nbSubBoxes = subBoxNames.length;
						for (var k = 0; k<nbSubBoxes; k++) {
							this[subBoxNames[k]+"s"] = [];
						}
					}
				}
			})(i, BoxParser.containerBoxCodes[i][1]);
			BoxParser[BoxParser.containerBoxCodes[i][0]+"Box"].prototype = new BoxParser.ContainerBox();
		}
		/* creating constructors for stsd entries  */
		length = BoxParser.sampleEntryCodes.length;
		for (j = 0; j < length; j++) {
			var prefix = BoxParser.sampleEntryCodes[j].prefix;
			var types = BoxParser.sampleEntryCodes[j].types;
			var nb_types = types.length;
			BoxParser[prefix+"SampleEntry"] = function(type, size) { BoxParser.SampleEntry.call(this, type, size); };
			BoxParser[prefix+"SampleEntry"].prototype = new BoxParser.SampleEntry();
			for (i=0; i<nb_types; i++) {
				BoxParser[types[i]+"SampleEntry"] = (function (k, l) {
					return function(size) {
						BoxParser[BoxParser.sampleEntryCodes[k].prefix+"SampleEntry"].call(this, BoxParser.sampleEntryCodes[k].types[l], size);
					}
				})(j, i);
				BoxParser[types[i]+"SampleEntry"].prototype = new BoxParser[prefix+"SampleEntry"]();
			}
		}
		/* creating constructors for stsd entries  */
		length = BoxParser.sampleGroupEntryCodes.length;
		for (i = 0; i < length; i++) {
			BoxParser[BoxParser.sampleGroupEntryCodes[i]+"SampleGroupEntry"] = (function (j) {
				return function(size) {
					BoxParser.SampleGroupEntry.call(this, BoxParser.sampleGroupEntryCodes[j], size);
				}
			})(i);
			BoxParser[BoxParser.sampleGroupEntryCodes[i]+"SampleGroupEntry"].prototype = new BoxParser.SampleGroupEntry();
		}
		/* creating constructors for track groups  */
		length = BoxParser.trackGroupTypes.length;
		for (i = 0; i < length; i++) {
			BoxParser[BoxParser.trackGroupTypes[i]+"Box"] = (function (j) {
				return function(size) {
					BoxParser.TrackGroupTypeBox.call(this, BoxParser.trackGroupTypes[j], size);
				}
			})(i);
			BoxParser[BoxParser.trackGroupTypes[i]+"Box"].prototype = new BoxParser.TrackGroupTypeBox();
		}
	},
	Box: function(_type, _size) {
		this.type = _type;
		this.size = _size;
	},
	FullBox: function(type, size) {
		BoxParser.Box.call(this, type, size);
		this.flags = 0;
		this.version = 0;
	},
	ContainerBox: function(type, size) {
		BoxParser.Box.call(this, type, size);
		this.boxes = [];
	},
	SampleEntry: function(type, size, hdr_size, start) {
		BoxParser.Box.call(this, type, size);
		this.hdr_size = hdr_size;
		this.start = start;
		this.boxes = [];
	},
	SampleGroupEntry: function(type) {
		this.grouping_type = type;
	},
	TrackGroupTypeBox: function(type, size) {
		BoxParser.FullBox.call(this, type, size);
	}
}

BoxParser.initialize();

BoxParser.TKHD_FLAG_ENABLED    = 0x000001;
BoxParser.TKHD_FLAG_IN_MOVIE   = 0x000002;
BoxParser.TKHD_FLAG_IN_PREVIEW = 0x000004;

BoxParser.TFHD_FLAG_BASE_DATA_OFFSET	= 0x01;
BoxParser.TFHD_FLAG_SAMPLE_DESC			= 0x02;
BoxParser.TFHD_FLAG_SAMPLE_DUR			= 0x08;
BoxParser.TFHD_FLAG_SAMPLE_SIZE			= 0x10;
BoxParser.TFHD_FLAG_SAMPLE_FLAGS		= 0x20;
BoxParser.TFHD_FLAG_DUR_EMPTY			= 0x10000;
BoxParser.TFHD_FLAG_DEFAULT_BASE_IS_MOOF= 0x20000;

BoxParser.TRUN_FLAGS_DATA_OFFSET= 0x01;
BoxParser.TRUN_FLAGS_FIRST_FLAG	= 0x04;
BoxParser.TRUN_FLAGS_DURATION	= 0x100;
BoxParser.TRUN_FLAGS_SIZE		= 0x200;
BoxParser.TRUN_FLAGS_FLAGS		= 0x400;
BoxParser.TRUN_FLAGS_CTS_OFFSET	= 0x800;

BoxParser.Box.prototype.add = function(name) {
	var i, j;
	var box = new BoxParser[name+"Box"]();
	this.boxes.push(box);
	if (this[name+"s"]) {
		this[name+"s"].push(box);
	} else {
		this[name] = box;
	}
	return box;
}

BoxParser.Box.prototype.set = function(prop, value) {
	this[prop] = value;
	return this;
}

BoxParser.Box.prototype.addEntry = function(value, _prop) {
	var prop = _prop || "entries";
	if (!this[prop]) {
		this[prop] = [];
	}
	this[prop].push(value);
	return this;
}

if (typeof exports !== "undefined") {
	exports.BoxParser = BoxParser;
}
<|endoftext|>