<commit_before>/*global module:false*/
module.exports = function(grunt) {
  var parentCWD = process.cwd();

  // http://stackoverflow.com/questions/17588466/grunt-task-dependencies
  process.chdir(__dirname);

  require('time-grunt')(grunt);

  // grunt.option.init() method overwrites the entire internal option state, https://github.com/gruntjs/grunt/issues/1023
  grunt.option('build-path', grunt.option('build-path') || parentCWD + '/build');
  grunt.option('source-path', grunt.option('source-path') || parentCWD + '/src');
  grunt.option('backup-path', grunt.option('backup-path') || parentCWD + '/backup');

  // Splits a CSS selector inti it's Block, Element and Modifier parts
  grunt.splitBEM = function(selector){
    if(selector.indexOf('.') == 0){
      selector = selector.substring(1);
    }

    // Only get the main BEM class name, not the descendants
    if(selector.indexOf(' ') != -1){
      selector = selector.split(' ')[0];
    }

    var BE = selector.split('__');
    var M = BE.pop().split('_');
    BE.push(M.shift());
    BE = BE.join('__');
    M = M[0];

    return {be: BE, m: M, selector: selector};
  };

  // Project configuration.
  grunt.config.merge({

    // Metadata.
    pkg: grunt.file.readJSON('package.json'),

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

    // https://github.com/gruntjs/grunt-contrib-connect
    connect: {
      bem: {
        options: {
          port: 9001,
          base: grunt.option('build-path') + '/bem',
          keepalive: true,
          open: true
        }
      },
      live: {
        options: {
          port: 9002,
          base: grunt.option('build-path') + '/live',
          keepalive: true,
          open: true
        }
      }
    },

    // https://github.com/gruntjs/grunt-contrib-clean
    clean: {
      options:{
        force: true
      },
      build: [grunt.option('build-path')],
      backup: [grunt.option('backup-path')],
      reset: [grunt.option('build-path'), grunt.option('source-path') + '/css/bem/**/*', grunt.option('source-path') + '/css/_all.scss', grunt.option('source-path') + '/css/bem_imports.scss']
    },

    // https://github.com/gruntjs/grunt-contrib-copy
    copy: {
      normalize: {
        src: 'bower_components/normalize.css/normalize.css',
        dest: grunt.option('source-path') + '/css/vendor/normalize.scss'
      },
      html5shiv: {
        src: 'bower_components/html5shiv/dist/html5shiv.min.js',
        dest: grunt.option('source-path') + '/scripts/vendor/html5shiv.min.js'
      },
      scripts: {
        files: [
          {expand: true, cwd: grunt.option('source-path') + '/scripts/', src: ['**/*'], dest: grunt.option('build-path') + '/live/scripts/', filter: 'isFile'},
          {expand: true, cwd: grunt.option('source-path') + '/scripts/', src: ['**/*'], dest: grunt.option('build-path') + '/bem/scripts/', filter: 'isFile'}
        ]
      },
      images: {
        files: [
          {expand: true, cwd: grunt.option('source-path') + '/images/', src: ['**/*'], dest: grunt.option('build-path') + '/live/images/', filter: 'isFile'},
          {expand: true, cwd: grunt.option('source-path') + '/images/', src: ['**/*'], dest: grunt.option('build-path') + '/bem/images/', filter: 'isFile'}
        ]
      },
      html: {
        src: grunt.option('build-path') + '/source/html/index.html',
        dest: grunt.option('build-path') + '/live/index.html'
      },
      live: {
        src: grunt.option('build-path') + '/source/css/index.source.prefixed.min.css',
        dest: grunt.option('build-path') + '/live/css/index.min.css'
      },
      bem: {
        src: grunt.option('build-path') + '/source/css/index.source.prefixed.css',
        dest: grunt.option('build-path') + '/bem/css/index.css'
      }
    },

    // https://www.npmjs.org/package/grunt-dom-munger
    dom_munger: {
      source_index: {
        options: {
          append: [
            {selector: 'head', html: '<link rel="stylesheet" href="/css/index.min.css">'},
            {selector: 'head', html: '<!--[if lt IE 9]><script src="/scripts/vendor/html5shiv.js"></script><![endif]-->'}
          ]
        },
        src: 'build/source/html/index.html'
      }
    },

    // https://www.npmjs.org/package/grunt-prettify
    prettify: {
      options: {
        'unformatted': []
      },
      all: {
        expand: true,
        cwd: grunt.option('build-path'),
        src: ['**/*.html'],
        dest: grunt.option('build-path')
      }
    },

    // https://github.com/gruntjs/grunt-contrib-sass
    sass: {
      dist: {
        files: [
          {expand: true, cwd: grunt.option('source-path'), src: ['index.scss'], dest: grunt.option('build-path') + '/source/css/', ext: '.source.css'},
          {expand: true, cwd: grunt.option('source-path') + '/css/', src: ['bem_imports.scss'], dest: grunt.option('build-path') + '/source/css/', ext: '.source.css'},
          {expand: true, cwd: grunt.option('source-path') + '/css/debug/', src: ['debug.scss'], dest: grunt.option('build-path') + '/bem/css/', ext: '.css'}
        ]
      }
    },

    // https://www.npmjs.org/package/grunt-autoprefixer
    autoprefixer: {
      index: {
        options: {},
        src: grunt.option('build-path') + '/source/css/index.source.css',
        dest: grunt.option('build-path') + '/source/css/index.source.prefixed.css',
      },
    },

    // https://github.com/gruntjs/grunt-contrib-cssmin
    cssmin: {
      index: {
        expand: true,
        files: {'<%= grunt.option("build-path") %>/source/css/index.source.prefixed.min.css': '<%= grunt.option("build-path") %>/source/css/index.source.prefixed.css'},
        options: {
          banner: '/* Minified with https://www.npmjs.org/package/grunt-contrib-cssmin */'
        }
      }
    },

    // https://www.npmjs.org/package/grunt-w3c-validation
    'css-validation': {
      options: {
        path: './doc/log/validation-css-status.json',
        reportpath: './doc/log/validation-css-report.json',
        stoponerror: false,
        relaxerror: [],
        profile: 'css3',
        medium: 'all',
        warnings: '2'
      },
      files: {
        src: [grunt.option('build-path') + '/source/css/*.css']
      }
    },

    'html-validation': {
      options: {
        path: './doc/log/validation-html-status.json',
        reportpath: './doc/log/validation-html-report.json',
        stoponerror: false,
        relaxerror: [] //ignores these errors
      },
      files: {
        src: [grunt.option('build-path') + '/live/index.html']
      }
    },

    // https://github.com/phamann/grunt-css-metrics
    cssmetrics: {
      index: {
        src: [grunt.option('build-path') + '/source/css/index.source.css']
      }
    },

    // https://github.com/gruntjs/grunt-contrib-watch
    watch: {
      html: {
        files: [grunt.option('source-path') + '/index.html'],
        tasks: ['vb-kabem']
      },
      sass: {
        files: [grunt.option('source-path') + '/**/**.scss'],
        tasks: ['vb-kabem']
      },
      css: {
        files: [grunt.option('source-path') + '/**/**.css'],
        tasks: ['copy:css']
      },
      grunt: {
        files: ['Gruntfile.js'],
        tasks: ['dev']
      },
      options: {
        livereload: true
      }
    },

    prompt: {
      reset: {
        options: {
          questions: [{
              config: 'reset',
              type: 'confirm',
              message: 'This will throw all your work out, are you sure?',
              default: true
            }
          ]
        }
      }
    },

    // https://github.com/gruntjs/grunt-contrib-watch
    githooks: {
      all: {
        // Will run the jshint and test:unit tasks at every commit
      }
    }

  });

  // what the task title says
  grunt.registerTask('do-reset', 'Clean working environment', function() {
    if(grunt.config('reset')){
      grunt.task.run('clean:reset');
    }
  });

  // load all custom tasks
  grunt.task.loadTasks('tasks');

  // https://www.npmjs.org/package/load-grunt-tasks
  require('load-grunt-tasks')(grunt, {config: __dirname + '/package.json'});

  grunt.registerTask('dev', ['vb-kabem']);
  grunt.registerTask('reset', ['prompt:reset', 'do-reset']);
  grunt.registerTask('validate', ['html-validation', 'cssmetrics', 'css-validation']);

  // WOW... loads!
  grunt.registerTask('vb-kabem', [
    'clean:build',                  // clean up folders
    'copy:normalize',               // copy a bower normalize package into the src/css/vendor
    'copy:html5shiv',               // copy a bower html5 shiv package into the src/script/vendor
    'copy:scripts',                 // copy any src scrips into build/../scrips
    'copy:images',                  // copy any src images into build/../scrips
    'parse-index',                  // add stub data to build/source/html/index.html using underscore templates
    'scaffold-sass',                // rip apart the build/source/html/index.html and create SASS files for each block/element and modifier in there
    'sass-imports',                 // generate a CSS file with all needed SASS @import's
    'sass',                         // SASS up the resulting build/source/css/index.source.css
    'autoprefixer',                 // prefix CSS shizzle
    'cssmin',                       // minify CSS shizzle
    'copy:html',                    // copy the build/source/html/index.html to build/live/index.html
    'dom_munger:source_index',      // create a index HTML file used the source for all other pages
    'copy:live',                    // copy a minified/prefixed CSS to the build/live
    'copy:bem',                     // the same for the build/bem pages
    'scaffold-bem',                 // generate testing pages for all defined BEM modifiers
    'prettify:all'                  // clean the resulting HTML up a bit
  ]);

};
<commit_msg>forgot one build path variable<commit_after>/*global module:false*/
module.exports = function(grunt) {
  var parentCWD = process.cwd();

  // http://stackoverflow.com/questions/17588466/grunt-task-dependencies
  process.chdir(__dirname);

  require('time-grunt')(grunt);

  // grunt.option.init() method overwrites the entire internal option state, https://github.com/gruntjs/grunt/issues/1023
  grunt.option('build-path', grunt.option('build-path') || parentCWD + '/build');
  grunt.option('source-path', grunt.option('source-path') || parentCWD + '/src');
  grunt.option('backup-path', grunt.option('backup-path') || parentCWD + '/backup');

  // Splits a CSS selector inti it's Block, Element and Modifier parts
  grunt.splitBEM = function(selector){
    if(selector.indexOf('.') == 0){
      selector = selector.substring(1);
    }

    // Only get the main BEM class name, not the descendants
    if(selector.indexOf(' ') != -1){
      selector = selector.split(' ')[0];
    }

    var BE = selector.split('__');
    var M = BE.pop().split('_');
    BE.push(M.shift());
    BE = BE.join('__');
    M = M[0];

    return {be: BE, m: M, selector: selector};
  };

  // Project configuration.
  grunt.config.merge({

    // Metadata.
    pkg: grunt.file.readJSON('package.json'),

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

    // https://github.com/gruntjs/grunt-contrib-connect
    connect: {
      bem: {
        options: {
          port: 9001,
          base: grunt.option('build-path') + '/bem',
          keepalive: true,
          open: true
        }
      },
      live: {
        options: {
          port: 9002,
          base: grunt.option('build-path') + '/live',
          keepalive: true,
          open: true
        }
      }
    },

    // https://github.com/gruntjs/grunt-contrib-clean
    clean: {
      options:{
        force: true
      },
      build: [grunt.option('build-path')],
      backup: [grunt.option('backup-path')],
      reset: [grunt.option('build-path'), grunt.option('source-path') + '/css/bem/**/*', grunt.option('source-path') + '/css/_all.scss', grunt.option('source-path') + '/css/bem_imports.scss']
    },

    // https://github.com/gruntjs/grunt-contrib-copy
    copy: {
      normalize: {
        src: 'bower_components/normalize.css/normalize.css',
        dest: grunt.option('source-path') + '/css/vendor/normalize.scss'
      },
      html5shiv: {
        src: 'bower_components/html5shiv/dist/html5shiv.min.js',
        dest: grunt.option('source-path') + '/scripts/vendor/html5shiv.min.js'
      },
      scripts: {
        files: [
          {expand: true, cwd: grunt.option('source-path') + '/scripts/', src: ['**/*'], dest: grunt.option('build-path') + '/live/scripts/', filter: 'isFile'},
          {expand: true, cwd: grunt.option('source-path') + '/scripts/', src: ['**/*'], dest: grunt.option('build-path') + '/bem/scripts/', filter: 'isFile'}
        ]
      },
      images: {
        files: [
          {expand: true, cwd: grunt.option('source-path') + '/images/', src: ['**/*'], dest: grunt.option('build-path') + '/live/images/', filter: 'isFile'},
          {expand: true, cwd: grunt.option('source-path') + '/images/', src: ['**/*'], dest: grunt.option('build-path') + '/bem/images/', filter: 'isFile'}
        ]
      },
      html: {
        src: grunt.option('build-path') + '/source/html/index.html',
        dest: grunt.option('build-path') + '/live/index.html'
      },
      live: {
        src: grunt.option('build-path') + '/source/css/index.source.prefixed.min.css',
        dest: grunt.option('build-path') + '/live/css/index.min.css'
      },
      bem: {
        src: grunt.option('build-path') + '/source/css/index.source.prefixed.css',
        dest: grunt.option('build-path') + '/bem/css/index.css'
      }
    },

    // https://www.npmjs.org/package/grunt-dom-munger
    dom_munger: {
      source_index: {
        options: {
          append: [
            {selector: 'head', html: '<link rel="stylesheet" href="/css/index.min.css">'},
            {selector: 'head', html: '<!--[if lt IE 9]><script src="/scripts/vendor/html5shiv.js"></script><![endif]-->'}
          ]
        },
        src: grunt.option('build-path') + '/source/html/index.html'
      }
    },

    // https://www.npmjs.org/package/grunt-prettify
    prettify: {
      options: {
        'unformatted': []
      },
      all: {
        expand: true,
        cwd: grunt.option('build-path'),
        src: ['**/*.html'],
        dest: grunt.option('build-path')
      }
    },

    // https://github.com/gruntjs/grunt-contrib-sass
    sass: {
      dist: {
        files: [
          {expand: true, cwd: grunt.option('source-path'), src: ['index.scss'], dest: grunt.option('build-path') + '/source/css/', ext: '.source.css'},
          {expand: true, cwd: grunt.option('source-path') + '/css/', src: ['bem_imports.scss'], dest: grunt.option('build-path') + '/source/css/', ext: '.source.css'},
          {expand: true, cwd: grunt.option('source-path') + '/css/debug/', src: ['debug.scss'], dest: grunt.option('build-path') + '/bem/css/', ext: '.css'}
        ]
      }
    },

    // https://www.npmjs.org/package/grunt-autoprefixer
    autoprefixer: {
      index: {
        options: {},
        src: grunt.option('build-path') + '/source/css/index.source.css',
        dest: grunt.option('build-path') + '/source/css/index.source.prefixed.css',
      },
    },

    // https://github.com/gruntjs/grunt-contrib-cssmin
    cssmin: {
      index: {
        expand: true,
        files: {'<%= grunt.option("build-path") %>/source/css/index.source.prefixed.min.css': '<%= grunt.option("build-path") %>/source/css/index.source.prefixed.css'},
        options: {
          banner: '/* Minified with https://www.npmjs.org/package/grunt-contrib-cssmin */'
        }
      }
    },

    // https://www.npmjs.org/package/grunt-w3c-validation
    'css-validation': {
      options: {
        path: './doc/log/validation-css-status.json',
        reportpath: './doc/log/validation-css-report.json',
        stoponerror: false,
        relaxerror: [],
        profile: 'css3',
        medium: 'all',
        warnings: '2'
      },
      files: {
        src: [grunt.option('build-path') + '/source/css/*.css']
      }
    },

    'html-validation': {
      options: {
        path: './doc/log/validation-html-status.json',
        reportpath: './doc/log/validation-html-report.json',
        stoponerror: false,
        relaxerror: [] //ignores these errors
      },
      files: {
        src: [grunt.option('build-path') + '/live/index.html']
      }
    },

    // https://github.com/phamann/grunt-css-metrics
    cssmetrics: {
      index: {
        src: [grunt.option('build-path') + '/source/css/index.source.css']
      }
    },

    // https://github.com/gruntjs/grunt-contrib-watch
    watch: {
      html: {
        files: [grunt.option('source-path') + '/index.html'],
        tasks: ['vb-kabem']
      },
      sass: {
        files: [grunt.option('source-path') + '/**/**.scss'],
        tasks: ['vb-kabem']
      },
      css: {
        files: [grunt.option('source-path') + '/**/**.css'],
        tasks: ['copy:css']
      },
      grunt: {
        files: ['Gruntfile.js'],
        tasks: ['dev']
      },
      options: {
        livereload: true
      }
    },

    prompt: {
      reset: {
        options: {
          questions: [{
              config: 'reset',
              type: 'confirm',
              message: 'This will throw all your work out, are you sure?',
              default: true
            }
          ]
        }
      }
    },

    // https://github.com/gruntjs/grunt-contrib-watch
    githooks: {
      all: {
        // Will run the jshint and test:unit tasks at every commit
      }
    }

  });

  // what the task title says
  grunt.registerTask('do-reset', 'Clean working environment', function() {
    if(grunt.config('reset')){
      grunt.task.run('clean:reset');
    }
  });

  // load all custom tasks
  grunt.task.loadTasks('tasks');

  // https://www.npmjs.org/package/load-grunt-tasks
  require('load-grunt-tasks')(grunt, {config: __dirname + '/package.json'});

  grunt.registerTask('dev', ['vb-kabem']);
  grunt.registerTask('reset', ['prompt:reset', 'do-reset']);
  grunt.registerTask('validate', ['html-validation', 'cssmetrics', 'css-validation']);

  // WOW... loads!
  grunt.registerTask('vb-kabem', [
    'clean:build',                  // clean up folders
    'copy:normalize',               // copy a bower normalize package into the src/css/vendor
    'copy:html5shiv',               // copy a bower html5 shiv package into the src/script/vendor
    'copy:scripts',                 // copy any src scrips into build/../scrips
    'copy:images',                  // copy any src images into build/../scrips
    'parse-index',                  // add stub data to build/source/html/index.html using underscore templates
    'scaffold-sass',                // rip apart the build/source/html/index.html and create SASS files for each block/element and modifier in there
    'sass-imports',                 // generate a CSS file with all needed SASS @import's
    'sass',                         // SASS up the resulting build/source/css/index.source.css
    'autoprefixer',                 // prefix CSS shizzle
    'cssmin',                       // minify CSS shizzle
    'copy:html',                    // copy the build/source/html/index.html to build/live/index.html
    'dom_munger:source_index',      // create a index HTML file used the source for all other pages
    'copy:live',                    // copy a minified/prefixed CSS to the build/live
    'copy:bem',                     // the same for the build/bem pages
    'scaffold-bem',                 // generate testing pages for all defined BEM modifiers
    'prettify:all'                  // clean the resulting HTML up a bit
  ]);

};
<|endoftext|>


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

    grunt.initConfig( {
        pkg: grunt.file.readJSON( "package.json" ),
        watch: {
            scripts: {
                files: [ "angular-skycons.js" ],
                tasks: [ "uglify" ]
            }
        },
        uglify: {
            options: {
                mangle: true,
                compress: true
            },
            project: {
                files: {
                    "angular-skycons.min.js": [ "angular-skycons.js" ]
                }
            }
        }

    } );

    grunt.loadNpmTasks( "grunt-contrib-watch" );
    grunt.loadNpmTasks( "grunt-contrib-uglify" );

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

};
<commit_msg>Concat and minify with skycons<commit_after>module.exports = function ( grunt ) {

    grunt.initConfig( {
        pkg: grunt.file.readJSON( "package.json" ),
        watch: {
            scripts: {
                files: [ "angular-skycons.js" ],
                tasks: [ "uglify" ]
            }
        },
        uglify: {
            options: {
                mangle: true,
                compress: true
            },
            project: {
                files: {
                    "angular-skycons.min.js": [
                        "tmp/angular-skycons.concat.js"
                    ]
                }
            }
        },
        concat: {
            scripts: {
                src: [
                    "bower_components/skycons/skycons.js",
                    "angular-skycons.js"
                ],
                dest: "tmp/angular-skycons.concat.js"
            },
        }

    } );

    grunt.loadNpmTasks( "grunt-contrib-watch" );
    grunt.loadNpmTasks( "grunt-contrib-uglify" );
    grunt.loadNpmTasks( "grunt-contrib-concat" );

    grunt.registerTask( "default", [ "concat", "uglify" ] );

};
<|endoftext|>


<commit_before>/*
	The MIT License (MIT)

	Copyright (c) 2014 Julian Xhokaxhiu

	Permission is hereby granted, free of charge, to any person obtaining a copy
	of this software and associated documentation files (the "Software"), to deal
	in the Software without restriction, including without limitation the rights
	to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
	copies of the Software, and to permit persons to whom the Software is
	furnished to do so, subject to the following conditions:

	The above copyright notice and this permission notice shall be included in all
	copies or substantial portions of the Software.

	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
	OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
	SOFTWARE.
*/
module.exports = function(grunt) {

	var extend = require('node.extend'),
    	app = grunt.file.readJSON('app.json'),
        appExists = function(name) {
            var ret = false;
            ret = grunt.file.exists('app/' + name);
            return ret;
        },
        pathExistsInApp = function(path) {
            var ret = false;

            if (grunt.file.exists(app.path + '/tpl/' + path))
                ret = path;

            return ret;
        },
        getResourcePath = function() {
        	return app.path + '/rsc/';
        },
        getFullPath = function(path) {
        	if ( path === undefined ) path = '';
        	else path = path + '/';
            return app.path + '/tpl/' + path;
        },
        getFontsPath = function() {
        	return app.path + '/fonts/';
        },
        getWebFontsPath = function() {
        	return app.path + '/webfonts/';
        },
        getIconsPath = function() {
        	return app.path + '/icons/';
        },
        getWebIconsPath = function() {
        	return app.path + '/webicons/';
        },
        getAppConfig = function() {
            var ret = {
                name: app.name,
                liveReloadHost: app.liveReloadHost,
                cssFiles: {
                    'screen': grunt.file.expand({
                        filter: 'isFile',
                        cwd: getFullPath()
                    }, app.cssPath),
                    'print': grunt.file.expand({
                        filter: 'isFile',
                        cwd: getFullPath()
                    }, app.cssPrintPath)
                },
                jsFiles: [
                	app.jsMin
                ]
            };

            if ( ['build_deploy','deploy'].indexOf(app.command) > -1 ) {
                ret.liveReloadHost = false;
                ret.cssFiles = {
                    'screen': [app.cssMin],
                    'print': [app.cssPrintMin]
                };
                ret.jsFiles = [app.jsMin];
            }

            if ( grunt.file.exists( app.path + '/data.json' ) )
                ret.data = grunt.file.readJSON( app.path + '/data.json' );

            return ret;
        },
        setAppConfig = function(command, config) {
            // Initialize with required data for extension
            app.path = 'app/' + config.name;

            // Extend with app configuration
            if ( grunt.file.exists( app.path + '/config.json' ) )
                app = extend( app, grunt.file.readJSON( app.path + '/config.json' ) );

            // Continue setting our core app data
            app.command = command;
            app.name = config.name;
            app.cssMin = 'css/' + config.name + '.min.css';
            app.cssPath = 'css/**/*.css';
            app.cssMapPath = 'css/**/*.map';
            app.scssPath = 'scss/screen.scss';
            app.cssPrintMin = 'css/' + config.name + '.min.print.css';
            app.cssPrintPath = 'css-print/**/*.css';
            app.cssPrintMapPath = 'css-print/**/*.map';
            app.scssPrintPath = 'scss/print.scss';
            app.jsMin = 'js/' + config.name + '.min.js';
            app.jsPath = 'js/**/*.js';
            app.cssConfigFiles = {}
            app.cssConfigFiles[app.wwwPath + app.cssMin] = [ getFullPath() + app.cssPath ];
            app.cssConfigFiles[app.wwwPath + app.cssPrintMin] = [ getFullPath() + app.cssPrintPath ];
            app.scssConfigFiles = {}
            app.scssConfigFiles[ getFullPath('css') + '99_' + app.name + '.css' ] = [ getFullPath() + app.scssPath ];
            app.scssConfigFiles[ getFullPath('css-print') + '99_' + app.name + '.css' ] = [ getFullPath() + app.scssPrintPath ];
            app.jsExternalLibraries = [
            	'bower_components/bootstrap-sass-official/assets/javascripts/bootstrap.js'
            ];
            app.jsConfigFiles = {}
            app.jsConfigFiles[ app.wwwPath + app.jsMin ] = app.jsExternalLibraries.concat( [ getFullPath() + app.jsPath ] );
            app.fontConfigFiles = {}
            app.fontConfigFiles[ getWebFontsPath() ] = [
            	getFontsPath() + '*.otf',
				getFontsPath() + '*.ttf'
            ];
            app.webFontConfigFiles = {};
            app.webFontConfigFiles[ getFullPath('css') + '98_webfonts.css' ] = [
            	getWebFontsPath() + '*.css'
            ];
            app.webFontConfigFiles[ getFullPath('css-print') + '98_webfonts.css' ] = [
            	getWebFontsPath() + '*.css'
            ];
            app.iconsConfigFiles = {}
            app.iconsConfigFiles[ getWebIconsPath() ] = [
            	getIconsPath() + '*.svg'
            ];

            // Configure the tasks
            grunt.initConfig({
                pkg: grunt.file.readJSON('package.json'),
                clean: {
                    options: {
                        force: true
                    },
                    www: [
                        app.wwwPath + '*',
                        getFullPath('scss') + '_' + app.name + '-icons.scss'
                    ],
                    cssFiles: [
                        getFullPath('css') + '99_' + app.name + '.css',
                        getFullPath('css-print') + '99_' + app.name + '.css'
                    ],
                    mapFiles: [
                    	getFullPath('css') + '*.map',
                        getFullPath('css-print') + '*.map',
                    ],
                    webfonts: [
                    	getWebFontsPath()
                    ],
                    webicons: [
                    	getWebIconsPath()
                    ]
                },
                tasty_swig: {
                	options: {
                		context: {
                			app: getAppConfig()
                		}
                	},
                	build: {
						src: [ getFullPath() + '*.swig' ],
						dest: app.wwwPath
					}
                },
				sass: {
					build: {
						files: app.scssConfigFiles
					},
					deploy: {
						files: app.scssConfigFiles
					},
				},
				fontgen: {
					build: {
						options: {
							path_prefix: '../fonts/'
						},
						files: app.fontConfigFiles
					}
				},
				webfont: {
					icons: {
						src: getIconsPath() + '*.svg',
						dest: getWebIconsPath(),
                        destCss: getFullPath('scss'),
						options: {
                            relativeFontPath: '../fonts/',
							font: app.name + '-icons',
                            stylesheet: 'scss',
                            htmlDemo: false,
                            templateOptions: {
                                baseClass: app.name + '-icon',
                                classPrefix: app.name + '-icon-',
                                mixinPrefix: app.name + '-icon-'
                            }
						}
					}
				},
                concat: {
                	webfonts: {
                		files: app.webFontConfigFiles
                	},
                    css: {
                        filter: 'isFile',
                        src: getFullPath( app.cssPath ),
                        dest: app.wwwPath + app.cssMin
                    },
                    cssPrint: {
                        filter: 'isFile',
                        src: getFullPath( app.cssPrintPath ),
                        dest: app.wwwPath + app.cssPrintMin
                    },
                    js: {
                    	files: app.jsConfigFiles
                    }
                },
                autoprefixer: {
                    options: {
                        map: true,
                        browsers: ['last 3 versions', 'bb 10', 'android 3']
                    },
                    build: {
                        src: app.wwwPath + 'css/*.css'
                    },
                },
                cssmin: {
                    build: {
                        files: app.cssConfigFiles
                    }
                },
                closurecompiler: {
                    build: {
                    	files: app.jsConfigFiles,
                    	options: {
			                // Any options supported by Closure Compiler, for example:
			                "compilation_level": "SIMPLE_OPTIMIZATIONS",

			                // Plus a simultaneous processes limit
			                "max_processes": 5,
			            }
                    }
                },
                copy: {
                    build: {
                        files: [
	                        // The project CSS and JS files
	                        {
	                            expand: true,
	                            cwd: getFullPath(),
	                            src: [
	                                app.cssPath,
	                                app.cssPrintPath,
	                                app.cssMapPath,
	                                app.cssPrintMapPath,
	                                app.jsPath
	                            ],
	                            dest: app.wwwPath
	                        }
                        ]
                    },
                    deploy: {
                        files: [
                        	// External Packages Fonts
                        	{
                        		expand: true,
                        		flatten: true,
                        		cwd: 'bower_components/',
                        		src: ['**/*.{ttf,woff,eot,svg,otf}'],
                        		dest: app.wwwPath + '/fonts/'
                        	},
                        	// The project Webfonts
                        	{
                        		expand: true,
                        		flatten: true,
                        		cwd: getWebFontsPath(),
                        		src: ['**/*.{ttf,woff,eot,svg,otf}'],
                        		dest: app.wwwPath + '/fonts/'
                        	},
                        	// The project Webicons
                        	{
                        		expand: true,
                        		flatten: true,
                        		cwd: getWebIconsPath(),
                        		src: ['**/*.{ttf,woff,eot,svg,otf}'],
                        		dest: app.wwwPath + '/fonts/'
                        	},
                        	// Webicons sass generated file
                        	{
                                expand: true,
                                cwd: getWebIconsPath(),
                                src: [
                                    '*.scss'
                                ],
                                dest: getFullPath('scss')
                            },
                        	// The project resource files
	                        {
	                            expand: true,
	                            cwd: getResourcePath(),
	                            src: ['**'],
	                            dest: app.wwwPath
	                        }
                        ]
                    },
                    make: {
                        files: [{
                            expand: true,
                            cwd: '_apptpl/',
                            src: ['**'],
                            dest: app.path
                        }]
                    }
                },
                watch: {
                    html: {
                        options: {
                            livereload: app.liveReloadPort
                        },
                        files: [
                            getFullPath() + '**/*.swig',
                            app.path + '/data.json'
                        ],
                        tasks: [
                        	'rebuild:' + app.name + ':html'
                        ]
                    },
                    css: {
                        options: {
                            livereload: app.liveReloadPort
                        },
                        files: [
                            getFullPath() + '**/*.scss',
                        ],
                        tasks: [
                            'rebuild:' + app.name + ':css'
                        ]
                    },
                    js: {
                        options: {
                            livereload: app.liveReloadPort
                        },
                        files: [
                            getFullPath() + '**/*.js'
                        ],
                        tasks: [
                            'rebuild:' + app.name + ':js'
                        ]
                    }
                },
                rsync: {
                    options: {
                        recursive: true
                    },
                    deploy: {
                        options: {
                            src: app.wwwPath,
                            dest: app.deployPath,
                            host: app.deployHost
                        }
                    }
                }
            });
        };

    // Load Tasks
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-contrib-sass');
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-yui-compressor');
    grunt.loadNpmTasks('grunt-closurecompiler');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-tasty-swig');
    grunt.loadNpmTasks('grunt-autoprefixer');
    grunt.loadNpmTasks('grunt-rsync');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-fontgen');
    grunt.loadNpmTasks('grunt-webfont');

    grunt.registerTask('default', 'Gruntfile for Mockups', function() {
        grunt.warn('No project name specified.\n\nAvailable commands:\n"build:project_name"\n"deploy:project_name"\n"make:project_name"\n');
    });

    grunt.registerTask('build', 'Build a mockup and watch for file modifications', function ( name ) {
        if (appExists(name)) {
            setAppConfig(this.name, {
                name: name
            });
            grunt.task.run([
                'rebuild:' + name,
                'watch'
            ]);
        } else
            grunt.warn('[' + name + '] does not exist. Have you typed it correctly?\n');
    });

    grunt.registerTask('rebuild', 'Build a mockup without watching for file modifications', function ( name, watchTask ) {
        if (appExists(name)) {
            var tasks = [];
            if ( watchTask === undefined ) watchTask = 'all';

            if ( watchTask == 'all' ) {
                tasks = tasks.concat([
                    'clean',
                    'fontgen',
                    'webfont',
                    'concat:webfonts',
                    'sass:build',
                    'concat:js',
                    'tasty_swig',
                    'copy:deploy',
                    'copy:build',
                    'autoprefixer',
                    'clean:mapFiles',
                    'clean:webfonts',
                    'clean:webicons'
                ]);
            } else if ( watchTask == 'html' ) {
                tasks = tasks.concat([
                    'tasty_swig',
                    'copy:deploy',
                    'copy:build'
                ]);
            } else if ( watchTask == 'css' ) {
                tasks = tasks.concat([
                    'clean:cssFiles',
                    'sass:build',
                    'copy:deploy',
                    'copy:build',
                    'autoprefixer'
                ]);
            } else if ( watchTask == 'js' ) {
                tasks = tasks.concat([
                    'concat:js',
                    'copy:deploy',
                    'copy:build'
                ]);
            }

            setAppConfig(this.name, {
                name: name
            });
            grunt.task.run(tasks);
        } else
            grunt.warn('[' + name + '] does not exist. Have you typed it correctly?\n');
    });

    grunt.registerTask('build_deploy', 'Build a mockup ready for deployment sync', function ( name ) {
        if (appExists(name)) {
            setAppConfig(this.name, {
                name: name
            });
            grunt.task.run([
                'clean',
                'fontgen',
                'webfont',
                'concat:webfonts',
                'sass:deploy',
                'concat:css',
                'concat:cssPrint',
                'cssmin',
                'closurecompiler',
                'tasty_swig',
                'copy:deploy',
                'autoprefixer',
                'clean:mapFiles',
                'clean:webfonts',
                'clean:webicons'
            ]);
        } else
            grunt.warn('[' + name + '] does not exist. Have you typed it correctly?\n');
    });

    grunt.registerTask('deploy', 'Deploy a mockup to the Mockups Server', function ( name ) {
    	if (appExists(name)) {
            setAppConfig(this.name, {
                name: name
            });
            grunt.task.run([
                'build_deploy:' + name,
                'rsync:deploy'
            ]);
        } else
            grunt.warn('[' + name + '] does not exist. Have you typed it correctly?\n');
    });

    grunt.registerTask('make', 'Create a new mockup folder based on a template', function ( name ) {
        if (!appExists(name)) {
            setAppConfig(this.name, {
                name: name
            });
            grunt.task.run([
                'copy:make'
            ]);
        } else
            grunt.warn('[' + name + '] already exists. Please use another name.\n');
    });
};
<commit_msg>Add timestamps to minified files.<commit_after>/*
	The MIT License (MIT)

	Copyright (c) 2014 Julian Xhokaxhiu

	Permission is hereby granted, free of charge, to any person obtaining a copy
	of this software and associated documentation files (the "Software"), to deal
	in the Software without restriction, including without limitation the rights
	to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
	copies of the Software, and to permit persons to whom the Software is
	furnished to do so, subject to the following conditions:

	The above copyright notice and this permission notice shall be included in all
	copies or substantial portions of the Software.

	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
	OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
	SOFTWARE.
*/
module.exports = function(grunt) {

	var extend = require('node.extend'),
    	app = grunt.file.readJSON('app.json'),
        appExists = function(name) {
            var ret = false;
            ret = grunt.file.exists('app/' + name);
            return ret;
        },
        pathExistsInApp = function(path) {
            var ret = false;

            if (grunt.file.exists(app.path + '/tpl/' + path))
                ret = path;

            return ret;
        },
        getResourcePath = function() {
        	return app.path + '/rsc/';
        },
        getFullPath = function(path) {
        	if ( path === undefined ) path = '';
        	else path = path + '/';
            return app.path + '/tpl/' + path;
        },
        getFontsPath = function() {
        	return app.path + '/fonts/';
        },
        getWebFontsPath = function() {
        	return app.path + '/webfonts/';
        },
        getIconsPath = function() {
        	return app.path + '/icons/';
        },
        getWebIconsPath = function() {
        	return app.path + '/webicons/';
        },
        getAppConfig = function() {
            var ret = {
                name: app.name,
                liveReloadHost: app.liveReloadHost,
                cssFiles: {
                    'screen': grunt.file.expand({
                        filter: 'isFile',
                        cwd: getFullPath()
                    }, app.cssPath),
                    'print': grunt.file.expand({
                        filter: 'isFile',
                        cwd: getFullPath()
                    }, app.cssPrintPath)
                },
                jsFiles: [
                	app.jsMin
                ]
            };

            if ( ['build_deploy','deploy'].indexOf(app.command) > -1 ) {
                ret.liveReloadHost = false;
                ret.cssFiles = {
                    'screen': [app.cssMin],
                    'print': [app.cssPrintMin]
                };
                ret.jsFiles = [app.jsMin];
            }

            if ( grunt.file.exists( app.path + '/data.json' ) )
                ret.data = grunt.file.readJSON( app.path + '/data.json' );

            return ret;
        },
        setAppConfig = function(command, config) {
            // Initialize with required data for extension
            app.path = 'app/' + config.name;

            // Extend with app configuration
            if ( grunt.file.exists( app.path + '/config.json' ) )
                app = extend( app, grunt.file.readJSON( app.path + '/config.json' ) );

            // Continue setting our core app data
            app.command = command;
            app.name = config.name;
            app.cssMin = 'css/' + config.name + '.min.' + Date.now() + '.css';
            app.cssPath = 'css/**/*.css';
            app.cssMapPath = 'css/**/*.map';
            app.scssPath = 'scss/screen.scss';
            app.cssPrintMin = 'css/' + config.name + '.min.' + Date.now() + '.print.css';
            app.cssPrintPath = 'css-print/**/*.css';
            app.cssPrintMapPath = 'css-print/**/*.map';
            app.scssPrintPath = 'scss/print.scss';
            app.jsMin = 'js/' + config.name + '.min.' + Date.now() + '.js';
            app.jsPath = 'js/**/*.js';
            app.cssConfigFiles = {}
            app.cssConfigFiles[app.wwwPath + app.cssMin] = [ getFullPath() + app.cssPath ];
            app.cssConfigFiles[app.wwwPath + app.cssPrintMin] = [ getFullPath() + app.cssPrintPath ];
            app.scssConfigFiles = {}
            app.scssConfigFiles[ getFullPath('css') + '99_' + app.name + '.css' ] = [ getFullPath() + app.scssPath ];
            app.scssConfigFiles[ getFullPath('css-print') + '99_' + app.name + '.css' ] = [ getFullPath() + app.scssPrintPath ];
            app.jsExternalLibraries = [
            	'bower_components/bootstrap-sass-official/assets/javascripts/bootstrap.js'
            ];
            app.jsConfigFiles = {}
            app.jsConfigFiles[ app.wwwPath + app.jsMin ] = app.jsExternalLibraries.concat( [ getFullPath() + app.jsPath ] );
            app.fontConfigFiles = {}
            app.fontConfigFiles[ getWebFontsPath() ] = [
            	getFontsPath() + '*.otf',
				getFontsPath() + '*.ttf'
            ];
            app.webFontConfigFiles = {};
            app.webFontConfigFiles[ getFullPath('css') + '98_webfonts.css' ] = [
            	getWebFontsPath() + '*.css'
            ];
            app.webFontConfigFiles[ getFullPath('css-print') + '98_webfonts.css' ] = [
            	getWebFontsPath() + '*.css'
            ];
            app.iconsConfigFiles = {}
            app.iconsConfigFiles[ getWebIconsPath() ] = [
            	getIconsPath() + '*.svg'
            ];

            // Configure the tasks
            grunt.initConfig({
                pkg: grunt.file.readJSON('package.json'),
                clean: {
                    options: {
                        force: true
                    },
                    www: [
                        app.wwwPath + '*',
                        getFullPath('scss') + '_' + app.name + '-icons.scss'
                    ],
                    cssFiles: [
                        getFullPath('css') + '99_' + app.name + '.css',
                        getFullPath('css-print') + '99_' + app.name + '.css'
                    ],
                    mapFiles: [
                    	getFullPath('css') + '*.map',
                        getFullPath('css-print') + '*.map',
                    ],
                    webfonts: [
                    	getWebFontsPath()
                    ],
                    webicons: [
                    	getWebIconsPath()
                    ]
                },
                tasty_swig: {
                	options: {
                		context: {
                			app: getAppConfig()
                		}
                	},
                	build: {
						src: [ getFullPath() + '*.swig' ],
						dest: app.wwwPath
					}
                },
				sass: {
					build: {
						files: app.scssConfigFiles
					},
					deploy: {
						files: app.scssConfigFiles
					},
				},
				fontgen: {
					build: {
						options: {
							path_prefix: '../fonts/'
						},
						files: app.fontConfigFiles
					}
				},
				webfont: {
					icons: {
						src: getIconsPath() + '*.svg',
						dest: getWebIconsPath(),
                        destCss: getFullPath('scss'),
						options: {
                            relativeFontPath: '../fonts/',
							font: app.name + '-icons',
                            stylesheet: 'scss',
                            htmlDemo: false,
                            templateOptions: {
                                baseClass: app.name + '-icon',
                                classPrefix: app.name + '-icon-',
                                mixinPrefix: app.name + '-icon-'
                            }
						}
					}
				},
                concat: {
                	webfonts: {
                		files: app.webFontConfigFiles
                	},
                    css: {
                        filter: 'isFile',
                        src: getFullPath( app.cssPath ),
                        dest: app.wwwPath + app.cssMin
                    },
                    cssPrint: {
                        filter: 'isFile',
                        src: getFullPath( app.cssPrintPath ),
                        dest: app.wwwPath + app.cssPrintMin
                    },
                    js: {
                    	files: app.jsConfigFiles
                    }
                },
                autoprefixer: {
                    options: {
                        map: true,
                        browsers: ['last 3 versions', 'bb 10', 'android 3']
                    },
                    build: {
                        src: app.wwwPath + 'css/*.css'
                    },
                },
                cssmin: {
                    build: {
                        files: app.cssConfigFiles
                    }
                },
                closurecompiler: {
                    build: {
                    	files: app.jsConfigFiles,
                    	options: {
			                // Any options supported by Closure Compiler, for example:
			                "compilation_level": "SIMPLE_OPTIMIZATIONS",

			                // Plus a simultaneous processes limit
			                "max_processes": 5,
			            }
                    }
                },
                copy: {
                    build: {
                        files: [
	                        // The project CSS and JS files
	                        {
	                            expand: true,
	                            cwd: getFullPath(),
	                            src: [
	                                app.cssPath,
	                                app.cssPrintPath,
	                                app.cssMapPath,
	                                app.cssPrintMapPath,
	                                app.jsPath
	                            ],
	                            dest: app.wwwPath
	                        }
                        ]
                    },
                    deploy: {
                        files: [
                        	// External Packages Fonts
                        	{
                        		expand: true,
                        		flatten: true,
                        		cwd: 'bower_components/',
                        		src: ['**/*.{ttf,woff,eot,svg,otf}'],
                        		dest: app.wwwPath + '/fonts/'
                        	},
                        	// The project Webfonts
                        	{
                        		expand: true,
                        		flatten: true,
                        		cwd: getWebFontsPath(),
                        		src: ['**/*.{ttf,woff,eot,svg,otf}'],
                        		dest: app.wwwPath + '/fonts/'
                        	},
                        	// The project Webicons
                        	{
                        		expand: true,
                        		flatten: true,
                        		cwd: getWebIconsPath(),
                        		src: ['**/*.{ttf,woff,eot,svg,otf}'],
                        		dest: app.wwwPath + '/fonts/'
                        	},
                        	// Webicons sass generated file
                        	{
                                expand: true,
                                cwd: getWebIconsPath(),
                                src: [
                                    '*.scss'
                                ],
                                dest: getFullPath('scss')
                            },
                        	// The project resource files
	                        {
	                            expand: true,
	                            cwd: getResourcePath(),
	                            src: ['**'],
	                            dest: app.wwwPath
	                        }
                        ]
                    },
                    make: {
                        files: [{
                            expand: true,
                            cwd: '_apptpl/',
                            src: ['**'],
                            dest: app.path
                        }]
                    }
                },
                watch: {
                    html: {
                        options: {
                            livereload: app.liveReloadPort
                        },
                        files: [
                            getFullPath() + '**/*.swig',
                            app.path + '/data.json'
                        ],
                        tasks: [
                        	'rebuild:' + app.name + ':html'
                        ]
                    },
                    css: {
                        options: {
                            livereload: app.liveReloadPort
                        },
                        files: [
                            getFullPath() + '**/*.scss',
                        ],
                        tasks: [
                            'rebuild:' + app.name + ':css'
                        ]
                    },
                    js: {
                        options: {
                            livereload: app.liveReloadPort
                        },
                        files: [
                            getFullPath() + '**/*.js'
                        ],
                        tasks: [
                            'rebuild:' + app.name + ':js'
                        ]
                    }
                },
                rsync: {
                    options: {
                        recursive: true
                    },
                    deploy: {
                        options: {
                            src: app.wwwPath,
                            dest: app.deployPath,
                            host: app.deployHost
                        }
                    }
                }
            });
        };

    // Load Tasks
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-contrib-sass');
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-yui-compressor');
    grunt.loadNpmTasks('grunt-closurecompiler');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-tasty-swig');
    grunt.loadNpmTasks('grunt-autoprefixer');
    grunt.loadNpmTasks('grunt-rsync');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-fontgen');
    grunt.loadNpmTasks('grunt-webfont');

    grunt.registerTask('default', 'Gruntfile for Mockups', function() {
        grunt.warn('No project name specified.\n\nAvailable commands:\n"build:project_name"\n"deploy:project_name"\n"make:project_name"\n');
    });

    grunt.registerTask('build', 'Build a mockup and watch for file modifications', function ( name ) {
        if (appExists(name)) {
            setAppConfig(this.name, {
                name: name
            });
            grunt.task.run([
                'rebuild:' + name,
                'watch'
            ]);
        } else
            grunt.warn('[' + name + '] does not exist. Have you typed it correctly?\n');
    });

    grunt.registerTask('rebuild', 'Build a mockup without watching for file modifications', function ( name, watchTask ) {
        if (appExists(name)) {
            var tasks = [];
            if ( watchTask === undefined ) watchTask = 'all';

            if ( watchTask == 'all' ) {
                tasks = tasks.concat([
                    'clean',
                    'fontgen',
                    'webfont',
                    'concat:webfonts',
                    'sass:build',
                    'concat:js',
                    'tasty_swig',
                    'copy:deploy',
                    'copy:build',
                    'autoprefixer',
                    'clean:mapFiles',
                    'clean:webfonts',
                    'clean:webicons'
                ]);
            } else if ( watchTask == 'html' ) {
                tasks = tasks.concat([
                    'tasty_swig',
                    'copy:deploy',
                    'copy:build'
                ]);
            } else if ( watchTask == 'css' ) {
                tasks = tasks.concat([
                    'clean:cssFiles',
                    'sass:build',
                    'copy:deploy',
                    'copy:build',
                    'autoprefixer'
                ]);
            } else if ( watchTask == 'js' ) {
                tasks = tasks.concat([
                    'concat:js',
                    'copy:deploy',
                    'copy:build'
                ]);
            }

            setAppConfig(this.name, {
                name: name
            });
            grunt.task.run(tasks);
        } else
            grunt.warn('[' + name + '] does not exist. Have you typed it correctly?\n');
    });

    grunt.registerTask('build_deploy', 'Build a mockup ready for deployment sync', function ( name ) {
        if (appExists(name)) {
            setAppConfig(this.name, {
                name: name
            });
            grunt.task.run([
                'clean',
                'fontgen',
                'webfont',
                'concat:webfonts',
                'sass:deploy',
                'concat:css',
                'concat:cssPrint',
                'cssmin',
                'closurecompiler',
                'tasty_swig',
                'copy:deploy',
                'autoprefixer',
                'clean:mapFiles',
                'clean:webfonts',
                'clean:webicons'
            ]);
        } else
            grunt.warn('[' + name + '] does not exist. Have you typed it correctly?\n');
    });

    grunt.registerTask('deploy', 'Deploy a mockup to the Mockups Server', function ( name ) {
    	if (appExists(name)) {
            setAppConfig(this.name, {
                name: name
            });
            grunt.task.run([
                'build_deploy:' + name,
                'rsync:deploy'
            ]);
        } else
            grunt.warn('[' + name + '] does not exist. Have you typed it correctly?\n');
    });

    grunt.registerTask('make', 'Create a new mockup folder based on a template', function ( name ) {
        if (!appExists(name)) {
            setAppConfig(this.name, {
                name: name
            });
            grunt.task.run([
                'copy:make'
            ]);
        } else
            grunt.warn('[' + name + '] already exists. Please use another name.\n');
    });
};
<|endoftext|>


<commit_before>/*global module:false*/
module.exports = function(grunt) {

  // Project configuration.
  grunt.initConfig({
    // Metadata.
    pkg: grunt.file.readJSON('package.json'),
    banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
      '<%= grunt.template.today("yyyy-mm-dd") %>\n' +
      '<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
      '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
      ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n',
    // Task configuration.
    /** // Don't need these at the moment...
    concat: {
      options: {
        banner: '<%= banner %>',
        stripBanners: true
      },
      dist: {
        src: ['lib/<%= pkg.name %>.js'],
        dest: 'dist/<%= pkg.name %>.js'
      }
    },
    uglify: {
      options: {
        banner: '<%= banner %>'
      },
      dist: {
        src: '<%= concat.dist.dest %>',
        dest: 'dist/<%= pkg.name %>.min.js'
      }
    },
    // **/
    jshint: {
      options: {
        curly: true,
        eqeqeq: true,
        immed: true,
        latedef: true,
        newcap: true,
        noarg: true,
        sub: true,
        undef: true,
        unused: true,
        boss: true,
        eqnull: true,
        browser: true,
        globals: {
          jQuery: true
        }
      },
      gruntfile: {
        src: 'Gruntfile.js'
      },
      lib_test: {
        src: ['lib/**/*.js', 'test/**/*.js']
      }
    },
    typescript: {
      lib: {
        src: ['src/**/*.ts'],
        dest: 'src/',
        options: {
          noResolve: true,
          ignoreError: true, // FIXME: Don't just ignore me!
        },
      },
      examples: {
        src: ['examples/**/*.ts'],
      }
    },
    watch: {
      gruntfile: {
        files: '<%= jshint.gruntfile.src %>',
        tasks: ['jshint:gruntfile']
      },
      lib_test: {
        files: '<%= jshint.lib_test.src %>',
        tasks: ['jshint:lib_test']
      },
      lib: {
        files: ['src/**/*.ts'],
        tasks: ['typescript:lib'],
      },
      examples: {
        files: ['examples/**/*.*'],
        tasks: ['typescript:examples'],
        options: {
          livereload: true
        }
      }
    },
    connect: {
      examples: {
        /** defaults
        host: '0.0.0.0', // alias to localhost
        port: 8000
        */
        options: {
          base: [ 'src/', 'bower_components/', 'examples/' ],
        }
      }
    }
  });

  // These plugins provide necessary tasks.
  /** // Unused at the moment...
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  // **/
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-connect');
  grunt.loadNpmTasks('grunt-typescript');

  // Default task.
  grunt.registerTask('default', ['jshint', /*'concat', 'uglify' */]);

  grunt.registerTask('serve', ['connect:examples', 'watch']);

};
<commit_msg>No need for a `dest` target with `grunt-typescript` apparently...<commit_after>/*global module:false*/
module.exports = function(grunt) {

  // Project configuration.
  grunt.initConfig({
    // Metadata.
    pkg: grunt.file.readJSON('package.json'),
    banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
      '<%= grunt.template.today("yyyy-mm-dd") %>\n' +
      '<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
      '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
      ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n',
    // Task configuration.
    /** // Don't need these at the moment...
    concat: {
      options: {
        banner: '<%= banner %>',
        stripBanners: true
      },
      dist: {
        src: ['lib/<%= pkg.name %>.js'],
        dest: 'dist/<%= pkg.name %>.js'
      }
    },
    uglify: {
      options: {
        banner: '<%= banner %>'
      },
      dist: {
        src: '<%= concat.dist.dest %>',
        dest: 'dist/<%= pkg.name %>.min.js'
      }
    },
    // **/
    jshint: {
      options: {
        curly: true,
        eqeqeq: true,
        immed: true,
        latedef: true,
        newcap: true,
        noarg: true,
        sub: true,
        undef: true,
        unused: true,
        boss: true,
        eqnull: true,
        browser: true,
        globals: {
          jQuery: true
        }
      },
      gruntfile: {
        src: 'Gruntfile.js'
      },
      lib_test: {
        src: ['lib/**/*.js', 'test/**/*.js']
      }
    },
    typescript: {
      lib: {
        src: ['src/**/*.ts'],
        options: {
          noResolve: true,
          ignoreError: true, // FIXME: Don't just ignore me!
        },
      },
      examples: {
        src: ['examples/**/*.ts'],
      }
    },
    watch: {
      gruntfile: {
        files: '<%= jshint.gruntfile.src %>',
        tasks: ['jshint:gruntfile']
      },
      lib_test: {
        files: '<%= jshint.lib_test.src %>',
        tasks: ['jshint:lib_test']
      },
      lib: {
        files: ['src/**/*.ts'],
        tasks: ['typescript:lib'],
      },
      examples: {
        files: ['examples/**/*.*'],
        tasks: ['typescript:examples'],
        options: {
          livereload: true
        }
      }
    },
    connect: {
      examples: {
        /** defaults
        host: '0.0.0.0', // alias to localhost
        port: 8000
        */
        options: {
          base: [ 'src/', 'bower_components/', 'examples/' ],
        }
      }
    }
  });

  // These plugins provide necessary tasks.
  /** // Unused at the moment...
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  // **/
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-connect');
  grunt.loadNpmTasks('grunt-typescript');

  // Default task.
  grunt.registerTask('default', ['jshint', /*'concat', 'uglify' */]);

  grunt.registerTask('serve', ['connect:examples', 'watch']);

};
<|endoftext|>


<commit_before>module.exports = function(grunt) {
  require('grunt-log-headers')(grunt);

  // Returns the repetitive shell commands for measuring the size.
  function sizeOptions() {
    var ret = {};
    function oneSize(file, gzip) {
      ret[file + (gzip ? '.gz' : '')] = {
        command: 'cat build/' + file + ' | ' +
            (gzip ? 'gzip -c | ' : '') +
            'wc -c',
        options: {
          gruntLogHeader: false,
          stdout: false,
          callback: function(err, stdout, stderr, cb) {
            console.log(file + (gzip ? '.gz' : '') + ':\t' + stdout.trim());
            cb();
          }
        }
      };
    }

    oneSize('foam.js', false);
    oneSize('foam.js', true);
    oneSize('foam.min.js', false);
    oneSize('foam.min.js', true);
    return ret;
  }

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    concat: {
      options: {
        banner: '/*! <%= pkg.name %> v<%= pkg.version %> */\n' +
                '/* <%= grunt.option("gitRevision") %> */\n'
      },
      foam: {
        dest: 'build/foam.js',
        src: [
          'core/firefox.js',
          'core/funcName.js',
          'core/safari.js',
          'core/i18n.js',
          'core/stdlib.js',
          'core/WeakMap.js',
          'core/io.js',
          'core/writer.js',
          'core/socket.js',
          'core/base64.js',
          'core/encodings.js',
          'core/utf8.js',
          'core/async.js',
          'core/parse.js',
          'core/event.js',
          'core/JSONUtil.js',
          'core/XMLUtil.js',
          'core/context.js',
          'core/JSONParser.js',
          'core/TemplateUtil.js',
          'core/FOAM.js',
          'core/FObject.js',
          'core/BootstrapModel.js',
          'core/mm1Model.js',
          'core/mm2Property.js',
          'core/mm3Types.js',
          'core/mm4Method.js',
          'core/mm6Misc.js',
          'core/value.js',
          'core/view.js',
          'core/layout.js',
          'core/ChoiceView.js',
          'core/DetailView.js',
          'core/TableView.js',
          'core/cview.js',
          'core/cview2.js',
          'core/RichTextView.js',
          'core/listchoiceview.js',
          'core/scroll.js',
          'core/HTMLParser.js',
          'core/mlang.js',
          'core/QueryParser.js',
          'core/search.js',
          'core/oam.js',
          'core/visitor.js',
          'core/messaging.js',
          'core/dao.js',
          'core/arrayDAO.js',
          'core/ClientDAO.js',
          'core/diff.js',
          'core/SplitDAO.js',
          'core/index.js',
          'core/StackView.js',
          'core/MementoMgr.js',
          'core/DAOController.js',
          'core/ThreePaneController.js',
          'core/experimental/protobufparser.js',
          'core/experimental/protobuf.js',
          'core/models.js',
          'core/touch.js',
          'core/glang.js',
          'core/oauth.js',
          'core/busy.js',
          'core/turntable.js',
          'core/CORE.js'
        ]
      }
    },

    uglify: {
      foam: {
        src:  'build/foam.js',
        dest: 'build/foam.min.js',
        preserveComments: 'all'
      }
    },

    'git-describe': {
      foam: {}
    },

    shell: sizeOptions()
  });

  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-git-describe');
  grunt.loadNpmTasks('grunt-shell');

  // Custom logic: Read in the git metadata, and save it as a value.
  // This value is used in the concat banner.
  grunt.registerTask('loadGitData', function() {
    grunt.event.once('git-describe', function(rev) {
      grunt.option('gitRevision', rev);
    });
    grunt.task.run('git-describe');
  });

  grunt.registerTask('sizes', function() {
    grunt.task.run('shell:foam.js');
    grunt.task.run('shell:foam.js.gz');
    grunt.task.run('shell:foam.min.js');
    grunt.task.run('shell:foam.min.js.gz');
  });

  grunt.registerTask('default', ['loadGitData', 'concat', 'uglify', 'sizes']);
};

<commit_msg>Removed search.js from Gruntfile.js.<commit_after>module.exports = function(grunt) {
  require('grunt-log-headers')(grunt);

  // Returns the repetitive shell commands for measuring the size.
  function sizeOptions() {
    var ret = {};
    function oneSize(file, gzip) {
      ret[file + (gzip ? '.gz' : '')] = {
        command: 'cat build/' + file + ' | ' +
            (gzip ? 'gzip -c | ' : '') +
            'wc -c',
        options: {
          gruntLogHeader: false,
          stdout: false,
          callback: function(err, stdout, stderr, cb) {
            console.log(file + (gzip ? '.gz' : '') + ':\t' + stdout.trim());
            cb();
          }
        }
      };
    }

    oneSize('foam.js', false);
    oneSize('foam.js', true);
    oneSize('foam.min.js', false);
    oneSize('foam.min.js', true);
    return ret;
  }

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    concat: {
      options: {
        banner: '/*! <%= pkg.name %> v<%= pkg.version %> */\n' +
                '/* <%= grunt.option("gitRevision") %> */\n'
      },
      foam: {
        dest: 'build/foam.js',
        src: [
          'core/firefox.js',
          'core/funcName.js',
          'core/safari.js',
          'core/i18n.js',
          'core/stdlib.js',
          'core/WeakMap.js',
          'core/io.js',
          'core/writer.js',
          'core/socket.js',
          'core/base64.js',
          'core/encodings.js',
          'core/utf8.js',
          'core/async.js',
          'core/parse.js',
          'core/event.js',
          'core/JSONUtil.js',
          'core/XMLUtil.js',
          'core/context.js',
          'core/JSONParser.js',
          'core/TemplateUtil.js',
          'core/FOAM.js',
          'core/FObject.js',
          'core/BootstrapModel.js',
          'core/mm1Model.js',
          'core/mm2Property.js',
          'core/mm3Types.js',
          'core/mm4Method.js',
          'core/mm6Misc.js',
          'core/value.js',
          'core/view.js',
          'core/layout.js',
          'core/ChoiceView.js',
          'core/DetailView.js',
          'core/TableView.js',
          'core/cview.js',
          'core/cview2.js',
          'core/RichTextView.js',
          'core/listchoiceview.js',
          'core/scroll.js',
          'core/HTMLParser.js',
          'core/mlang.js',
          'core/QueryParser.js',
          'core/oam.js',
          'core/visitor.js',
          'core/messaging.js',
          'core/dao.js',
          'core/arrayDAO.js',
          'core/ClientDAO.js',
          'core/diff.js',
          'core/SplitDAO.js',
          'core/index.js',
          'core/StackView.js',
          'core/MementoMgr.js',
          'core/DAOController.js',
          'core/ThreePaneController.js',
          'core/experimental/protobufparser.js',
          'core/experimental/protobuf.js',
          'core/models.js',
          'core/touch.js',
          'core/glang.js',
          'core/oauth.js',
          'core/busy.js',
          'core/turntable.js',
          'core/CORE.js'
        ]
      }
    },

    uglify: {
      foam: {
        src:  'build/foam.js',
        dest: 'build/foam.min.js',
        preserveComments: 'all'
      }
    },

    'git-describe': {
      foam: {}
    },

    shell: sizeOptions()
  });

  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-git-describe');
  grunt.loadNpmTasks('grunt-shell');

  // Custom logic: Read in the git metadata, and save it as a value.
  // This value is used in the concat banner.
  grunt.registerTask('loadGitData', function() {
    grunt.event.once('git-describe', function(rev) {
      grunt.option('gitRevision', rev);
    });
    grunt.task.run('git-describe');
  });

  grunt.registerTask('sizes', function() {
    grunt.task.run('shell:foam.js');
    grunt.task.run('shell:foam.js.gz');
    grunt.task.run('shell:foam.min.js');
    grunt.task.run('shell:foam.min.js.gz');
  });

  grunt.registerTask('default', ['loadGitData', 'concat', 'uglify', 'sizes']);
};

<|endoftext|>


<commit_before>/**
 * Created by alpipego on 09.12.2016.
 */
module.exports = function (grunt) {

    require('load-grunt-tasks')(grunt);
    require('time-grunt')(grunt);

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

        uglify: {
            files: {
                "js/wield-menu.js": "assets/src/wield-menu.js"
            }
        },

        cssmin: {
            target: {
                files:
                    {
                        "css/wield-menu.css": "assets/src/wield-menu.css"
                    }
            }
        },

        watch: {
            grunt: {
                files: ['Gruntfile.js'],
                tasks: ['cssmin', 'uglify']
            },
            sass: {
                files: 'assets/src/**/*.css',
                tasks: ['cssmin']
            },
            js: {
                files: 'assets/src/**/*.js',
                tasks: ['uglify']
            }
        }
    });

    grunt.registerTask('dev', ['cssmin', 'uglify', 'watch']);
    grunt.registerTask('default', ['cssmin', 'uglify']);
};
<commit_msg>dev js task<commit_after>/**
 * Created by alpipego on 09.12.2016.
 */
module.exports = function (grunt) {

    require('load-grunt-tasks')(grunt);
    require('time-grunt')(grunt);

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

        uglify: {
            default: {
                options: {
                    compress: {
                        drop_console: true
                    }
                },
                files: {
                    "js/wield-menu.js": "assets/src/wield-menu.js"
                }
            },
            dev: {
                options: {
                    mangle: false,
                    compress: false,
                    beautify: false,
                },
                files: {
                    "js/wield-menu.js": "assets/src/wield-menu.js"
                }
            }
        },

        cssmin: {
            target: {
                files: {
                    "css/wield-menu.css": "assets/src/wield-menu.css"
                }
            }
        },

        watch: {
            grunt: {
                files: ['Gruntfile.js'],
                tasks: ['cssmin', 'uglify:dev']
            },
            sass: {
                files: 'assets/src/**/*.css',
                tasks: ['cssmin']
            },
            js: {
                files: 'assets/src/**/*.js',
                tasks: ['uglify:dev']
            }
        }
    });

    grunt.registerTask('dev', ['cssmin', 'uglify:dev', 'watch']);
    grunt.registerTask('default', ['cssmin', 'uglify']);
};
<|endoftext|>


<commit_before>define("app/App", [
    "use!backbone",
    "app/AppView",
    "app/AppRouter",
    "datum/Datums",
    "activity_feed/ActivityFeed",
    "user/User",
    "authentication/Authentication",
    "corpus/Corpus",
    "import/Import",
    "lexicon/Lexicon"
], function(Backbone, AppView, AppRouter, Datums, ActivityFeed, User, Authentication, Corpus, Import, Lexicon) {
    var App = Backbone.Model.extend(
    /** @lends App.prototype */
    {
        /**
		 * @class The App handles the renitialization and loading of the app
		 *        depending on which platform (Android, Chrome, web) the app is
		 *        running, who is logged in etc.
		 *
		 * The App should be serializable to save state to local storage for the
		 * next run.
		 *
		 * @property {Corpus} corpus The corpus is a Corpus object which will
		 *           permit access to the datum, and the data lists. The corpus
		 *           feeds the search object with indexes and fields for
		 *           advanced search, the corpus has datalists, has teams with
		 *           permissions, has a confidentiality_encryption key, it's
		 *           datum have sessions, its datalists have export.
		 * @property {Glosser} glosser The glosser listens to
		 *           orthography/utterence lines and attempts to guess the
		 *           gloss.
		 * @property {Lexicon} lexicon The lexicon is a list of morphemes,
		 *           allomorphs and glosses which are used to index datum, and
		 *           also to gloss datum.
		 * @property {User} user The user is a User object (User, Bot or
		 *           Informant) which is logged in and viewing the app with that
		 *           user's perspective. To check whether some data is
		 *           public/viewable/editable the app.user should be used to
		 *           verify the permissions. If no user is logged in a special
		 *           user "public" is logged in and used to calculate
		 *           permissions.
		 *
		 *
		 * @property {ActivityFeed} activityFeed The activityFeed is an Activity
		 *           Feed object which attaches itself to a div.
		 * @property {Authentication} auth The auth member variable is an
		 *           Authentication object permits access to the login and
		 *           logout functions, and the database of users depending on
		 *           whether the app is online or not.
		 * @property {Import} importer The importer is an Importer object which
		 *           attaches itself to the document page on Chrome Extensions
		 *           and non-mobile browsers to listen to drag and drop events
		 *           and attempt to import the contents of the dragged and
		 *           dropped files. On android the app will have to import data
		 *           via the menus.
		 * @property {Search} search The search is the primary surface where the
		 *           global search features will attach.
		 * @property
		 * @extends Backbone.Model
		 * @constructs
		 */
        initialize : function() {
            this.bind('error', function(model, error) {
                console.log("Error in Activity Feed Item: "+ error);
            });

        	// Start the Router
            Backbone.history.start();
        },
        defaults : {
        	corpus: new Corpus("corpus"),
//        	glosser: new Glosser(lexicon),
    		lexicon: new Lexicon(""), //has indexes, stored in local storage
        	user: new User("user") //has preferences (skins, colors etc), has hotkeys
        },
        activityFeed: new ActivityFeed("activity_feed"),
        auth: new Authentication("authentication"),
        importer: new Import(),
        view: new AppView(),
    	router: new AppRouter(),
    	datumList: new Datums() //TODO remove this later and use corpus instead
//      nav: new Navigation(),
//    	search: new Search("global_search")
    });

    return App;
});
<commit_msg>Fetches current datums from the Pouch at startup #109<commit_after>define("app/App", [
    "use!backbone",
    "app/AppView",
    "app/AppRouter",
    "datum/Datums",
    "activity_feed/ActivityFeed",
    "user/User",
    "authentication/Authentication",
    "corpus/Corpus",
    "import/Import",
    "lexicon/Lexicon"
], function(Backbone, AppView, AppRouter, Datums, ActivityFeed, User, Authentication, Corpus, Import, Lexicon) {
    var App = Backbone.Model.extend(
    /** @lends App.prototype */
    {
        /**
		 * @class The App handles the renitialization and loading of the app
		 *        depending on which platform (Android, Chrome, web) the app is
		 *        running, who is logged in etc.
		 *
		 * The App should be serializable to save state to local storage for the
		 * next run.
		 *
		 * @property {Corpus} corpus The corpus is a Corpus object which will
		 *           permit access to the datum, and the data lists. The corpus
		 *           feeds the search object with indexes and fields for
		 *           advanced search, the corpus has datalists, has teams with
		 *           permissions, has a confidentiality_encryption key, it's
		 *           datum have sessions, its datalists have export.
		 * @property {Glosser} glosser The glosser listens to
		 *           orthography/utterence lines and attempts to guess the
		 *           gloss.
		 * @property {Lexicon} lexicon The lexicon is a list of morphemes,
		 *           allomorphs and glosses which are used to index datum, and
		 *           also to gloss datum.
		 * @property {User} user The user is a User object (User, Bot or
		 *           Informant) which is logged in and viewing the app with that
		 *           user's perspective. To check whether some data is
		 *           public/viewable/editable the app.user should be used to
		 *           verify the permissions. If no user is logged in a special
		 *           user "public" is logged in and used to calculate
		 *           permissions.
		 *
		 *
		 * @property {ActivityFeed} activityFeed The activityFeed is an Activity
		 *           Feed object which attaches itself to a div.
		 * @property {Authentication} auth The auth member variable is an
		 *           Authentication object permits access to the login and
		 *           logout functions, and the database of users depending on
		 *           whether the app is online or not.
		 * @property {Import} importer The importer is an Importer object which
		 *           attaches itself to the document page on Chrome Extensions
		 *           and non-mobile browsers to listen to drag and drop events
		 *           and attempt to import the contents of the dragged and
		 *           dropped files. On android the app will have to import data
		 *           via the menus.
		 * @property {Search} search The search is the primary surface where the
		 *           global search features will attach.
		 * @property
		 * @extends Backbone.Model
		 * @constructs
		 */
        initialize : function() {
            this.bind('error', function(model, error) {
                console.log("Error in Activity Feed Item: "+ error);
            });

        	// Start the Router
            Backbone.history.start();

            // Populate datumList from Pouch
            //TODO remove this later and use corpus instead
            this.datumList = new Datums();
            this.datumList.fetch();
        },
        defaults : {
        	corpus: new Corpus("corpus"),
//        	glosser: new Glosser(lexicon),
    		lexicon: new Lexicon(""), //has indexes, stored in local storage
        	user: new User("user") //has preferences (skins, colors etc), has hotkeys
        },
        activityFeed: new ActivityFeed("activity_feed"),
        auth: new Authentication("authentication"),
        importer: new Import(),
        view: new AppView(),
    	router: new AppRouter()
//      nav: new Navigation(),
//    	search: new Search("global_search")
    });

    return App;
});
<|endoftext|>


<commit_before>//jshint node:true

"use strict";

module.exports = function(grunt) {

	var ui5version = ""; //jshint ignore:line
	var uirepo     = "sapui5.hana.ondemand.com"; //jshint ignore:line

	// measures the time each task takes
	require("time-grunt")(grunt);

	// Project configuration.
	grunt.initConfig({

		// Configuration to be run (and then tested).
		openui5_preload: { //jshint ignore:line
			component: {
				options: {
					resources: {
						cwd: "webapp", // path to app root folder
						src: [
						  "**/*.js",
						  "**/*.fragment.html",
						  "**/*.fragment.json",
						  "**/*.fragment.xml",
						  "**/*.view.html",
						  "**/*.view.json",
						  "**/*.view.xml",
						  "**/*.properties"
						],
						prefix: "de/linuxdozent/gittest/publicui" // namespace prefix (in case the namespace is not already in folder structure like sap/ui/core/**)
					},
					compress: true,
					dest: "dist"
				},
				components: true
			}
		},

		// validate JS files
		jshint: {
			files: [
				"Gruntfile.js",
				"src/main/webapp/**/*.js",
				"!src/main/webapp/util/**",
				"!src/main/webapp/*-preload.js"
			],
			options: {
				jshintrc: ".jshintrc"
			}
		},

		//validate XML files (XML Views)
		xml_validator: {				//jshint ignore:line
			your_target: {			  //jshint ignore:line
				src: ["src/main/webapp/**/*.xml"]
			},
		},

		//watch for changed files and reload browser
		watch: {
			livereload: {
				options: {
					livereload: 35729,
					keepAlive:true
				},
				tasks: ["validate"],
				files: ["<%= jshint.files %>", "<%= xml_validator.your_target.src %>"]
			},
		}

	});

	grunt.loadNpmTasks("grunt-openui5");
	grunt.loadNpmTasks("grunt-contrib-connect");
	grunt.loadNpmTasks("grunt-xml-validator");
	grunt.loadNpmTasks("grunt-contrib-jshint");
	grunt.loadNpmTasks("grunt-contrib-watch");

	// grunt.registerTask("default", [ "openui5_preload"]);

	grunt.registerTask("validate", [
		"jshint",
		"xml_validator"]);

	grunt.registerTask("default", [
		"jshint",
		"xml_validator",
		"configureProxies:server",
		"connect:server",
		"watch"]);

};<commit_msg>Make openui5_preload the default task<commit_after>//jshint node:true

"use strict";

module.exports = function(grunt) {

	var ui5version = ""; //jshint ignore:line
	var uirepo     = "sapui5.hana.ondemand.com"; //jshint ignore:line

	// measures the time each task takes
	require("time-grunt")(grunt);

	// Project configuration.
	grunt.initConfig({

		// Configuration to be run (and then tested).
		openui5_preload: { //jshint ignore:line
			component: {
				options: {
					resources: {
						cwd: "webapp", // path to app root folder
						src: [
						  "**/*.js",
						  "**/*.fragment.html",
						  "**/*.fragment.json",
						  "**/*.fragment.xml",
						  "**/*.view.html",
						  "**/*.view.json",
						  "**/*.view.xml",
						  "**/*.properties"
						],
						prefix: "de/linuxdozent/gittest/publicui" // namespace prefix (in case the namespace is not already in folder structure like sap/ui/core/**)
					},
					compress: true,
					dest: "webapp"
				},
				components: true
			}
		},

		// validate JS files
		jshint: {
			files: [
				"Gruntfile.js",
				"src/main/webapp/**/*.js",
				"!src/main/webapp/util/**",
				"!src/main/webapp/*-preload.js"
			],
			options: {
				jshintrc: ".jshintrc"
			}
		},

		//validate XML files (XML Views)
		xml_validator: {				//jshint ignore:line
			your_target: {			  //jshint ignore:line
				src: ["src/main/webapp/**/*.xml"]
			},
		},

		//watch for changed files and reload browser
		watch: {
			livereload: {
				options: {
					livereload: 35729,
					keepAlive:true
				},
				tasks: ["validate"],
				files: ["<%= jshint.files %>", "<%= xml_validator.your_target.src %>"]
			},
		}

	});

	grunt.loadNpmTasks("grunt-openui5");
	grunt.loadNpmTasks("grunt-contrib-connect");
	grunt.loadNpmTasks("grunt-xml-validator");
	grunt.loadNpmTasks("grunt-contrib-jshint");
	grunt.loadNpmTasks("grunt-contrib-watch");

	grunt.registerTask("default", [ "openui5_preload"]);

	grunt.registerTask("validate", [
		"jshint",
		"xml_validator"]);

	grunt.registerTask("default", [
		"jshint",
		"xml_validator",
		"configureProxies:server",
		"connect:server",
		"watch"]);

};<|endoftext|>


<commit_before>/* App Module */

var postrApp = angular.module('postrApp', [
	'ngResource', 'ngCookies', 'ngTable'
]);

postrApp.config(['$routeProvider', function ($routeProvider) {
	$routeProvider.
	when('/', {
		templateUrl: '/app/views/home.html',
		controller: 'HomeCtrl'
	}).
	when('/404', {
		templateUrl: '/app/views/404.html',
		controller: 'HomeCtrl'
	}).
	when('/posts/:type', {
		templateUrl: '/app/views/posts.html',
		controller: 'PostsCtrl'
	}).
	when('/posts', {
		templateUrl: '/app/views/posts.html',
		controller: 'PostsCtrl'
	}).
	when('/post/:id', {
		templateUrl: '/app/views/view-post.html',
		controller: 'ViewPostCtrl'
	}).
	when('/newpost/:type/:uid', {
		templateUrl: '/app/views/new-post.html',
		controller: 'NewPostCtrl'
	}).
	when('/newpost/:type', {
		templateUrl: '/app/views/new-post.html',
		controller: 'NewPostCtrl'
	}).
	when('/newpost', {
		templateUrl: '/app/views/new-post.html',
		controller: 'NewPostCtrl'
	}).
	when('/repost/:id', {
		templateUrl: '/app/views/re-post.html',
		controller: 'RePostCtrl'
	}).
	when('/settings', {
		templateUrl: '/app/views/settings.html',
		controller: 'SettingsCtrl'
	}).
	otherwise({
		redirectTo: '/404'
	});
}]);<commit_msg>added login controller<commit_after>/* App Module */

var postrApp = angular.module('postrApp', [
	'ngResource', 'ngCookies', 'ngTable'
]);

postrApp.config(['$routeProvider', function ($routeProvider) {
	$routeProvider.
	when('/', {
		templateUrl: '/app/views/home.html',
		controller: 'HomeCtrl'
	}).
	when('/404', {
		templateUrl: '/app/views/404.html',
		controller: 'HomeCtrl'
	}).
	when('/login', {
		templateUrl: '/app/views/login.html',
		controller: 'LoginCtrl'
	}).
	when('/posts/:type', {
		templateUrl: '/app/views/posts.html',
		controller: 'PostsCtrl'
	}).
	when('/posts', {
		templateUrl: '/app/views/posts.html',
		controller: 'PostsCtrl'
	}).
	when('/post/:id', {
		templateUrl: '/app/views/view-post.html',
		controller: 'ViewPostCtrl'
	}).
	when('/newpost/:type/:uid', {
		templateUrl: '/app/views/new-post.html',
		controller: 'NewPostCtrl'
	}).
	when('/newpost/:type', {
		templateUrl: '/app/views/new-post.html',
		controller: 'NewPostCtrl'
	}).
	when('/newpost', {
		templateUrl: '/app/views/new-post.html',
		controller: 'NewPostCtrl'
	}).
	when('/repost/:id', {
		templateUrl: '/app/views/re-post.html',
		controller: 'RePostCtrl'
	}).
	when('/settings', {
		templateUrl: '/app/views/settings.html',
		controller: 'SettingsCtrl'
	}).
	otherwise({
		redirectTo: '/404'
	});
}]);<|endoftext|>


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

  // Project configuration.
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    jshint: {
      build: ['Gruntfile.js', 'src/**/*.js']
    },
    watch: {
      scripts: {
        files: 'src/**/*.js',
        tasks: ['jshint', 'uglify:dev']
      },
      styles: {
        files: 'src/**/*.css',
        tasks: ['cssmin']
      },
      html: {
        files: 'src/**/*.html',
        tasks: ['htmlmin']
      },
      python: {
        files: 'src/**/*.py',
        tasks: ['copy:python']
      }
    },
    copy: {
      build: {
        files: [
          {
            expand: true,
            src: 'node_modules/knockout/build/output/knockout-latest.js',
            dest: 'dist/js/',
            flatten: true,
            rename: function (dest, src) {
              return dest + 'knockout.js';
            }
          }
        ]
      },
      python: {
        files: [
          {
            expand: true,
            flatten: true,
            src: 'src/**/*.py',
            dest: 'dist/'
          }
        ]
      }
    },
    htmlmin: {
      build: {
        options: {
          removeComments: true,
          collapseWhitespace: true
        },
        files: {
          'dist/index.html': 'src/index.html'
        }
      }
    },
    cssmin: {
      target: {
        files: [{
          expand: true,
          cwd: 'src/css',
          src: ['*.css', '!*.min.css'],
          dest: 'dist/css',
          ext: '.min.css'
        }]
      }
    },
    uglify: {
      target: {
        files: {
          'dist/js/app.min.js': ['src/js/app.js'],
          'dist/js/map.min.js': ['src/js/map.js']
        }
      },
      dev: {
        options: {
          beautify: true,
          compress: false
        },
        files: {
          'dist/js/app.min.js': ['src/js/app.js'],
          'dist/js/map.min.js': ['src/js/map.js'],
          'dist/js/offcanvas.min.js': ['src/js/offcanvas.js']
        }
      }
    }
  });

  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-contrib-htmlmin');
  grunt.loadNpmTasks('grunt-contrib-cssmin');
  grunt.loadNpmTasks('grunt-contrib-uglify');

  // Default task(s).
  grunt.registerTask('default', ['jshint']);

};
<commit_msg>Remove option that removes comments in HTML in Grunt so that knockout's containerless control flow works<commit_after>module.exports = function(grunt) {

  // Project configuration.
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    jshint: {
      build: ['Gruntfile.js', 'src/**/*.js']
    },
    watch: {
      scripts: {
        files: 'src/**/*.js',
        tasks: ['jshint', 'uglify:dev']
      },
      styles: {
        files: 'src/**/*.css',
        tasks: ['cssmin']
      },
      html: {
        files: 'src/**/*.html',
        tasks: ['htmlmin']
      },
      python: {
        files: 'src/**/*.py',
        tasks: ['copy:python']
      }
    },
    copy: {
      build: {
        files: [
          {
            expand: true,
            src: 'node_modules/knockout/build/output/knockout-latest.js',
            dest: 'dist/js/',
            flatten: true,
            rename: function (dest, src) {
              return dest + 'knockout.js';
            }
          }
        ]
      },
      python: {
        files: [
          {
            expand: true,
            flatten: true,
            src: 'src/**/*.py',
            dest: 'dist/'
          }
        ]
      }
    },
    htmlmin: {
      build: {
        options: {
          removeComments: false,
          collapseWhitespace: true
        },
        files: {
          'dist/index.html': 'src/index.html'
        }
      }
    },
    cssmin: {
      target: {
        files: [{
          expand: true,
          cwd: 'src/css',
          src: ['*.css', '!*.min.css'],
          dest: 'dist/css',
          ext: '.min.css'
        }]
      }
    },
    uglify: {
      target: {
        files: {
          'dist/js/app.min.js': ['src/js/app.js'],
          'dist/js/map.min.js': ['src/js/map.js']
        }
      },
      dev: {
        options: {
          beautify: true,
          compress: false
        },
        files: {
          'dist/js/app.min.js': ['src/js/app.js'],
          'dist/js/map.min.js': ['src/js/map.js'],
          'dist/js/offcanvas.min.js': ['src/js/offcanvas.js']
        }
      }
    }
  });

  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-contrib-htmlmin');
  grunt.loadNpmTasks('grunt-contrib-cssmin');
  grunt.loadNpmTasks('grunt-contrib-uglify');

  // Default task(s).
  grunt.registerTask('default', ['jshint']);

};
<|endoftext|>