<commit_before>module.exports = function (grunt) {
	'use strict';

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

	grunt.initConfig({

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

		date: grunt.template.today('yyyy-mm-dd'),

		path: {
			src: 'source',
			dev: 'html',
			build: 'build',
			doc: 'doc',
			layouts: '<%%= path.src %>/layouts',
			pages: '<%%= path.src %>/pages',
			data: '<%%= path.src %>/data',
			bower: 'bower_components',
			reports: '<%%= path.build %>/<%%= path.date %>/build'
		},

		bower: {
			install: {
				options: {
					copy: false
				}
			}
		},

		copy: {
			bower: {
				files: [
					{
						expand: true,
						flatten: true,
						src: ['<%%= path.bower %>/**/*.js'],
						dest: '<%%= path.dev %>/assets/js/lib'
					},
					{
						expand: true,
						flatten: true,
						src: ['<%%= path.bower %>/**/*.css'],
						dest: '<%%= path.dev %>/assets/css/lib'
					}
				]
			},
			sass: {
				expand: true,
				flatten: true,
				cwd: '<%%= path.src %>/assets/css',
				src: ['*.css'],
				dest: '<%%= path.dev %>/assets/css'
			},
			js: {
				expand: true,
				flatten: true,
				cwd: '<%%= path.src %>/assets/js',
				src: ['*.js'],
				dest: '<%%= path.dev %>/assets/js'
			},
			img: {
				expand: true,
				cwd: '<%%= path.src %>/assets/images',
				src: ['**/*.{png,jpg,jpeg,gif}'],
				dest: '<%%= path.dev %>/assets/images'
			},
			build: {
				options: {
					expand: true,
					flatten: true
				},
				files: [
					{
						src: [
							'<%%= path.dev %>/**',
							'!<%%= path.dev %>/assets/images/dummy/**'
						],
						dest: '<%%= path.build %>/<%%= date %>/'
					},
					{
						src: [
							'<%%= path.src %>/**',
							'!<%%= path.src %>/**/*.hbs',
							'!<%%= path.src %>/data/**',
							'!<%%= path.src %>/assets/images/dummy/**',
							'!<%%= path.layouts %>/**',
							'!<%%= path.pages %>/**',
						],
						dest: '<%%= path.build %>/<%%= date %>/'
					},
					{
						src: ['<%%= path.doc %>/js/**'],
						dest: '<%%= path.build %>/<%%= date %>/'
					}
				]
			}
		},

		assemble: {
			options: {
				flatten: true,
				data: '<%%= path.data %>/*',
				layoutdir: '<%%= path.layouts %>',
				layout: 'default.hbs',
				partials: ['<%%= path.layouts %>/partials/**/*.hbs'],
				basepath: '<%%= path.basepath %>',
				production: false
			},
			dev: {
				options: {
					layout: 'default.hbs'
				},

				// ディレクトリ毎に分けて定義
				files: [
					{
						expand: true,
						cwd: '<%%= path.src %>/',
						src: 'index.hbs',
						dest: '<%%= path.dev %>'
					},
					{
						expand: true,
						cwd: '<%%= path.pages %>/',
						src: '*.hbs',
						dest: '<%%= path.dev %>'
					}
				]
			},
			prod: {
				options: {
					production: true,
					layout: 'default.hbs'
				},
				files: [
					{
						expand: true,
						cwd: '<%%= path.src %>/',
						src: 'index.hbs',
						dest: '<%%= path.dev %>'
					},
					{
						expand: true,
						cwd: '<%%= path.pages %>/',
						src: '*.hbs',
						dest: '<%%= path.dev %>'
					}
				]
			}
		},

		htmlhint: {
			options: {
				htmlhintrc: '.htmlhintrc',
				force: true
			},
			dev: {
				src: ['<%%= path.src %>/!(index|headers).html']
			},
			prod: {
				options: {
					formatters: [
						{
							id: 'checkstyle',
							dest: '<%%= path.reports %>/htmlhint.xml'
						}
					]
				},
				src: ['!<%%= path.src %>/!(index|headers).html']
			}
		},

		htmlmin: {
			options: {
				collapseBooleanAttributes: true,
				collapseWhitespace: true,
				removeComments: true,
				removeEmptyAttributes: true,
				removeOptionalTags: true,
				removeRedundantAttributes: true
			},
			min: {
				files: [
					{
						expand: true,
						cwd: '<%%= path.src %>/',
						src: '**/*.html',
						dest: '<%%= path.dist %>/'
					}
				]
			}
		},

		compass: {
			dist: {
				options: {
					sassDir: '<%%= path.src %>/assets/scss',
					cssDir: '<%%= path.src %>/assets/css'
				},
			}
		},

		sass: {
			dist: {
				files: [
					{
						expand: true,
						cwd: '<%%= path.src %>/assets/css/scss',
						src: '*.scss',
						dest: '<%%= path.src %>/assets/css',
						ext: '.css'
					}
				]
			}
		},

		autoprefixer: {
			options: {
				browsers: ['last 2 version', '> 1%', 'ie 8']
			},
			all: {
				src: '<%%= path.src %>/**/*.css'
			}
		},

		csslint: {
			options: {
				csslintrc: '.csslintrc',
				force: true
			},
			dev: {
				src: ['<%%= path.src %>/**/*.css']
			},
			prod: {
				options: {
					formatters: [
						{
							id: 'checkstyle-xml',
							dest: '<%%= path.reports %>/csslint.xml'
						}
					]
				},
				src: ['<%%= path.src %>/**/*.css']
			}
		},

		cssmin: {
			options: {
				report: 'min'
			},
			min: {
				files: [
					{
						expand: true,
						cwd: '<%%= path.src %>/',
						src: '**/*.css',
						dest: '<%%= path.dist %>/'
					}
				]
			}
		},

		styleguide: {
			options: {
				name: '<%%= pkg.name %>',
				template: {
					include: ['<%%= path.src %>/css/common.css', '<%%= path.src %>/js/common.js']
				}
			},
			assets: {
				files: {
					'<%%= path.styleguide %>': ['<%%= path.src %>/assets/css/*.scss']
				}
			}
		},

		jshint: {
			options: {
				jshintrc: '.jshintrc',
				force: true,
				reporter: require('jshint-stylish')
			},
			dev: {
				src: ['<%%= path.src %>/assets/js/modules/*.js']
			},
			prod: {
				options: {
					reporter: 'checkstyle',
					reporterOutput: '<%%= path.reports %>/jshint.xml'
				},
				src: ['<%%= path.src %>/assets/js/modules/*.js']
			}
		},

		browserify: {
			options: {
				expand: true,
				noParse: ['<%%= path.dev %>/assets/js/lib/jquery.js']
			},
			compile: {
				files: {
					'<%%= path.src %>/assets/js/index.js': ['<%%= path.src %>/assets/js/bundle/index.js']
				}
			}
		},

		uglify: {
			options: {
				preserveComments: 'some',
				report: 'min'
			},
			min: {
				files: [
					{
						expand: true,
						cwd: '<%%= path.src %>/',
						src: 'js/!(html5shiv|respond.min).js',
						dest: '<%%= path.dist %>/'
					}
				]
			}
		},

		sprite: {
			create: {
				src: '<%%= path.src %>/img/sprites/*',
				destImg: '<%%= path.src %>/img/sprite.png',
				destCSS: '<%%= path.build %>/css/sprite.scss',
				imgPath: '../img/sprite.png',
				algorithm: 'binary-tree'
			}
		},

		imagemin: {
			min: {
				files: [
					{
						expand: true,
						cwd: '<%%= path.src %>/',
						src: ['**/*.{png,jpg,jpeg}', '!img/sprites/**'],
						dest: '<%%= path.dist %>/'
					},
					{
						expand: true,
						cwd: '<%%= path.src %>/',
						src: '**/*.{png,jpg,jpeg}',
						dest: '<%%= path.dist %>/'
					}
				]
			}
		},

		compress: {
			dist: {
				options: {
					archive: '<%%= path.build %>/assets.zip'
				},
				expand: true,
				cwd: '<%%= path.dist %>/',
				src: ['**/*'],
				dest: 'assets/'
			}
		},

		connect: {
			options: {
				port: 9000,
				livereload: 35729,
				open: true
			},
			livereload: {
				options: {
					base: ['<%%= path.dev %>']
				}
			}
		},

		watch: {
			options: {
				spawn: false,
				livereload: '<%%= connect.options.livereload %>'
			},
			html: {
				files: ['<%%= path.src %>/**/*.{hbs,md}', '<%%= path.layouts %>/**', '<%%= path.data %>/**'],
				tasks: ['newer:assemble:dev']
			},
			css: {
				files: ['<%%= path.src %>/**/*.scss'],
				tasks: ['compass', 'newer:autoprefixer', 'copy:sass']
			},
			js: {
				files: ['<%%= path.src %>/**/*.js'],
				tasks: ['browserify', 'jshint:dev', 'newer:copy:js']
			},
			img: {
				files: ['<%%= path.src %>/**/*.{png,jpg,jpeg,gif}'],
				tasks: ['newer:copy:img']
			}
		},

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

		prettify: {
			options: {
				indent: 1,
				indent_char: '	',
				unformatted: ['a', 'i', 'b', 'em', 'span']
			},
			all: {
				files: [
					{
						expand: true,
						cwd: '<%%= path.dev %>/',
						src: ['**/*.html'],
						dest: '<%%= path.dev %>/'
					}
				]
			}
		}

	});

	var loadGrunt = require('load-grunt-tasks');

	grunt.registerTask('default', [], function () {
		loadGrunt(grunt, {
			pattern: ['assemble', 'grunt-contrib-copy', 'grunt-contrib-compass', 'grunt-browserify', 'grunt-prettify', 'grunt-newer']
		});

		grunt.task.run('newer:assemble', 'compass', 'browserify', 'newer:prettify');
	});

	grunt.registerTask('install', [], function () {
		loadGrunt(grunt, {
			pattern: ['grunt-bower-task', 'grunt-contrib-copy', 'grunt-newer']
		});

		grunt.task.run('newer:bower:install', 'newer:copy:bower');
	});

	grunt.registerTask('compile:dev', [], function () {
		loadGrunt(grunt, {
			pattern: ['assemble', 'grunt-contrib-compass', 'grunt-browserify', 'grunt-prettify', 'grunt-newer']
		});

		grunt.task.run('newer:assemble:dev', 'compass', 'browserify', 'newer:prettify');
	});

	grunt.registerTask('compile:prod', [], function () {
		loadGrunt(grunt, {
			pattern: ['assemble', 'grunt-contrib-compass', 'grunt-browserify', 'grunt-prettify']
		});

		grunt.task.run('assemble:prod', 'compass', 'browserify', 'prettify');
	});

	grunt.registerTask('doc', [], function () {
		loadGrunt(grunt, {
			pattern: ['grunt-contrib-yuidoc']
		});

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

	grunt.registerTask('lint:dev', [], function () {
		loadGrunt(grunt, {
			pattern: ['grunt-htmlhint', 'grunt-contrib-csslint', 'grunt-contrib-jshint']
		});

		grunt.task.run('htmlhint:dev', 'csslint:dev', 'jshint:dev');
	});

	grunt.registerTask('lint:prod', [], function () {
		loadGrunt(grunt, {
			pattern: ['grunt-htmlhint', 'grunt-contrib-csslint', 'grunt-contrib-jshint']
		});

		grunt.task.run('htmlhint:prod', 'csslint:prod', 'jshint:prod');
	});

	grunt.registerTask('serve', [], function () {
		loadGrunt(grunt, {
			pattern: ['assemble', 'grunt-contrib-compass', 'grunt-browserify', 'grunt-prettify', 'grunt-newer', 'grunt-htmlhint', 'grunt-contrib-csslint', 'grunt-contrib-jshint', 'grunt-contrib-copy', 'grunt-contrib-connect', 'grunt-contrib-watch']
		});

		grunt.task.run('newer:assemble:dev', 'compass', 'browserify', 'newer:prettify', 'htmlhint:dev', 'csslint:dev', 'jshint:dev', 'newer:copy:sass', 'newer:copy:js', 'newer:copy:img', 'connect', 'watch');
	});

	grunt.registerTask('build', [], function () {
		loadGrunt(grunt, {
			pattern: ['assemble', 'grunt-contrib-compass', 'grunt-browserify', 'grunt-prettify', 'grunt-htmlhint', 'grunt-contrib-csslint', 'grunt-contrib-jshint', 'grunt-contrib-yuidoc', 'grunt-contrib-copy']
		});

		grunt.task.run('assemble:prod', 'compass', 'browserify', 'prettify', 'htmlhint:prod', 'csslint:prod', 'jshint:prod', 'yuidoc', 'copy:build');
	});
};
<commit_msg>change build dir<commit_after>module.exports = function (grunt) {
	'use strict';

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

	grunt.initConfig({

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

		date: grunt.template.today('yyyy-mm-dd'),

		path: {
			src: 'source',
			dev: 'html',
			build: 'build',
			doc: 'doc',
			layouts: '<%%= path.src %>/layouts',
			pages: '<%%= path.src %>/pages',
			data: '<%%= path.src %>/data',
			bower: 'bower_components',
			reports: '<%%= path.build %>/reports'
		},

		bower: {
			install: {
				options: {
					copy: false
				}
			}
		},

		copy: {
			bower: {
				files: [
					{
						expand: true,
						flatten: true,
						src: ['<%%= path.bower %>/**/*.js'],
						dest: '<%%= path.dev %>/assets/js/lib'
					},
					{
						expand: true,
						flatten: true,
						src: ['<%%= path.bower %>/**/*.css'],
						dest: '<%%= path.dev %>/assets/css/lib'
					}
				]
			},
			sass: {
				expand: true,
				flatten: true,
				cwd: '<%%= path.src %>/assets/css',
				src: ['*.css'],
				dest: '<%%= path.dev %>/assets/css'
			},
			js: {
				expand: true,
				flatten: true,
				cwd: '<%%= path.src %>/assets/js',
				src: ['*.js'],
				dest: '<%%= path.dev %>/assets/js'
			},
			img: {
				expand: true,
				cwd: '<%%= path.src %>/assets/images',
				src: ['**/*.{png,jpg,jpeg,gif}'],
				dest: '<%%= path.dev %>/assets/images'
			},
			build: {
				options: {
					expand: true,
					flatten: true
				},
				files: [
					{
						src: [
							'<%%= path.dev %>/**',
							'!<%%= path.dev %>/assets/images/dummy/**'
						],
						dest: '<%%= path.build %>/'
					},
					{
						src: [
							'<%%= path.src %>/**',
							'!<%%= path.src %>/**/*.hbs',
							'!<%%= path.src %>/data/**',
							'!<%%= path.src %>/assets/images/dummy/**',
							'!<%%= path.layouts %>/**',
							'!<%%= path.pages %>/**',
						],
						dest: '<%%= path.build %>/'
					},
					{
						src: ['<%%= path.doc %>/js/**'],
						dest: '<%%= path.build %>/'
					}
				]
			}
		},

		assemble: {
			options: {
				flatten: true,
				data: '<%%= path.data %>/*',
				layoutdir: '<%%= path.layouts %>',
				layout: 'default.hbs',
				partials: ['<%%= path.layouts %>/partials/**/*.hbs'],
				basepath: '<%%= path.basepath %>',
				production: false
			},
			dev: {
				options: {
					layout: 'default.hbs'
				},

				// ディレクトリ毎に分けて定義
				files: [
					{
						expand: true,
						cwd: '<%%= path.src %>/',
						src: 'index.hbs',
						dest: '<%%= path.dev %>'
					},
					{
						expand: true,
						cwd: '<%%= path.pages %>/',
						src: '*.hbs',
						dest: '<%%= path.dev %>'
					}
				]
			},
			prod: {
				options: {
					production: true,
					layout: 'default.hbs'
				},
				files: [
					{
						expand: true,
						cwd: '<%%= path.src %>/',
						src: 'index.hbs',
						dest: '<%%= path.dev %>'
					},
					{
						expand: true,
						cwd: '<%%= path.pages %>/',
						src: '*.hbs',
						dest: '<%%= path.dev %>'
					}
				]
			}
		},

		htmlhint: {
			options: {
				htmlhintrc: '.htmlhintrc',
				force: true
			},
			dev: {
				src: ['<%%= path.src %>/!(index|headers).html']
			},
			prod: {
				options: {
					formatters: [
						{
							id: 'checkstyle',
							dest: '<%%= path.reports %>/htmlhint.xml'
						}
					]
				},
				src: ['!<%%= path.src %>/!(index|headers).html']
			}
		},

		htmlmin: {
			options: {
				collapseBooleanAttributes: true,
				collapseWhitespace: true,
				removeComments: true,
				removeEmptyAttributes: true,
				removeOptionalTags: true,
				removeRedundantAttributes: true
			},
			min: {
				files: [
					{
						expand: true,
						cwd: '<%%= path.src %>/',
						src: '**/*.html',
						dest: '<%%= path.dist %>/'
					}
				]
			}
		},

		compass: {
			dist: {
				options: {
					sassDir: '<%%= path.src %>/assets/scss',
					cssDir: '<%%= path.src %>/assets/css'
				},
			}
		},

		sass: {
			dist: {
				files: [
					{
						expand: true,
						cwd: '<%%= path.src %>/assets/css/scss',
						src: '*.scss',
						dest: '<%%= path.src %>/assets/css',
						ext: '.css'
					}
				]
			}
		},

		autoprefixer: {
			options: {
				browsers: ['last 2 version', '> 1%', 'ie 8']
			},
			all: {
				src: '<%%= path.src %>/**/*.css'
			}
		},

		csslint: {
			options: {
				csslintrc: '.csslintrc',
				force: true
			},
			dev: {
				src: ['<%%= path.src %>/**/*.css']
			},
			prod: {
				options: {
					formatters: [
						{
							id: 'checkstyle-xml',
							dest: '<%%= path.reports %>/csslint.xml'
						}
					]
				},
				src: ['<%%= path.src %>/**/*.css']
			}
		},

		cssmin: {
			options: {
				report: 'min'
			},
			min: {
				files: [
					{
						expand: true,
						cwd: '<%%= path.src %>/',
						src: '**/*.css',
						dest: '<%%= path.dist %>/'
					}
				]
			}
		},

		styleguide: {
			options: {
				name: '<%%= pkg.name %>',
				template: {
					include: ['<%%= path.src %>/css/common.css', '<%%= path.src %>/js/common.js']
				}
			},
			assets: {
				files: {
					'<%%= path.styleguide %>': ['<%%= path.src %>/assets/css/*.scss']
				}
			}
		},

		jshint: {
			options: {
				jshintrc: '.jshintrc',
				force: true,
				reporter: require('jshint-stylish')
			},
			dev: {
				src: ['<%%= path.src %>/assets/js/modules/*.js']
			},
			prod: {
				options: {
					reporter: 'checkstyle',
					reporterOutput: '<%%= path.reports %>/jshint.xml'
				},
				src: ['<%%= path.src %>/assets/js/modules/*.js']
			}
		},

		browserify: {
			options: {
				expand: true,
				noParse: ['<%%= path.dev %>/assets/js/lib/jquery.js']
			},
			compile: {
				files: {
					'<%%= path.src %>/assets/js/index.js': ['<%%= path.src %>/assets/js/bundle/index.js']
				}
			}
		},

		uglify: {
			options: {
				preserveComments: 'some',
				report: 'min'
			},
			min: {
				files: [
					{
						expand: true,
						cwd: '<%%= path.src %>/',
						src: 'js/!(html5shiv|respond.min).js',
						dest: '<%%= path.dist %>/'
					}
				]
			}
		},

		sprite: {
			create: {
				src: '<%%= path.src %>/img/sprites/*',
				destImg: '<%%= path.src %>/img/sprite.png',
				destCSS: '<%%= path.build %>/css/sprite.scss',
				imgPath: '../img/sprite.png',
				algorithm: 'binary-tree'
			}
		},

		imagemin: {
			min: {
				files: [
					{
						expand: true,
						cwd: '<%%= path.src %>/',
						src: ['**/*.{png,jpg,jpeg}', '!img/sprites/**'],
						dest: '<%%= path.dist %>/'
					},
					{
						expand: true,
						cwd: '<%%= path.src %>/',
						src: '**/*.{png,jpg,jpeg}',
						dest: '<%%= path.dist %>/'
					}
				]
			}
		},

		compress: {
			deliver: {
				options: {
					archive: '<%%= path.deliver %>/<%= pkg.name %>_<%%= date %>.zip'
				},
				files: [
					{
						expand: true,
						src: [
							'<%%= path.dev %>/**',
							'!<%%= path.dev %>/assets/images/dummy/**',
							'<%%= path.src %>/**',
							'!<%%= path.src %>/**/*.hbs',
							'!<%%= path.src %>/data/**',
							'!<%%= path.src %>/assets/images/dummy/**',
							'!<%%= path.layouts %>/**',
							'!<%%= path.pages %>/**',
							'<%%= path.doc %>/js/**',
						]
					}
				]
			}
		},

		connect: {
			options: {
				port: 9000,
				livereload: 35729,
				open: true
			},
			livereload: {
				options: {
					base: ['<%%= path.dev %>']
				}
			}
		},

		watch: {
			options: {
				spawn: false,
				livereload: '<%%= connect.options.livereload %>'
			},
			html: {
				files: ['<%%= path.src %>/**/*.{hbs,md}', '<%%= path.layouts %>/**', '<%%= path.data %>/**'],
				tasks: ['newer:assemble:dev']
			},
			css: {
				files: ['<%%= path.src %>/**/*.scss'],
				tasks: ['compass', 'newer:autoprefixer', 'copy:sass']
			},
			js: {
				files: ['<%%= path.src %>/**/*.js'],
				tasks: ['browserify', 'jshint:dev', 'newer:copy:js']
			},
			img: {
				files: ['<%%= path.src %>/**/*.{png,jpg,jpeg,gif}'],
				tasks: ['newer:copy:img']
			}
		},

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

		prettify: {
			options: {
				indent: 1,
				indent_char: '	',
				unformatted: ['a', 'i', 'b', 'em', 'span']
			},
			all: {
				files: [
					{
						expand: true,
						cwd: '<%%= path.dev %>/',
						src: ['**/*.html'],
						dest: '<%%= path.dev %>/'
					}
				]
			}
		}

	});

	var loadGrunt = require('load-grunt-tasks');

	grunt.registerTask('default', [], function () {
		loadGrunt(grunt, {
			pattern: ['assemble', 'grunt-contrib-copy', 'grunt-contrib-compass', 'grunt-browserify', 'grunt-prettify', 'grunt-newer']
		});

		grunt.task.run('newer:assemble', 'compass', 'browserify', 'newer:prettify');
	});

	grunt.registerTask('install', [], function () {
		loadGrunt(grunt, {
			pattern: ['grunt-bower-task', 'grunt-contrib-copy', 'grunt-newer']
		});

		grunt.task.run('newer:bower:install', 'newer:copy:bower');
	});

	grunt.registerTask('compile:dev', [], function () {
		loadGrunt(grunt, {
			pattern: ['assemble', 'grunt-contrib-compass', 'grunt-browserify', 'grunt-prettify', 'grunt-newer']
		});

		grunt.task.run('newer:assemble:dev', 'compass', 'browserify', 'newer:prettify');
	});

	grunt.registerTask('compile:prod', [], function () {
		loadGrunt(grunt, {
			pattern: ['assemble', 'grunt-contrib-compass', 'grunt-browserify', 'grunt-prettify']
		});

		grunt.task.run('assemble:prod', 'compass', 'browserify', 'prettify');
	});

	grunt.registerTask('doc', [], function () {
		loadGrunt(grunt, {
			pattern: ['grunt-contrib-yuidoc']
		});

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

	grunt.registerTask('lint:dev', [], function () {
		loadGrunt(grunt, {
			pattern: ['grunt-htmlhint', 'grunt-contrib-csslint', 'grunt-contrib-jshint']
		});

		grunt.task.run('htmlhint:dev', 'csslint:dev', 'jshint:dev');
	});

	grunt.registerTask('lint:prod', [], function () {
		loadGrunt(grunt, {
			pattern: ['grunt-htmlhint', 'grunt-contrib-csslint', 'grunt-contrib-jshint']
		});

		grunt.task.run('htmlhint:prod', 'csslint:prod', 'jshint:prod');
	});

	grunt.registerTask('serve', [], function () {
		loadGrunt(grunt, {
			pattern: ['assemble', 'grunt-contrib-compass', 'grunt-browserify', 'grunt-prettify', 'grunt-newer', 'grunt-htmlhint', 'grunt-contrib-csslint', 'grunt-contrib-jshint', 'grunt-contrib-copy', 'grunt-contrib-connect', 'grunt-contrib-watch']
		});

		grunt.task.run('newer:assemble:dev', 'compass', 'browserify', 'newer:prettify', 'htmlhint:dev', 'csslint:dev', 'jshint:dev', 'newer:copy:sass', 'newer:copy:js', 'newer:copy:img', 'connect', 'watch');
	});

	grunt.registerTask('build', [], function () {
		loadGrunt(grunt, {
			pattern: ['assemble', 'grunt-contrib-compass', 'grunt-browserify', 'grunt-prettify', 'grunt-htmlhint', 'grunt-contrib-csslint', 'grunt-contrib-jshint', 'grunt-contrib-yuidoc', 'grunt-contrib-copy']
		});

		grunt.task.run('assemble:prod', 'compass', 'browserify', 'prettify', 'htmlhint:prod', 'csslint:prod', 'jshint:prod', 'yuidoc', 'copy:build');
	});

	grunt.registerTask('deliver', [], function () {
		loadGrunt(grunt, {
			pattern: ['assemble', 'grunt-contrib-compass', 'grunt-browserify', 'grunt-prettify', 'grunt-htmlhint', 'grunt-contrib-csslint', 'grunt-contrib-jshint', 'grunt-contrib-yuidoc', 'grunt-contrib-compress']
		});

		grunt.task.run('assemble:prod', 'compass', 'browserify', 'prettify', 'htmlhint:prod', 'csslint:prod', 'jshint:prod', 'yuidoc', 'compress:deliver');
	});
};
<|endoftext|>


<commit_before>// Generated on <%= (new Date).toISOString().split('T')[0] %> using <%= pkg.name %> <%= pkg.version %>
'use strict';

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

module.exports = function (grunt) {

    // Load grunt tasks automatically
    require('load-grunt-tasks')(grunt);

    // Time how long tasks take. Can help when optimizing build times
    require('time-grunt')(grunt);

    // Configurable paths
    var config = {
        app: 'app',
        dist: 'dist'
    };

    // Define the configuration for all the tasks
    grunt.initConfig({

        // Project settings
        config: config,

        // Watches files for changes and runs tasks based on the changed files
        watch: {
            bower: {
                files: ['bower.json'],
                tasks: ['bowerInstall']
            },<% if (coffee) { %>
            coffee: {
                files: ['<%%= config.app %>/scripts/{,*/}*.{coffee,litcoffee,coffee.md}'],
                tasks: ['coffee:dist']
            },
            coffeeTest: {
                files: ['test/spec/{,*/}*.{coffee,litcoffee,coffee.md}'],
                tasks: ['coffee:test', 'test:watch']
            },<% } else { %>
            js: {
                files: ['<%%= config.app %>/scripts/{,*/}*.js'],
                tasks: ['jshint'],
                options: {
                    livereload: true
                }
            },
            jstest: {
                files: ['test/spec/{,*/}*.js'],
                tasks: ['test:watch']
            },<% } %>
            gruntfile: {
                files: ['Gruntfile.js']
            },<% if (includeCompass) { %>
            compass: {
                files: ['<%%= config.app %>/styles/{,*/}*.{scss,sass}'],
                tasks: ['compass:server', 'autoprefixer']
            },<% } %>
            styles: {
                files: ['<%%= config.app %>/styles/{,*/}*.css'],
                tasks: ['newer:copy:styles', 'autoprefixer']
            },
            livereload: {
                options: {
                    livereload: '<%%= connect.options.livereload %>'
                },
                files: [
                    '<%%= config.app %>/{,*/}*.html',
                    '.tmp/styles/{,*/}*.css',<% if (coffee) { %>
                    '.tmp/scripts/{,*/}*.js',<% } %>
                    '<%%= config.app %>/images/{,*/}*'
                ]
            }
        },

        // The actual grunt server settings
        connect: {
            options: {
                port: 9000,
                open: true,
                livereload: 35729,
                // Change this to '0.0.0.0' to access the server from outside
                hostname: 'localhost'
            },
            livereload: {
                options: {
                    middleware: function(connect) {
                        return [
                            connect.static('.tmp'),
                            connect().use('/bower_components', connect.static('./bower_components')),
                            connect.static(config.app)
                        ]
                    }
                }
            },
            test: {
                options: {
                    open: false,
                    port: 9001,
                    middleware: function(connect) {
                        return [
                            connect.static('.tmp'),
                            connect.static('test'),
                            connect().use('/bower_components', connect.static('./bower_components')),
                            connect.static(config.app)
                        ]
                    }
                }
            },
            dist: {
                options: {
                    base: '<%%= config.dist %>',
                    livereload: false
                }
            }
        },

        // Empties folders to start fresh
        clean: {
            dist: {
                files: [{
                    dot: true,
                    src: [
                        '.tmp',
                        '<%%= config.dist %>/*',
                        '!<%%= config.dist %>/.git*'
                    ]
                }]
            },
            server: '.tmp'
        },

        // Make sure code styles are up to par and there are no obvious mistakes
        jshint: {
            options: {
                jshintrc: '.jshintrc',
                reporter: require('jshint-stylish')
            },
            all: [
                'Gruntfile.js',
                '<%%= config.app %>/scripts/{,*/}*.js',
                '!<%%= config.app %>/scripts/vendor/*',
                'test/spec/{,*/}*.js'
            ]
        },<% if (testFramework === 'mocha') { %>

        // Mocha testing framework configuration options
        mocha: {
            all: {
                options: {
                    run: true,
                    urls: ['http://<%%= connect.test.options.hostname %>:<%%= connect.test.options.port %>/index.html']
                }
            }
        },<% } else if (testFramework === 'jasmine') { %>

        // Jasmine testing framework configuration options
        jasmine: {
            all: {
                options: {
                    specs: 'test/spec/{,*/}*.js'
                }
            }
        },<% } %><% if (coffee) { %>

        // Compiles CoffeeScript to JavaScript
        coffee: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%%= config.app %>/scripts',
                    src: '{,*/}*.{coffee,litcoffee,coffee.md}',
                    dest: '.tmp/scripts',
                    ext: '.js'
                }]
            },
            test: {
                files: [{
                    expand: true,
                    cwd: 'test/spec',
                    src: '{,*/}*.{coffee,litcoffee,coffee.md}',
                    dest: '.tmp/spec',
                    ext: '.js'
                }]
            }
        },<% } %><% if (includeCompass) { %>

        // Compiles Sass to CSS and generates necessary files if requested
        compass: {
            options: {
                sassDir: '<%%= config.app %>/styles',
                cssDir: '.tmp/styles',
                generatedImagesDir: '.tmp/images/generated',
                imagesDir: '<%%= config.app %>/images',
                javascriptsDir: '<%%= config.app %>/scripts',
                fontsDir: '<%%= config.app %>/styles/fonts',
                importPath: './bower_components',
                httpImagesPath: '/images',
                httpGeneratedImagesPath: '/images/generated',
                httpFontsPath: '/styles/fonts',
                relativeAssets: false,
                assetCacheBuster: false
            },
            dist: {
                options: {
                    generatedImagesDir: '<%%= config.dist %>/images/generated'
                }
            },
            server: {
                options: {
                    debugInfo: true
                }
            }
        },<% } %>

        // Add vendor prefixed styles
        autoprefixer: {
            options: {
                browsers: ['last 1 version']
            },
            dist: {
                files: [{
                    expand: true,
                    cwd: '.tmp/styles/',
                    src: '{,*/}*.css',
                    dest: '.tmp/styles/'
                }]
            }
        },

        // Automatically inject Bower components into the HTML file
        bowerInstall: {
            app: {
                src: ['<%%= config.app %>/index.html'],
                ignorePath: '<%%= config.app %>/'<% if (includeCompass) { %>,
                exclude: ['bower_components/bootstrap-sass-official/vendor/assets/javascripts/bootstrap.js']
            },
            sass: {
                src: ['<%%= config.app %>/styles/{,*/}*.{scss,sass}'],
                ignorePath: '<%%= config.app %>/bower_components/'
            }<% } else { %>
            }<% } %>
        },

        // Renames files for browser caching purposes
        rev: {
            dist: {
                files: {
                    src: [
                        '<%%= config.dist %>/scripts/{,*/}*.js',
                        '<%%= config.dist %>/styles/{,*/}*.css',
                        '<%%= config.dist %>/images/{,*/}*.*',
                        '<%%= config.dist %>/styles/fonts/{,*/}*.*',
                        '<%%= config.dist %>/*.{ico,png}'
                    ]
                }
            }
        },

        // Reads HTML for usemin blocks to enable smart builds that automatically
        // concat, minify and revision files. Creates configurations in memory so
        // additional tasks can operate on them
        useminPrepare: {
            options: {
                dest: '<%%= config.dist %>'
            },
            html: '<%%= config.app %>/index.html'
        },

        // Performs rewrites based on rev and the useminPrepare configuration
        usemin: {
            options: {
                assetsDirs: ['<%%= config.dist %>', '<%%= config.dist %>/images']
            },
            html: ['<%%= config.dist %>/{,*/}*.html'],
            css: ['<%%= config.dist %>/styles/{,*/}*.css']
        },

        // The following *-min tasks produce minified files in the dist folder
        imagemin: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%%= config.app %>/images',
                    src: '{,*/}*.{gif,jpeg,jpg,png}',
                    dest: '<%%= config.dist %>/images'
                }]
            }
        },

        svgmin: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%%= config.app %>/images',
                    src: '{,*/}*.svg',
                    dest: '<%%= config.dist %>/images'
                }]
            }
        },

        htmlmin: {
            dist: {
                options: {
                    collapseBooleanAttributes: true,
                    collapseWhitespace: true,
                    removeAttributeQuotes: true,
                    removeCommentsFromCDATA: true,
                    removeEmptyAttributes: true,
                    removeOptionalTags: true,
                    removeRedundantAttributes: true,
                    useShortDoctype: true
                },
                files: [{
                    expand: true,
                    cwd: '<%%= config.dist %>',
                    src: '{,*/}*.html',
                    dest: '<%%= config.dist %>'
                }]
            }
        },

        // By default, your `index.html`'s <!-- Usemin block --> will take care of
        // minification. These next options are pre-configured if you do not wish
        // to use the Usemin blocks.
        // cssmin: {
        //     dist: {
        //         files: {
        //             '<%%= config.dist %>/styles/main.css': [
        //                 '.tmp/styles/{,*/}*.css',
        //                 '<%%= config.app %>/styles/{,*/}*.css'
        //             ]
        //         }
        //     }
        // },
        // uglify: {
        //     dist: {
        //         files: {
        //             '<%%= config.dist %>/scripts/scripts.js': [
        //                 '<%%= config.dist %>/scripts/scripts.js'
        //             ]
        //         }
        //     }
        // },
        // concat: {
        //     dist: {}
        // },

        // Copies remaining files to places other tasks can use
        copy: {
            dist: {
                files: [{
                    expand: true,
                    dot: true,
                    cwd: '<%%= config.app %>',
                    dest: '<%%= config.dist %>',
                    src: [
                        '*.{ico,png,txt}',
                        '.htaccess',
                        'images/{,*/}*.webp',
                        '{,*/}*.html',
                        'styles/fonts/{,*/}*.*'
                    ]
                }<% if (includeBootstrap) { %>, {
                    expand: true,
                    dot: true,
                    cwd: '.',
                    dest: '<%%= config.dist %>',
                    src: [<% if (includeCompass) { %>
                        'bower_components/bootstrap-sass-official/vendor/assets/fonts/bootstrap/*.*'<% } else { %>
                        'bower_components/bootstrap/dist/fonts/*.*'<% } %>
                    ]
                }<% } %>]
            },
            styles: {
                expand: true,
                dot: true,
                cwd: '<%%= config.app %>/styles',
                dest: '.tmp/styles/',
                src: '{,*/}*.css'
            }
        },<% if (includeModernizr) { %>

        // Generates a custom Modernizr build that includes only the tests you
        // reference in your app
        modernizr: {
            devFile: 'bower_components/modernizr/modernizr.js',
            outputFile: '<%%= config.dist %>/scripts/vendor/modernizr.js',
            files: [
                '<%%= config.dist %>/scripts/{,*/}*.js',
                '<%%= config.dist %>/styles/{,*/}*.css',
                '!<%%= config.dist %>/scripts/vendor/*'
            ],
            uglify: true
        },<% } %>

        // Run some tasks in parallel to speed up build process
        concurrent: {
            server: [<% if (includeCompass) { %>
                'compass:server',<% } if (coffee) { %>
                'coffee:dist',<% } %>
                'copy:styles'
            ],
            test: [<% if (coffee) { %>
                'coffee',<% } %>
                'copy:styles'
            ],
            dist: [<% if (coffee) { %>
                'coffee',<% } if (includeCompass) { %>
                'compass',<% } %>
                'copy:styles',
                'imagemin',
                'svgmin'
            ]
        }
    });

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

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

    grunt.registerTask('server', function (target) {
        grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
        grunt.task.run([target ? ('serve:' + target) : 'serve']);
    });

    grunt.registerTask('test', function (target) {
        if (target !== 'watch') {
            grunt.task.run([
                'clean:server',
                'concurrent:test',
                'autoprefixer'
            ]);
        }

        grunt.task.run([
            'connect:test',<% if (testFramework === 'mocha') { %>
            'mocha'<% } else if (testFramework === 'jasmine') { %>
            'jasmine'<% } %>
        ]);
    });

    grunt.registerTask('build', [
        'clean:dist',
        'useminPrepare',
        'concurrent:dist',
        'autoprefixer',
        'concat',
        'cssmin',
        'uglify',
        'copy:dist',<% if (includeModernizr) { %>
        'modernizr',<% } %>
        'rev',
        'usemin',
        'htmlmin'
    ]);

    grunt.registerTask('default', [
        'newer:jshint',
        'test',
        'build'
    ]);
};
<commit_msg>Exclude the Bootstrap JS file on LESS Bootstrap too<commit_after>// Generated on <%= (new Date).toISOString().split('T')[0] %> using <%= pkg.name %> <%= pkg.version %>
'use strict';

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

module.exports = function (grunt) {

    // Load grunt tasks automatically
    require('load-grunt-tasks')(grunt);

    // Time how long tasks take. Can help when optimizing build times
    require('time-grunt')(grunt);

    // Configurable paths
    var config = {
        app: 'app',
        dist: 'dist'
    };

    // Define the configuration for all the tasks
    grunt.initConfig({

        // Project settings
        config: config,

        // Watches files for changes and runs tasks based on the changed files
        watch: {
            bower: {
                files: ['bower.json'],
                tasks: ['bowerInstall']
            },<% if (coffee) { %>
            coffee: {
                files: ['<%%= config.app %>/scripts/{,*/}*.{coffee,litcoffee,coffee.md}'],
                tasks: ['coffee:dist']
            },
            coffeeTest: {
                files: ['test/spec/{,*/}*.{coffee,litcoffee,coffee.md}'],
                tasks: ['coffee:test', 'test:watch']
            },<% } else { %>
            js: {
                files: ['<%%= config.app %>/scripts/{,*/}*.js'],
                tasks: ['jshint'],
                options: {
                    livereload: true
                }
            },
            jstest: {
                files: ['test/spec/{,*/}*.js'],
                tasks: ['test:watch']
            },<% } %>
            gruntfile: {
                files: ['Gruntfile.js']
            },<% if (includeCompass) { %>
            compass: {
                files: ['<%%= config.app %>/styles/{,*/}*.{scss,sass}'],
                tasks: ['compass:server', 'autoprefixer']
            },<% } %>
            styles: {
                files: ['<%%= config.app %>/styles/{,*/}*.css'],
                tasks: ['newer:copy:styles', 'autoprefixer']
            },
            livereload: {
                options: {
                    livereload: '<%%= connect.options.livereload %>'
                },
                files: [
                    '<%%= config.app %>/{,*/}*.html',
                    '.tmp/styles/{,*/}*.css',<% if (coffee) { %>
                    '.tmp/scripts/{,*/}*.js',<% } %>
                    '<%%= config.app %>/images/{,*/}*'
                ]
            }
        },

        // The actual grunt server settings
        connect: {
            options: {
                port: 9000,
                open: true,
                livereload: 35729,
                // Change this to '0.0.0.0' to access the server from outside
                hostname: 'localhost'
            },
            livereload: {
                options: {
                    middleware: function(connect) {
                        return [
                            connect.static('.tmp'),
                            connect().use('/bower_components', connect.static('./bower_components')),
                            connect.static(config.app)
                        ]
                    }
                }
            },
            test: {
                options: {
                    open: false,
                    port: 9001,
                    middleware: function(connect) {
                        return [
                            connect.static('.tmp'),
                            connect.static('test'),
                            connect().use('/bower_components', connect.static('./bower_components')),
                            connect.static(config.app)
                        ]
                    }
                }
            },
            dist: {
                options: {
                    base: '<%%= config.dist %>',
                    livereload: false
                }
            }
        },

        // Empties folders to start fresh
        clean: {
            dist: {
                files: [{
                    dot: true,
                    src: [
                        '.tmp',
                        '<%%= config.dist %>/*',
                        '!<%%= config.dist %>/.git*'
                    ]
                }]
            },
            server: '.tmp'
        },

        // Make sure code styles are up to par and there are no obvious mistakes
        jshint: {
            options: {
                jshintrc: '.jshintrc',
                reporter: require('jshint-stylish')
            },
            all: [
                'Gruntfile.js',
                '<%%= config.app %>/scripts/{,*/}*.js',
                '!<%%= config.app %>/scripts/vendor/*',
                'test/spec/{,*/}*.js'
            ]
        },<% if (testFramework === 'mocha') { %>

        // Mocha testing framework configuration options
        mocha: {
            all: {
                options: {
                    run: true,
                    urls: ['http://<%%= connect.test.options.hostname %>:<%%= connect.test.options.port %>/index.html']
                }
            }
        },<% } else if (testFramework === 'jasmine') { %>

        // Jasmine testing framework configuration options
        jasmine: {
            all: {
                options: {
                    specs: 'test/spec/{,*/}*.js'
                }
            }
        },<% } %><% if (coffee) { %>

        // Compiles CoffeeScript to JavaScript
        coffee: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%%= config.app %>/scripts',
                    src: '{,*/}*.{coffee,litcoffee,coffee.md}',
                    dest: '.tmp/scripts',
                    ext: '.js'
                }]
            },
            test: {
                files: [{
                    expand: true,
                    cwd: 'test/spec',
                    src: '{,*/}*.{coffee,litcoffee,coffee.md}',
                    dest: '.tmp/spec',
                    ext: '.js'
                }]
            }
        },<% } %><% if (includeCompass) { %>

        // Compiles Sass to CSS and generates necessary files if requested
        compass: {
            options: {
                sassDir: '<%%= config.app %>/styles',
                cssDir: '.tmp/styles',
                generatedImagesDir: '.tmp/images/generated',
                imagesDir: '<%%= config.app %>/images',
                javascriptsDir: '<%%= config.app %>/scripts',
                fontsDir: '<%%= config.app %>/styles/fonts',
                importPath: './bower_components',
                httpImagesPath: '/images',
                httpGeneratedImagesPath: '/images/generated',
                httpFontsPath: '/styles/fonts',
                relativeAssets: false,
                assetCacheBuster: false
            },
            dist: {
                options: {
                    generatedImagesDir: '<%%= config.dist %>/images/generated'
                }
            },
            server: {
                options: {
                    debugInfo: true
                }
            }
        },<% } %>

        // Add vendor prefixed styles
        autoprefixer: {
            options: {
                browsers: ['last 1 version']
            },
            dist: {
                files: [{
                    expand: true,
                    cwd: '.tmp/styles/',
                    src: '{,*/}*.css',
                    dest: '.tmp/styles/'
                }]
            }
        },

        // Automatically inject Bower components into the HTML file
        bowerInstall: {
            app: {
                src: ['<%%= config.app %>/index.html'],
                ignorePath: '<%%= config.app %>/',<% if (includeCompass) { %>
                exclude: ['bower_components/bootstrap-sass-official/vendor/assets/javascripts/bootstrap.js']<% } else { %>
                exclude: ['bower_components/bootstrap/dist/js/bootstrap.js']<% } %>
            }<% if (includeCompass) { %>,
            sass: {
                src: ['<%%= config.app %>/styles/{,*/}*.{scss,sass}'],
                ignorePath: '<%%= config.app %>/bower_components/'
            }<% } %>
        },

        // Renames files for browser caching purposes
        rev: {
            dist: {
                files: {
                    src: [
                        '<%%= config.dist %>/scripts/{,*/}*.js',
                        '<%%= config.dist %>/styles/{,*/}*.css',
                        '<%%= config.dist %>/images/{,*/}*.*',
                        '<%%= config.dist %>/styles/fonts/{,*/}*.*',
                        '<%%= config.dist %>/*.{ico,png}'
                    ]
                }
            }
        },

        // Reads HTML for usemin blocks to enable smart builds that automatically
        // concat, minify and revision files. Creates configurations in memory so
        // additional tasks can operate on them
        useminPrepare: {
            options: {
                dest: '<%%= config.dist %>'
            },
            html: '<%%= config.app %>/index.html'
        },

        // Performs rewrites based on rev and the useminPrepare configuration
        usemin: {
            options: {
                assetsDirs: ['<%%= config.dist %>', '<%%= config.dist %>/images']
            },
            html: ['<%%= config.dist %>/{,*/}*.html'],
            css: ['<%%= config.dist %>/styles/{,*/}*.css']
        },

        // The following *-min tasks produce minified files in the dist folder
        imagemin: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%%= config.app %>/images',
                    src: '{,*/}*.{gif,jpeg,jpg,png}',
                    dest: '<%%= config.dist %>/images'
                }]
            }
        },

        svgmin: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%%= config.app %>/images',
                    src: '{,*/}*.svg',
                    dest: '<%%= config.dist %>/images'
                }]
            }
        },

        htmlmin: {
            dist: {
                options: {
                    collapseBooleanAttributes: true,
                    collapseWhitespace: true,
                    removeAttributeQuotes: true,
                    removeCommentsFromCDATA: true,
                    removeEmptyAttributes: true,
                    removeOptionalTags: true,
                    removeRedundantAttributes: true,
                    useShortDoctype: true
                },
                files: [{
                    expand: true,
                    cwd: '<%%= config.dist %>',
                    src: '{,*/}*.html',
                    dest: '<%%= config.dist %>'
                }]
            }
        },

        // By default, your `index.html`'s <!-- Usemin block --> will take care of
        // minification. These next options are pre-configured if you do not wish
        // to use the Usemin blocks.
        // cssmin: {
        //     dist: {
        //         files: {
        //             '<%%= config.dist %>/styles/main.css': [
        //                 '.tmp/styles/{,*/}*.css',
        //                 '<%%= config.app %>/styles/{,*/}*.css'
        //             ]
        //         }
        //     }
        // },
        // uglify: {
        //     dist: {
        //         files: {
        //             '<%%= config.dist %>/scripts/scripts.js': [
        //                 '<%%= config.dist %>/scripts/scripts.js'
        //             ]
        //         }
        //     }
        // },
        // concat: {
        //     dist: {}
        // },

        // Copies remaining files to places other tasks can use
        copy: {
            dist: {
                files: [{
                    expand: true,
                    dot: true,
                    cwd: '<%%= config.app %>',
                    dest: '<%%= config.dist %>',
                    src: [
                        '*.{ico,png,txt}',
                        '.htaccess',
                        'images/{,*/}*.webp',
                        '{,*/}*.html',
                        'styles/fonts/{,*/}*.*'
                    ]
                }<% if (includeBootstrap) { %>, {
                    expand: true,
                    dot: true,
                    cwd: '.',
                    dest: '<%%= config.dist %>',
                    src: [<% if (includeCompass) { %>
                        'bower_components/bootstrap-sass-official/vendor/assets/fonts/bootstrap/*.*'<% } else { %>
                        'bower_components/bootstrap/dist/fonts/*.*'<% } %>
                    ]
                }<% } %>]
            },
            styles: {
                expand: true,
                dot: true,
                cwd: '<%%= config.app %>/styles',
                dest: '.tmp/styles/',
                src: '{,*/}*.css'
            }
        },<% if (includeModernizr) { %>

        // Generates a custom Modernizr build that includes only the tests you
        // reference in your app
        modernizr: {
            devFile: 'bower_components/modernizr/modernizr.js',
            outputFile: '<%%= config.dist %>/scripts/vendor/modernizr.js',
            files: [
                '<%%= config.dist %>/scripts/{,*/}*.js',
                '<%%= config.dist %>/styles/{,*/}*.css',
                '!<%%= config.dist %>/scripts/vendor/*'
            ],
            uglify: true
        },<% } %>

        // Run some tasks in parallel to speed up build process
        concurrent: {
            server: [<% if (includeCompass) { %>
                'compass:server',<% } if (coffee) { %>
                'coffee:dist',<% } %>
                'copy:styles'
            ],
            test: [<% if (coffee) { %>
                'coffee',<% } %>
                'copy:styles'
            ],
            dist: [<% if (coffee) { %>
                'coffee',<% } if (includeCompass) { %>
                'compass',<% } %>
                'copy:styles',
                'imagemin',
                'svgmin'
            ]
        }
    });

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

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

    grunt.registerTask('server', function (target) {
        grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
        grunt.task.run([target ? ('serve:' + target) : 'serve']);
    });

    grunt.registerTask('test', function (target) {
        if (target !== 'watch') {
            grunt.task.run([
                'clean:server',
                'concurrent:test',
                'autoprefixer'
            ]);
        }

        grunt.task.run([
            'connect:test',<% if (testFramework === 'mocha') { %>
            'mocha'<% } else if (testFramework === 'jasmine') { %>
            'jasmine'<% } %>
        ]);
    });

    grunt.registerTask('build', [
        'clean:dist',
        'useminPrepare',
        'concurrent:dist',
        'autoprefixer',
        'concat',
        'cssmin',
        'uglify',
        'copy:dist',<% if (includeModernizr) { %>
        'modernizr',<% } %>
        'rev',
        'usemin',
        'htmlmin'
    ]);

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


<commit_before>/* global _ */

'use strict';

angular
	.module('core')
	.constant('_', window._)
	.constant('d3', window.d3)
	.constant('google', window.google)
	.constant('moment', window.moment)
	.constant('PROVINCES',
		{
			'ab': 'Alberta',
			'bc': 'British Columbia',
			'mb': 'Manitoba',
			'nb': 'New Brunswick',
			'nl': 'Newfoundland and Labrador',
			'ns': 'Nova Scotia',
			'on': 'Ontario',
			'pe': 'Prince Edward Island',
			'qc': 'Quebec',
			'sk': 'Saskatchewan',
			'nt': 'Northwest Territories',
			'nu': 'Nunavut',
			'yt': 'Yukon'
		}
	)
	.constant('REGIONS',
		{
			'cariboo': 'Cariboo',
			'kootenay': 'Kootenay',
			'lower mainland': 'Lower Mainland',
			'okanagan': 'Okanagan',
			'thompson okanagan': 'Thompson Okanagan',
			'thompson-nicola': 'Thompson-Nicola',
			'omineca': 'Omineca',
			'peace': 'Peace',
			'skeena': 'Skeena',
			'vancouver island': 'Vancouver Island',
			'south central (kamloops office)': 'South Central (Kamloops Office)',
			'southeast (cranbrook office)': 'Southeast (Cranbrook Office)',
			'northwest (smithers office)': 'Northwest (Smithers Office)',
			'central-northeast (prince george office)': 'Central-Northeast (Prince George Office)',
			'southwest (victoria office)': 'Southwest (Victoria Office)',
			'southeast (cranbrook)': 'Southeast (Cranbrook)'
		}
	)
	.constant('COMPANY_TYPES',
		{
			'private': 'Privately Owned',
			'public': 'Publically Traded',
		}
	)
	.constant('TASK_STATUS',
		[
			'Not Required',
			'Not Started',
			'In Progress',
			'Complete'
		]
	)
	.constant('VC_ASSESSMENT_CATEGORIES',
		[
			'Environment',
			'Economic',
			'Social',
			'Heritage',
			'Health',
			'Other',
			'Requirements'
		]
	)
	.constant('VCTYPES',
		[ 'Valued Component',
		'Pathway Component'
		]
	)
	.constant('PILLARS',
		[
			'Environment',
			'Economic',
			'Social',
			'Heritage',
			'Health',
			'Other',
			'Requirements'
		]
	)
	.constant('PROJECT_CONDITION_PHASES',
		[
			'Pre-Construction',
			'Construction',
			'Operations',
			'Decommissioning'
		]
	)
	.constant('PROJECT_TYPES',
		[
			'Mining',
			'Energy-Electrical',
			'Energy-Petroleum & Natural Gas',
			'Transportation',
			'Water Management',
			'Industrial',
			'Waste Disposal',
			'Food Processing',
			'Tourist Destination',
			'Other'
		]
	)
	.constant('PROJECT_SUB_TYPES',
		{
			'Mining': [
				'Coal Mines',
				'Construction Stone and Industrial Mineral Quarries',
				'Mineral Mines',
				'Off-shore Mines',
				'Placer Mineral Mines',
				'Sand and Gravel Pits'
			],
			'Energy-Electrical': [
				'Electric Transmission Lines',
				'Power Plants'
			],
			'Energy-Petroleum & Natural Gas': [
				'Energy Storage Facilities',
				'Natural Gas Processing Plants',
				'Off-shore Oil or Gas Facilities',
				'Transmission Pipelines'
			],
			'Transportation': [
				'Airports',
				'Ferry Terminals',
				'Marine Port Facilities',
				'Public Highways',
				'Railways'
			],
			'Water Management': [
				'Dams',
				'Dykes',
				'Groundwater Extraction',
				'Shoreline Modification',
				'Water Diversion'
			],
			'Industrial': [
				'Forest Products Industries',
				'Non-metallic Mineral Products Industries',
				'Organic and Inorganic Chemical Industry',
				'Other Industries',
				'Primary Metals Industry'
			],
			'Waste Disposal': [
				'Hazardous Waste Facilities',
				'Local Government Liquid Waste Management Facilities',
				'Local Government Solid Waste Management Facilities'
			],
			'Food Processing': [
				'Fish Products Industry',
				'Meat and Meat Products Industry',
				'Poultry Products Industry'
			],
			'Tourist Destination': [
				'Golf Resorts',
				'Marina Resorts',
				'Resort Developments',
				'Ski Resorts'
			],
			'Other': [
				'Other'
			]
		})
	.constant('CEAA_TYPES',
		[
			'None',
			'Comprehensive Study (Pre CEAA 2012)',
			'Cooperative (CEAA 2012)',
			'Cooperative (Pre CEAA 2012)',
			'Coordinated',
			'Equivalent (Provincial Lead)',
			'Equivilant (Federal Lead)',
			'Panel (CEAA 2012)',
			'Panel (Pre CEAA 2012)',
			'Screening (Pre CEAA 2012)',
			'Substituted (Federal Lead)',
			'Substituted (Provincial Lead)'
		]
	)
	.constant('CE_STAGES',
		[
			'Pre-Construction',
			'Construction',
			'Operations',
			'Decommissioning'
		]
	)
	.constant('DOCUMENT_TEMPLATE_TYPES',
		[
			'Project Description',
			'Schedule A',
			'Section 7(3) Order',
			'Section 10(1)(a) Order',
			'Section 10(1)(b) Order',
			'Section 10(1)(c) Order',
			'Section 11 Order',
			'Valued Component',
			'AIR',
			'Application',
			'Conditions List',
			'Section 34 Order',
			'Section 36 Order',
			'Environmental Assessment Certificate'
		]
	)
	.constant('COMMENT_REJECT',
		[
			'Unsuitable Language',
			'Quoting Third Parties',
			'Petitions',
			'Personally Identifying Information'
		]
	)
	.constant('PROJECT_ROLES',
		[
			{'code':'project:staff','name':'Staff'},
			{'code':'project:wg','name':'Working Group'},
			{'code':'project:proponent','name':'Proponent'}
		]
	)
	.constant('PROJECT_STATUS',
		{
			'initiated' : 'Initiated',
			'submitted' : 'Submitted',
			'inprogress' : 'In Progress',
			'certified' : 'Certified',
			'decommissioned' : 'Decommissioned'
		}
	)
	.constant('PROJECT_STATUS_ARRAY',
		[
			'Initiated',
			'Submitted',
			'In Progress',
			'Certified',
			'Not Certified',
			'Decommissioned'
		]
	)
	.constant('PROJECT_STATUS_PUBLIC',
		{
			'inprogress' : 'In Progress',
			'certified' : 'Certified',
			'decommissioned' : 'Decommissioned'
		}
	)
	.constant('ENFORCEMENT_ACTIONS',
		[
			'Warning',
			'Order to Cease',
			'Order to Remedy',
			'Compliance Agreement',
			'Referral',
			'Other'
		]
	)
	.constant('ENFORCEMENT_STATUS',
		[
			'Open',
			'Resolved',
			'Recinded'
		]
	)	.constant('PROJECT_DECISION',
		{
			'pre-ea-act-approval' : 'Pre-EA Act Approval',
			'in-progress' : 'In Progress',
			'certificate-not-required' : 'Certificate Not Required',
			'further-assessment-required' : 'Further Assessment Required',
			'certificate-issued' : 'Certificate Issued',
			'certificate-refused' : 'Certificate Refused',
			'terminated' : 'Terminated',
			'withdrawn' : 'Withdrawn'
		}
	)	.factory('ENV', function () {
		 // MEM, EAO
		if (	window.location.href.indexOf('mem.') >= 0 ||
			window.location.href.indexOf('mem-') >= 0 ||
			window.location.href.indexOf('mines.') >= 0 ) return 'MEM';
		else return 'EAO';
	})
	.constant('RELEASE',
		{
			'enableEnforcements': true,
			'enableDecisions': true,
			'enableSchedule': true,
			'enableComplaints': true,
			'enableConditions': true,
			'enableInvitations': true,
			'enableInspectionReports': true,
			'redirectHomepageToGeorgeMassey': false
		}
	)
	.factory('LOGO', function (ENV) {
		// Use the env from above to determine the logo.
		if (ENV === 'EAO') {
			return 'modules/core/client/img/brand/bc_logo_transparent.png'; // BC Logo
		}
		if (ENV === 'MEM') {
			return 'modules/core/client/img/brand/mem-logo-inverted.png'; // EAO Logo
		}
	})
	.constant('SALUTATIONS', ['Mr','Mrs','Miss','Ms','Dr','Capt','Prof','Rev','Other'])
	.factory ('codeFromTitle', function () {
		return function (title) {
			var s = title.toLowerCase ();
			s = s.replace (/\W/g,'-');
			s = s.replace (/-+/,'-');
			return s;
		};
	})
	.value('ProcessCodes', []);
<commit_msg>ESM-423 - Fixing a spelling mistake<commit_after>/* global _ */

'use strict';

angular
	.module('core')
	.constant('_', window._)
	.constant('d3', window.d3)
	.constant('google', window.google)
	.constant('moment', window.moment)
	.constant('PROVINCES',
		{
			'ab': 'Alberta',
			'bc': 'British Columbia',
			'mb': 'Manitoba',
			'nb': 'New Brunswick',
			'nl': 'Newfoundland and Labrador',
			'ns': 'Nova Scotia',
			'on': 'Ontario',
			'pe': 'Prince Edward Island',
			'qc': 'Quebec',
			'sk': 'Saskatchewan',
			'nt': 'Northwest Territories',
			'nu': 'Nunavut',
			'yt': 'Yukon'
		}
	)
	.constant('REGIONS',
		{
			'cariboo': 'Cariboo',
			'kootenay': 'Kootenay',
			'lower mainland': 'Lower Mainland',
			'okanagan': 'Okanagan',
			'thompson okanagan': 'Thompson Okanagan',
			'thompson-nicola': 'Thompson-Nicola',
			'omineca': 'Omineca',
			'peace': 'Peace',
			'skeena': 'Skeena',
			'vancouver island': 'Vancouver Island',
			'south central (kamloops office)': 'South Central (Kamloops Office)',
			'southeast (cranbrook office)': 'Southeast (Cranbrook Office)',
			'northwest (smithers office)': 'Northwest (Smithers Office)',
			'central-northeast (prince george office)': 'Central-Northeast (Prince George Office)',
			'southwest (victoria office)': 'Southwest (Victoria Office)',
			'southeast (cranbrook)': 'Southeast (Cranbrook)'
		}
	)
	.constant('COMPANY_TYPES',
		{
			'private': 'Privately Owned',
			'public': 'Publically Traded',
		}
	)
	.constant('TASK_STATUS',
		[
			'Not Required',
			'Not Started',
			'In Progress',
			'Complete'
		]
	)
	.constant('VC_ASSESSMENT_CATEGORIES',
		[
			'Environment',
			'Economic',
			'Social',
			'Heritage',
			'Health',
			'Other',
			'Requirements'
		]
	)
	.constant('VCTYPES',
		[ 'Valued Component',
		'Pathway Component'
		]
	)
	.constant('PILLARS',
		[
			'Environment',
			'Economic',
			'Social',
			'Heritage',
			'Health',
			'Other',
			'Requirements'
		]
	)
	.constant('PROJECT_CONDITION_PHASES',
		[
			'Pre-Construction',
			'Construction',
			'Operations',
			'Decommissioning'
		]
	)
	.constant('PROJECT_TYPES',
		[
			'Mining',
			'Energy-Electrical',
			'Energy-Petroleum & Natural Gas',
			'Transportation',
			'Water Management',
			'Industrial',
			'Waste Disposal',
			'Food Processing',
			'Tourist Destination',
			'Other'
		]
	)
	.constant('PROJECT_SUB_TYPES',
		{
			'Mining': [
				'Coal Mines',
				'Construction Stone and Industrial Mineral Quarries',
				'Mineral Mines',
				'Off-shore Mines',
				'Placer Mineral Mines',
				'Sand and Gravel Pits'
			],
			'Energy-Electrical': [
				'Electric Transmission Lines',
				'Power Plants'
			],
			'Energy-Petroleum & Natural Gas': [
				'Energy Storage Facilities',
				'Natural Gas Processing Plants',
				'Off-shore Oil or Gas Facilities',
				'Transmission Pipelines'
			],
			'Transportation': [
				'Airports',
				'Ferry Terminals',
				'Marine Port Facilities',
				'Public Highways',
				'Railways'
			],
			'Water Management': [
				'Dams',
				'Dykes',
				'Groundwater Extraction',
				'Shoreline Modification',
				'Water Diversion'
			],
			'Industrial': [
				'Forest Products Industries',
				'Non-metallic Mineral Products Industries',
				'Organic and Inorganic Chemical Industry',
				'Other Industries',
				'Primary Metals Industry'
			],
			'Waste Disposal': [
				'Hazardous Waste Facilities',
				'Local Government Liquid Waste Management Facilities',
				'Local Government Solid Waste Management Facilities'
			],
			'Food Processing': [
				'Fish Products Industry',
				'Meat and Meat Products Industry',
				'Poultry Products Industry'
			],
			'Tourist Destination': [
				'Golf Resorts',
				'Marina Resorts',
				'Resort Developments',
				'Ski Resorts'
			],
			'Other': [
				'Other'
			]
		})
	.constant('CEAA_TYPES',
		[
			'None',
			'Comprehensive Study (Pre CEAA 2012)',
			'Cooperative (CEAA 2012)',
			'Cooperative (Pre CEAA 2012)',
			'Coordinated',
			'Equivalent (Provincial Lead)',
			'Equivalant (Federal Lead)',
			'Panel (CEAA 2012)',
			'Panel (Pre CEAA 2012)',
			'Screening (Pre CEAA 2012)',
			'Substituted (Federal Lead)',
			'Substituted (Provincial Lead)'
		]
	)
	.constant('CE_STAGES',
		[
			'Pre-Construction',
			'Construction',
			'Operations',
			'Decommissioning'
		]
	)
	.constant('DOCUMENT_TEMPLATE_TYPES',
		[
			'Project Description',
			'Schedule A',
			'Section 7(3) Order',
			'Section 10(1)(a) Order',
			'Section 10(1)(b) Order',
			'Section 10(1)(c) Order',
			'Section 11 Order',
			'Valued Component',
			'AIR',
			'Application',
			'Conditions List',
			'Section 34 Order',
			'Section 36 Order',
			'Environmental Assessment Certificate'
		]
	)
	.constant('COMMENT_REJECT',
		[
			'Unsuitable Language',
			'Quoting Third Parties',
			'Petitions',
			'Personally Identifying Information'
		]
	)
	.constant('PROJECT_ROLES',
		[
			{'code':'project:staff','name':'Staff'},
			{'code':'project:wg','name':'Working Group'},
			{'code':'project:proponent','name':'Proponent'}
		]
	)
	.constant('PROJECT_STATUS',
		{
			'initiated' : 'Initiated',
			'submitted' : 'Submitted',
			'inprogress' : 'In Progress',
			'certified' : 'Certified',
			'decommissioned' : 'Decommissioned'
		}
	)
	.constant('PROJECT_STATUS_ARRAY',
		[
			'Initiated',
			'Submitted',
			'In Progress',
			'Certified',
			'Not Certified',
			'Decommissioned'
		]
	)
	.constant('PROJECT_STATUS_PUBLIC',
		{
			'inprogress' : 'In Progress',
			'certified' : 'Certified',
			'decommissioned' : 'Decommissioned'
		}
	)
	.constant('ENFORCEMENT_ACTIONS',
		[
			'Warning',
			'Order to Cease',
			'Order to Remedy',
			'Compliance Agreement',
			'Referral',
			'Other'
		]
	)
	.constant('ENFORCEMENT_STATUS',
		[
			'Open',
			'Resolved',
			'Recinded'
		]
	)	.constant('PROJECT_DECISION',
		{
			'pre-ea-act-approval' : 'Pre-EA Act Approval',
			'in-progress' : 'In Progress',
			'certificate-not-required' : 'Certificate Not Required',
			'further-assessment-required' : 'Further Assessment Required',
			'certificate-issued' : 'Certificate Issued',
			'certificate-refused' : 'Certificate Refused',
			'terminated' : 'Terminated',
			'withdrawn' : 'Withdrawn'
		}
	)	.factory('ENV', function () {
		 // MEM, EAO
		if (	window.location.href.indexOf('mem.') >= 0 ||
			window.location.href.indexOf('mem-') >= 0 ||
			window.location.href.indexOf('mines.') >= 0 ) return 'MEM';
		else return 'EAO';
	})
	.constant('RELEASE',
		{
			'enableEnforcements': true,
			'enableDecisions': true,
			'enableSchedule': true,
			'enableComplaints': true,
			'enableConditions': true,
			'enableInvitations': true,
			'enableInspectionReports': true,
			'redirectHomepageToGeorgeMassey': false
		}
	)
	.factory('LOGO', function (ENV) {
		// Use the env from above to determine the logo.
		if (ENV === 'EAO') {
			return 'modules/core/client/img/brand/bc_logo_transparent.png'; // BC Logo
		}
		if (ENV === 'MEM') {
			return 'modules/core/client/img/brand/mem-logo-inverted.png'; // EAO Logo
		}
	})
	.constant('SALUTATIONS', ['Mr','Mrs','Miss','Ms','Dr','Capt','Prof','Rev','Other'])
	.factory ('codeFromTitle', function () {
		return function (title) {
			var s = title.toLowerCase ();
			s = s.replace (/\W/g,'-');
			s = s.replace (/-+/,'-');
			return s;
		};
	})
	.value('ProcessCodes', []);
<|endoftext|>


<commit_before>'use strict';

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

var paths = {
  lint: ['./gulpfile.js', './lib/**/*.js'],
  watch: ['./gulpfile.js', './lib/**', './test/**/*.js', '!test/{temp,temp/**}'],
  tests: ['./test/**/*.js', '!test/{temp,temp/**}']<% if (istanbulModule) { %>,
  source: ['./lib/*.js']<% } %>
};
var watching = false;

gulp.task('lint', function () {
  return gulp.src(paths.lint)
    .pipe(plugins.jshint('.jshintrc'))<% if (jscsModule) { %>
    .pipe(plugins.jscs())<% } %>
    .pipe(plugins.jshint.reporter('jshint-stylish'));
});<% if (istanbulModule) { %>

gulp.task('istanbul', function (cb) {
  gulp.src(paths.source)
    .pipe(plugins.istanbul()) // Covering files
    .on('finish', function () {
      gulp.src(paths.tests)
        .pipe(plugins.plumber())
        .pipe(plugins.mocha())
        .pipe(plugins.istanbul.writeReports()) // Creating the reports after tests runned
        .on('finish', function() {
          process.chdir(__dirname);
          cb();
        });
    });
});<% } else { %>

gulp.task('mocha', function () {
  gulp.src(paths.tests, {cwd: __dirname})
    .pipe(plugins.plumber())
    .pipe(mocha({ reporter: 'list' }));
});<% } %><% if (releaseModule) { %>

gulp.task('bump', ['test'], function () {
  var bumpType = process.env.BUMP || 'patch'; // major.minor.patch

  return gulp.src(['./package.json'])
    .pipe(plugins.bump({ type: bumpType }))
    .pipe(gulp.dest('./'));
});<% } %>

gulp.task('watch', function () {
  watching = true;
  gulp.run('test');
  gulp.watch(paths.watch, ['test']);
});

gulp.task('default', ['test']);
gulp.task('test', ['lint', <% if (istanbulModule) { %>'istanbul'<% } else { %>'mocha'<% } %>]);
<% if (releaseModule) { %>gulp.task('release', ['bump']);<% } %>
<commit_msg>Remove unused variable<commit_after>'use strict';

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

var paths = {
  lint: ['./gulpfile.js', './lib/**/*.js'],
  watch: ['./gulpfile.js', './lib/**', './test/**/*.js', '!test/{temp,temp/**}'],
  tests: ['./test/**/*.js', '!test/{temp,temp/**}']<% if (istanbulModule) { %>,
  source: ['./lib/*.js']<% } %>
};

gulp.task('lint', function () {
  return gulp.src(paths.lint)
    .pipe(plugins.jshint('.jshintrc'))<% if (jscsModule) { %>
    .pipe(plugins.jscs())<% } %>
    .pipe(plugins.jshint.reporter('jshint-stylish'));
});<% if (istanbulModule) { %>

gulp.task('istanbul', function (cb) {
  gulp.src(paths.source)
    .pipe(plugins.istanbul()) // Covering files
    .on('finish', function () {
      gulp.src(paths.tests)
        .pipe(plugins.plumber())
        .pipe(plugins.mocha())
        .pipe(plugins.istanbul.writeReports()) // Creating the reports after tests runned
        .on('finish', function() {
          process.chdir(__dirname);
          cb();
        });
    });
});<% } else { %>

gulp.task('mocha', function () {
  gulp.src(paths.tests, {cwd: __dirname})
    .pipe(plugins.plumber())
    .pipe(mocha({ reporter: 'list' }));
});<% } %><% if (releaseModule) { %>

gulp.task('bump', ['test'], function () {
  var bumpType = process.env.BUMP || 'patch'; // major.minor.patch

  return gulp.src(['./package.json'])
    .pipe(plugins.bump({ type: bumpType }))
    .pipe(gulp.dest('./'));
});<% } %>

gulp.task('watch', function () {
  gulp.run('test');
  gulp.watch(paths.watch, ['test']);
});

gulp.task('default', ['test']);
gulp.task('test', ['lint', <% if (istanbulModule) { %>'istanbul'<% } else { %>'mocha'<% } %>]);
<% if (releaseModule) { %>gulp.task('release', ['bump']);<% } %>
<|endoftext|>


<commit_before>/* global Module */

/* Magic Mirror
 * Module: Calendar
 *
 * By Michael Teeuw http://michaelteeuw.nl
 * MIT Licensed.
 */

Module.register("calendar",{

	// Define module defaults
	defaults: {
		maximumEntries: 10, // Total Maximum Entries
		maximumNumberOfDays: 365,
		displaySymbol: true,
		defaultSymbol: "calendar", // Fontawsome Symbol see http://fontawesome.io/cheatsheet/
		displayRepeatingCountTitle: false,
		defaultRepeatingCountTitle: '',
		maxTitleLength: 25,
		fetchInterval: 5 * 60 * 1000, // Update every 5 minutes.
		animationSpeed: 2000,
		fade: true,
		fadePoint: 0.25, // Start on 1/4th of the list.
		calendars: [
			{
				symbol: "calendar",
				url: "http://www.calendarlabs.com/templates/ical/US-Holidays.ics",
			},
		],
		titleReplace: {
			"De verjaardag van ": ""
		},
	},

	// Define required scripts.
	getStyles: function() {
		return ["calendar.css", "font-awesome.css"];
	},

	// Define required scripts.
	getScripts: function() {
		return ["moment.js"];
	},

	// Define required translations.
	getTranslations: function() {
		return {
			en: "translations/en.json",
			de: "translations/de.json",
			nl: "translations/nl.json"
		};
	},

	// Override start method.
	start: function() {
		Log.log("Starting module: " + this.name);

		// Set locale.
		moment.locale(config.language);

		for (var c in this.config.calendars) {
			var calendar = this.config.calendars[c];
			calendar.url = calendar.url.replace("webcal://", "http://");
			this.addCalendar(calendar.url);
		}

		this.calendarData = {};
		this.loaded = false;
	},

	// Override socket notification handler.
	socketNotificationReceived: function(notification, payload) {
		if (notification === "CALENDAR_EVENTS") {
			if (this.hasCalendarURL(payload.url)) {
				this.calendarData[payload.url] = payload.events;
				this.loaded = true;
			}
		} else if (notification === "FETCH_ERROR") {
			Log.error("Calendar Error. Could not fetch calendar: " + payload.url);
		} else if (notification === "INCORRECT_URL") {
			Log.error("Calendar Error. Incorrect url: " + payload.url);
		} else {
			Log.log("Calendar received an unknown socket notification: " + notification);
		}

		this.updateDom(this.config.animationSpeed);
	},

	// Override dom generator.
	getDom: function() {

		var events = this.createEventList();
		var wrapper = document.createElement("table");
		wrapper.className = "small";

		if (events.length === 0) {
			wrapper.innerHTML = (this.loaded) ? this.translate("EMPTY") : this.translate("LOADING");
			wrapper.className = "small dimmed";
			return wrapper;
		}

		for (var e in events) {
			var event = events[e];

			var eventWrapper = document.createElement("tr");
			eventWrapper.className = "normal";

			if (this.config.displaySymbol) {
				var symbolWrapper =  document.createElement("td");
				symbolWrapper.className = "symbol";
				var symbol =  document.createElement("span");
				symbol.className = "fa fa-" + this.symbolForUrl(event.url);
				symbolWrapper.appendChild(symbol);
				eventWrapper.appendChild(symbolWrapper);
			}

			var titleWrapper = document.createElement("td"),
				repeatingCountTitle = '';

			if (this.config.displayRepeatingCountTitle) {

				repeatingCountTitle = this.countTitleForUrl(event.url);

				if(repeatingCountTitle !== '') {
					var thisYear = new Date().getFullYear(),
						yearDiff = thisYear - event.firstYear;

					repeatingCountTitle = ', '+ yearDiff + '. ' + repeatingCountTitle;
				}
			}

			titleWrapper.innerHTML = this.titleTransform(event.title) + repeatingCountTitle;
			titleWrapper.className = "title bright";
			eventWrapper.appendChild(titleWrapper);

			var timeWrapper =  document.createElement("td");
			//console.log(event.today);
			var now = new Date();
			if (event.fullDayEvent) {
				if (event.today) {
					timeWrapper.innerHTML = this.translate("TODAY");
				} else if (event.startDate - now < 24 * 60 * 60 * 1000 && event.startDate - now > 0) {
					timeWrapper.innerHTML = this.translate("TOMORROW");
				} else {
					timeWrapper.innerHTML =  moment(event.startDate,"x").fromNow();
				}
			} else {
				if (event.startDate >= new Date()) {
					if (event.startDate - now > 48 * 60 * 60 * 1000) {
						// if the event is no longer than 2 days away, display the absolute time.
						timeWrapper.innerHTML = moment(event.startDate,"x").fromNow();
					} else {
						timeWrapper.innerHTML = moment(event.startDate,"x").calendar();
					}
				} else {
					timeWrapper.innerHTML =  this.translate("RUNNING") + ' ' + moment(event.endDate,"x").fromNow(true);
				}
			}
			//timeWrapper.innerHTML += ' - '+ moment(event.startDate,'x').format('lll');
			//console.log(event);
			timeWrapper.className = "time light";
			eventWrapper.appendChild(timeWrapper);

			wrapper.appendChild(eventWrapper);

			// Create fade effect.
			if (this.config.fade && this.config.fadePoint < 1) {
				if (this.config.fadePoint < 0) {
					this.config.fadePoint = 0;
				}
				var startingPoint = events.length * this.config.fadePoint;
				var steps = events.length - startingPoint;
				if (e >= startingPoint) {
					var currentStep = e - startingPoint;
					eventWrapper.style.opacity = 1 - (1 / steps * currentStep);
				}
			}
		}

		return wrapper;
	},

	/* hasCalendarURL(url)
	 * Check if this config contains the calendar url.
	 *
	 * argument url sting - Url to look for.
	 *
	 * return bool - Has calendar url
	 */
	hasCalendarURL: function(url) {
		for (var c in this.config.calendars) {
			var calendar = this.config.calendars[c];
			if (calendar.url === url) {
				return true;
			}
		}

		return false;
	},

	/* createEventList()
	 * Creates the sorted list of all events.
	 *
	 * return array - Array with events.
	 */
	createEventList: function() {
		var events = [];
		var today = moment().startOf("day");
		for (var c in this.calendarData) {
			var calendar = this.calendarData[c];
			for (var e in calendar) {
				var event = calendar[e];
				event.url = c;
				event.today = event.startDate >= today && event.startDate < (today + 24 * 60 * 60 * 1000);
				events.push(event);
			}
		}

		events.sort(function(a, b) {
			return a.startDate - b.startDate;
		});

		return events.slice(0, this.config.maximumEntries);
	},

	/* createEventList(url)
	 * Requests node helper to add calendar url.
	 *
	 * argument url sting - Url to add.
	 */
	addCalendar: function(url) {
		this.sendSocketNotification("ADD_CALENDAR", {
			url: url,
			maximumEntries: this.config.maximumEntries,
			maximumNumberOfDays: this.config.maximumNumberOfDays,
			fetchInterval: this.config.fetchInterval
		});
	},

	/* symbolForUrl(url)
	 * Retrieves the symbol for a specific url.
	 *
	 * argument url sting - Url to look for.
	 *
	 * return string - The Symbol
	 */
	symbolForUrl: function(url) {
		for (var c in this.config.calendars) {
			var calendar = this.config.calendars[c];
			if (calendar.url === url && typeof calendar.symbol === "string")  {
				return calendar.symbol;
			}
		}

		return this.config.defaultSymbol;
	},
	/* countTitleForUrl(url)
	 * Retrieves the name for a specific url.
	 *
	 * argument url sting - Url to look for.
	 *
	 * return string - The Symbol
	 */
	countTitleForUrl: function(url) {
		for (var c in this.config.calendars) {
			var calendar = this.config.calendars[c];
			if (calendar.url === url && typeof calendar.repeatingCountTitle === "string")  {
				return calendar.repeatingCountTitle;
			}
		}

		return this.config.defaultRepeatingCountTitle;
	},

	/* shorten(string, maxLength)
	 * Shortens a sting if it's longer than maxLenthg.
	 * Adds an ellipsis to the end.
	 *
	 * argument string string - The string to shorten.
	 * argument maxLength number - The max lenth of the string.
	 *
	 * return string - The shortened string.
	 */
	shorten: function(string, maxLength) {
		if (string.length > maxLength) {
			return string.slice(0,maxLength) + "…";
		}

		return string;
	},

	/* titleTransform(title)
	 * Transforms the title of an event for usage.
	 * Replaces parts of the text as defined in config.titleReplace.
	 * Shortens title based on config.maxTitleLength
	 *
	 * argument title string - The title to transform.
	 *
	 * return string - The transformed title.
	 */
	titleTransform: function(title) {
		for (var needle in this.config.titleReplace) {
			var replacement = this.config.titleReplace[needle];
			title = title.replace(needle, replacement);
		}

		title = this.shorten(title, this.config.maxTitleLength);
		return title;
	}
});
<commit_msg>Update calendar.js<commit_after>/* global Module */

/* Magic Mirror
 * Module: Calendar
 *
 * By Michael Teeuw http://michaelteeuw.nl
 * MIT Licensed.
 */

Module.register("calendar",{

	// Define module defaults
	defaults: {
		maximumEntries: 10, // Total Maximum Entries
		maximumNumberOfDays: 365,
		displaySymbol: true,
		defaultSymbol: "calendar", // Fontawsome Symbol see http://fontawesome.io/cheatsheet/
		displayRepeatingCountTitle: false,
		defaultRepeatingCountTitle: '',
		maxTitleLength: 25,
		fetchInterval: 5 * 60 * 1000, // Update every 5 minutes.
		animationSpeed: 2000,
		fade: true,
		fadePoint: 0.25, // Start on 1/4th of the list.
		calendars: [
			{
				symbol: "calendar",
				url: "http://www.calendarlabs.com/templates/ical/US-Holidays.ics",
			},
		],
		titleReplace: {
			"De verjaardag van ": ""
		},
	},

	// Define required scripts.
	getStyles: function() {
		return ["calendar.css", "font-awesome.css"];
	},

	// Define required scripts.
	getScripts: function() {
		return ["moment.js"];
	},

	// Define required translations.
	getTranslations: function() {
		return {
			en: "translations/en.json",
			de: "translations/de.json",
			nl: "translations/nl.json",
			fr: "translations/fr.json"
		};
	},

	// Override start method.
	start: function() {
		Log.log("Starting module: " + this.name);

		// Set locale.
		moment.locale(config.language);

		for (var c in this.config.calendars) {
			var calendar = this.config.calendars[c];
			calendar.url = calendar.url.replace("webcal://", "http://");
			this.addCalendar(calendar.url);
		}

		this.calendarData = {};
		this.loaded = false;
	},

	// Override socket notification handler.
	socketNotificationReceived: function(notification, payload) {
		if (notification === "CALENDAR_EVENTS") {
			if (this.hasCalendarURL(payload.url)) {
				this.calendarData[payload.url] = payload.events;
				this.loaded = true;
			}
		} else if (notification === "FETCH_ERROR") {
			Log.error("Calendar Error. Could not fetch calendar: " + payload.url);
		} else if (notification === "INCORRECT_URL") {
			Log.error("Calendar Error. Incorrect url: " + payload.url);
		} else {
			Log.log("Calendar received an unknown socket notification: " + notification);
		}

		this.updateDom(this.config.animationSpeed);
	},

	// Override dom generator.
	getDom: function() {

		var events = this.createEventList();
		var wrapper = document.createElement("table");
		wrapper.className = "small";

		if (events.length === 0) {
			wrapper.innerHTML = (this.loaded) ? this.translate("EMPTY") : this.translate("LOADING");
			wrapper.className = "small dimmed";
			return wrapper;
		}

		for (var e in events) {
			var event = events[e];

			var eventWrapper = document.createElement("tr");
			eventWrapper.className = "normal";

			if (this.config.displaySymbol) {
				var symbolWrapper =  document.createElement("td");
				symbolWrapper.className = "symbol";
				var symbol =  document.createElement("span");
				symbol.className = "fa fa-" + this.symbolForUrl(event.url);
				symbolWrapper.appendChild(symbol);
				eventWrapper.appendChild(symbolWrapper);
			}

			var titleWrapper = document.createElement("td"),
				repeatingCountTitle = '';

			if (this.config.displayRepeatingCountTitle) {

				repeatingCountTitle = this.countTitleForUrl(event.url);

				if(repeatingCountTitle !== '') {
					var thisYear = new Date().getFullYear(),
						yearDiff = thisYear - event.firstYear;

					repeatingCountTitle = ', '+ yearDiff + '. ' + repeatingCountTitle;
				}
			}

			titleWrapper.innerHTML = this.titleTransform(event.title) + repeatingCountTitle;
			titleWrapper.className = "title bright";
			eventWrapper.appendChild(titleWrapper);

			var timeWrapper =  document.createElement("td");
			//console.log(event.today);
			var now = new Date();
			if (event.fullDayEvent) {
				if (event.today) {
					timeWrapper.innerHTML = this.translate("TODAY");
				} else if (event.startDate - now < 24 * 60 * 60 * 1000 && event.startDate - now > 0) {
					timeWrapper.innerHTML = this.translate("TOMORROW");
				} else {
					timeWrapper.innerHTML =  moment(event.startDate,"x").fromNow();
				}
			} else {
				if (event.startDate >= new Date()) {
					if (event.startDate - now > 48 * 60 * 60 * 1000) {
						// if the event is no longer than 2 days away, display the absolute time.
						timeWrapper.innerHTML = moment(event.startDate,"x").fromNow();
					} else {
						timeWrapper.innerHTML = moment(event.startDate,"x").calendar();
					}
				} else {
					timeWrapper.innerHTML =  this.translate("RUNNING") + ' ' + moment(event.endDate,"x").fromNow(true);
				}
			}
			//timeWrapper.innerHTML += ' - '+ moment(event.startDate,'x').format('lll');
			//console.log(event);
			timeWrapper.className = "time light";
			eventWrapper.appendChild(timeWrapper);

			wrapper.appendChild(eventWrapper);

			// Create fade effect.
			if (this.config.fade && this.config.fadePoint < 1) {
				if (this.config.fadePoint < 0) {
					this.config.fadePoint = 0;
				}
				var startingPoint = events.length * this.config.fadePoint;
				var steps = events.length - startingPoint;
				if (e >= startingPoint) {
					var currentStep = e - startingPoint;
					eventWrapper.style.opacity = 1 - (1 / steps * currentStep);
				}
			}
		}

		return wrapper;
	},

	/* hasCalendarURL(url)
	 * Check if this config contains the calendar url.
	 *
	 * argument url sting - Url to look for.
	 *
	 * return bool - Has calendar url
	 */
	hasCalendarURL: function(url) {
		for (var c in this.config.calendars) {
			var calendar = this.config.calendars[c];
			if (calendar.url === url) {
				return true;
			}
		}

		return false;
	},

	/* createEventList()
	 * Creates the sorted list of all events.
	 *
	 * return array - Array with events.
	 */
	createEventList: function() {
		var events = [];
		var today = moment().startOf("day");
		for (var c in this.calendarData) {
			var calendar = this.calendarData[c];
			for (var e in calendar) {
				var event = calendar[e];
				event.url = c;
				event.today = event.startDate >= today && event.startDate < (today + 24 * 60 * 60 * 1000);
				events.push(event);
			}
		}

		events.sort(function(a, b) {
			return a.startDate - b.startDate;
		});

		return events.slice(0, this.config.maximumEntries);
	},

	/* createEventList(url)
	 * Requests node helper to add calendar url.
	 *
	 * argument url sting - Url to add.
	 */
	addCalendar: function(url) {
		this.sendSocketNotification("ADD_CALENDAR", {
			url: url,
			maximumEntries: this.config.maximumEntries,
			maximumNumberOfDays: this.config.maximumNumberOfDays,
			fetchInterval: this.config.fetchInterval
		});
	},

	/* symbolForUrl(url)
	 * Retrieves the symbol for a specific url.
	 *
	 * argument url sting - Url to look for.
	 *
	 * return string - The Symbol
	 */
	symbolForUrl: function(url) {
		for (var c in this.config.calendars) {
			var calendar = this.config.calendars[c];
			if (calendar.url === url && typeof calendar.symbol === "string")  {
				return calendar.symbol;
			}
		}

		return this.config.defaultSymbol;
	},
	/* countTitleForUrl(url)
	 * Retrieves the name for a specific url.
	 *
	 * argument url sting - Url to look for.
	 *
	 * return string - The Symbol
	 */
	countTitleForUrl: function(url) {
		for (var c in this.config.calendars) {
			var calendar = this.config.calendars[c];
			if (calendar.url === url && typeof calendar.repeatingCountTitle === "string")  {
				return calendar.repeatingCountTitle;
			}
		}

		return this.config.defaultRepeatingCountTitle;
	},

	/* shorten(string, maxLength)
	 * Shortens a sting if it's longer than maxLenthg.
	 * Adds an ellipsis to the end.
	 *
	 * argument string string - The string to shorten.
	 * argument maxLength number - The max lenth of the string.
	 *
	 * return string - The shortened string.
	 */
	shorten: function(string, maxLength) {
		if (string.length > maxLength) {
			return string.slice(0,maxLength) + "…";
		}

		return string;
	},

	/* titleTransform(title)
	 * Transforms the title of an event for usage.
	 * Replaces parts of the text as defined in config.titleReplace.
	 * Shortens title based on config.maxTitleLength
	 *
	 * argument title string - The title to transform.
	 *
	 * return string - The transformed title.
	 */
	titleTransform: function(title) {
		for (var needle in this.config.titleReplace) {
			var replacement = this.config.titleReplace[needle];
			title = title.replace(needle, replacement);
		}

		title = this.shorten(title, this.config.maxTitleLength);
		return title;
	}
});
<|endoftext|>


<commit_before>var gulp = require('gulp'),
    gutil = require('gulp-util'),
    path = require('path'),
    argv = require('yargs').alias('p', 'port').argv;

var devServer = {
  port: argv.port || Math.round(31337 + Math.random() * 1000),
  livereload: 35000 + Math.round((Math.random() * 1000)),
  root: './dist'
};

var paths = {
  scripts: ['src/**/*.js'],
  markup: ['src/*.html'],
  styles: { paths: [ path.join(__dirname, 'src/styles') ] }
};

gulp.task('default', ['build', 'startStaticServer', 'watchChanges']);
gulp.task('build', ['makeDist', 'runBrowserify', 'copyDist', 'compileLess']);

gulp.task('runBrowserify', runBrowserify);
gulp.task('compileLess', compileLess);
gulp.task('makeDist', makeDist);
gulp.task('copyDist', copyDist);
gulp.task('watchChanges', watchChanges);
gulp.task('startStaticServer', startStaticServer);

function runBrowserify() {
  var fs = require('fs');

  var bundle = require('browserify')()
    .add('./src/scripts/index.js')
    .bundle()
    .on('error', function (err) {
        gutil.log('Failed to browserify', err.message);
    });
  bundle.pipe(fs.createWriteStream(path.join(__dirname + '/dist/bundle.js')));
}

function compileLess() {
  var less = require('gulp-less')(paths.styles);
  less.on('error', function (err) {
    gutil.log('Failed to compile less: ', err.message);
  });

	gulp.src('src/styles/style.less')
		.pipe(less)
		.pipe(gulp.dest('dist/styles'));
}

function makeDist() {
  var fs = require('fs');
  if (!fs.existsSync('./dist')) {
    fs.mkdirSync('./dist');
  }
}

function copyDist() {
  var concat = require('gulp-concat');

  gulp.src('./src/index.html')
      .pipe(gulp.dest('./dist'));

  gulp.src('./node_modules/angular/lib/angular.min.js')
      .pipe(concat('external.min.js'))
      .pipe(gulp.dest('./dist'));

  gulp.src('./node_modules/twitter-bootstrap-3.0.0/fonts/*')
      .pipe(gulp.dest('./dist/fonts/'));
}

function watchChanges() {
  gulp.watch(paths.scripts, ['runBrowserify']);
  gulp.watch('src/styles/*.less', ['compileLess']);
  gulp.watch(paths.markup, ['copyDist']);
  gulp.watch('dist/**').on('change', notifyLivereload);
}

var lr;
function startStaticServer() {
  var express = require('express');
  var app = express();
  app.use(require('connect-livereload')({port: devServer.livereload }));
  app.use(express.static(devServer.root));
  app.listen(devServer.port, function () {
    gutil.log("opened server on http://127.0.0.1:" + devServer.port);
  });

  lr = require('tiny-lr')();
  lr.listen(devServer.livereload);
}

function notifyLivereload(event) {
  var fileName = require('path').relative(devServer.root, event.path);
  lr.changed({ body: { files: [fileName] } });
}
<commit_msg>Highlight errors<commit_after>var gulp = require('gulp'),
    gutil = require('gulp-util'),
    path = require('path'),
    argv = require('yargs').alias('p', 'port').argv;

var devServer = {
  port: argv.port || Math.round(31337 + Math.random() * 1000),
  livereload: 35000 + Math.round((Math.random() * 1000)),
  root: './dist'
};

var paths = {
  scripts: ['src/**/*.js'],
  markup: ['src/*.html'],
  styles: { paths: [ path.join(__dirname, 'src/styles') ] }
};

gulp.task('default', ['build', 'startStaticServer', 'watchChanges']);
gulp.task('build', ['makeDist', 'runBrowserify', 'copyDist', 'compileLess']);

gulp.task('runBrowserify', runBrowserify);
gulp.task('compileLess', compileLess);
gulp.task('makeDist', makeDist);
gulp.task('copyDist', copyDist);
gulp.task('watchChanges', watchChanges);
gulp.task('startStaticServer', startStaticServer);

function runBrowserify() {
  var fs = require('fs');

  var bundle = require('browserify')()
    .add('./src/scripts/index.js')
    .bundle()
    .on('error', function (err) {
        gutil.log(gutil.colors.red('Failed to browserify'), gutil.colors.yellow(err.message));
    });
  bundle.pipe(fs.createWriteStream(path.join(__dirname + '/dist/bundle.js')));
}

function compileLess() {
  var less = require('gulp-less')(paths.styles);
  less.on('error', function (err) {
    gutil.log(gutil.colors.red('Failed to compile less: '), gutil.colors.yellow(err.message));
  });

	gulp.src('src/styles/style.less')
		.pipe(less)
		.pipe(gulp.dest('dist/styles'));
}

function makeDist() {
  var fs = require('fs');
  if (!fs.existsSync('./dist')) {
    fs.mkdirSync('./dist');
  }
}

function copyDist() {
  var concat = require('gulp-concat');

  gulp.src('./src/index.html')
      .pipe(gulp.dest('./dist'));

  gulp.src('./node_modules/angular/lib/angular.min.js')
      .pipe(concat('external.min.js'))
      .pipe(gulp.dest('./dist'));

  gulp.src('./node_modules/twitter-bootstrap-3.0.0/fonts/*')
      .pipe(gulp.dest('./dist/fonts/'));
}

function watchChanges() {
  gulp.watch(paths.scripts, ['runBrowserify']);
  gulp.watch('src/styles/*.less', ['compileLess']);
  gulp.watch(paths.markup, ['copyDist']);
  gulp.watch('dist/**').on('change', notifyLivereload);
}

var lr;
function startStaticServer() {
  var express = require('express');
  var app = express();
  app.use(require('connect-livereload')({port: devServer.livereload }));
  app.use(express.static(devServer.root));
  app.listen(devServer.port, function () {
    gutil.log("opened server on http://127.0.0.1:" + devServer.port);
  });

  lr = require('tiny-lr')();
  lr.listen(devServer.livereload);
}

function notifyLivereload(event) {
  var fileName = require('path').relative(devServer.root, event.path);
  lr.changed({ body: { files: [fileName] } });
}
<|endoftext|>


<commit_before>var _ = require('underscore');

var socketio = {};
var config, player;

var playbackEvent = function(socket) {
    socket.emit('playback', player.queue[0] ? {
        songID: player.queue[0].songID,
        format: player.queue[0].format,
        backendName: player.queue[0].backendName,
        duration: player.queue[0].duration,
        position: player.playbackStart ? player.playbackPosition + (new Date() - player.playbackStart) : player.playbackPosition,
        playbackStart: player.playbackStart
    } : null);
};

var queueEvent = function(socket) {
    socket.emit('queue', player.queue);
};

// called when nodeplayer is started to initialize the plugin
// do any necessary initialization here
socketio.init = function(_player, callback) {
    player = _player;
    config = _player.config;

    if(!player.httpServer) {
        callback('module must be initialized after expressjs module!');
    } else {
        socketio.io = require('socket.io')(player.httpServer);
        socketio.io.on('connection', function(socket) {
            playbackEvent(socket);
            queueEvent(socket);
        });

        player.socketio = socketio;

        console.log('listening on port ' + (process.env.PORT || config.port));
        callback();
    }
};

socketio.onSongChange = function(song) {
    playbackEvent(socketio.io);
};

socketio.onSongPause = function(song) {
    playbackEvent(socketio.io);
};

socketio.onQueueModify = function(queue) {
    queueEvent(socketio.io);
};

socketio.onEndOfQueue = function() {
    playbackEvent(socketio.io);
    queueEvent(socketio.io);
};

module.exports = socketio;
<commit_msg>rest api calls replicated for socket.io connections<commit_after>var _ = require('underscore');

var socketio = {};
var config, player;

var playbackEvent = function(socket) {
    socket.emit('playback', player.queue[0] ? {
        songID: player.queue[0].songID,
        format: player.queue[0].format,
        backendName: player.queue[0].backendName,
        duration: player.queue[0].duration,
        position: player.playbackStart ? player.playbackPosition + (new Date() - player.playbackStart) : player.playbackPosition,
        playbackStart: player.playbackStart
    } : null);
};

var queueEvent = function(socket) {
    socket.emit('queue', player.queue);
};

// called when nodeplayer is started to initialize the plugin
// do any necessary initialization here
socketio.init = function(_player, callback) {
    player = _player;
    config = _player.config;

    if(!player.httpServer) {
        callback('module must be initialized after expressjs module!');
    } else {
        socketio.io = require('socket.io')(player.httpServer);
        socketio.io.on('connection', function(socket) {
            socket.on('addToQueue', function(data) {
                var err = player.addToQueue(data.songs, data.pos);
                socket.emit('addToQueueResult', err);
            });
            socket.on('removeFromQueue', function(data) {
                var err = player.removeFromQueue(data.pos, data.cnt);
                socket.emit('removeFromQueueResult', err);
            });
            socket.on('searchBackends', function(query) {
                player.searchBackends(query, function(results) {
                    socket.emit('searchBackendsResult', results);
                });
            });
            socket.on('startPlayback', player.startPlayback);
            socket.on('pausePlayback', player.pausePlayback);
            socket.on('skipSongs', player.skipSongs);
            socket.on('shuffleQueue', player.shuffleQueue);

            playbackEvent(socket);
            queueEvent(socket);
        });

        player.socketio = socketio;

        console.log('listening on port ' + (process.env.PORT || config.port));
        callback();
    }
};

socketio.onSongChange = function(song) {
    playbackEvent(socketio.io);
};

socketio.onSongPause = function(song) {
    playbackEvent(socketio.io);
};

socketio.onQueueModify = function(queue) {
    queueEvent(socketio.io);
};

socketio.onEndOfQueue = function() {
    playbackEvent(socketio.io);
    queueEvent(socketio.io);
};

module.exports = socketio;
<|endoftext|>