<commit_before>/*
 * grunt-ejs-static
 * https://github.com/shaekuronen/grunt-ejs-static
 *
 * Copyright (c) 2013 Shae Kuronen
 * Licensed under the MIT license.
 */

'use strict';

module.exports = function(grunt) {

  // Project configuration.
  grunt.initConfig({
    jshint: {
      all: [
        'Gruntfile.js',
        'tasks/*.js',
        'lib/*.js',
        '<%= nodeunit.tests %>',
      ],
      options: {
        jshintrc: '.jshintrc',
      },
    },

    // Before generating any new files, remove any previously-created files.
    clean: {
      preview: ['demo/preview'],
      optimize: ['demo/production'],
      post_optimize: [
        'demo/production/pages',
        'demo/production/templates',
        'demo/production/head.ejs',
        'demo/production/scripts.ejs'
      ],
      test: ['tests/test*']
    },

    copy: {
      preview: {
        files: [
          {expand: true, cwd: 'demo/dev/', src: ['img/**'], dest: 'demo/preview/'},
          {expand: true, cwd: 'demo/dev/', src: ['css/**'], dest: 'demo/preview/'},
          {expand: true, cwd: 'demo/dev/', src: ['js/**'], dest: 'demo/preview/'}
        ]
      },
      optimize: {
        files: [
          // temporary files for usemin task
          {expand: true, flatten: true, cwd: 'demo/dev/', src: ['templates/global/head.ejs'], dest: 'demo/production/', filter: 'isFile'},
          {expand: true, flatten: true, cwd: 'demo/dev/', src: ['templates/global/scripts.ejs'], dest: 'demo/production/', filter: 'isFile'},
          // end temporary files for usemin task
          // temporary files for ejs_static task
          {expand: true, cwd: 'demo/dev/', src: ['pages/**'], dest: 'demo/production/'},
          {expand: true, cwd: 'demo/dev/', src: ['templates/**'], dest: 'demo/production/'},
          // end temporary files for ejs_static task
          {expand: true, cwd: 'demo/dev/', src: ['img/**'], dest: 'demo/production/'},
          {expand: true, cwd: 'demo/dev/', src: ['css/**'], dest: 'demo/production/'},
          {expand: true, cwd: 'demo/dev/', src: ['js/**'], dest: 'demo/production/'},
          {expand: true, cwd: 'demo/dev/', src: ['data/**'], dest: 'demo/production/'}
        ]
      }
    },

    // get the scripts inside preview:js block
    'useminPrepare': {
      html: [
        'demo/production/head.ejs',
        'demo/production/scripts.ejs'
      ]
    },

    // update the scripts links to point to the concatenated and minified js/main.js
    usemin: {
      html: [
        'demo/production/templates/global/head.ejs',
        'demo/production/templates/global/scripts.ejs'
      ]
    },

    ejs_static: {
      preview: {
        options: {
          dest: 'demo/preview',
          path_to_data: 'demo/dev/data/data.json',
          path_to_layouts: 'demo/dev/layouts/',
          index_page: 'home',
          parent_dirs: false,
          underscores_to_dashes: true,
          file_extension: '.html',
          underscore: true,
          helper_functions: {
            highlight: function(text) {
              return "
" + text + "
";
            },
            func2: function(text) {
              grunt.log.debug('value for text is currently ' + text);
            },
            print_object: function(obj) {
              var output = '';
              for(var property in obj) {
                output += property + ': ' + obj[property]+'; \n';
              }
              console.log(output);
            }
          }
        }
      },
      optimize: {
        options: {
          dest: 'demo/production',
          path_to_data: 'demo/dev/data/data.json',
          path_to_layouts: 'demo/dev/layouts',
          index_page: 'home',
          parent_dirs: false,
          underscores_to_dashes: true,
          file_extension: '.html',
          helper_functions: [
            'demo/dev/js/site/helper_function1.js',
            'demo/dev/js/site/helper_function2.js'
          ]
        }
      },
      // test that parent_dirs false works as expected
      test1: {
        options: {
          dest: 'tests/test1',
          path_to_data: 'demo/dev/data/data.json',
          path_to_layouts: 'demo/dev/layouts',
          index_page: 'home',
          parent_dirs: false,
          underscores_to_dashes: true,
          file_extension: '.html'
        }
      },
      // test that parent_dirs true works as expected
      test2: {
        options: {
          dest: 'tests/test2',
          path_to_data: 'demo/dev/data/data.json',
          path_to_layouts: 'demo/dev/layouts',
          index_page: 'home',
          parent_dirs: true,
          underscores_to_dashes: true,
          file_extension: '.html'
        }
      },
      // test that underscores_to_dashes true works as expected
      test3: {
        options: {
          dest: 'tests/test3',
          path_to_data: 'demo/dev/data/data.json',
          path_to_layouts: 'demo/dev/layouts',
          index_page: 'home',
          parent_dirs: false,
          underscores_to_dashes: true,
          file_extension: '.html'
        }
      },
      // test that underscores_to_dashes false works as expected
      test4: {
        options: {
          dest: 'tests/test4',
          path_to_data: 'demo/dev/data/data.json',
          path_to_layouts: 'demo/dev/layouts',
          index_page: 'home',
          parent_dirs: false,
          underscores_to_dashes: false,
          file_extension: '.html'
        }
      },
      // test that changing file_extension works as expected
      test5: {
        options: {
          dest: 'tests/test5',
          path_to_data: 'demo/dev/data/data.json',
          path_to_layouts: 'demo/dev/layouts',
          index_page: 'home',
          parent_dirs: false,
          underscores_to_dashes: true,
          file_extension: '.php'
        }
      },
      // test include helper functions as an object
      test6: {
        options: {
          dest: 'tests/test6',
          path_to_data: 'test/data/helper_function_test.json',
          path_to_layouts: 'demo/dev/layouts',
          index_page: 'home',
          parent_dirs: false,
          underscores_to_dashes: true,
          file_extension: '.html',
          underscore: true,
          helper_functions: {
            highlight: function(text) {
              return "
" + text + "
";
            },
            build_url: function(scheme, hostname, path, queries) {
              console.log('this hnappen ' + queries);
              var url = "";
              console.log("url is now " + url);
              url += scheme;
              url += "://";
              url += hostname;
              url += path;
              if (queries.length > 0) {
                url += "?";
                console.log(url);
                console.log(queries);
                queries.forEach(function(query, index) {
                  if (index === 0) {
                    url += query;
                  } else {
                    url += "&" + query;
                  }
                });
              }
              return url;
            },
            print_object: function(obj) {
              var output = '';
              for(var property in obj) {
                output += property + ': ' + obj[property]+'; \n';
              }
              console.log(output);
            }
          }
        }
      },
      // test include helper functions as an array
      // test7: {
      //   options: {
      //     dest: 'tests/test7',
      //     path_to_data: 'demo/dev/data/data.json',
      //     path_to_layouts: 'demo/dev/layouts',
      //     index_page: 'home',
      //     parent_dirs: false,
      //     underscores_to_dashes: true,
      //     file_extension: '.html',
      //     helper_functions: [
      //       'path/to/file1.js',
      //       'path/to/file2.js',
      //       'path/to/file3.js']
      //   }
      // }

    },

    // Unit tests.
    nodeunit: {
      tests: ['test/ejs_static_test.js'],
    },

  });

  // Actually load this plugin's task(s).
  grunt.loadTasks('tasks');

  // These plugins provide necessary tasks.
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-nodeunit');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-usemin');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-cssmin');

  // build the site for preview during development
  grunt.registerTask('preview', [
    'clean:preview',
    'copy:preview',
    'ejs_static:preview'
  ]);

  // optimize the site before deploying to production
  grunt.registerTask('optimize', [
    'clean:optimize',
    'copy:optimize',
    'useminPrepare',
    'concat',
    'cssmin',
    'uglify',
    'usemin',
    'ejs_static:optimize',
    'clean:post_optimize'
  ]);

  // test
  grunt.registerTask('test', [
    'clean:test',
    'ejs_static:test1',
    'ejs_static:test2',
    'ejs_static:test3',
    'ejs_static:test4',
    'ejs_static:test5',
    'ejs_static:test6',
    // 'ejs_static:test7',
    'nodeunit'
  ]);

  // test
  grunt.registerTask('test6', [
    'clean:test',
    'ejs_static:test6',
    'nodeunit'
  ]);

};
<commit_msg>cleaned up a little cruft<commit_after>/*
 * grunt-ejs-static
 * https://github.com/shaekuronen/grunt-ejs-static
 *
 * Copyright (c) 2013 Shae Kuronen
 * Licensed under the MIT license.
 */

'use strict';

module.exports = function(grunt) {

  // Project configuration.
  grunt.initConfig({
    jshint: {
      all: [
        'Gruntfile.js',
        'tasks/*.js',
        'lib/*.js',
        '<%= nodeunit.tests %>',
      ],
      options: {
        jshintrc: '.jshintrc',
      },
    },

    // Before generating any new files, remove any previously-created files.
    clean: {
      preview: ['demo/preview'],
      optimize: ['demo/production'],
      post_optimize: [
        'demo/production/pages',
        'demo/production/templates',
        'demo/production/head.ejs',
        'demo/production/scripts.ejs'
      ],
      test: ['tests/test*']
    },

    copy: {
      preview: {
        files: [
          {expand: true, cwd: 'demo/dev/', src: ['img/**'], dest: 'demo/preview/'},
          {expand: true, cwd: 'demo/dev/', src: ['css/**'], dest: 'demo/preview/'},
          {expand: true, cwd: 'demo/dev/', src: ['js/**'], dest: 'demo/preview/'}
        ]
      },
      optimize: {
        files: [
          // temporary files for usemin task
          {expand: true, flatten: true, cwd: 'demo/dev/', src: ['templates/global/head.ejs'], dest: 'demo/production/', filter: 'isFile'},
          {expand: true, flatten: true, cwd: 'demo/dev/', src: ['templates/global/scripts.ejs'], dest: 'demo/production/', filter: 'isFile'},
          // end temporary files for usemin task
          // temporary files for ejs_static task
          {expand: true, cwd: 'demo/dev/', src: ['pages/**'], dest: 'demo/production/'},
          {expand: true, cwd: 'demo/dev/', src: ['templates/**'], dest: 'demo/production/'},
          // end temporary files for ejs_static task
          {expand: true, cwd: 'demo/dev/', src: ['img/**'], dest: 'demo/production/'},
          {expand: true, cwd: 'demo/dev/', src: ['css/**'], dest: 'demo/production/'},
          {expand: true, cwd: 'demo/dev/', src: ['js/**'], dest: 'demo/production/'},
          {expand: true, cwd: 'demo/dev/', src: ['data/**'], dest: 'demo/production/'}
        ]
      }
    },

    // get the scripts inside preview:js block
    'useminPrepare': {
      html: [
        'demo/production/head.ejs',
        'demo/production/scripts.ejs'
      ]
    },

    // update the scripts links to point to the concatenated and minified js/main.js
    usemin: {
      html: [
        'demo/production/templates/global/head.ejs',
        'demo/production/templates/global/scripts.ejs'
      ]
    },

    ejs_static: {
      preview: {
        options: {
          dest: 'demo/preview',
          path_to_data: 'demo/dev/data/data.json',
          path_to_layouts: 'demo/dev/layouts/',
          index_page: 'home',
          parent_dirs: false,
          underscores_to_dashes: true,
          file_extension: '.html',
          underscore: true
        }
      },
      optimize: {
        options: {
          dest: 'demo/production',
          path_to_data: 'demo/dev/data/data.json',
          path_to_layouts: 'demo/dev/layouts',
          index_page: 'home',
          parent_dirs: false,
          underscores_to_dashes: true,
          file_extension: '.html',
          helper_functions: [
            'demo/dev/js/site/helper_function1.js',
            'demo/dev/js/site/helper_function2.js'
          ]
        }
      },
      // test that parent_dirs false works as expected
      test1: {
        options: {
          dest: 'tests/test1',
          path_to_data: 'demo/dev/data/data.json',
          path_to_layouts: 'demo/dev/layouts',
          index_page: 'home',
          parent_dirs: false,
          underscores_to_dashes: true,
          file_extension: '.html'
        }
      },
      // test that parent_dirs true works as expected
      test2: {
        options: {
          dest: 'tests/test2',
          path_to_data: 'demo/dev/data/data.json',
          path_to_layouts: 'demo/dev/layouts',
          index_page: 'home',
          parent_dirs: true,
          underscores_to_dashes: true,
          file_extension: '.html'
        }
      },
      // test that underscores_to_dashes true works as expected
      test3: {
        options: {
          dest: 'tests/test3',
          path_to_data: 'demo/dev/data/data.json',
          path_to_layouts: 'demo/dev/layouts',
          index_page: 'home',
          parent_dirs: false,
          underscores_to_dashes: true,
          file_extension: '.html'
        }
      },
      // test that underscores_to_dashes false works as expected
      test4: {
        options: {
          dest: 'tests/test4',
          path_to_data: 'demo/dev/data/data.json',
          path_to_layouts: 'demo/dev/layouts',
          index_page: 'home',
          parent_dirs: false,
          underscores_to_dashes: false,
          file_extension: '.html'
        }
      },
      // test that changing file_extension works as expected
      test5: {
        options: {
          dest: 'tests/test5',
          path_to_data: 'demo/dev/data/data.json',
          path_to_layouts: 'demo/dev/layouts',
          index_page: 'home',
          parent_dirs: false,
          underscores_to_dashes: true,
          file_extension: '.php'
        }
      },
      // test include helper functions as an object
      test6: {
        options: {
          dest: 'tests/test6',
          path_to_data: 'test/data/helper_function_test.json',
          path_to_layouts: 'demo/dev/layouts',
          index_page: 'home',
          parent_dirs: false,
          underscores_to_dashes: true,
          file_extension: '.html',
          underscore: true,
          helper_functions: {
            highlight: function(text) {
              return "
" + text + "
";
            },
            build_url: function(scheme, hostname, path, queries) {
              console.log('this hnappen ' + queries);
              var url = "";
              url += scheme;
              url += "://";
              url += hostname;
              url += path;
              if (queries.length > 0) {
                url += "?";
                queries.forEach(function(query, index) {
                  if (index === 0) {
                    url += query;
                  } else {
                    url += "&" + query;
                  }
                });
              }
              return url;
            },
            print_object: function(obj) {
              var output = '';
              for(var property in obj) {
                output += property + ': ' + obj[property]+'; \n';
              }
              console.log(output);
            }
          }
        }
      },
      // test include helper functions as an array
      // test7: {
      //   options: {
      //     dest: 'tests/test7',
      //     path_to_data: 'demo/dev/data/data.json',
      //     path_to_layouts: 'demo/dev/layouts',
      //     index_page: 'home',
      //     parent_dirs: false,
      //     underscores_to_dashes: true,
      //     file_extension: '.html',
      //     helper_functions: [
      //       'path/to/file1.js',
      //       'path/to/file2.js',
      //       'path/to/file3.js']
      //   }
      // }

    },

    // Unit tests.
    nodeunit: {
      tests: ['test/ejs_static_test.js'],
    },

  });

  // Actually load this plugin's task(s).
  grunt.loadTasks('tasks');

  // These plugins provide necessary tasks.
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-nodeunit');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-usemin');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-cssmin');

  // build the site for preview during development
  grunt.registerTask('preview', [
    'clean:preview',
    'copy:preview',
    'ejs_static:preview'
  ]);

  // optimize the site before deploying to production
  grunt.registerTask('optimize', [
    'clean:optimize',
    'copy:optimize',
    'useminPrepare',
    'concat',
    'cssmin',
    'uglify',
    'usemin',
    'ejs_static:optimize',
    'clean:post_optimize'
  ]);

  // test
  grunt.registerTask('test', [
    'clean:test',
    'ejs_static:test1',
    'ejs_static:test2',
    'ejs_static:test3',
    'ejs_static:test4',
    'ejs_static:test5',
    'ejs_static:test6',
    // 'ejs_static:test7',
    'nodeunit'
  ]);

  // test
  grunt.registerTask('test6', [
    'clean:test',
    'ejs_static:test6',
    'nodeunit'
  ]);

};
<|endoftext|>


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

  // Project configuration.
  grunt.initConfig({
     ts: {
            default: {
                src: ["**/*.ts", "!node_modules/**/*.ts"],

                options: {
                    comments: true
                },
                out: "build/angular-applicationinsights.js"
            }
        },
    pkg: grunt.file.readJSON('package.json'),
    uglify: {
      options: {
        banner: '/*! <%= pkg.name %> version <%= pkg.version %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
      },
      build: {
        src: 'build/<%= pkg.name %>.js',
        dest: 'build/<%= pkg.name %>.min.js'
      }
    },
    coveralls: {
      options: {
          debug: true,
          coverageDir: 'coverage/',
          dryRun: false,
          force: false,
          recursive: true
      }
    },
    jshint: {
      all: ['src/**/*js', 'build/angular-applicationinsights.js', 'test/**/*.js']
    },
    karma: {
      unit: {
        configFile: 'karma.conf.js'
      }
    },
    concat: {
      options: {
        separator: '\n',
      },
      dist: {
        src: ['build/angular-applicationinsights.js'],
        dest: 'build/angular-applicationinsights.js',
      },
    },

    strip_code: {
    options: {
      start_comment: "test-code",
      end_comment: "end-test-code",
    },
    your_target: {
      // a list of files you want to strip code from
      src: "build/*.js"
    }
  }

  });

  grunt.loadNpmTasks("grunt-ts");
  grunt.loadNpmTasks('grunt-strip-code');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-jshint');
 // grunt.loadNpmTasks('grunt-karma');
  grunt.loadNpmTasks('grunt-contrib-uglify');
 // grunt.loadNpmTasks('grunt-karma-coveralls');

  grunt.registerTask('default', ['ts', 'concat', 'strip_code', 'uglify']);
  grunt.registerTask('travis',['ts','karma','concat','strip_code','uglify','coveralls']);

};<commit_msg>Grunt file changes<commit_after>module.exports = function(grunt) {

  // Project configuration.
  grunt.initConfig({
     ts: {
            default: {
                src: ["**/*.ts", "!node_modules/**/*.ts"],

                options: {
                    comments: true
                },
                out: "build/angular-applicationinsights.js"
            }
        },
    pkg: grunt.file.readJSON('package.json'),
    uglify: {
      options: {
        banner: '/*! <%= pkg.name %> version <%= pkg.version %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
      },
      build: {
        src: 'build/<%= pkg.name %>.js',
        dest: 'build/<%= pkg.name %>.min.js'
      }
    },
    coveralls: {
      options: {
          debug: true,
          coverageDir: 'coverage/',
          dryRun: false,
          force: false,
          recursive: true
      }
    },
    jshint: {
      all: ['src/**/*js', 'build/angular-applicationinsights.js', 'test/**/*.js']
    },
    karma: {
      unit: {
        configFile: 'karma.conf.js'
      }
    },
    concat: {
      options: {
        separator: '\n',
      },
      dist: {
        src: ['build/angular-applicationinsights.js'],
        dest: 'build/angular-applicationinsights.js',
      },
    },

    strip_code: {
    options: {
      start_comment: "test-code",
      end_comment: "end-test-code",
    },
    your_target: {
      // a list of files you want to strip code from
      src: "build/*.js"
    }
  }

  });

  grunt.loadNpmTasks("grunt-ts");
  grunt.loadNpmTasks('grunt-strip-code');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-karma');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-karma-coveralls');

  grunt.registerTask('default', ['ts', 'karma', 'concat', 'strip_code', 'uglify']);
  grunt.registerTask('travis',['ts','karma','concat','strip_code','uglify','coveralls']);

};<|endoftext|>


<commit_before>module.exports = function( grunt ) {
	var configObject = {
		config: {
			assets: {
				src: 'resources/assets/',
				dest: 'assets/'
			},
			images: {
				src: 'resources/images/',
				dest: 'src/assets/images/'
			},
			scripts: {
				src: 'resources/js/',
				dest: 'src/assets/js/'
			},
			src: 'src/',
			styles: {
				src: 'resources/scss/',
				dest: 'src/assets/css/'
			},
			tests: {
				php: 'tests/php/'
			}
		},

		browserify: {
			options: {
				transform: [
					[ "babelify" ]
				]
			},
			scripts: {
				expand: true,
				cwd: '<%= config.scripts.src %>',
				src: [ '*.js' ],
				dest: '<%= config.scripts.dest %>'
			}
		},

		cssmin: {
			options: {
				compatibility: 'ie8'
			},
			styles: {
				expand: true,
				cwd: '<%= config.styles.dest %>',
				src: [ '*.css', '!*.min.css' ],
				dest: '<%= config.styles.dest %>',
				ext: '.min.css'
			}
		},

		// Allow grunt-newer to run tasks if files other than the individual src files have changed since the last run.
		delegate: {
			'browserify': {
				task: 'browserify',
				src: [ '<%= config.scripts.src %>**/*.js' ]
			},
			'imagemin-assets': {
				task: 'imagemin:assets',
				src: [ '<%= config.assets.src %>*.{gif,jpeg,jpg,png}' ]
			},
			'imagemin-images': {
				task: 'imagemin:images',
				src: [ '<%= config.images.src %>**/*.{gif,jpeg,jpg,png}' ]
			}
		},

		eslint: {
			grunt: {
				src: [ 'Gruntfile.js' ]
			},
			src: {
				expand: true,
				cwd: '<%= config.scripts.src %>',
				src: [ '**/*.js' ]
			}
		},

		imagemin: {
			options: {
				optimizationLevel: 7
			},
			assets: {
				expand: true,
				cwd: '<%= config.assets.src %>',
				src: [ '*.{gif,jpeg,jpg,png}' ],
				dest: '<%= config.assets.dest %>'
			},
			images: {
				expand: true,
				cwd: '<%= config.images.src %>',
				src: [ '**/*.{gif,jpeg,jpg,png}' ],
				dest: '<%= config.images.dest %>'
			}
		},

		jsonlint: {
			configs: {
				src: [ '.*rc' ]
			},
			json: {
				src: [ '*.json' ]
			}
		},

		jsvalidate: {
			options: {
				globals: {},
				esprimaOptions: {},
				verbose: false
			},
			grunt: {
				src: [ 'Gruntfile.js' ]
			},
			dest: {
				src: [ '<%= config.scripts.dest %>*.js' ]
			}
		},

		lineending: {
			options: {
				eol: 'lf',
				overwrite: true
			},
			grunt: {
				src: [ 'Gruntfile.js' ]
			},
			scripts: {
				src: [ '<%= config.scripts.dest %>*.js' ]
			},
			styles: {
				src: [ '<%= config.styles.dest %>*.css' ]
			}
		},

		phplint: {
			src: {
				src: [ '<%= config.src %>**/*.php' ]
			},
			tests: {
				src: [ '<%= config.tests.php %>**/*.php' ]
			}
		},

		postcss: {
			options: {
				processors: [
					require( 'autoprefixer' )( {
						browsers: '> 1%, last 2 versions, IE 8',
						cascade: false
					} )
				]
			},
			styles: {
				expand: true,
				cwd: '<%= config.styles.dest %>',
				src: [ '*.css', '!*.min.css' ],
				dest: '<%= config.styles.dest %>'
			}
		},

		sass: {
			options: {
				style: 'expanded',
				noCache: true
			},
			check: {
				options: {
					check: true
				},
				src: '<%= config.styles.src %>*.scss'
			},
			convert: {
				expand: true,
				cwd: '<%= config.styles.src %>',
				src: [ '*.scss' ],
				dest: '<%= config.styles.dest %>',
				ext: '.css'
			}
		},

		uglify: {
			options: {
				ASCIIOnly: true
			},
			scripts: {
				expand: true,
				cwd: '<%= config.scripts.dest %>',
				src: [ '*.js', '!*.min.js' ],
				dest: '<%= config.scripts.dest %>',
				ext: '.min.js'
			}
		},

		watch: {
			options: {
				dot: true,
				spawn: true,
				interval: 2000
			},

			assets: {
				files: [ '<%= config.assets.src %>*.{gif,jpeg,jpg,png}' ],
				tasks: [
					'newer:delegate:imagemin-assets'
				]
			},

			configs: {
				files: [ '.*rc' ],
				tasks: [
					'newer:jsonlint:configs'
				]
			},

			grunt: {
				files: [ 'Gruntfile.js' ],
				tasks: [
					'newer:eslint:grunt',
					'newer:lineending:grunt',
					'changed:jsvalidate:grunt'
				]
			},

			images: {
				files: [ '<%= config.images.src %>**/*.{gif,jpeg,jpg,png}' ],
				tasks: [
					'newer:delegate:imagemin-images'
				]
			},

			json: {
				files: [ '*.json' ],
				tasks: [
					'newer:jsonlint:json'
				]
			},

			php: {
				files: [
					'<%= config.src %>**/*.php',
					'<%= config.tests.php %>**/*.php'
				],
				tasks: [
					'newer:phplint',
					'phpunit'
				]
			},

			scripts: {
				files: [ '<%= config.scripts.src %>**/*.js' ],
				tasks: [
					'newer:eslint:src',
					'newer:delegate:browserify',
					'changed:lineending:scripts',
					'changed:uglify',
					'changed:jsvalidate:dest'
				]
			},

			styles: {
				files: [ '<%= config.styles.src %>**/*.scss' ],
				tasks: [
					'sass:convert',
					'changed:postcss',
					'changed:lineending:styles',
					'changed:cssmin'
				]
			},

			travis: {
				files: [ '.travis.yml' ],
				tasks: [
					'travis-lint'
				]
			}
		}
	};

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

	grunt.initConfig( configObject );

	// Delegation task for grunt-newer to check files different from the individual task's files.
	grunt.registerMultiTask( 'delegate', function() {
		var data = this.data,
			task = this.target,
			target = Array.prototype.join.call( arguments, ':' );

		if ( data.task ) {
			task = data.task;
		} else if ( target ) {
			task = task + ':' + target;
		}

		grunt.task.run( task );
	} );

	// PHPUnit task.
	grunt.registerTask( 'phpunit', function() {
		grunt.util.spawn( {
			cmd: 'phpunit',
			opts: {
				stdio: 'inherit'
			}
		}, this.async() );
	} );

	grunt.registerTask( 'assets', configObject.watch.assets.tasks );

	grunt.registerTask( 'configs', configObject.watch.configs.tasks );

	grunt.registerTask( 'grunt', configObject.watch.grunt.tasks );

	grunt.registerTask( 'images', configObject.watch.images.tasks );

	grunt.registerTask( 'json', configObject.watch.json.tasks );

	grunt.registerTask( 'php', configObject.watch.php.tasks );

	grunt.registerTask( 'scripts', configObject.watch.scripts.tasks );

	grunt.registerTask( 'styles', configObject.watch.styles.tasks );

	grunt.registerTask( 'travis', configObject.watch.travis.tasks );

	grunt.registerTask( 'common', [
		'configs',
		'grunt',
		'json',
		'php'
	] );

	grunt.registerTask( 'ci', [
		'changed-clean',
		'newer-clean',
		'common',
		'eslint:src',
		'jsvalidate:dest',
		'sass:check'
	] );

	grunt.registerTask( 'develop', [
		'common',
		'scripts',
		'styles'
	] );

	grunt.registerTask( 'pre-commit', [
		'changed-clean',
		'newer-clean',
		'common',
		'assets',
		'images',
		'scripts',
		'styles',
		'travis'
	] );

	grunt.registerTask( 'default', 'develop' );

	grunt.registerTask( 'temp', [
		'eslint:src',
		'browserify',
		'uglify'
	] );
};
<commit_msg>Update Gruntfile.<commit_after>module.exports = function( grunt ) {
	var configObject = {
		config: {
			assets: {
				src: 'resources/assets/',
				dest: 'assets/'
			},
			images: {
				src: 'resources/images/',
				dest: 'src/assets/images/'
			},
			scripts: {
				src: 'resources/js/',
				dest: 'src/assets/js/'
			},
			src: 'src/',
			styles: {
				src: 'resources/scss/',
				dest: 'src/assets/css/'
			},
			tests: {
				php: 'tests/php/'
			}
		},

		browserify: {
			options: {
				transform: [
					[ "babelify" ]
				]
			},
			scripts: {
				expand: true,
				cwd: '<%= config.scripts.src %>',
				src: [ '*.js' ],
				dest: '<%= config.scripts.dest %>'
			}
		},

		cssmin: {
			options: {
				compatibility: 'ie8'
			},
			styles: {
				expand: true,
				cwd: '<%= config.styles.dest %>',
				src: [ '*.css', '!*.min.css' ],
				dest: '<%= config.styles.dest %>',
				ext: '.min.css'
			}
		},

		// Allow grunt-newer to run tasks if files other than the individual src files have changed since the last run.
		delegate: {
			'browserify': {
				task: 'browserify',
				src: [ '<%= config.scripts.src %>**/*.js' ]
			},
			'imagemin-assets': {
				task: 'imagemin:assets',
				src: [ '<%= config.assets.src %>*.{gif,jpeg,jpg,png}' ]
			},
			'imagemin-images': {
				task: 'imagemin:images',
				src: [ '<%= config.images.src %>**/*.{gif,jpeg,jpg,png}' ]
			}
		},

		eslint: {
			grunt: {
				src: [ 'Gruntfile.js' ]
			},
			src: {
				expand: true,
				cwd: '<%= config.scripts.src %>',
				src: [ '**/*.js' ]
			}
		},

		imagemin: {
			options: {
				optimizationLevel: 7
			},
			assets: {
				expand: true,
				cwd: '<%= config.assets.src %>',
				src: [ '*.{gif,jpeg,jpg,png}' ],
				dest: '<%= config.assets.dest %>'
			},
			images: {
				expand: true,
				cwd: '<%= config.images.src %>',
				src: [ '**/*.{gif,jpeg,jpg,png}' ],
				dest: '<%= config.images.dest %>'
			}
		},

		jsonlint: {
			configs: {
				src: [ '.*rc' ]
			},
			json: {
				src: [ '*.json' ]
			}
		},

		jsvalidate: {
			options: {
				globals: {},
				esprimaOptions: {},
				verbose: false
			},
			grunt: {
				src: [ 'Gruntfile.js' ]
			},
			dest: {
				src: [ '<%= config.scripts.dest %>*.js' ]
			}
		},

		lineending: {
			options: {
				eol: 'lf',
				overwrite: true
			},
			grunt: {
				src: [ 'Gruntfile.js' ]
			},
			scripts: {
				src: [ '<%= config.scripts.dest %>*.js' ]
			},
			styles: {
				src: [ '<%= config.styles.dest %>*.css' ]
			}
		},

		phplint: {
			src: {
				src: [ '<%= config.src %>**/*.php' ]
			},
			tests: {
				src: [ '<%= config.tests.php %>**/*.php' ]
			}
		},

		postcss: {
			options: {
				processors: [
					require( 'autoprefixer' )( {
						browsers: '> 1%, last 2 versions, IE 8',
						cascade: false
					} )
				]
			},
			styles: {
				expand: true,
				cwd: '<%= config.styles.dest %>',
				src: [ '*.css', '!*.min.css' ],
				dest: '<%= config.styles.dest %>'
			}
		},

		sass: {
			options: {
				style: 'expanded',
				noCache: true
			},
			check: {
				options: {
					check: true
				},
				src: '<%= config.styles.src %>*.scss'
			},
			convert: {
				expand: true,
				cwd: '<%= config.styles.src %>',
				src: [ '*.scss' ],
				dest: '<%= config.styles.dest %>',
				ext: '.css'
			}
		},

		uglify: {
			options: {
				ASCIIOnly: true
			},
			scripts: {
				expand: true,
				cwd: '<%= config.scripts.dest %>',
				src: [ '*.js', '!*.min.js' ],
				dest: '<%= config.scripts.dest %>',
				ext: '.min.js'
			}
		},

		watch: {
			options: {
				dot: true,
				spawn: false,
				interval: 2000
			},

			assets: {
				files: [ '<%= config.assets.src %>*.{gif,jpeg,jpg,png}' ],
				tasks: [
					'newer:delegate:imagemin-assets'
				]
			},

			configs: {
				files: [ '.*rc' ],
				tasks: [
					'newer:jsonlint:configs'
				]
			},

			grunt: {
				files: [ 'Gruntfile.js' ],
				tasks: [
					'newer:eslint:grunt',
					'newer:jsvalidate:grunt',
					'newer:lineending:grunt'
				]
			},

			images: {
				files: [ '<%= config.images.src %>**/*.{gif,jpeg,jpg,png}' ],
				tasks: [
					'newer:delegate:imagemin-images'
				]
			},

			json: {
				files: [ '*.json' ],
				tasks: [
					'newer:jsonlint:json'
				]
			},

			php: {
				files: [
					'<%= config.src %>**/*.php',
					'<%= config.tests.php %>**/*.php'
				],
				tasks: [
					'newer:phplint',
					'phpunit'
				]
			},

			scripts: {
				files: [ '<%= config.scripts.src %>**/*.js' ],
				tasks: [
					'newer:eslint:src',
					'newer:delegate:browserify',
					'newer:jsvalidate:dest',
					'changed:lineending:scripts',
					'changed:uglify'
				]
			},

			styles: {
				files: [ '<%= config.styles.src %>**/*.scss' ],
				tasks: [
					'sass:convert',
					'changed:postcss',
					'changed:lineending:styles',
					'changed:cssmin'
				]
			},

			travis: {
				files: [ '.travis.yml' ],
				tasks: [
					'travis-lint'
				]
			}
		}
	};

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

	grunt.initConfig( configObject );

	// Delegation task for grunt-newer to check files different from the individual task's files.
	grunt.registerMultiTask( 'delegate', function() {
		var data = this.data,
			task = this.target,
			target = Array.prototype.join.call( arguments, ':' );

		if ( data.task ) {
			task = data.task;
		} else if ( target ) {
			task = task + ':' + target;
		}

		grunt.task.run( task );
	} );

	// PHPUnit task.
	grunt.registerTask( 'phpunit', function() {
		grunt.util.spawn( {
			cmd: 'phpunit',
			opts: {
				stdio: 'inherit'
			}
		}, this.async() );
	} );

	grunt.registerTask( 'assets', configObject.watch.assets.tasks );

	grunt.registerTask( 'configs', configObject.watch.configs.tasks );

	grunt.registerTask( 'grunt', configObject.watch.grunt.tasks );

	grunt.registerTask( 'images', configObject.watch.images.tasks );

	grunt.registerTask( 'json', configObject.watch.json.tasks );

	grunt.registerTask( 'php', configObject.watch.php.tasks );

	grunt.registerTask( 'scripts', configObject.watch.scripts.tasks );

	grunt.registerTask( 'styles', configObject.watch.styles.tasks );

	grunt.registerTask( 'travis', configObject.watch.travis.tasks );

	grunt.registerTask( 'common', [
		'configs',
		'grunt',
		'json',
		'php'
	] );

	grunt.registerTask( 'ci', [
		'changed-clean',
		'newer-clean',
		'common',
		'eslint:src',
		'jsvalidate:dest',
		'sass:check'
	] );

	grunt.registerTask( 'develop', [
		'common',
		'scripts',
		'styles'
	] );

	grunt.registerTask( 'pre-commit', [
		'changed-clean',
		'newer-clean',
		'common',
		'assets',
		'images',
		'scripts',
		'styles',
		'travis'
	] );

	grunt.registerTask( 'default', 'develop' );
};
<|endoftext|>


<commit_before>module.exports = function(grunt) {
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
      sass: {
        dist: {
          files: {
            'style.css' : 'sass/style.scss'
          }
        }
      },
      watch: {
      css: {
        files: '**/*.scss',
        tasks: ['sass']
        }
      }
    });
  grunt.loadNpmTasks('grunt-contrib-sass');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.registerTask('default',['watch']);
}
<commit_msg>Defining watch task<commit_after>module.exports = function(grunt) {
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
      sass: {
        dist: {
          files: {
            'css/style.css' : 'scss/style.scss'
          }
        }
      },
      watch: {
        css: {
          files: '**/*.scss',
          tasks: ['sass']
          }
        }
      }
  );
  grunt.loadNpmTasks('grunt-contrib-sass');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.registerTask('default',['watch']);
}
<|endoftext|>


<commit_before>module.exports = function(grunt) {
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),

    concat: {
      dist: {
        src: ['lib/responsive.js', 'lib/*.js'],
        dest: 'dist/<%= pkg.name %>.js'
      },
      test: {
        src: [
          'bower_components/jquery/dist/jquery.js',
          'bower_components/handlebars/handlebars.js',
          'bower_components/ember/ember.js',
          'bower_components/qunit/qunit/qunit.js',
          'bower_components/sinonjs/sinon.js',
          'lib/responsive.js',
          'lib/*.js',
          'tests/**.js',
        ],
        dest: 'dist/<%= pkg.name %>.test.js'
      }
    },

    testem: {
      test: {
        options: {
          test_page: 'tests/index.html',
          framework: 'qunit',
          launch_in_dev: ['PhantomJS', 'Chrome'],
          launch_in_ci: ['PhantomJS', 'Chrome'],
        }
      }
    },

    yuidoc: {
      compile: {
        name: '<%= pkg.name %>',
        description: '<%= pkg.description %>',
        version: '<%= pkg.version %>',
        url: '<%= pkg.homepage %>',
        options: {
          paths: 'lib',
          outdir: 'dist/doc'
        }
      }
    },

    bump: {
      options: {
        files: ['package.json', 'bower.json'],
        commitFiles: ['package.json', 'bower.json', 'dist'],
        pushTo: 'origin',
      }
    },

    clean: ['dist']
  });

  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-testem');
  grunt.loadNpmTasks('grunt-contrib-yuidoc');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-bump');

  grunt.registerTask('test', 'Run tests using testem and PhantomJS',
                     ['concat:test', 'testem:ci:test']);

  grunt.registerTask('dist', 'Create a distributable version',
                     ['doc', 'concat:dist']);

  grunt.registerTask('doc', 'Generate API documentation',
                     ['yuidoc:compile']);

  grunt.registerTask('release:minor', 'Generates and tags a minor release',
                     ['test', 'clean', 'dist', 'bump:minor']);

  grunt.registerTask('release:patch', 'Generates and tags a patch release',
                     ['test', 'clean', 'dist', 'bump:patch']);
}
<commit_msg>Update configuration so YUIDoc receives the right version.<commit_after>module.exports = function(grunt) {
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),

    concat: {
      dist: {
        src: ['lib/responsive.js', 'lib/*.js'],
        dest: 'dist/<%= pkg.name %>.js'
      },
      test: {
        src: [
          'bower_components/jquery/dist/jquery.js',
          'bower_components/handlebars/handlebars.js',
          'bower_components/ember/ember.js',
          'bower_components/qunit/qunit/qunit.js',
          'bower_components/sinonjs/sinon.js',
          'lib/responsive.js',
          'lib/*.js',
          'tests/**.js',
        ],
        dest: 'dist/<%= pkg.name %>.test.js'
      }
    },

    testem: {
      test: {
        options: {
          test_page: 'tests/index.html',
          framework: 'qunit',
          launch_in_dev: ['PhantomJS', 'Chrome'],
          launch_in_ci: ['PhantomJS', 'Chrome'],
        }
      }
    },

    yuidoc: {
      compile: {
        name: '<%= pkg.name %>',
        description: '<%= pkg.description %>',
        version: '<%= pkg.version %>',
        url: '<%= pkg.homepage %>',
        options: {
          paths: 'lib',
          outdir: 'dist/doc'
        }
      }
    },

    bump: {
      options: {
        files: ['package.json', 'bower.json'],
        updateConfigs: ['pkg'],
        commitFiles: ['package.json', 'bower.json', 'dist/'],
        pushTo: 'origin',
      }
    },

    clean: ['dist']
  });

  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-testem');
  grunt.loadNpmTasks('grunt-contrib-yuidoc');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-bump');

  grunt.registerTask('test', 'Run tests using testem and PhantomJS',
                     ['concat:test', 'testem:ci:test']);

  grunt.registerTask('dist', 'Create a distributable version',
                     ['doc', 'concat:dist']);

  grunt.registerTask('doc', 'Generate API documentation',
                     ['yuidoc:compile']);

  grunt.registerTask('release:minor', 'Generates and tags a minor release',
                     ['test', 'clean', 'dist', 'bump:minor']);

  grunt.registerTask('release:patch', 'Generates and tags a patch release',
                     ['test', 'clean', 'dist', 'bump:patch']);
}
<|endoftext|>


<commit_before>/**
 * @license
 * Copyright 2012 Google Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

CLASS({
  name: 'Relationship',
  tableProperties: [
    'name', 'label', 'relatedModel', 'relatedProperty'
  ],

  documentation: function() { /*
      $$DOC{ref:'Relationship',usePlural:true} indicate a parent-child relation
      between instances of
      a $$DOC{ref:'Model'} and some child $$DOC{ref:'Model',usePlural:true},
      through the indicated
      $$DOC{ref:'Property',usePlural:true}. If your $$DOC{ref:'Model',usePlural:true}
      build a tree
      structure of instances, they could likely benefit from a declared
      $$DOC{ref:'Relationship'}.
    */},

  properties: [
    {
      name:  'name',
      type:  'String',
      displayWidth: 30,
      displayHeight: 1,
      defaultValueFn: function() { return GLOBAL[this.relatedModel] ? GLOBAL[this.relatedModel].plural : ''; },
      documentation: function() { /* The identifier used in code to represent this $$DOC{ref:'.'}.
        $$DOC{ref:'.name'} should generally only contain identifier-safe characters.
        $$DOC{ref:'.'} names should use camelCase staring with a lower case letter.
         */},
      help: 'The coding identifier for the relationship.'
    },
    {
      name: 'label',
      type: 'String',
      displayWidth: 70,
      displayHeight: 1,
      defaultValueFn: function() { return this.name.labelize(); },
      documentation: function() { /* A human readable label for the $$DOC{ref:'.'}. May
        contain spaces or other odd characters.
         */},
      help: 'The display label for the relationship.'
    },
    {
      name: 'help',
      label: 'Help Text',
      type: 'String',
      displayWidth: 70,
      displayHeight: 6,
      defaultValue: '',
      documentation: function() { /*
          This $$DOC{ref:'.help'} text informs end users how to use the $$DOC{ref:'.'},
          through field labels or tooltips.
      */},
      help: 'Help text associated with the relationship.'
    },
    {
      model_: 'DocumentationProperty',
      name: 'documentation',
      documentation: function() { /*
          The developer documentation.
      */}
    },
    {
      name:  'relatedModel',
      type:  'String',
      required: true,
      displayWidth: 30,
      displayHeight: 1,
      defaultValue: '',
      documentation: function() { /* The $$DOC{ref:'Model.name'} of the related $$DOC{ref:'Model'}.*/},
      help: 'The name of the related Model.'
    },
    {
      name:  'relatedProperty',
      type:  'String',
      required: true,
      displayWidth: 30,
      displayHeight: 1,
      defaultValue: '',
      documentation: function() { /*
        The join $$DOC{ref:'Property'} of the related $$DOC{ref:'Model'}.
        This is the property that links back to this $$DOC{ref:'Model'} from the other
        $$DOC{ref:'Model',usePlural:true}.
      */},
      help: 'The join property of the related Model.'
    }
  ]/*,
  methods: {
    dao: function() {
      var m = this.X[this.relatedModel];
      return this.X[m.name + 'DAO'];
    },
    JOIN: function(sink, opt_where) {
      var m = this.X[this.relatedModel];
      var dao = this.X[m.name + 'DAO'] || this.X[m.plural];
      return MAP(JOIN(
        dao.where(opt_where || TRUE),
        m.getProperty(this.relatedProperty),
        []), sink);
    }
  }*/
});

(function() {
  for ( var i = 0 ; i < Model.templates.length ; i++ )
    Model.templates[i] = JSONUtil.mapToObj(X, Model.templates[i]);

  Model.properties = Model.properties;
  delete Model.instance_.prototype_;
  Model = Model.create(Model);
})();

// Go back over each model so far, assigning the new Model to remove any reference
// to the bootstrap Model, then FOAMalize any features that were missed due to
// the model for that feature type ("Method", "Documentation", etc.) being
// missing previously. This time the preSet for each should be fully operational.
function recopyModelFeatures(m) {
  m.model_ = Model;

  // the preSet for each of these does the work
  m.methods       = m.methods;
  m.templates     = m.templates;
  m.relationships = m.relationships;
  m.properties    = m.properties;
  m.actions       = m.actions;
  m.listeners     = m.listeners;
  m.models        = m.models;
  m.tests         = m.tests;
  m.issues        = m.issues;

  // check for old bootstrap Property instances
  if ( m.properties && m.properties[0] && ! Property.isInstance(m.properties[0]) ) {
    m.properties.forEach(function(p) {
      if ( p.model_.name === 'Property' ) p.model_ = Property;
    });
  }

  // keep copies of the updated lists
  if ( DEBUG ) BootstrapModel.saveDefinition(m);
}

// Update Model in everything we've created so far
for ( var id in USED_MODELS ) {
  recopyModelFeatures(GLOBAL.lookup(id));
}

if ( DEBUG ) {
  for ( var id in UNUSED_MODELS ) {
    if ( USED_MODELS[id] ) recopyModelFeatures(GLOBAL.lookup(id));
  }
}

USED_MODELS['Model'] = true;
<commit_msg>Added DEBUG check.<commit_after>/**
 * @license
 * Copyright 2012 Google Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

CLASS({
  name: 'Relationship',
  tableProperties: [
    'name', 'label', 'relatedModel', 'relatedProperty'
  ],

  documentation: function() { /*
      $$DOC{ref:'Relationship',usePlural:true} indicate a parent-child relation
      between instances of
      a $$DOC{ref:'Model'} and some child $$DOC{ref:'Model',usePlural:true},
      through the indicated
      $$DOC{ref:'Property',usePlural:true}. If your $$DOC{ref:'Model',usePlural:true}
      build a tree
      structure of instances, they could likely benefit from a declared
      $$DOC{ref:'Relationship'}.
    */},

  properties: [
    {
      name:  'name',
      type:  'String',
      displayWidth: 30,
      displayHeight: 1,
      defaultValueFn: function() { return GLOBAL[this.relatedModel] ? GLOBAL[this.relatedModel].plural : ''; },
      documentation: function() { /* The identifier used in code to represent this $$DOC{ref:'.'}.
        $$DOC{ref:'.name'} should generally only contain identifier-safe characters.
        $$DOC{ref:'.'} names should use camelCase staring with a lower case letter.
         */},
      help: 'The coding identifier for the relationship.'
    },
    {
      name: 'label',
      type: 'String',
      displayWidth: 70,
      displayHeight: 1,
      defaultValueFn: function() { return this.name.labelize(); },
      documentation: function() { /* A human readable label for the $$DOC{ref:'.'}. May
        contain spaces or other odd characters.
         */},
      help: 'The display label for the relationship.'
    },
    {
      name: 'help',
      label: 'Help Text',
      type: 'String',
      displayWidth: 70,
      displayHeight: 6,
      defaultValue: '',
      documentation: function() { /*
          This $$DOC{ref:'.help'} text informs end users how to use the $$DOC{ref:'.'},
          through field labels or tooltips.
      */},
      help: 'Help text associated with the relationship.'
    },
    {
      model_: 'DocumentationProperty',
      name: 'documentation',
      documentation: function() { /*
          The developer documentation.
      */}
    },
    {
      name:  'relatedModel',
      type:  'String',
      required: true,
      displayWidth: 30,
      displayHeight: 1,
      defaultValue: '',
      documentation: function() { /* The $$DOC{ref:'Model.name'} of the related $$DOC{ref:'Model'}.*/},
      help: 'The name of the related Model.'
    },
    {
      name:  'relatedProperty',
      type:  'String',
      required: true,
      displayWidth: 30,
      displayHeight: 1,
      defaultValue: '',
      documentation: function() { /*
        The join $$DOC{ref:'Property'} of the related $$DOC{ref:'Model'}.
        This is the property that links back to this $$DOC{ref:'Model'} from the other
        $$DOC{ref:'Model',usePlural:true}.
      */},
      help: 'The join property of the related Model.'
    }
  ]/*,
  methods: {
    dao: function() {
      var m = this.X[this.relatedModel];
      return this.X[m.name + 'DAO'];
    },
    JOIN: function(sink, opt_where) {
      var m = this.X[this.relatedModel];
      var dao = this.X[m.name + 'DAO'] || this.X[m.plural];
      return MAP(JOIN(
        dao.where(opt_where || TRUE),
        m.getProperty(this.relatedProperty),
        []), sink);
    }
  }*/
});

(function() {
  for ( var i = 0 ; i < Model.templates.length ; i++ )
    Model.templates[i] = JSONUtil.mapToObj(X, Model.templates[i]);

  Model.properties = Model.properties;
  delete Model.instance_.prototype_;
  Model = Model.create(Model);
})();

// Go back over each model so far, assigning the new Model to remove any reference
// to the bootstrap Model, then FOAMalize any features that were missed due to
// the model for that feature type ("Method", "Documentation", etc.) being
// missing previously. This time the preSet for each should be fully operational.
function recopyModelFeatures(m) {
  m.model_ = Model;

  // the preSet for each of these does the work
  m.methods       = m.methods;
  m.templates     = m.templates;
  m.relationships = m.relationships;
  m.properties    = m.properties;
  m.actions       = m.actions;
  m.listeners     = m.listeners;
  m.models        = m.models;
  if ( DEBUG ) {
    m.tests       = m.tests;
    m.issues      = m.issues;
  }

  // check for old bootstrap Property instances
  if ( m.properties && m.properties[0] && ! Property.isInstance(m.properties[0]) ) {
    m.properties.forEach(function(p) {
      if ( p.model_.name === 'Property' ) p.model_ = Property;
    });
  }

  // keep copies of the updated lists
  if ( DEBUG ) BootstrapModel.saveDefinition(m);
}

// Update Model in everything we've created so far
for ( var id in USED_MODELS ) {
  recopyModelFeatures(GLOBAL.lookup(id));
}

if ( DEBUG ) {
  for ( var id in UNUSED_MODELS ) {
    if ( USED_MODELS[id] ) recopyModelFeatures(GLOBAL.lookup(id));
  }
}

USED_MODELS['Model'] = true;
<|endoftext|>


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

	'use strict';

	/*
	   Javascript settings - Edit this section
	   ========================================================================== */
	/**
	 * Specify which js files you want to include
	 */
	var jsFileList = [
		'js/helpers/helpers.js',
		'js/helpers/console.js',
		'js/script.js'
	];

	/**
	 * Specify your output directory
	 */
	var distDir = 'js/dist/';

	/**
	 * Specify the name of your compiled JS file
	 * which will be placed in the directory you define above
	 */
	var jsFile = 'app.min.js';

	/* ==================== */

	/**
	 * Project configuration
	 */
	grunt.initConfig({
		pkg: require('./package'),
		site: grunt.file.readYAML('src/data/site.yml'),

		/**
		 * JSHint
		 * https://github.com/gruntjs/grunt-contrib-jshint
		 * Manage the options inside .jshintrc file
		 */
		jshint: {
			all: jsFileList,
			options: {
				jshintrc: '.jshintrc'
			}
		},

		/**
		 * Sass compilation
		 * https://github.com/gruntjs/grunt-contrib-sass
		 * Separate options for dev and production environments
		 * Includes kickoff.scss and kickoff-old-ie.scss by default
		 * Also creates source maps
		 */
		sass: {
			dev: {
				options: {
					unixNewlines: true,
					style: 'expanded',
					lineNumbers: false,
					debugInfo : false,
					precision : 8,
					sourcemap : true
				},
				files: {
					'css/kickoff.css': 'scss/kickoff.scss',
					'css/kickoff-old-ie.css': 'scss/kickoff-old-ie.scss'
				}
			},
			production: {
				options: {
					style: 'compressed',
					precision : 8
				},
				files: {
					'css/kickoff.css': 'scss/kickoff.scss',
					'css/kickoff-old-ie.css': 'scss/kickoff-old-ie.scss'
				}

			}
		},

		/**
		 * Uglify
		 * https://github.com/gruntjs/grunt-contrib-uglify
		 * Minifies and concatinates your JS
		 * Also creates source maps
		 */
		uglify: {
			options: {
				// mangle: Turn on or off mangling
				mangle: true,

				// beautify: beautify your code for debugging/troubleshooting purposes
				beautify: false,

				// report: Show file size report
				report: 'gzip',

				// sourceMap: @string. The location of the source map, relative to the project
				sourceMap: jsFile + '.map',

				// sourceMappingURL: @string. The string that is printed to the final file
				sourceMappingURL: '../../'+ jsFile +'.map'

				// sourceMapRoot: @string. The location where your source files can be found. This sets the sourceRoot field in the source map.
				// sourceMapRoot: 'js',

				// sourceMapPrefix: @integer. The number of directories to drop from the path prefix when declaring files in the source map.
				// sourceMapPrefix: 1,

			},

			/**
			 * Use the array at the top of this file to specify which js files you include
			 */
			js: {
				src: jsFileList,
				dest: distDir + jsFile
			}
		},

		/**
		 * Watch
		 * https://github.com/gruntjs/grunt-contrib-watch
		 * Watches your scss, js etc for changes and compiles them
		 */
		watch: {
			scss: {
				files: ['scss/**/*.scss'],
				tasks: ['sass:dev']
				// tasks: ['sass:dev', 'autoprefixer:dist', 'csso']
			},

			js: {
				files: [
					'Gruntfile.js',
					'js/*.js',
					'js/libs/**/*.js'
				],
				tasks: ['uglify']
			},

			assemble : {
				files: ['src/templates/**/*.hbs'],
				tasks: ['assemble']
			},

			livereload: {
				options: { livereload: true },
				files: [
					'the-visual-web/*.html',
					'css/*.css'
				]
			}
		},

		connect: {
			options: {
                port: 9000,
                // change this to '0.0.0.0' to access the server from outside
                hostname: 'localhost'
            },
			server: {
				options: {
					base: 'the-visual-web'
				}
			}
		},

		open: {
            server: {
                path: 'http://localhost:<%= connect.options.port %>'
            }
        },

		/**
		 * Autoprefixer
		 * https://github.com/ai/autoprefixer
		 * Auto prefixes your CSS using caniuse data
		 */
		autoprefixer: {
			dist : {
				options: {
					// Task-specific options go here - we are supporting
					// the last 2 browsers, any browsers with >1% market share,
					// and ensuring we support IE7 + 8 with prefixes
					browsers: ['last 2 versions', '> 1%', 'ie 8', 'ie 7']
				},
				files: {
					'css/kickoff.prefixed.css': 'css/kickoff.css',
					'css/kickoff-old-ie.prefixed.css': 'css/kickoff-old-ie.css'
				}
			}
		},

		/**
		 * CSSO
		 * https://github.com/t32k/grunt-csso
		 * Minify CSS files with CSSO
		 */
		csso: {
			dist: {
				files: {
					'css/kickoff.min.css': ['css/kickoff.prefixed.css'],
					'css/kickoff-old-ie.min.css': ['css/kickoff-old-ie.prefixed.css']
				},

			}
		},

		assemble: {
			options: {
				data: 'src/**/*.{json,yml}',
				assets: '<%= site.destination %>/assets',
				helpers: 'src/helpers/helper-*.js',
				layoutdir: 'src/templates/layouts',
				partials: ['src/templates/includes/**/*.hbs'],
				flatten: true
			},

			site: {
				// Target-level options
				options: {layout: 'default.hbs'},
				files: [
					{ expand: true, cwd: 'src/templates/pages', src: ['*.hbs'], dest: '<%= site.destination %>/' }
				]
			}
		},

		readme: {
			options: {
				sep: '',
				docs: ['docs/']
			}
		}
	});

	// Load some stuff
	grunt.loadNpmTasks('grunt-readme');
	grunt.loadNpmTasks('grunt-contrib-connect');
	grunt.loadNpmTasks('grunt-open');
	grunt.loadNpmTasks('grunt-contrib-jshint');
	grunt.loadNpmTasks('grunt-contrib-sass');
	grunt.loadNpmTasks('grunt-contrib-uglify');
	grunt.loadNpmTasks('grunt-contrib-watch');
	grunt.loadNpmTasks('grunt-autoprefixer');
	grunt.loadNpmTasks('grunt-csso');
	grunt.loadNpmTasks('assemble');
	grunt.loadNpmTasks('grunt-newer');

	/**
	 * Available tasks:
	   * grunt        : run jshint, uglify and sass:dev
	   * grunt watch  : run sass:dev, uglify and livereload
	   * grunt dev    : run jshint, uglify and sass:dev
	   * grunt deploy : run jshint, uglify and sass:production
	 */

	/**
	 * Default task
	 * run jshint, uglify and sass:dev
	 */
	// Default task
	grunt.registerTask('default', ['readme', 'jshint', 'uglify', 'sass:dev', 'newer:assemble']);

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

        grunt.task.run([
            //'clean:server',
            //'concurrent:server',
            'connect',
            'open',
            'watch'
        ]);
    });

	/**
	 * A task for development
	 * run jshint, uglify and sass:dev
	 */
	grunt.registerTask('dev', ['jshint', 'uglify', 'sass:dev']);

	/**
	 * A task for your production environment
	 * run jshint, uglify and sass:production
	 */
	grunt.registerTask('deploy', ['jshint', 'uglify', 'sass:production']);
	// grunt.registerTask('production', ['jshint', 'uglify', 'sass:production', 'autoprefixer', 'csso']);

};
<commit_msg>Gruntfile build processes tidied up<commit_after>module.exports = function (grunt) {

	'use strict';

	/*
	   Javascript settings - Edit this section
	   ========================================================================== */
	/**
	 * Specify which js files you want to include
	 */
	var jsFileList = [
		'js/helpers/helpers.js',
		'js/helpers/console.js',
		'js/script.js'
	];

	/**
	 * Specify your output directory
	 */
	var distDir = 'js/dist/';

	/**
	 * Specify the name of your compiled JS file
	 * which will be placed in the directory you define above
	 */
	var jsFile = 'app.min.js';

	/* ==================== */

	/**
	 * Project configuration
	 */
	grunt.initConfig({
		pkg: require('./package'),
		site: grunt.file.readYAML('src/data/site.yml'),

		/**
		 * JSHint
		 * https://github.com/gruntjs/grunt-contrib-jshint
		 * Manage the options inside .jshintrc file
		 */
		jshint: {
			all: jsFileList,
			options: {
				jshintrc: '.jshintrc'
			}
		},

		/**
		 * Sass compilation
		 * https://github.com/gruntjs/grunt-contrib-sass
		 * Separate options for dev and production environments
		 * Includes kickoff.scss and kickoff-old-ie.scss by default
		 * Also creates source maps
		 */
		sass: {
			dev: {
				options: {
					unixNewlines: true,
					style: 'expanded',
					lineNumbers: false,
					debugInfo : false,
					precision : 8,
					sourcemap : true
				},
				files: {
					'css/kickoff.css': 'scss/kickoff.scss',
					'css/kickoff-old-ie.css': 'scss/kickoff-old-ie.scss'
				}
			},
			production: {
				options: {
					style: 'compressed',
					precision : 8
				},
				files: {
					'css/kickoff.css': 'scss/kickoff.scss',
					'css/kickoff-old-ie.css': 'scss/kickoff-old-ie.scss'
				}

			}
		},

		/**
		 * Uglify
		 * https://github.com/gruntjs/grunt-contrib-uglify
		 * Minifies and concatinates your JS
		 * Also creates source maps
		 */
		uglify: {
			options: {
				// mangle: Turn on or off mangling
				mangle: true,

				// beautify: beautify your code for debugging/troubleshooting purposes
				beautify: false,

				// report: Show file size report
				report: 'gzip',

				// sourceMap: @string. The location of the source map, relative to the project
				sourceMap: jsFile + '.map',

				// sourceMappingURL: @string. The string that is printed to the final file
				sourceMappingURL: '../../'+ jsFile +'.map'

				// sourceMapRoot: @string. The location where your source files can be found. This sets the sourceRoot field in the source map.
				// sourceMapRoot: 'js',

				// sourceMapPrefix: @integer. The number of directories to drop from the path prefix when declaring files in the source map.
				// sourceMapPrefix: 1,

			},

			/**
			 * Use the array at the top of this file to specify which js files you include
			 */
			js: {
				src: jsFileList,
				dest: distDir + jsFile
			}
		},

		/**
		 * Watch
		 * https://github.com/gruntjs/grunt-contrib-watch
		 * Watches your scss, js etc for changes and compiles them
		 */
		watch: {
			scss: {
				files: ['scss/**/*.scss'],
				tasks: ['sass:dev']
				// tasks: ['sass:dev', 'autoprefixer:dist', 'csso']
			},

			js: {
				files: [
					'Gruntfile.js',
					'js/*.js',
					'js/libs/**/*.js'
				],
				tasks: ['uglify']
			},

			assemble : {
				files: ['src/templates/**/*.hbs'],
				tasks: ['assemble']
			},

			livereload: {
				options: { livereload: true },
				files: [
					'the-visual-web/*.html',
					'css/*.css'
				]
			}
		},

		connect: {
			options: {
                port: 9000,
                // change this to '0.0.0.0' to access the server from outside
                hostname: 'localhost'
            },
			server: {
				options: {
					base: 'the-visual-web'
				}
			}
		},

		open: {
            server: {
                path: 'http://localhost:<%= connect.options.port %>'
            }
        },

		/**
		 * Autoprefixer
		 * https://github.com/ai/autoprefixer
		 * Auto prefixes your CSS using caniuse data
		 */
		autoprefixer: {
			dist : {
				options: {
					// Task-specific options go here - we are supporting
					// the last 2 browsers, any browsers with >1% market share,
					// and ensuring we support IE7 + 8 with prefixes
					browsers: ['last 2 versions', '> 1%', 'ie 8', 'ie 7']
				},
				files: {
					'css/kickoff.prefixed.css': 'css/kickoff.css',
					'css/kickoff-old-ie.prefixed.css': 'css/kickoff-old-ie.css'
				}
			}
		},

		/**
		 * CSSO
		 * https://github.com/t32k/grunt-csso
		 * Minify CSS files with CSSO
		 */
		csso: {
			dist: {
				files: {
					'css/kickoff.min.css': ['css/kickoff.prefixed.css'],
					'css/kickoff-old-ie.min.css': ['css/kickoff-old-ie.prefixed.css']
				},

			}
		},

		assemble: {
			options: {
				data: 'src/**/*.{json,yml}',
				assets: '<%= site.destination %>/assets',
				helpers: 'src/helpers/helper-*.js',
				layoutdir: 'src/templates/layouts',
				partials: ['src/templates/includes/**/*.hbs'],
				flatten: true
			},

			site: {
				// Target-level options
				options: {layout: 'default.hbs'},
				files: [
					{ expand: true, cwd: 'src/templates/pages', src: ['*.hbs'], dest: '<%= site.destination %>/' }
				]
			}
		},

		readme: {
			options: {
				sep: '',
				docs: ['docs/']
			}
		}
	});

	// Load some stuff
	grunt.loadNpmTasks('grunt-readme');
	grunt.loadNpmTasks('grunt-contrib-connect');
	grunt.loadNpmTasks('grunt-open');
	grunt.loadNpmTasks('grunt-contrib-jshint');
	grunt.loadNpmTasks('grunt-contrib-sass');
	grunt.loadNpmTasks('grunt-contrib-uglify');
	grunt.loadNpmTasks('grunt-contrib-watch');
	grunt.loadNpmTasks('grunt-autoprefixer');
	grunt.loadNpmTasks('grunt-csso');
	grunt.loadNpmTasks('assemble');
	grunt.loadNpmTasks('grunt-newer');

	/**
	 * Available tasks:
	   * grunt        : run jshint, uglify and sass:dev
	   * grunt watch  : run sass:dev, uglify and livereload
	   * grunt dev    : run jshint, uglify and sass:dev
	   * grunt deploy : run jshint, uglify and sass:production
	 */

	/**
	 * Default task
	 * run jshint, uglify and sass:dev
	 */
	// Default task
	grunt.registerTask('default', ['readme', 'jshint', 'uglify', 'sass:dev', 'newer:assemble']);

	grunt.registerTask('server', function (target) {
        grunt.task.run([
            'connect',
            'open',
            'watch'
        ]);
    });

	/*
		NEED TO UPDATE DEV AND PROD GRUNT BUILDS AS THESE ARE JUST PLACEHOLDERS

	 */

	/**
	 * A task for development
	 * run jshint, uglify and sass:dev
	 */
	grunt.registerTask('dev', ['jshint', 'uglify', 'sass:dev']);

	/**
	 * A task for your production environment
	 * run jshint, uglify and sass:production
	 */
	grunt.registerTask('deploy', ['jshint', 'uglify', 'sass:production']);
	// grunt.registerTask('production', ['jshint', 'uglify', 'sass:production', 'autoprefixer', 'csso']);

};
<|endoftext|>


<commit_before>// Copyright 2015 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// This library provides access to the Handler registration database.

"use strict";

(function() {

// Promise-based wrappers around indexedDB.

// Takes an IDBRequest object (the result of calling some indexedDB function).
// Returns a promise that resolves with the request's result, or rejects with
// the request's DOMError.
function promisify(request) {
  return new Promise((resolve, reject) => {
    request.onerror = e => reject(request.error);
    request.onsuccess = e => resolve(request.result);
  });
}

// Opens an indexeddb database. |upgradefunction| is called with the IDBDatabase
// and old version as arguments, if an upgrade is needed (it should return a
// promise). Returns a promise that resolves with the IDBDatabase object.
function openDatabase(name, version, upgradefunction) {
  var request = window.indexedDB.open(name, version);
  return new Promise((resolve, reject) => {
    request.onerror = e => reject(request.error);
    request.onblocked = e => reject(
        new DOMError('The database cannot be upgraded because it is in use.'));
    request.onsuccess = e => resolve(request.result);
    request.onupgradeneeded = e => {
      upgradefunction(request.result, e.oldVersion)
          .then(() => resolve(request.result), error => reject(error));
    }
  });
}

// Takes an IDBTransaction object and waits for the transaction to complete.
// Returns a promise that resolves (with no argument) when the transaction
// completes.
function transactionWait(transaction) {
  return new Promise((resolve, reject) => {
    transaction.onerror = e => reject(transaction.error);
    transaction.oncomplete = e => resolve();
  });
}

function storeAdd(objectStore, value, key) {
  return promisify(objectStore.add(value, key));
}

function storePut(objectStore, value, key) {
  return promisify(objectStore.put(value, key));
}

function storeDelete(objectStore, key) {
  return promisify(objectStore.delete(key));
}

function storeGet(objectStore, key) {
  return promisify(objectStore.get(key));
}

// Handler registration database code.

// Class representing a Handler entry in the database. |name| and |url| are
// strings (|url| is the primary key). |verbs| is a list of strings.
window.Handler = function(name, url, verbs) {
  this.name = name;
  this.url = url;
  this.verbs = verbs;
};

// Convert an Object into a Handler with the same fields.
function handlerFromObject(object) {
  if (object == undefined)
    return object;

  var handler = new Handler();
  for (var k in object)
    handler[k] = object[k];
  return handler;
}

function onUpgradeNeeded(db, oldVersion) {
  // The 'handlers' store maps arbitrary ints onto Handler objects.
  var objectStore = db.createObjectStore('handlers', {keyPath: 'url'});
  return new Promise((resolve, reject) => resolve());
}

// Wrapper around the database, providing methods for accessing handlers.
function RegistryDatabase(db) {
  this.db = db;
}

// Adds a new handler to the database. Returns a promise that resolves once the
// transaction is complete.
RegistryDatabase.prototype.registerHandler = function(handler) {
  var transaction = this.db.transaction(['handlers'], 'readwrite');
  var store = transaction.objectStore('handlers');
  return Promise.all([storePut(store, handler), transactionWait(transaction)]);
};

// Deletes handlers from the database. Returns a promise that resolves once the
// transaction is complete.
RegistryDatabase.prototype.deleteHandlerForUrls = function(urls) {
  var transaction = this.db.transaction(['handlers'], 'readwrite');
  var store = transaction.objectStore('handlers');
  var promises = urls.map(url => storeDelete(store, url));
  promises.push(transactionWait(transaction));
  return Promise.all(promises);
};

// Deletes a handler from the database. Returns a promise that resolves once the
// transaction is complete.
RegistryDatabase.prototype.deleteHandlerForUrl = function(url) {
  db.deleteHandlerForUrls([url]);
};

// Gets all handlers in the database. Returns a promise that resolves with an
// array of Handlers.
RegistryDatabase.prototype.getAllHandlers = function() {
  var transaction = this.db.transaction(['handlers']);
  var store = transaction.objectStore('handlers');
  var handlers = [];
  return new Promise((resolve, reject) => {
    store.openCursor().onsuccess = e => {
      var cursor = e.target.result;
      if (cursor) {
        handlers.push(handlerFromObject(cursor.value));
        cursor.continue();
      } else {
        resolve(handlers);
      }
    };
  });
};

// Gets a handler for a specific URL. Returns a promise that resolves with the
// Handler, or undefined if it is not found.
RegistryDatabase.prototype.getHandlerForUrl = function(url) {
  var transaction = this.db.transaction(['handlers']);
  var store = transaction.objectStore('handlers');
  return storeGet(store, url).then(handlerFromObject);
};

// Gets a handler for a specific URL. Returns a promise that resolves with the
// Handler, or undefined if it is not found.
RegistryDatabase.prototype.getHandlersForVerb = function(verb) {
  var transaction = this.db.transaction(['handlers']);
  var store = transaction.objectStore('handlers');
  var handlers = [];
  return new Promise((resolve, reject) => {
    // TODO(mgiuca): Index handlers by verb, to avoid a full database search.
    store.openCursor().onsuccess = e => {
      var cursor = e.target.result;
      if (cursor) {
        var verbs = cursor.value.verbs;
        if (verbs && verbs.indexOf(verb) >= 0)
          handlers.push(handlerFromObject(cursor.value));
        cursor.continue();
      } else {
        resolve(handlers);
      }
    };
  });
};

RegistryDatabase.prototype.close = function() {
  this.db.close();
};

window.openRegistryDatabase = function() {
  return openDatabase('ProxyRegistry', 1, onUpgradeNeeded)
      .then(db => new RegistryDatabase(db));
};

})();
<commit_msg>registry: deleteHandlerForUrl returns a promise.<commit_after>// Copyright 2015 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// This library provides access to the Handler registration database.

"use strict";

(function() {

// Promise-based wrappers around indexedDB.

// Takes an IDBRequest object (the result of calling some indexedDB function).
// Returns a promise that resolves with the request's result, or rejects with
// the request's DOMError.
function promisify(request) {
  return new Promise((resolve, reject) => {
    request.onerror = e => reject(request.error);
    request.onsuccess = e => resolve(request.result);
  });
}

// Opens an indexeddb database. |upgradefunction| is called with the IDBDatabase
// and old version as arguments, if an upgrade is needed (it should return a
// promise). Returns a promise that resolves with the IDBDatabase object.
function openDatabase(name, version, upgradefunction) {
  var request = window.indexedDB.open(name, version);
  return new Promise((resolve, reject) => {
    request.onerror = e => reject(request.error);
    request.onblocked = e => reject(
        new DOMError('The database cannot be upgraded because it is in use.'));
    request.onsuccess = e => resolve(request.result);
    request.onupgradeneeded = e => {
      upgradefunction(request.result, e.oldVersion)
          .then(() => resolve(request.result), error => reject(error));
    }
  });
}

// Takes an IDBTransaction object and waits for the transaction to complete.
// Returns a promise that resolves (with no argument) when the transaction
// completes.
function transactionWait(transaction) {
  return new Promise((resolve, reject) => {
    transaction.onerror = e => reject(transaction.error);
    transaction.oncomplete = e => resolve();
  });
}

function storeAdd(objectStore, value, key) {
  return promisify(objectStore.add(value, key));
}

function storePut(objectStore, value, key) {
  return promisify(objectStore.put(value, key));
}

function storeDelete(objectStore, key) {
  return promisify(objectStore.delete(key));
}

function storeGet(objectStore, key) {
  return promisify(objectStore.get(key));
}

// Handler registration database code.

// Class representing a Handler entry in the database. |name| and |url| are
// strings (|url| is the primary key). |verbs| is a list of strings.
window.Handler = function(name, url, verbs) {
  this.name = name;
  this.url = url;
  this.verbs = verbs;
};

// Convert an Object into a Handler with the same fields.
function handlerFromObject(object) {
  if (object == undefined)
    return object;

  var handler = new Handler();
  for (var k in object)
    handler[k] = object[k];
  return handler;
}

function onUpgradeNeeded(db, oldVersion) {
  // The 'handlers' store maps arbitrary ints onto Handler objects.
  var objectStore = db.createObjectStore('handlers', {keyPath: 'url'});
  return new Promise((resolve, reject) => resolve());
}

// Wrapper around the database, providing methods for accessing handlers.
function RegistryDatabase(db) {
  this.db = db;
}

// Adds a new handler to the database. Returns a promise that resolves once the
// transaction is complete.
RegistryDatabase.prototype.registerHandler = function(handler) {
  var transaction = this.db.transaction(['handlers'], 'readwrite');
  var store = transaction.objectStore('handlers');
  return Promise.all([storePut(store, handler), transactionWait(transaction)]);
};

// Deletes handlers from the database. Returns a promise that resolves once the
// transaction is complete.
RegistryDatabase.prototype.deleteHandlerForUrls = function(urls) {
  var transaction = this.db.transaction(['handlers'], 'readwrite');
  var store = transaction.objectStore('handlers');
  var promises = urls.map(url => storeDelete(store, url));
  promises.push(transactionWait(transaction));
  return Promise.all(promises);
};

// Deletes a handler from the database. Returns a promise that resolves once the
// transaction is complete.
RegistryDatabase.prototype.deleteHandlerForUrl = function(url) {
  return db.deleteHandlerForUrls([url]);
};

// Gets all handlers in the database. Returns a promise that resolves with an
// array of Handlers.
RegistryDatabase.prototype.getAllHandlers = function() {
  var transaction = this.db.transaction(['handlers']);
  var store = transaction.objectStore('handlers');
  var handlers = [];
  return new Promise((resolve, reject) => {
    store.openCursor().onsuccess = e => {
      var cursor = e.target.result;
      if (cursor) {
        handlers.push(handlerFromObject(cursor.value));
        cursor.continue();
      } else {
        resolve(handlers);
      }
    };
  });
};

// Gets a handler for a specific URL. Returns a promise that resolves with the
// Handler, or undefined if it is not found.
RegistryDatabase.prototype.getHandlerForUrl = function(url) {
  var transaction = this.db.transaction(['handlers']);
  var store = transaction.objectStore('handlers');
  return storeGet(store, url).then(handlerFromObject);
};

// Gets a handler for a specific URL. Returns a promise that resolves with the
// Handler, or undefined if it is not found.
RegistryDatabase.prototype.getHandlersForVerb = function(verb) {
  var transaction = this.db.transaction(['handlers']);
  var store = transaction.objectStore('handlers');
  var handlers = [];
  return new Promise((resolve, reject) => {
    // TODO(mgiuca): Index handlers by verb, to avoid a full database search.
    store.openCursor().onsuccess = e => {
      var cursor = e.target.result;
      if (cursor) {
        var verbs = cursor.value.verbs;
        if (verbs && verbs.indexOf(verb) >= 0)
          handlers.push(handlerFromObject(cursor.value));
        cursor.continue();
      } else {
        resolve(handlers);
      }
    };
  });
};

RegistryDatabase.prototype.close = function() {
  this.db.close();
};

window.openRegistryDatabase = function() {
  return openDatabase('ProxyRegistry', 1, onUpgradeNeeded)
      .then(db => new RegistryDatabase(db));
};

})();
<|endoftext|>


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

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

    // Sass: Compiles .scss files and saves them as .css
    sass: {
      options: {
        includePaths: ['bower_components/foundation/scss'],
      },
      dev: {
        options: {
          outputStyle: 'nested',
          imagePath: '/assets/img'
        },
        files: {
          'static/css/app.css': 'src/scss/app.scss',
          'static/css/summary.css': 'src/scss/summary.scss',
          'static/css/summary_raw.css': 'src/scss/summary_raw.scss',
        }
      },
      deploy: {
        options: {
          outputStyle: 'compressed',
          imagePath: '/static/assets/img'
        },
        files: {
          'static/css/app.css': 'src/scss/app.scss',
          'static/css/summary.css': 'src/scss/summary.scss'
        }
      }
    },

    // CSS Autorpefix https://github.com/postcss/autoprefixer
    postcss: {
      options: {
        map: true,
        processors: [
          require('autoprefixer-core')({browsers: 'last 1 version'}),
          require('csswring').postcss
        ]
      },
      dist: {
        src: 'static/css/app.css'
      }
    },

    // Assemble: Compiles .hbs files and saves them as .html
    assemble: {
      options: {
        layoutdir: 'src/layout/',
        layout: 'default.hbs',
        data: 'src/data/*.json',
        flatten: true
      },
      pages: {
        options:{
          partials: ['src/partial/**/*.hbs']
        },
        files: {
          'static/': ['src/page/*.hbs']
        }
      }
    },

    // Imagemin: Minifies and copies images
    imagemin: {
      main: {
        files: [{
          expand: true,
          cwd: 'src/assets/img',
          src: ['**/*.{png,jpg}'], // GIFs are copied manually
          dest: 'static/assets/img'
        }]
      },
    },

    // SVG Store for vector icons
    svgstore: {
      options: {
        prefix : 'icon-', // This will prefix each ID
        cleanup: true,
        svg: { // will add and overide the the default xmlns="http://www.w3.org/2000/svg" attribute to the resulting SVG
          style: "display: none;"
        }
      },
      dist: {
        files: {
          // 'src/partial/svg.html': ['src/assets/icons/*.svg']
          'templates/svg.html': ['src/assets/icons/*.svg']
        }
      },
    },

    // Foundation scripts
    // 1 file to rule them all! (just choose what you always need)
    concat: {
      options: {
        separator: ';\n'
      },
      dist: {
        src: [
          'bower_components/foundation/js/foundation/foundation.js',
          // 'bower_components/foundation/js/foundation/foundation.abide.js',
          'bower_components/foundation/js/foundation/foundation.accordion.js',
          // 'bower_components/foundation/js/foundation/foundation.alert.js',
          'bower_components/foundation/js/foundation/foundation.clearing.js',
          'bower_components/foundation/js/foundation/foundation.dropdown.js',
          'bower_components/foundation/js/foundation/foundation.equalizer.js',
          'bower_components/foundation/js/foundation/foundation.interchange.js',
          // 'bower_components/foundation/js/foundation/foundation.joyride.js',
          'bower_components/foundation/js/foundation/foundation.magellan.js',
          'bower_components/foundation/js/foundation/foundation.offcanvas.js',
          'bower_components/foundation/js/foundation/foundation.orbit.js',
          'bower_components/foundation/js/foundation/foundation.reveal.js',
          // 'bower_components/foundation/js/foundation/foundation.slider.js',
          'bower_components/foundation/js/foundation/foundation.tab.js',
          'bower_components/foundation/js/foundation/foundation.tooltip.js',
          'bower_components/foundation/js/foundation/foundation.topbar.js'
        ],
        dest: 'src/js/foundation.js',
      },
      app: {
        src: [
          'src/js/app.js',
        ],
        dest: 'static/js/app.js',
      },
      filter: {
        src: [
          'src/js/filter.js',
        ],
        dest: 'static/js/filter.js',
      }
    },
    // Make it smaller
    uglify: {
      options: {
        mangle: false
      },
      dist: {
        files: {
          'static/js/foundation.min.js': ['src/js/foundation.js']
        }
      },
      app: {
        files: {
          'static/js/app.min.js': ['static/js/app.js']
        }
      },
      filter: {
        files: {
          'static/js/filter.min.js': ['static/js/filter.js']
        }
      },
      wizard: {
        files: {
          'static/js/wizard.min.js': ['src/js/wizard.js']
        }
      },
      map: {
        files: {
          'static/js/map.min.js': ['src/js/map.js']
        }
      },
      review: {
        files: {
          'static/js/review.min.js': ['src/js/review.js']
        }
      }
    },

    // Copy: copies files (libraries and single files, e.g. fonts)
    copy: {
      main: {
        files: [{
          'static/js/modernizr.js': 'bower_components/modernizr/modernizr.js',
          'static/js/jquery.min.js': 'bower_components/jquery/dist/jquery.min.js',
          'static/js/jquery.min.map': 'bower_components/jquery/dist/jquery.min.map',
          'static/js/jquery-ui.min.js': 'bower_components/jquery-ui/jquery-ui.min.js',
          'static/js/jquery.nstSlider.min.js': 'bower_components/jquery-nstSlider/dist/jquery.nstSlider.min.js',
          'static/js/dropzone.min.js': 'bower_components/dropzone/dist/min/dropzone.min.js',
          'static/js/app.js': 'src/js/app.js',
          'static/js/filter.js': 'src/js/filter.js',
          'static/js/focusPoint.js': 'src/js/focusPoint.js',
          'static/js/parallax.js': 'src/js/parallax.js',
          'static/js/scrollTop.js': 'src/js/scrollTop.js',
          'static/js/wizard.js': 'src/js/wizard.js',
          'static/js/review.js': 'src/js/review.js',
          'static/js/handlebars.min.js': 'bower_components/handlebars/handlebars.min.js',
          'static/js/chosen.jquery.min.js': 'bower_components/chosen/chosen.jquery.min.js',
          'static/js/intro.min.js': 'bower_components/intro.js/minified/intro.min.js',
          'static/js/ol.min.js': 'bower_components/openlayers/ol.js',
          'static/js/ol3gm.min.js': 'bower_components/ol3gm/ol3gm.js',
          'static/css/introjs.min.css': 'bower_components/intro.js/minified/introjs.min.css',
          'static/css/chosen.min.css': 'bower_components/chosen/chosen.min.css',
          'static/css/chosen-sprite.png': 'bower_components/chosen/chosen-sprite.png',
          'static/css/jquery-ui.min.css': 'bower_components/jquery-ui/themes/base/jquery-ui.min.css',
          'static/css/ol.css': 'bower_components/openlayers/ol.css',
          'static/css/ol3gm.css': 'bower_components/ol3gm/ol3gm.css'
        }
        ,{
          expand: true,
          cwd: 'bower_components/foundation/js/foundation/',
          src: ['**/*'],
          dest: 'static/js/foundation/'
        }
        ,{
          expand: true,
          cwd: 'bower_components/jquery-ui/themes/base/images/',
          src: ['**/*'],
          dest: 'static/css/images/'
        }
        // Manually copy GIFs
        ,{
          expand: true,
          cwd: 'src/assets/img/',
          src: ['*.gif'],
          dest: 'static/assets/img/'
        }
        ]
      },
      assets: {
        files: [{
          expand: true,
          cwd: 'src/assets/files',
          src: ['**/*'],
          dest: 'static/assets/files'
        },{
          expand: true,
          cwd: 'src/assets/fonts',
          src: ['**/*'],
          dest: 'static/assets/fonts'
        },{
          // Copy svg
          expand: true,
          cwd: 'src/assets/img',
          src: ['*.svg'],
          dest: 'static/assets/img'
        }, {
          expand: true,
          cwd: 'src/assets/favicons',
          src: ['*'],
          dest: 'static/assets/favicons'
        }]
      }
    },

    // Watch: check for changes and reload web browser
    watch: {
      sass: {
        files: 'src/scss/**/*.scss',
        tasks: ['sass:dev', 'postcss'],
        options: {
          livereload: true,
        }
      },
      assets: {
        files: 'src/assets/**/*',
        tasks: ['copy', 'imagemin'],
        options: {
          livereload: true,
        }
      },
      js: {
        files: 'src/js/**/*.js',
        tasks: ['concat', 'uglify', 'copy'],
        options: {
          livereload: true,
        }
      },
      html: {
        files: ['src/**/*.hbs', 'src/embed/**/*'],
        tasks: ['assemble'],
        options: {
          livereload: true,
        }
      },
      data: {
        files: 'src/data/*.json',
        tasks: ['assemble'],
        options: {
          livereload: true,
        }
      }
    },

    // Connect: Grunt server
    connect: {
      server: {
        options: {
          hostname: '0.0.0.0',
          port: 3000,
          livereload: true,
          open: true,
          base: 'static'
        }
      }
    }
  });

  grunt.loadNpmTasks('assemble');
  grunt.loadNpmTasks('grunt-sass');
  grunt.loadNpmTasks('grunt-postcss');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-connect');
  grunt.loadNpmTasks('grunt-contrib-imagemin');
  grunt.loadNpmTasks('grunt-svgstore');

  /**
   * Available commands:
   * IMPORTANT: Update the documentation if you edit or add commands.
   * grunt                : Build (uncompressed) and run the server
   * grunt build          : Build (uncompressed)
   * grunt build:deploy   : Build (compressed)
   * grunt server         : Run the server
   */
  grunt.registerTask('build', function(arg) {
    // Default mode is 'dev'
    var mode = (arg && arg === 'deploy') ? 'deploy' : 'dev';
    grunt.task.run(['sass:' + mode, 'postcss', 'svgstore', 'imagemin', 'concat', 'uglify', 'copy', 'assemble']);
  });
  grunt.registerTask('server', ['connect:server', 'watch']);
  grunt.registerTask('default', ['build', 'server']);
}
<commit_msg>1693 Include raw summary css in deploy<commit_after>module.exports = function(grunt) {

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

    // Sass: Compiles .scss files and saves them as .css
    sass: {
      options: {
        includePaths: ['bower_components/foundation/scss'],
      },
      dev: {
        options: {
          outputStyle: 'nested',
          imagePath: '/assets/img'
        },
        files: {
          'static/css/app.css': 'src/scss/app.scss',
          'static/css/summary.css': 'src/scss/summary.scss',
          'static/css/summary_raw.css': 'src/scss/summary_raw.scss'
        }
      },
      deploy: {
        options: {
          outputStyle: 'compressed',
          imagePath: '/static/assets/img'
        },
        files: {
          'static/css/app.css': 'src/scss/app.scss',
          'static/css/summary.css': 'src/scss/summary.scss',
          'static/css/summary_raw.css': 'src/scss/summary_raw.scss'
        }
      }
    },

    // CSS Autorpefix https://github.com/postcss/autoprefixer
    postcss: {
      options: {
        map: true,
        processors: [
          require('autoprefixer-core')({browsers: 'last 1 version'}),
          require('csswring').postcss
        ]
      },
      dist: {
        src: 'static/css/app.css'
      }
    },

    // Assemble: Compiles .hbs files and saves them as .html
    assemble: {
      options: {
        layoutdir: 'src/layout/',
        layout: 'default.hbs',
        data: 'src/data/*.json',
        flatten: true
      },
      pages: {
        options:{
          partials: ['src/partial/**/*.hbs']
        },
        files: {
          'static/': ['src/page/*.hbs']
        }
      }
    },

    // Imagemin: Minifies and copies images
    imagemin: {
      main: {
        files: [{
          expand: true,
          cwd: 'src/assets/img',
          src: ['**/*.{png,jpg}'], // GIFs are copied manually
          dest: 'static/assets/img'
        }]
      },
    },

    // SVG Store for vector icons
    svgstore: {
      options: {
        prefix : 'icon-', // This will prefix each ID
        cleanup: true,
        svg: { // will add and overide the the default xmlns="http://www.w3.org/2000/svg" attribute to the resulting SVG
          style: "display: none;"
        }
      },
      dist: {
        files: {
          // 'src/partial/svg.html': ['src/assets/icons/*.svg']
          'templates/svg.html': ['src/assets/icons/*.svg']
        }
      },
    },

    // Foundation scripts
    // 1 file to rule them all! (just choose what you always need)
    concat: {
      options: {
        separator: ';\n'
      },
      dist: {
        src: [
          'bower_components/foundation/js/foundation/foundation.js',
          // 'bower_components/foundation/js/foundation/foundation.abide.js',
          'bower_components/foundation/js/foundation/foundation.accordion.js',
          // 'bower_components/foundation/js/foundation/foundation.alert.js',
          'bower_components/foundation/js/foundation/foundation.clearing.js',
          'bower_components/foundation/js/foundation/foundation.dropdown.js',
          'bower_components/foundation/js/foundation/foundation.equalizer.js',
          'bower_components/foundation/js/foundation/foundation.interchange.js',
          // 'bower_components/foundation/js/foundation/foundation.joyride.js',
          'bower_components/foundation/js/foundation/foundation.magellan.js',
          'bower_components/foundation/js/foundation/foundation.offcanvas.js',
          'bower_components/foundation/js/foundation/foundation.orbit.js',
          'bower_components/foundation/js/foundation/foundation.reveal.js',
          // 'bower_components/foundation/js/foundation/foundation.slider.js',
          'bower_components/foundation/js/foundation/foundation.tab.js',
          'bower_components/foundation/js/foundation/foundation.tooltip.js',
          'bower_components/foundation/js/foundation/foundation.topbar.js'
        ],
        dest: 'src/js/foundation.js',
      },
      app: {
        src: [
          'src/js/app.js',
        ],
        dest: 'static/js/app.js',
      },
      filter: {
        src: [
          'src/js/filter.js',
        ],
        dest: 'static/js/filter.js',
      }
    },
    // Make it smaller
    uglify: {
      options: {
        mangle: false
      },
      dist: {
        files: {
          'static/js/foundation.min.js': ['src/js/foundation.js']
        }
      },
      app: {
        files: {
          'static/js/app.min.js': ['static/js/app.js']
        }
      },
      filter: {
        files: {
          'static/js/filter.min.js': ['static/js/filter.js']
        }
      },
      wizard: {
        files: {
          'static/js/wizard.min.js': ['src/js/wizard.js']
        }
      },
      map: {
        files: {
          'static/js/map.min.js': ['src/js/map.js']
        }
      },
      review: {
        files: {
          'static/js/review.min.js': ['src/js/review.js']
        }
      }
    },

    // Copy: copies files (libraries and single files, e.g. fonts)
    copy: {
      main: {
        files: [{
          'static/js/modernizr.js': 'bower_components/modernizr/modernizr.js',
          'static/js/jquery.min.js': 'bower_components/jquery/dist/jquery.min.js',
          'static/js/jquery.min.map': 'bower_components/jquery/dist/jquery.min.map',
          'static/js/jquery-ui.min.js': 'bower_components/jquery-ui/jquery-ui.min.js',
          'static/js/jquery.nstSlider.min.js': 'bower_components/jquery-nstSlider/dist/jquery.nstSlider.min.js',
          'static/js/dropzone.min.js': 'bower_components/dropzone/dist/min/dropzone.min.js',
          'static/js/app.js': 'src/js/app.js',
          'static/js/filter.js': 'src/js/filter.js',
          'static/js/focusPoint.js': 'src/js/focusPoint.js',
          'static/js/parallax.js': 'src/js/parallax.js',
          'static/js/scrollTop.js': 'src/js/scrollTop.js',
          'static/js/wizard.js': 'src/js/wizard.js',
          'static/js/review.js': 'src/js/review.js',
          'static/js/handlebars.min.js': 'bower_components/handlebars/handlebars.min.js',
          'static/js/chosen.jquery.min.js': 'bower_components/chosen/chosen.jquery.min.js',
          'static/js/intro.min.js': 'bower_components/intro.js/minified/intro.min.js',
          'static/js/ol.min.js': 'bower_components/openlayers/ol.js',
          'static/js/ol3gm.min.js': 'bower_components/ol3gm/ol3gm.js',
          'static/css/introjs.min.css': 'bower_components/intro.js/minified/introjs.min.css',
          'static/css/chosen.min.css': 'bower_components/chosen/chosen.min.css',
          'static/css/chosen-sprite.png': 'bower_components/chosen/chosen-sprite.png',
          'static/css/jquery-ui.min.css': 'bower_components/jquery-ui/themes/base/jquery-ui.min.css',
          'static/css/ol.css': 'bower_components/openlayers/ol.css',
          'static/css/ol3gm.css': 'bower_components/ol3gm/ol3gm.css'
        }
        ,{
          expand: true,
          cwd: 'bower_components/foundation/js/foundation/',
          src: ['**/*'],
          dest: 'static/js/foundation/'
        }
        ,{
          expand: true,
          cwd: 'bower_components/jquery-ui/themes/base/images/',
          src: ['**/*'],
          dest: 'static/css/images/'
        }
        // Manually copy GIFs
        ,{
          expand: true,
          cwd: 'src/assets/img/',
          src: ['*.gif'],
          dest: 'static/assets/img/'
        }
        ]
      },
      assets: {
        files: [{
          expand: true,
          cwd: 'src/assets/files',
          src: ['**/*'],
          dest: 'static/assets/files'
        },{
          expand: true,
          cwd: 'src/assets/fonts',
          src: ['**/*'],
          dest: 'static/assets/fonts'
        },{
          // Copy svg
          expand: true,
          cwd: 'src/assets/img',
          src: ['*.svg'],
          dest: 'static/assets/img'
        }, {
          expand: true,
          cwd: 'src/assets/favicons',
          src: ['*'],
          dest: 'static/assets/favicons'
        }]
      }
    },

    // Watch: check for changes and reload web browser
    watch: {
      sass: {
        files: 'src/scss/**/*.scss',
        tasks: ['sass:dev', 'postcss'],
        options: {
          livereload: true,
        }
      },
      assets: {
        files: 'src/assets/**/*',
        tasks: ['copy', 'imagemin'],
        options: {
          livereload: true,
        }
      },
      js: {
        files: 'src/js/**/*.js',
        tasks: ['concat', 'uglify', 'copy'],
        options: {
          livereload: true,
        }
      },
      html: {
        files: ['src/**/*.hbs', 'src/embed/**/*'],
        tasks: ['assemble'],
        options: {
          livereload: true,
        }
      },
      data: {
        files: 'src/data/*.json',
        tasks: ['assemble'],
        options: {
          livereload: true,
        }
      }
    },

    // Connect: Grunt server
    connect: {
      server: {
        options: {
          hostname: '0.0.0.0',
          port: 3000,
          livereload: true,
          open: true,
          base: 'static'
        }
      }
    }
  });

  grunt.loadNpmTasks('assemble');
  grunt.loadNpmTasks('grunt-sass');
  grunt.loadNpmTasks('grunt-postcss');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-connect');
  grunt.loadNpmTasks('grunt-contrib-imagemin');
  grunt.loadNpmTasks('grunt-svgstore');

  /**
   * Available commands:
   * IMPORTANT: Update the documentation if you edit or add commands.
   * grunt                : Build (uncompressed) and run the server
   * grunt build          : Build (uncompressed)
   * grunt build:deploy   : Build (compressed)
   * grunt server         : Run the server
   */
  grunt.registerTask('build', function(arg) {
    // Default mode is 'dev'
    var mode = (arg && arg === 'deploy') ? 'deploy' : 'dev';
    grunt.task.run(['sass:' + mode, 'postcss', 'svgstore', 'imagemin', 'concat', 'uglify', 'copy', 'assemble']);
  });
  grunt.registerTask('server', ['connect:server', 'watch']);
  grunt.registerTask('default', ['build', 'server']);
}
<|endoftext|>