<commit_before>'use strict';

const fs = require('fs');

module.exports = function(grunt) {
	let isTravisCi = (process.env.TRAVIS === 'true');

	const chromeExtensionId = 'hhinaapppaileiechjoiifaancjggfjm';
	const amoExtensionId = '{799c0914-748b-41df-a25c-22d008f9e83f}';

	const srcDir = 'src';
	const buildDir = 'build';
	const packageName = 'web-scrobbler.zip';
	const manifestFile = 'src/manifest.json';

	// Files to build package
	const extensionSources = [
		'**/*',
		// Skip files
		'!content/testReporter.js', '!icons/src/**',
	];
	const documentationFiles = [
		'README.md', 'LICENSE.md'
	];

	// Files to lint
	const jsFiles = [
		// Custom Grunt tasks
		'.grunt',
		// Connectors
		`${srcDir}/connectors/**/*.js`,
		// Core files
		`${srcDir}/core/**/*.js`, `${srcDir}/options/*.js`,
		`${srcDir}/popups/*.js`,
		// Tests
		'tests/**/*.js'
	];
	const jsonFiles = ['*.json', '.stylelintrc'];
	const htmlFiles = [`${srcDir}/options/*.html`, `${srcDir}/popups/*.html`];
	const cssFiles = [`${srcDir}options/*.css`, `${srcDir}/popups/*.css`];

	const webStoreConfig = loadWebStoreConfig();
	const githubConfig = loadGithubConfig();
	const amoConfig = loadAmoConfig();

	grunt.initConfig({
		manifest: grunt.file.readJSON(manifestFile),

		/**
		 * Configs of build tasks.
		 */

		clean: {
			build: buildDir,
			package: [packageName],
			chrome: [
				`${buildDir}/icons/icon128_firefox.png`,
				`${buildDir}/icons/icon48_firefox.png`
			],
		},
		copy: {
			source_files: {
				expand: true,
				cwd: srcDir,
				src: extensionSources,
				dest: buildDir,
			},
			documentation: {
				expand: true,
				src: documentationFiles,
				dest: buildDir,
			}
		},
		compress: {
			main: {
				options: {
					archive: packageName,
					pretty: true
				},
				expand: true,
				cwd: buildDir,
				src: '**/*',
			}
		},
		imagemin: {
			static: {
				options: {
					svgoPlugins: [{
						removeViewBox: false
					}],
				},
				files: [{
					expand: true,
					src: [
						`${buildDir}/icons/*.svg`,
						`${buildDir}/icons/*.png`
					]
				}]
			}
		},
		preprocess: {
			firefox: {
				src: `${buildDir}/**/*.js`,
				expand: true,
				options: {
					inline: true,
					context: {
						FIREFOX: true,
					}
				}
			},
			chrome: {
				src: `${buildDir}/**/*.js`,
				expand: true,
				options: {
					inline: true,
					context: {
						CHROME: true,
					}
				}
			}
		},
		rename: {
			firefox: {
				files: [{
					src: `${buildDir}/icons/icon128_firefox.png`,
					dest: `${buildDir}/icons/icon128.png`
				}, {
					src: `${buildDir}/icons/icon48_firefox.png`,
					dest: `${buildDir}/icons/icon48.png`
				}]
			}
		},
		replace_json: {
			chrome: {
				src: `${buildDir}/manifest.json`,
				changes: {
					'options_ui': undefined,
				}
			},
			firefox: {
				src: `${buildDir}/manifest.json`,
				changes: {
					'applications.gecko.id': amoExtensionId,
					'applications.gecko.strict_min_version': '53.0',

					'options_page': undefined,
				}
			},
		},

		/**
		 * Publish tasks.
		 */

		bump: {
			options: {
				files: [manifestFile],
				updateConfigs: ['manifest'],
				commitFiles: [manifestFile],
			}
		},
		dump_changelog: {
			token: githubConfig.token,
			version: '<%= manifest.version %>',
		},
		github_publish: {
			token: githubConfig.token,
			version: '<%= manifest.version %>',
		},
		amo_upload: {
			issuer: amoConfig.issuer,
			secret: amoConfig.secret,
			id: amoExtensionId,
			version: '<%= manifest.version %>',
			src: packageName,
		},
		webstore_upload: {
			accounts: {
				default: {
					publish: true,
					client_id: webStoreConfig.clientId,
					client_secret: webStoreConfig.clientSecret,
					refresh_token: webStoreConfig.refreshToken,
				},
			},
			extensions: {
				'web-scrobbler': {
					appID: chromeExtensionId,
					zip: packageName,
				}
			}
		},

		/**
		 * Linter configs.
		 */

		eslint: {
			target: jsFiles,
			options: {
				configFile: '.eslintrc.js',
				fix: !isTravisCi
			},
		},
		jsonlint: {
			src: jsonFiles
		},
		lintspaces: {
			src: [jsFiles, jsonFiles, cssFiles, htmlFiles],
			options: {
				editorconfig: '.editorconfig',
				ignores: ['js-comments']
			}
		},
		stylelint: {
			all: cssFiles
		},

		/**
		 * Configs of other tasks.
		 */

		exec: {
			run_tests: {
				cmd: (...args) => `node tests/runner.js ${args.join(' ')}`
			}
		},
		gitcommit: {
			add0n_changelog: {
				options: {
					message: 'Update changelog on add0n.com'
				},
				files: {
					src: ['.add0n/changelog.json']
				}
			}
		}
	});

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

	/**
	 * Some tasks take browser name as an argument.
	 * We support only Chrome and Firefox, which can be specified
	 * as 'chrome' and 'firefox' respectively:
	 *
	 *   Build a package for Chrome browser
	 *   > grunt build:chrome
	 *
	 *   Compile sources for Firefox browser
	 *   > grunt compile:firefox
	 */

	/**
	 * Set the extension icon according to specified browser.
	 * @param {String} browser Browser name
	 */
	grunt.registerTask('icons', (browser) => {
		assertBrowserIsSupported(browser);

		switch (browser) {
			case 'chrome':
				grunt.task.run('clean:chrome');
				break;
			case 'firefox':
				grunt.task.run('rename:firefox');
				break;
		}
	});

	/**
	 * Copy source filed to build directory, preprocess them and
	 * set the extension icon according to specified browser.
	 * @param {String} browser Browser name
	 */
	grunt.registerTask('compile', (browser) => {
		assertBrowserIsSupported(browser);

		grunt.task.run([
			'copy', `preprocess:${browser}`,
			`icons:${browser}`, 'imagemin',
			`replace_json:${browser}`
		]);
	});

	/**
	 * Compile source files and package them.
	 * @param  {String} browser Browser name
	 */
	grunt.registerTask('build', (browser) => {
		assertBrowserIsSupported(browser);

		grunt.task.run([
			'clean:build', `compile:${browser}`, 'clean:package',
			'compress', 'clean:build',
		]);
	});

	/**
	 * Publish data.
	 * @param  {String} arg Task argument
	 */
	grunt.registerTask('publish', (arg) => {
		/**
		 * Generate and commit changelog file for add0n.com website.
		 */
		if (arg === 'add0n' || arg === 'addon') {
			grunt.task.run([
				'dump_changelog', 'gitcommit:add0n_changelog'
			]);
			return;
		}

		if (arg === 'github') {
			grunt.task.run('github_publish');
			return;
		}

		/**
		 * Create package and publish it.
		 */

		let browser = arg;
		assertBrowserIsSupported(browser);

		switch (browser) {
			case 'chrome':
				grunt.task.run(['build:chrome', 'webstore_upload', 'clean:package']);
				break;
			case 'firefox':
				grunt.task.run(['build:firefox', 'amo_upload', 'clean:package']);
				break;
		}
	});

	/**
	 * Release new version for CI to pickup.
	 *
	 * @param {String} releaseType Release type that 'grunt-bump' supports
	 */
	grunt.registerTask('release', (releaseType) => {
		if (!releaseType) {
			grunt.fail.fatal('You should specify release type!');
		}

		grunt.task.run(`bump-only:${releaseType}`);
		grunt.task.run('bump-commit');
	});

	/**
	 * Release new version locally and publish all packages.
	 *
	 * @param {String} releaseType Release type that 'grunt-bump' supports
	 */
	grunt.registerTask('release-local', (releaseType) => {
		if (!releaseType) {
			grunt.fail.fatal('You should specify release type!');
		}

		// Patch releases are in vX.X.X branch, so there's no reason
		// to make changelogs for them.
		if (releaseType !== 'patch') {
			grunt.task.run('publish:add0n');
		}

		grunt.task.run(`release:${releaseType}`);

		grunt.task.run(['publish:chrome', 'publish:firefox']);
	});

	/**
	 * Run core or connectors tests.
	 *
	 * You can easily run all test by the following command:
	 *   > grunt test
	 *
	 * To run core tests use 'core' as an argument:
	 *   > grunt test:core
	 *
	 * Note: running core and connectors tests at the same time is not supported.
	 *
	 * You can specify tests you want to run as arguments:
	 *   > grunt test:8tracks
	 *   Run single test for 8tracks connector
	 *
	 *   > grunt test:hypem:dashradio
	 *   Run tests for Hype Machine and Dash Radio connectors
	 *
	 * Also, you can use following options:
	 *   - debug: enable debug mode. Disabled by default.
	 *     Use true|on|1 value to enable and false|off|0 to disable debug mode.
	 *   - quitOnEnd: close browser when all tests are completed. Enabled by default.
	 *     Use true|on|1 value to enable and false|off|0 to disable this feature.
	 *   - skip: skip given tests.
	 *     Tests can be specified as string of tests filenames joined by comma.
	 *
	 * Of course, you can mix both options and tests in arguments:
	 *   > grunt test:8tracks:debug=1
	 */
	grunt.registerTask('test', 'Run tests.', function(...args) {
		grunt.task.run([
			`exec:run_tests:${args.join(':')}`
		]);
	});

	/**
	 * Lint source code using linters specified below.
	 */
	grunt.registerTask('lint', [
		'eslint', 'jsonlint', 'lintspaces', 'stylelint'
	]);

	/**
	 * Register default task
	 */
	grunt.registerTask('default', ['lint', 'test:core']);

	/**
	 * Throw an error if the extension doesn't support given browser.
	 * @param  {String}  browser Browser name
	 */
	function assertBrowserIsSupported(browser) {
		const supportedBrowsers = ['chrome', 'firefox'];

		if (!browser) {
			grunt.fail.fatal(
				'You have not specified browser.\n' +
				`Currently supported browsers: ${supportedBrowsers.join(', ')}.`
			);
		}

		if (supportedBrowsers.indexOf(browser) === -1) {
			grunt.fail.fatal(`Unknown browser: ${browser}`);
		}
	}

	/**
	 * Get JSON config.
	 *
	 * @param  {String} configPath Path to config file
	 * @return {Object} Config object
	 */
	function loadConfig(configPath) {
		if (fs.existsSync(configPath)) {
			return require(configPath);
		}

		return {};
	}

	/**
	 * Get web store config.
	 *
	 * @return {Object} Config object
	 */
	function loadWebStoreConfig() {
		if (isTravisCi) {
			let webStoreConfig =  {
				clientId: process.env.CHROME_CLIENT_ID,
				clientSecret: process.env.CHROME_CLIENT_SECRET,
				refreshToken: process.env.CHROME_REFRESH_TOKEN
			};

			return webStoreConfig;
		}

		let webStoreConfig = loadConfig('./.publish/web-store.json');

		return webStoreConfig;
	}

	/**
	 * Get github config.
	 *
	 * @return {Object} Config object
	 */
	function loadGithubConfig() {
		if (isTravisCi) {
			let githubConfig =  {
				token: process.env.GITHUB_TOKEN,
			};

			return githubConfig;
		}

		let githubConfig = loadConfig('./.publish/github.json');

		return githubConfig;
	}

	/**
	 * Get Amo config.
	 *
	 * @return {Object} Config object
	 */
	function loadAmoConfig() {
		if (isTravisCi) {
			let amoConfig =  {
				issuer: process.env.AMO_ISSUER,
				secret: process.env.AMO_SECRET,
			};

			return amoConfig;
		}

		let amoConfig = loadConfig('./.publish/amo.json');

		return amoConfig;
	}
};
<commit_msg>Fix deployment for add0n changelog (#1776)<commit_after>'use strict';

const fs = require('fs');

module.exports = function(grunt) {
	let isTravisCi = (process.env.TRAVIS === 'true');

	const chromeExtensionId = 'hhinaapppaileiechjoiifaancjggfjm';
	const amoExtensionId = '{799c0914-748b-41df-a25c-22d008f9e83f}';

	const srcDir = 'src';
	const buildDir = 'build';
	const packageName = 'web-scrobbler.zip';
	const manifestFile = 'src/manifest.json';

	// Files to build package
	const extensionSources = [
		'**/*',
		// Skip files
		'!content/testReporter.js', '!icons/src/**',
	];
	const documentationFiles = [
		'README.md', 'LICENSE.md'
	];

	// Files to lint
	const jsFiles = [
		// Custom Grunt tasks
		'.grunt',
		// Connectors
		`${srcDir}/connectors/**/*.js`,
		// Core files
		`${srcDir}/core/**/*.js`, `${srcDir}/options/*.js`,
		`${srcDir}/popups/*.js`,
		// Tests
		'tests/**/*.js'
	];
	const jsonFiles = ['*.json', '.stylelintrc'];
	const htmlFiles = [`${srcDir}/options/*.html`, `${srcDir}/popups/*.html`];
	const cssFiles = [`${srcDir}options/*.css`, `${srcDir}/popups/*.css`];

	const webStoreConfig = loadWebStoreConfig();
	const githubConfig = loadGithubConfig();
	const amoConfig = loadAmoConfig();

	grunt.initConfig({
		manifest: grunt.file.readJSON(manifestFile),

		/**
		 * Configs of build tasks.
		 */

		clean: {
			build: buildDir,
			package: [packageName],
			chrome: [
				`${buildDir}/icons/icon128_firefox.png`,
				`${buildDir}/icons/icon48_firefox.png`
			],
		},
		copy: {
			source_files: {
				expand: true,
				cwd: srcDir,
				src: extensionSources,
				dest: buildDir,
			},
			documentation: {
				expand: true,
				src: documentationFiles,
				dest: buildDir,
			}
		},
		compress: {
			main: {
				options: {
					archive: packageName,
					pretty: true
				},
				expand: true,
				cwd: buildDir,
				src: '**/*',
			}
		},
		imagemin: {
			static: {
				options: {
					svgoPlugins: [{
						removeViewBox: false
					}],
				},
				files: [{
					expand: true,
					src: [
						`${buildDir}/icons/*.svg`,
						`${buildDir}/icons/*.png`
					]
				}]
			}
		},
		preprocess: {
			firefox: {
				src: `${buildDir}/**/*.js`,
				expand: true,
				options: {
					inline: true,
					context: {
						FIREFOX: true,
					}
				}
			},
			chrome: {
				src: `${buildDir}/**/*.js`,
				expand: true,
				options: {
					inline: true,
					context: {
						CHROME: true,
					}
				}
			}
		},
		rename: {
			firefox: {
				files: [{
					src: `${buildDir}/icons/icon128_firefox.png`,
					dest: `${buildDir}/icons/icon128.png`
				}, {
					src: `${buildDir}/icons/icon48_firefox.png`,
					dest: `${buildDir}/icons/icon48.png`
				}]
			}
		},
		replace_json: {
			chrome: {
				src: `${buildDir}/manifest.json`,
				changes: {
					'options_ui': undefined,
				}
			},
			firefox: {
				src: `${buildDir}/manifest.json`,
				changes: {
					'applications.gecko.id': amoExtensionId,
					'applications.gecko.strict_min_version': '53.0',

					'options_page': undefined,
				}
			},
		},

		/**
		 * Publish tasks.
		 */

		bump: {
			options: {
				files: [manifestFile],
				updateConfigs: ['manifest'],
				commitFiles: [manifestFile],
			}
		},
		dump_changelog: {
			token: githubConfig.token,
			version: '<%= manifest.version %>',
		},
		github_publish: {
			token: githubConfig.token,
			version: '<%= manifest.version %>',
		},
		amo_upload: {
			issuer: amoConfig.issuer,
			secret: amoConfig.secret,
			id: amoExtensionId,
			version: '<%= manifest.version %>',
			src: packageName,
		},
		webstore_upload: {
			accounts: {
				default: {
					publish: true,
					client_id: webStoreConfig.clientId,
					client_secret: webStoreConfig.clientSecret,
					refresh_token: webStoreConfig.refreshToken,
				},
			},
			extensions: {
				'web-scrobbler': {
					appID: chromeExtensionId,
					zip: packageName,
				}
			}
		},

		/**
		 * Linter configs.
		 */

		eslint: {
			target: jsFiles,
			options: {
				configFile: '.eslintrc.js',
				fix: !isTravisCi
			},
		},
		jsonlint: {
			src: jsonFiles
		},
		lintspaces: {
			src: [jsFiles, jsonFiles, cssFiles, htmlFiles],
			options: {
				editorconfig: '.editorconfig',
				ignores: ['js-comments']
			}
		},
		stylelint: {
			all: cssFiles
		},

		/**
		 * Configs of other tasks.
		 */

		exec: {
			run_tests: {
				cmd: (...args) => `node tests/runner.js ${args.join(' ')}`
			}
		},
		gitcommit: {
			add0n_changelog: {
				options: {
					message: 'Update changelog on add0n.com'
				},
				files: {
					src: ['.add0n/changelog.json']
				}
			}
		}
	});

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

	/**
	 * Some tasks take browser name as an argument.
	 * We support only Chrome and Firefox, which can be specified
	 * as 'chrome' and 'firefox' respectively:
	 *
	 *   Build a package for Chrome browser
	 *   > grunt build:chrome
	 *
	 *   Compile sources for Firefox browser
	 *   > grunt compile:firefox
	 */

	/**
	 * Set the extension icon according to specified browser.
	 * @param {String} browser Browser name
	 */
	grunt.registerTask('icons', (browser) => {
		assertBrowserIsSupported(browser);

		switch (browser) {
			case 'chrome':
				grunt.task.run('clean:chrome');
				break;
			case 'firefox':
				grunt.task.run('rename:firefox');
				break;
		}
	});

	/**
	 * Copy source filed to build directory, preprocess them and
	 * set the extension icon according to specified browser.
	 * @param {String} browser Browser name
	 */
	grunt.registerTask('compile', (browser) => {
		assertBrowserIsSupported(browser);

		grunt.task.run([
			'copy', `preprocess:${browser}`,
			`icons:${browser}`, 'imagemin',
			`replace_json:${browser}`
		]);
	});

	/**
	 * Compile source files and package them.
	 * @param  {String} browser Browser name
	 */
	grunt.registerTask('build', (browser) => {
		assertBrowserIsSupported(browser);

		grunt.task.run([
			'clean:build', `compile:${browser}`, 'clean:package',
			'compress', 'clean:build',
		]);
	});

	/**
	 * Publish data.
	 * @param  {String} arg Task argument
	 */
	grunt.registerTask('publish', (arg) => {
		/**
		 * Generate and commit changelog file for add0n.com website.
		 */
		if (arg === 'add0n' || arg === 'addon') {
			grunt.task.run([
				'dump_changelog', 'gitcommit:add0n_changelog'
			]);
			return;
		}

		if (arg === 'github') {
			grunt.task.run('github_publish');
			return;
		}

		/**
		 * Create package and publish it.
		 */

		let browser = arg;
		assertBrowserIsSupported(browser);

		switch (browser) {
			case 'chrome':
				grunt.task.run(['build:chrome', 'webstore_upload', 'clean:package']);
				break;
			case 'firefox':
				grunt.task.run(['build:firefox', 'amo_upload', 'clean:package']);
				break;
		}
	});

	/**
	 * Release new version for CI to pickup.
	 *
	 * @param {String} releaseType Release type that 'grunt-bump' supports
	 */
	grunt.registerTask('release', (releaseType) => {
		if (!releaseType) {
			grunt.fail.fatal('You should specify release type!');
		}

		// Patch releases are in vX.X.X branch, so there's no reason
		// to make changelogs for them.
		if (releaseType !== 'patch') {
			grunt.task.run('publish:add0n');
		}

		grunt.task.run(`bump-only:${releaseType}`);
		grunt.task.run('bump-commit');
	});

	/**
	 * Release new version locally and publish all packages.
	 *
	 * @param {String} releaseType Release type that 'grunt-bump' supports
	 */
	grunt.registerTask('release-local', (releaseType) => {
		if (!releaseType) {
			grunt.fail.fatal('You should specify release type!');
		}

		grunt.task.run(`release:${releaseType}`);

		grunt.task.run(['publish:chrome', 'publish:firefox']);
	});

	/**
	 * Run core or connectors tests.
	 *
	 * You can easily run all test by the following command:
	 *   > grunt test
	 *
	 * To run core tests use 'core' as an argument:
	 *   > grunt test:core
	 *
	 * Note: running core and connectors tests at the same time is not supported.
	 *
	 * You can specify tests you want to run as arguments:
	 *   > grunt test:8tracks
	 *   Run single test for 8tracks connector
	 *
	 *   > grunt test:hypem:dashradio
	 *   Run tests for Hype Machine and Dash Radio connectors
	 *
	 * Also, you can use following options:
	 *   - debug: enable debug mode. Disabled by default.
	 *     Use true|on|1 value to enable and false|off|0 to disable debug mode.
	 *   - quitOnEnd: close browser when all tests are completed. Enabled by default.
	 *     Use true|on|1 value to enable and false|off|0 to disable this feature.
	 *   - skip: skip given tests.
	 *     Tests can be specified as string of tests filenames joined by comma.
	 *
	 * Of course, you can mix both options and tests in arguments:
	 *   > grunt test:8tracks:debug=1
	 */
	grunt.registerTask('test', 'Run tests.', function(...args) {
		grunt.task.run([
			`exec:run_tests:${args.join(':')}`
		]);
	});

	/**
	 * Lint source code using linters specified below.
	 */
	grunt.registerTask('lint', [
		'eslint', 'jsonlint', 'lintspaces', 'stylelint'
	]);

	/**
	 * Register default task
	 */
	grunt.registerTask('default', ['lint', 'test:core']);

	/**
	 * Throw an error if the extension doesn't support given browser.
	 * @param  {String}  browser Browser name
	 */
	function assertBrowserIsSupported(browser) {
		const supportedBrowsers = ['chrome', 'firefox'];

		if (!browser) {
			grunt.fail.fatal(
				'You have not specified browser.\n' +
				`Currently supported browsers: ${supportedBrowsers.join(', ')}.`
			);
		}

		if (supportedBrowsers.indexOf(browser) === -1) {
			grunt.fail.fatal(`Unknown browser: ${browser}`);
		}
	}

	/**
	 * Get JSON config.
	 *
	 * @param  {String} configPath Path to config file
	 * @return {Object} Config object
	 */
	function loadConfig(configPath) {
		if (fs.existsSync(configPath)) {
			return require(configPath);
		}

		return {};
	}

	/**
	 * Get web store config.
	 *
	 * @return {Object} Config object
	 */
	function loadWebStoreConfig() {
		if (isTravisCi) {
			let webStoreConfig =  {
				clientId: process.env.CHROME_CLIENT_ID,
				clientSecret: process.env.CHROME_CLIENT_SECRET,
				refreshToken: process.env.CHROME_REFRESH_TOKEN
			};

			return webStoreConfig;
		}

		let webStoreConfig = loadConfig('./.publish/web-store.json');

		return webStoreConfig;
	}

	/**
	 * Get github config.
	 *
	 * @return {Object} Config object
	 */
	function loadGithubConfig() {
		if (isTravisCi) {
			let githubConfig =  {
				token: process.env.GITHUB_TOKEN,
			};

			return githubConfig;
		}

		let githubConfig = loadConfig('./.publish/github.json');

		return githubConfig;
	}

	/**
	 * Get Amo config.
	 *
	 * @return {Object} Config object
	 */
	function loadAmoConfig() {
		if (isTravisCi) {
			let amoConfig =  {
				issuer: process.env.AMO_ISSUER,
				secret: process.env.AMO_SECRET,
			};

			return amoConfig;
		}

		let amoConfig = loadConfig('./.publish/amo.json');

		return amoConfig;
	}
};
<|endoftext|>


<commit_before>/*
 * Copyright (c) 2011, Yahoo! Inc.  All rights reserved.
 * Copyright (c) 2012, Log-Normal, Inc.  All rights reserved.
 * Copyrights licensed under the BSD License. See the accompanying LICENSE.txt file for terms.
 */

// This is the Round Trip Time plugin.  Abbreviated to RT
// the parameter is the window
(function(w) {

var d=w.document;

BOOMR = BOOMR || {};
BOOMR.plugins = BOOMR.plugins || {};

// private object
var impl = {
	complete: false,	//! Set when this plugin has completed

	timers: {},		//! Custom timers that the developer can use
				// Format for each timer is { start: XXX, end: YYY, delta: YYY-XXX }
	cookie: 'RT',		//! Name of the cookie that stores the start time and referrer
	cookie_exp:600,		//! Cookie expiry in seconds
	strict_referrer: true,	//! By default, don't beacon if referrers don't match.
				// If set to false, beacon both referrer values and let
				// the back end decide

	navigationType: 0,
	navigationStart: undefined,
	responseStart: undefined,
	t_start: undefined,
	r: undefined,
	r2: undefined,

	setCookie: function() {
		var t_end, t_start = new Date().getTime();

		// Disable use of RT cookie by setting its name to a falsy value
		if(!this.cookie) {
			return this;
		}

		// We use document.URL instead of location.href because of a bug in safari 4
		// where location.href is URL decoded
		if(!BOOMR.utils.setCookie(this.cookie,
						{ s: t_start, r: d.URL.replace(/#.*/, '') },
						this.cookie_exp)
		) {
			BOOMR.error("cannot set start cookie", "rt");
			return this;
		}

		t_end = new Date().getTime();
		if(t_end - t_start > 50) {
			// It took > 50ms to set the cookie
			// The user Most likely has cookie prompting turned on so
			// t_start won't be the actual unload time
			// We bail at this point since we can't reliably tell t_done
			BOOMR.utils.removeCookie(this.cookie);

			// at some point we may want to log this info on the server side
			BOOMR.error("took more than 50ms to set cookie... aborting: "
					+ t_start + " -> " + t_end, "rt");
		}

		return this;
	},

	initFromCookie: function() {
		var subcookies;

		if(!this.cookie) {
			return;
		}

		subcookies = BOOMR.utils.getSubCookies(BOOMR.utils.getCookie(this.cookie));

		if(!subcookies) {
			return;
		}

		if(subcookies.s && subcookies.r) {
			this.r = subcookies.r;
			if(!this.strict_referrer || this.r === this.r2) {
				this.t_start = parseInt(subcookies.s, 10);
			}
		}

	},

	checkPreRender: function() {
		if(
			!(d.webkitVisibilityState && d.webkitVisibilityState === "prerender")
			&&
			!(d.msVisibilityState && d.msVisibilityState === 3)
		) {
			return false;
		}

		// This means that onload fired through a pre-render.  We'll capture this
		// time, but wait for t_done until after the page has become either visible
		// or hidden (ie, it moved out of the pre-render state)
		// http://code.google.com/chrome/whitepapers/pagevisibility.html
		// http://www.w3.org/TR/2011/WD-page-visibility-20110602/
		// http://code.google.com/chrome/whitepapers/prerender.html

		BOOMR.plugins.RT.startTimer("t_load", this.navigationStart);
		BOOMR.plugins.RT.endTimer("t_load");					// this will measure actual onload time for a prerendered page
		BOOMR.plugins.RT.startTimer("t_prerender", this.navigationStart);
		BOOMR.plugins.RT.startTimer("t_postrender");				// time from prerender to visible or hidden

		BOOMR.subscribe("visibility_changed", BOOMR.plugins.RT.done, null, BOOMR.plugins.RT);

		return true;
	},

	initNavTiming: function() {
		var ti, p, source;

		if(this.navigationStart) {
			return;
		}

		// Get start time from WebTiming API see:
		// https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/NavigationTiming/Overview.html
		// http://blogs.msdn.com/b/ie/archive/2010/06/28/measuring-web-page-performance.aspx
		// http://blog.chromium.org/2010/07/do-you-know-how-slow-your-web-page-is.html
		p = w.performance || w.msPerformance || w.webkitPerformance || w.mozPerformance;

		if(p && p.navigation) {
			this.navigationType = p.navigation.type;
		}

		if(p && p.timing) {
			ti = p.timing;
		}
		else if(w.chrome && w.chrome.csi && w.chrome.csi().startE) {
			// Older versions of chrome also have a timing API that's sort of documented here:
			// http://ecmanaut.blogspot.com/2010/06/google-bom-feature-ms-since-pageload.html
			// source here:
			// http://src.chromium.org/viewvc/chrome/trunk/src/chrome/renderer/loadtimes_extension_bindings.cc?view=markup
			ti = {
				navigationStart: w.chrome.csi().startE
			};
			source = "csi";
		}
		else if(w.gtbExternal && w.gtbExternal.startE()) {
			// The Google Toolbar exposes navigation start time similar to old versions of chrome
			// This would work for any browser that has the google toolbar installed
			ti = {
				navigationStart: w.gtbExternal.startE()
			};
			source = 'gtb';
		}

		if(ti) {
			// Always use navigationStart since it falls back to fetchStart (not with redirects)
			// If not set, we leave t_start alone so that timers that depend
			// on it don't get sent back.  Never use requestStart since if
			// the first request fails and the browser retries, it will contain
			// the value for the new request.
			BOOMR.addVar("rt.start", source || "navigation");
			this.navigationStart = ti.navigationStart || ti.fetchStart || undefined;
			this.responseStart = ti.responseStart || undefined;

			// bug in Firefox 7 & 8 https://bugzilla.mozilla.org/show_bug.cgi?id=691547
			if(navigator.userAgent.match(/Firefox\/[78]\./)) {
				this.navigationStart = ti.unloadEventStart || ti.fetchStart || undefined;
			}
		}
		else {
			BOOMR.warn("This browser doesn't support the WebTiming API", "rt");
		}

		return;
	},

	page_unload: function(edata) {
		// set cookie for next page
		this.setCookie();
	},

	domloaded: function() {
		BOOMR.plugins.RT.endTimer("t_domloaded");
	}
};

BOOMR.plugins.RT = {
	// Methods

	init: function(config) {
		if(w != BOOMR.window) {
			w = BOOMR.window;
			d = w.document;
		}

		BOOMR.utils.pluginConfig(impl, config, "RT",
					["cookie", "cookie_exp", "strict_referrer"]);

		// if complete is already true
		// then we've already collected t_done so no point running init
		if(impl.complete) {
			return this;
		}

		impl.complete = false;
		impl.timers = {};

		BOOMR.subscribe("page_ready", this.done, null, this);
		BOOMR.subscribe("dom_loaded", impl.domloaded, null, impl);
		BOOMR.subscribe("page_unload", impl.page_unload, null, impl);

		if(BOOMR.t_start) {
			// How long does it take Boomerang to load up and execute
			this.startTimer('boomerang', BOOMR.t_start);
			this.endTimer('boomerang', BOOMR.t_end);	// t_end === null defaults to current time

			// How long did it take till Boomerang started
			this.endTimer('boomr_fb', BOOMR.t_start);
		}

		// A beacon may be fired automatically on page load or if the page dev fires
		// it manually with their own timers.  It may not always contain a referrer
		// (eg: XHR calls).  We set default values for these cases
		impl.r = impl.r2 = d.referrer.replace(/#.*/, '');

		impl.initFromCookie();

		return this;
	},

	startTimer: function(timer_name, time_value) {
		if(timer_name) {
			if (timer_name === 't_page') {
				this.endTimer('t_resp', time_value);
			}
			impl.timers[timer_name] = {start: (typeof time_value === "number" ? time_value : new Date().getTime())};
			impl.complete = false;
		}

		return this;
	},

	endTimer: function(timer_name, time_value) {
		if(timer_name) {
			impl.timers[timer_name] = impl.timers[timer_name] || {};
			if(!("end" in impl.timers[timer_name])) {
				impl.timers[timer_name].end =
						(typeof time_value === "number" ? time_value : new Date().getTime());
			}
		}

		return this;
	},

	setTimer: function(timer_name, time_delta) {
		if(timer_name) {
			impl.timers[timer_name] = { delta: time_delta };
		}

		return this;
	},

	// Called when the page has reached a "usable" state.  This may be when the
	// onload event fires, or it could be at some other moment during/after page
	// load when the page is usable by the user
	done: function() {
		var t_start, t_done=new Date().getTime(),
		    basic_timers = { t_done: 1, t_resp: 1, t_page: 1},
		    ntimers = 0, t_name, timer, t_other=[];

		impl.complete = false;

		impl.initNavTiming();

		if(impl.checkPreRender()) {
			return this;
		}

		if(impl.responseStart) {
			// Use NavTiming API to figure out resp latency and page time
			// t_resp will use the cookie if available or fallback to NavTiming
			this.endTimer("t_resp", impl.responseStart);
			if(impl.timers.t_load) {
				this.setTimer("t_page", impl.timers.t_load.end - impl.responseStart);
			}
			else {
				this.setTimer("t_page", t_done - impl.responseStart);
			}
		}
		else if(impl.timers.hasOwnProperty('t_page')) {
			// If the dev has already started t_page timer, we can end it now as well
			this.endTimer("t_page");
		}

		// If a prerender timer was started, we can end it now as well
		if(impl.timers.hasOwnProperty('t_postrender')) {
			this.endTimer("t_postrender");
			this.endTimer("t_prerender");
		}

		if(impl.navigationStart) {
			t_start = impl.navigationStart;
		}
		else if(impl.t_start && impl.navigationType !== 2) {
			t_start = impl.t_start;			// 2 is TYPE_BACK_FORWARD but the constant may not be defined across browsers
			BOOMR.addVar("rt.start", "cookie");	// if the user hit the back button, referrer will match, and cookie will match
		}						// but will have time of previous page start, so t_done will be wrong
		else {
			BOOMR.addVar("rt.start", "none");
			t_start = undefined;			// force all timers to NaN state
		}

		// If the dev has already called endTimer, then this call will do nothing
		// else, it will stop the page load timer
		this.endTimer("t_done", t_done);

		// make sure old variables don't stick around
		BOOMR.removeVar('t_done', 't_page', 't_resp', 'r', 'r2', 'rt.tstart', 'rt.bstart', 'rt.end', 't_postrender', 't_prerender', 't_load');

		BOOMR.addVar('rt.tstart', t_start);
		BOOMR.addVar('rt.bstart', BOOMR.t_start);
		BOOMR.addVar('rt.end', impl.timers.t_done.end);	// don't just use t_done because dev may have called endTimer before we did

		for(t_name in impl.timers) {
			if(!impl.timers.hasOwnProperty(t_name)) {
				continue;
			}

			timer = impl.timers[t_name];

			// if delta is a number, then it was set using setTimer
			// if not, then we have to calculate it using start & end
			if(typeof timer.delta !== "number") {
				if(typeof timer.start !== "number") {
					timer.start = t_start;
				}
				timer.delta = timer.end - timer.start;
			}

			// If the caller did not set a start time, and if there was no start cookie
			// Or if there was no end time for this timer,
			// then timer.delta will be NaN, in which case we discard it.
			if(isNaN(timer.delta)) {
				continue;
			}

			if(basic_timers.hasOwnProperty(t_name)) {
				BOOMR.addVar(t_name, timer.delta);
			}
			else {
				t_other.push(t_name + '|' + timer.delta);
			}
			ntimers++;
		}

		if(ntimers) {
			BOOMR.addVar("r", impl.r);

			if(impl.r2 !== impl.r) {
				BOOMR.addVar("r2", impl.r2);
			}

			if(t_other.length) {
				BOOMR.addVar("t_other", t_other.join(','));
			}
		}

		impl.timers = {};
		impl.complete = true;

		BOOMR.sendBeacon();	// we call sendBeacon() anyway because some other plugin
					// may have blocked waiting for RT to complete
		return this;
	},

	is_complete: function() { return impl.complete; }

};

}(window));
// End of RT plugin

<commit_msg>setCookie on click as well<commit_after>/*
 * Copyright (c) 2011, Yahoo! Inc.  All rights reserved.
 * Copyright (c) 2012, Log-Normal, Inc.  All rights reserved.
 * Copyrights licensed under the BSD License. See the accompanying LICENSE.txt file for terms.
 */

// This is the Round Trip Time plugin.  Abbreviated to RT
// the parameter is the window
(function(w) {

var d=w.document;

BOOMR = BOOMR || {};
BOOMR.plugins = BOOMR.plugins || {};

// private object
var impl = {
	complete: false,	//! Set when this plugin has completed

	timers: {},		//! Custom timers that the developer can use
				// Format for each timer is { start: XXX, end: YYY, delta: YYY-XXX }
	cookie: 'RT',		//! Name of the cookie that stores the start time and referrer
	cookie_exp:600,		//! Cookie expiry in seconds
	strict_referrer: true,	//! By default, don't beacon if referrers don't match.
				// If set to false, beacon both referrer values and let
				// the back end decide

	navigationType: 0,
	navigationStart: undefined,
	responseStart: undefined,
	t_start: undefined,
	r: undefined,
	r2: undefined,

	setCookie: function() {
		var t_end, t_start = new Date().getTime();

		// Disable use of RT cookie by setting its name to a falsy value
		if(!this.cookie) {
			return this;
		}

		// We use document.URL instead of location.href because of a bug in safari 4
		// where location.href is URL decoded
		if(!BOOMR.utils.setCookie(this.cookie,
						{ s: t_start, r: d.URL.replace(/#.*/, '') },
						this.cookie_exp)
		) {
			BOOMR.error("cannot set start cookie", "rt");
			return this;
		}

		t_end = new Date().getTime();
		if(t_end - t_start > 50) {
			// It took > 50ms to set the cookie
			// The user Most likely has cookie prompting turned on so
			// t_start won't be the actual unload time
			// We bail at this point since we can't reliably tell t_done
			BOOMR.utils.removeCookie(this.cookie);

			// at some point we may want to log this info on the server side
			BOOMR.error("took more than 50ms to set cookie... aborting: "
					+ t_start + " -> " + t_end, "rt");
		}

		return this;
	},

	initFromCookie: function() {
		var subcookies;

		if(!this.cookie) {
			return;
		}

		subcookies = BOOMR.utils.getSubCookies(BOOMR.utils.getCookie(this.cookie));

		if(!subcookies) {
			return;
		}

		if(subcookies.s && subcookies.r) {
			this.r = subcookies.r;
			if(!this.strict_referrer || this.r === this.r2) {
				this.t_start = parseInt(subcookies.s, 10);
			}
		}

	},

	checkPreRender: function() {
		if(
			!(d.webkitVisibilityState && d.webkitVisibilityState === "prerender")
			&&
			!(d.msVisibilityState && d.msVisibilityState === 3)
		) {
			return false;
		}

		// This means that onload fired through a pre-render.  We'll capture this
		// time, but wait for t_done until after the page has become either visible
		// or hidden (ie, it moved out of the pre-render state)
		// http://code.google.com/chrome/whitepapers/pagevisibility.html
		// http://www.w3.org/TR/2011/WD-page-visibility-20110602/
		// http://code.google.com/chrome/whitepapers/prerender.html

		BOOMR.plugins.RT.startTimer("t_load", this.navigationStart);
		BOOMR.plugins.RT.endTimer("t_load");					// this will measure actual onload time for a prerendered page
		BOOMR.plugins.RT.startTimer("t_prerender", this.navigationStart);
		BOOMR.plugins.RT.startTimer("t_postrender");				// time from prerender to visible or hidden

		BOOMR.subscribe("visibility_changed", BOOMR.plugins.RT.done, null, BOOMR.plugins.RT);

		return true;
	},

	initNavTiming: function() {
		var ti, p, source;

		if(this.navigationStart) {
			return;
		}

		// Get start time from WebTiming API see:
		// https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/NavigationTiming/Overview.html
		// http://blogs.msdn.com/b/ie/archive/2010/06/28/measuring-web-page-performance.aspx
		// http://blog.chromium.org/2010/07/do-you-know-how-slow-your-web-page-is.html
		p = w.performance || w.msPerformance || w.webkitPerformance || w.mozPerformance;

		if(p && p.navigation) {
			this.navigationType = p.navigation.type;
		}

		if(p && p.timing) {
			ti = p.timing;
		}
		else if(w.chrome && w.chrome.csi && w.chrome.csi().startE) {
			// Older versions of chrome also have a timing API that's sort of documented here:
			// http://ecmanaut.blogspot.com/2010/06/google-bom-feature-ms-since-pageload.html
			// source here:
			// http://src.chromium.org/viewvc/chrome/trunk/src/chrome/renderer/loadtimes_extension_bindings.cc?view=markup
			ti = {
				navigationStart: w.chrome.csi().startE
			};
			source = "csi";
		}
		else if(w.gtbExternal && w.gtbExternal.startE()) {
			// The Google Toolbar exposes navigation start time similar to old versions of chrome
			// This would work for any browser that has the google toolbar installed
			ti = {
				navigationStart: w.gtbExternal.startE()
			};
			source = 'gtb';
		}

		if(ti) {
			// Always use navigationStart since it falls back to fetchStart (not with redirects)
			// If not set, we leave t_start alone so that timers that depend
			// on it don't get sent back.  Never use requestStart since if
			// the first request fails and the browser retries, it will contain
			// the value for the new request.
			BOOMR.addVar("rt.start", source || "navigation");
			this.navigationStart = ti.navigationStart || ti.fetchStart || undefined;
			this.responseStart = ti.responseStart || undefined;

			// bug in Firefox 7 & 8 https://bugzilla.mozilla.org/show_bug.cgi?id=691547
			if(navigator.userAgent.match(/Firefox\/[78]\./)) {
				this.navigationStart = ti.unloadEventStart || ti.fetchStart || undefined;
			}
		}
		else {
			BOOMR.warn("This browser doesn't support the WebTiming API", "rt");
		}

		return;
	},

	page_unload: function(edata) {
		// set cookie for next page
		this.setCookie();
	},

	onclick: function(etarget) {
		if(etarget && etarget.nodeName.toUpperCase()=="A") {
			// user clicked a link, they may be going to another page
			// if this page is being opened in a different tab, then
			// our unload handler won't fire, so we need to set our
			// cookie on click
			this.setCookie();
		}
	},

	domloaded: function() {
		BOOMR.plugins.RT.endTimer("t_domloaded");
	}
};

BOOMR.plugins.RT = {
	// Methods

	init: function(config) {
		if(w != BOOMR.window) {
			w = BOOMR.window;
			d = w.document;
		}

		BOOMR.utils.pluginConfig(impl, config, "RT",
					["cookie", "cookie_exp", "strict_referrer"]);

		// if complete is already true
		// then we've already collected t_done so no point running init
		if(impl.complete) {
			return this;
		}

		impl.complete = false;
		impl.timers = {};

		BOOMR.subscribe("page_ready", this.done, null, this);
		BOOMR.subscribe("dom_loaded", impl.domloaded, null, impl);
		BOOMR.subscribe("page_unload", impl.page_unload, null, impl);
		BOOMR.subscribe("click", impl.onclick, null, impl);

		if(BOOMR.t_start) {
			// How long does it take Boomerang to load up and execute
			this.startTimer('boomerang', BOOMR.t_start);
			this.endTimer('boomerang', BOOMR.t_end);	// t_end === null defaults to current time

			// How long did it take till Boomerang started
			this.endTimer('boomr_fb', BOOMR.t_start);
		}

		// A beacon may be fired automatically on page load or if the page dev fires
		// it manually with their own timers.  It may not always contain a referrer
		// (eg: XHR calls).  We set default values for these cases
		impl.r = impl.r2 = d.referrer.replace(/#.*/, '');

		impl.initFromCookie();

		return this;
	},

	startTimer: function(timer_name, time_value) {
		if(timer_name) {
			if (timer_name === 't_page') {
				this.endTimer('t_resp', time_value);
			}
			impl.timers[timer_name] = {start: (typeof time_value === "number" ? time_value : new Date().getTime())};
			impl.complete = false;
		}

		return this;
	},

	endTimer: function(timer_name, time_value) {
		if(timer_name) {
			impl.timers[timer_name] = impl.timers[timer_name] || {};
			if(!("end" in impl.timers[timer_name])) {
				impl.timers[timer_name].end =
						(typeof time_value === "number" ? time_value : new Date().getTime());
			}
		}

		return this;
	},

	setTimer: function(timer_name, time_delta) {
		if(timer_name) {
			impl.timers[timer_name] = { delta: time_delta };
		}

		return this;
	},

	// Called when the page has reached a "usable" state.  This may be when the
	// onload event fires, or it could be at some other moment during/after page
	// load when the page is usable by the user
	done: function() {
		var t_start, t_done=new Date().getTime(),
		    basic_timers = { t_done: 1, t_resp: 1, t_page: 1},
		    ntimers = 0, t_name, timer, t_other=[];

		impl.complete = false;

		impl.initNavTiming();

		if(impl.checkPreRender()) {
			return this;
		}

		if(impl.responseStart) {
			// Use NavTiming API to figure out resp latency and page time
			// t_resp will use the cookie if available or fallback to NavTiming
			this.endTimer("t_resp", impl.responseStart);
			if(impl.timers.t_load) {
				this.setTimer("t_page", impl.timers.t_load.end - impl.responseStart);
			}
			else {
				this.setTimer("t_page", t_done - impl.responseStart);
			}
		}
		else if(impl.timers.hasOwnProperty('t_page')) {
			// If the dev has already started t_page timer, we can end it now as well
			this.endTimer("t_page");
		}

		// If a prerender timer was started, we can end it now as well
		if(impl.timers.hasOwnProperty('t_postrender')) {
			this.endTimer("t_postrender");
			this.endTimer("t_prerender");
		}

		if(impl.navigationStart) {
			t_start = impl.navigationStart;
		}
		else if(impl.t_start && impl.navigationType !== 2) {
			t_start = impl.t_start;			// 2 is TYPE_BACK_FORWARD but the constant may not be defined across browsers
			BOOMR.addVar("rt.start", "cookie");	// if the user hit the back button, referrer will match, and cookie will match
		}						// but will have time of previous page start, so t_done will be wrong
		else {
			BOOMR.addVar("rt.start", "none");
			t_start = undefined;			// force all timers to NaN state
		}

		// If the dev has already called endTimer, then this call will do nothing
		// else, it will stop the page load timer
		this.endTimer("t_done", t_done);

		// make sure old variables don't stick around
		BOOMR.removeVar('t_done', 't_page', 't_resp', 'r', 'r2', 'rt.tstart', 'rt.bstart', 'rt.end', 't_postrender', 't_prerender', 't_load');

		BOOMR.addVar('rt.tstart', t_start);
		BOOMR.addVar('rt.bstart', BOOMR.t_start);
		BOOMR.addVar('rt.end', impl.timers.t_done.end);	// don't just use t_done because dev may have called endTimer before we did

		for(t_name in impl.timers) {
			if(!impl.timers.hasOwnProperty(t_name)) {
				continue;
			}

			timer = impl.timers[t_name];

			// if delta is a number, then it was set using setTimer
			// if not, then we have to calculate it using start & end
			if(typeof timer.delta !== "number") {
				if(typeof timer.start !== "number") {
					timer.start = t_start;
				}
				timer.delta = timer.end - timer.start;
			}

			// If the caller did not set a start time, and if there was no start cookie
			// Or if there was no end time for this timer,
			// then timer.delta will be NaN, in which case we discard it.
			if(isNaN(timer.delta)) {
				continue;
			}

			if(basic_timers.hasOwnProperty(t_name)) {
				BOOMR.addVar(t_name, timer.delta);
			}
			else {
				t_other.push(t_name + '|' + timer.delta);
			}
			ntimers++;
		}

		if(ntimers) {
			BOOMR.addVar("r", impl.r);

			if(impl.r2 !== impl.r) {
				BOOMR.addVar("r2", impl.r2);
			}

			if(t_other.length) {
				BOOMR.addVar("t_other", t_other.join(','));
			}
		}

		impl.timers = {};
		impl.complete = true;

		BOOMR.sendBeacon();	// we call sendBeacon() anyway because some other plugin
					// may have blocked waiting for RT to complete
		return this;
	},

	is_complete: function() { return impl.complete; }

};

}(window));
// End of RT plugin

<|endoftext|>


<commit_before>var grunt = require('grunt')
// change the tasks in the list to your production tasks
grunt.registerTask('heroku:development', 'clean less mincss');<commit_msg>Remvoed development from grunt task<commit_after>var grunt = require('grunt')
// change the tasks in the list to your production tasks
grunt.registerTask('heroku', 'clean less mincss');<|endoftext|>


<commit_before>'use strict';

module.exports = function(grunt) {

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

    clean: {
      dist: ['dist']
    },

    copy: {
      dist: {
        files: [
          {expand: true, src: ['*.html', 'scripts/*', 'styles/*'], dest: 'dist/'}
        ]
      }
    },

    'gh-pages': {
      options: {
        base: 'dist'
      },
      src: ['**']
    }
  });

  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-gh-pages');

  grunt.registerTask('build', ['clean:dist', 'copy:dist']);
  grunt.registerTask('deploy', ['gh-pages']);

};
<commit_msg>Change Gruntfile to build the assets folder<commit_after>'use strict';

module.exports = function(grunt) {

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

    clean: {
      dist: ['dist']
    },

    copy: {
      dist: {
        files: [
          {expand: true, src: ['*.html', 'scripts/*', 'styles/*', 'assets/**'], dest: 'dist/'}
        ]
      }
    },

    'gh-pages': {
      options: {
        base: 'dist'
      },
      src: ['**']
    }
  });

  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-gh-pages');

  grunt.registerTask('build', ['clean:dist', 'copy:dist']);
  grunt.registerTask('deploy', ['gh-pages']);

};
<|endoftext|>


<commit_before>/**
 * Build process for CKEditor AutoSave Plugin
 * This file contributed by Timm Stokke <timm@stokke.me>
 *
 * Don't know where to start?
 * Try: http://24ways.org/2013/grunt-is-not-weird-and-hard/
 */
module.exports = function(grunt) {

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

    // Minimize JS
    min: {
      options: {
        report: false
      },
      difflib: {
        src: [
          'autosave/js/difflib.js',
          'autosave/js/diffview.js',
          'autosave/js/jsdiff.js',
          'autosave/js/moment.js',
		  'js/lz-string-1.3.3.js'
          ],
        dest: 'autosave/js/extensions.min.js',
      }
    },

    // CSS Minify
    cssmin: {
      combine: {
        files: {
          'autosave/css/autosave.min.css': ['autosave/css/autosave.css']
        }
      }
    },

  });

  // PLUGINS
  grunt.loadNpmTasks('grunt-yui-compressor');

  grunt.registerTask('default', [
    'min',
    'cssmin'
    ]);

};
<commit_msg>Updated Gruntfile.js to correct path of lz-string<commit_after>/**
 * Build process for CKEditor AutoSave Plugin
 * This file contributed by Timm Stokke <timm@stokke.me>
 *
 * Don't know where to start?
 * Try: http://24ways.org/2013/grunt-is-not-weird-and-hard/
 */
module.exports = function(grunt) {

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

    // Minimize JS
    min: {
      options: {
        report: false
      },
      difflib: {
        src: [
          'autosave/js/difflib.js',
          'autosave/js/diffview.js',
          'autosave/js/jsdiff.js',
          'autosave/js/moment.js',
          'autosave/js/lz-string-1.3.3.js'
          ],
        dest: 'autosave/js/extensions.min.js',
      }
    },

    // CSS Minify
    cssmin: {
      combine: {
        files: {
          'autosave/css/autosave.min.css': ['autosave/css/autosave.css']
        }
      }
    },

  });

  // PLUGINS
  grunt.loadNpmTasks('grunt-yui-compressor');

  grunt.registerTask('default', [
    'min',
    'cssmin'
    ]);

};
<|endoftext|>


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

  // Project configuration.
  grunt.initConfig({
	gitclone: {
		docs: {
			options: {
				directory: "site",
				repository: "https://github.com/SockDrawer/SockBot.git",
				branch: "gh-pages"
			}
		}
	},
	mkdocs: {
		dist: {
		  src: '.',
		  options: {
			clean: true
		  }
		}
	},
	jsdoc : {
        dist : {
            src: ['*.js', 'sock_modules/*.js', 'sock_modules/**/*.js'],
            options: {
                destination: 'site/docs',
                template : "node_modules/grunt-jsdoc/node_modules/ink-docstrap/template",
                configure: 'jsdoc.conf'
            }
        }
    },
	'gh-pages': {
		options: {
			// The default commit message for the gh-pages branch
			base: 'site',
			message: 'push documentation automatically',
			repo: 'https://' + process.env.GH_TOKEN + '@github.com/SockDrawer/SockBot'
		},
		src: "**"
	}
  });

  // Load the plugins
  grunt.loadNpmTasks('grunt-mkdocs');
  grunt.loadNpmTasks('grunt-git');
  grunt.loadNpmTasks('grunt-jsdoc');
  grunt.loadNpmTasks('grunt-gh-pages');

  // Default task(s).
  grunt.registerTask('generate-docs', ['mkdocs', 'jsdoc', 'gh-pages']);
  grunt.registerTask('default', ['mkdocs', 'jsdoc', 'gh-pages']);

};
<commit_msg>adding local-only grunt task<commit_after>module.exports = function(grunt) {

  // Project configuration.
  grunt.initConfig({
	gitclone: {
		docs: {
			options: {
				directory: "site",
				repository: "https://github.com/SockDrawer/SockBot.git",
				branch: "gh-pages"
			}
		}
	},
	mkdocs: {
		dist: {
		  src: '.',
		  options: {
			clean: true
		  }
		}
	},
	jsdoc : {
        dist : {
            src: ['*.js', 'sock_modules/*.js', 'sock_modules/**/*.js'],
            options: {
                destination: 'site/docs',
                template : "node_modules/grunt-jsdoc/node_modules/ink-docstrap/template",
                configure: 'jsdoc.conf'
            }
        }
    },
	'gh-pages': {
		options: {
			// The default commit message for the gh-pages branch
			base: 'site',
			message: 'push documentation automatically',
			repo: 'https://' + process.env.GH_TOKEN + '@github.com/SockDrawer/SockBot'
		},
		src: "**"
	}
  });

  // Load the plugins
  grunt.loadNpmTasks('grunt-mkdocs');
  grunt.loadNpmTasks('grunt-git');
  grunt.loadNpmTasks('grunt-jsdoc');
  grunt.loadNpmTasks('grunt-gh-pages');

  // Default task(s).
  grunt.registerTask('generate-docs', ['mkdocs', 'jsdoc', 'gh-pages']);
  grunt.registerTask('local', ['mkdocs', 'jsdoc']);
  grunt.registerTask('default', ['mkdocs', 'jsdoc', 'gh-pages']);

};
<|endoftext|>


<commit_before>module.exports = function(grunt) {
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        name: 'client',
        context_name: '<%= name %>##<%= pkg.version %>-<%= grunt.template.today("yyyymmddHHMM")%>',
        lib_scripts: [
            'www/bower_components/jquery/dist/jquery.js',
            'www/bower_components/angular/angular.js',
            'www/bower_components/angular-route/angular-route.js',
            'www/bower_components/angular-resource/angular-resource.js',
            'www/bower_components/angular-local-storage/dist/angular-local-storage.js',
            'www/bower_components/angular-translate/angular-translate.js',
            'www/bower_components/angular-translate-loader-static-files/angular-translate-loader-static-files.js',
            'www/bower_components/angular-simple-logger/dist/angular-simple-logger.js',
            'www/bower_components/angular-sanitize/angular-sanitize.js',
            'www/bower_components/moment/min/moment.min.js',
            'www/bower_components/flot/jquery.flot.js',
            'www/bower_components/flot/jquery.flot.time.js',
            'www/bower_components/flot/jquery.flot.crosshair.js',
            'www/bower_components/flot-downsample/jquery.flot.downsample.js',
            'www/bower_components/leaflet/dist/leaflet.js',
            'www/bower_components/leaflet.markercluster/dist/leaflet.markercluster.js',
            'www/bower_components/L.GeoSearch/src/js/l.control.geosearch.js',
            'www/bower_components/L.GeoSearch/src/js/l.geosearch.provider.openstreetmap.js',
            'www/bower_components/bootstrap/dist/js/bootstrap.js',
            'www/bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js',
            'www/bower_components/angular-ui-notification/dist/angular-ui-notification.min.js',
            'www/bower_components/qr-js/qr.min.js',
            'www/bower_components/ui-leaflet/dist/ui-leaflet.js',
            'www/bower_components/smalot-bootstrap-datetimepicker/js/bootstrap-datetimepicker.js',
            'www/bower_components/ng-table/dist/ng-table.js',
            'www/bower_components/xslt/dist/xslt.js'
        ],
        lib_ie9_scripts: [
            'www/bower_components/n52-sensorweb-client-core/src/js/IE9/*.js'
        ],
        lib_styles: [
            'www/bower_components/L.GeoSearch/src/css/l.geosearch.css',
            'www/bower_components/smalot-bootstrap-datetimepicker/css/bootstrap-datetimepicker.css',
            'www/bower_components/ng-table/dist/ng-table.css',
            'www/bower_components/bootstrap/dist/css/bootstrap.min.css',
            'www/bower_components/leaflet/dist/leaflet.css',
            'www/bower_components/leaflet.markercluster/dist/MarkerCluster.css',
            'www/bower_components/leaflet.markercluster/dist/MarkerCluster.Default.css',
            'www/bower_components/angular-ui-notification/dist/angular-ui-notification.min.css'
        ],
        core_scripts: [
            'www/bower_components/n52-sensorweb-client-core/src/js/Map/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Map/**/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Phenomenon/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Phenomenon/controller/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Provider/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Provider/controller/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Time/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Time/controller/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Time/directives/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Legend/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Legend/controller/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Legend/directives/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Styling/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Styling/controller/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Styling/directives/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Chart/*/*Mdul.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Chart/*/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Favorite/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Favorite/controller/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Favorite/directives/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Loading/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Loading/directives/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Table/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Table/controller/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Table/directives/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Settings/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Settings/controller/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Settings/directives/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/ListSelection/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/ListSelection/controller/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/ListSelection/directives/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/ListSelection/components/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/flotlib/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Menu/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Menu/controller/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Metadata/metadata.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Metadata/directives/procedureRawData.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Metadata/directives/procedureMetadata.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Metadata/directives/sosUrl.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Metadata/directives/timeseriesRawData.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/SeriesInterface/*MDUL.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/SeriesInterface/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/base/module.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/base/**/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/startup/module.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/startup/**/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/helper/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/helper/controller/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/helper/service/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/plugins/extendedGetTsData.js'
        ],
        app_js: [
            'www/app.js',
            'www/js/*.js',
            'www/js/*/*.js'
        ],
        app_styles: [
            'www/css/**/*.css'
        ],
        copy_files: [
            'settings.json',
            'templates/**/*.html',
            'i18n/*.json',
            'images/*',
            'css/images/*',
            'xslt/**.*'
        ],
        clean: ["dist/"],
        tags: {
            options: {
                scriptTemplate: '<script src="{{ path }}" type="text/javascript"></script>',
                linkTemplate: '<link href="{{ path }}" rel="stylesheet" type="text/css"/>'
            },
            build_lib_scripts: {
                options: {
                    openTag: '<!-- start lib script tags -->',
                    closeTag: '<!-- end lib script tags -->'
                },
                src: ['<%= lib_scripts %>'],
                dest: 'www/index.html'
            },
            build_client_scripts: {
                options: {
                    openTag: '<!-- start client script tags -->',
                    closeTag: '<!-- end client script tags -->'
                },
                src: ['<%= app_js %>'],
                dest: 'www/index.html'
            },
            build_core_scripts: {
                options: {
                    openTag: '<!-- start core script tags -->',
                    closeTag: '<!-- end core script tags -->'
                },
                src: ['<%= core_scripts %>'],
                dest: 'www/index.html'
            },
            build_lib_styles: {
                options: {
                    openTag: '<!-- start lib style tags -->',
                    closeTag: '<!-- end lib style tags -->'
                },
                src: ['<%= lib_styles %>'],
                dest: 'www/index.html'
            },
            build_client_styles: {
                options: {
                    openTag: '<!-- start client style tags -->',
                    closeTag: '<!-- end client style tags -->'
                },
                src: ['<%= app_styles %>'],
                dest: 'www/index.html'
            }
        },
        concat: {
            //core: {
            //    src: 'www/js/**/*.js',
            //    dest: 'dist/js/<%= name %>.js'
            //},
            libs: {
                src: ['<%= lib_scripts %>', '<%= core_scripts %>'],
                dest: 'dist/js/deps.<%= name %>.js'
            },
            app: {
                src: '<%= app_js %>',
                dest: 'dist/js/app.js'
            },
            styles: {
                src: 'www/css/**/*.css',
                dest: 'dist/css/<%= name %>.css'
            },
            libStyles: {
                src: '<%= lib_styles %>',
                dest: 'dist/css/deps.<%= name %>.css'
            }
        },
        babel: {
            options: {
                sourceMap: false,
                presets: ['es2015-script']
            },
            libs: {
                src: '<%= concat.libs.dest %>',
                dest: 'dist/js/deps.<%= name %>.min.js'
            },
            app: {
                src: '<%= concat.app.dest %>',
                dest: 'dist/app.js'
            }
        },
        uglify: {
            options: {
                banner: '/*! <%= name %> <%= grunt.template.today("yyyy-mm-dd HH:MM") %> */\n'
            },
            //core: {
            //    files: {
            //        'dist/js/<%= name %>.min.js': ['<%= concat.core.dest %>']
            //    }
            //},
            libIe9: {
                files: {
                    'dist/js/favoriteIE9ImExportCore.min.js': ['<%= lib_ie9_scripts %>']
                }
            },
            libs: {
                files: {
                    'dist/js/deps.<%= name %>.min.js': ['<%= babel.libs.dest %>']
                }
            },
            appJs: {
                files: {
                    'dist/app.js': ['<%= babel.app.dest %>']
                }
            }
        },
        cssmin: {
            options: {},
            styles: {
                files: {
                    'dist/css/<%= name %>.min.css': ['<%= concat.styles.dest %>']
                }
            },
            depStyles: {
                files: {
                    'dist/css/deps.<%= name %>.min.css': ['<%= concat.libStyles.dest %>']
                }
            }
        },
        copy: {
            depStyles: {
                files: [{
                    expand: true,
                    flatten: true,
                    src: ['www/bower_components/bootstrap/dist/fonts/*'],
                    dest: 'dist/fonts/',
                    filter: 'isFile'
                }]
            },
            locals: {
                files: [{
                    expand: true,
                    flatten: false,
                    cwd: 'www/',
                    src: '<%= copy_files %>',
                    dest: 'dist/',
                    filter: 'isFile'
                }]
            }
        },
        jshint: {
            files: ['gruntfile.js', 'www/js/**/*.js', 'test/**/*.js'],
            options: {
                reporterOutput: "",
                jshintrc: true
            }
        },
        processhtml: {
            options: {
                data: {
                    message: '<%= name %> - version <%= pkg.version %> - build at <%= grunt.template.today("yyyy-mm-dd HH:MM") %>',
                    buildTime: '<%= grunt.template.today() %>'
                }
            },
            index: {
                files: {
                    'dist/index.html': ['www/index.html']
                }
            }
        },
        watch: {
            jshint: {
                files: ['<%= jshint.files %>'],
                tasks: ['jshint']
            },
            less: {
                files: ['www/less/**/*.less'],
                tasks: ['less']
            }
        },
        less: {
            development: {
                options: {
                    paths: ['www/less/**/*.less']
                },
                files: {
                    'www/css/app.css': ['www/less/**/*.less']
                }
            }
        },
        war: {
            target: {
                options: {
                    war_dist_folder: 'build/',
                    war_name: '<%= context_name %>',
                    webxml_welcome: 'index.html',
                    webxml_display_name: '<%= name %> - version <%= pkg.version %> - build at <%= grunt.template.today("yyyy-mm-dd HH:MM") %>',
                    webxml_mime_mapping: [{
                        extension: 'woff',
                        mime_type: 'application/font-woff'
                    }]
                },
                files: [{
                    expand: true,
                    cwd: 'dist/',
                    src: ['**'],
                    dest: ''
                }]
            }
        }
    });

    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-cssmin');
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-contrib-less');
    grunt.loadNpmTasks('grunt-babel');
    grunt.loadNpmTasks('grunt-script-link-tags');
    grunt.loadNpmTasks('grunt-processhtml');
    grunt.loadNpmTasks('grunt-war');

    grunt.registerTask('test', ['jshint']);
    grunt.registerTask('env-build', ['tags']);
    grunt.registerTask('default', ['test', 'clean', 'less', 'concat', 'babel', 'uglify', 'cssmin', 'copy', 'processhtml']);

    grunt.registerTask('buildWar', ['default', 'war']);
};
<commit_msg>copy also templates.json<commit_after>module.exports = function(grunt) {
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        name: 'client',
        context_name: '<%= name %>##<%= pkg.version %>-<%= grunt.template.today("yyyymmddHHMM")%>',
        lib_scripts: [
            'www/bower_components/jquery/dist/jquery.js',
            'www/bower_components/angular/angular.js',
            'www/bower_components/angular-route/angular-route.js',
            'www/bower_components/angular-resource/angular-resource.js',
            'www/bower_components/angular-local-storage/dist/angular-local-storage.js',
            'www/bower_components/angular-translate/angular-translate.js',
            'www/bower_components/angular-translate-loader-static-files/angular-translate-loader-static-files.js',
            'www/bower_components/angular-simple-logger/dist/angular-simple-logger.js',
            'www/bower_components/angular-sanitize/angular-sanitize.js',
            'www/bower_components/moment/min/moment.min.js',
            'www/bower_components/flot/jquery.flot.js',
            'www/bower_components/flot/jquery.flot.time.js',
            'www/bower_components/flot/jquery.flot.crosshair.js',
            'www/bower_components/flot-downsample/jquery.flot.downsample.js',
            'www/bower_components/leaflet/dist/leaflet.js',
            'www/bower_components/leaflet.markercluster/dist/leaflet.markercluster.js',
            'www/bower_components/L.GeoSearch/src/js/l.control.geosearch.js',
            'www/bower_components/L.GeoSearch/src/js/l.geosearch.provider.openstreetmap.js',
            'www/bower_components/bootstrap/dist/js/bootstrap.js',
            'www/bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js',
            'www/bower_components/angular-ui-notification/dist/angular-ui-notification.min.js',
            'www/bower_components/qr-js/qr.min.js',
            'www/bower_components/ui-leaflet/dist/ui-leaflet.js',
            'www/bower_components/smalot-bootstrap-datetimepicker/js/bootstrap-datetimepicker.js',
            'www/bower_components/ng-table/dist/ng-table.js',
            'www/bower_components/xslt/dist/xslt.js'
        ],
        lib_ie9_scripts: [
            'www/bower_components/n52-sensorweb-client-core/src/js/IE9/*.js'
        ],
        lib_styles: [
            'www/bower_components/L.GeoSearch/src/css/l.geosearch.css',
            'www/bower_components/smalot-bootstrap-datetimepicker/css/bootstrap-datetimepicker.css',
            'www/bower_components/ng-table/dist/ng-table.css',
            'www/bower_components/bootstrap/dist/css/bootstrap.min.css',
            'www/bower_components/leaflet/dist/leaflet.css',
            'www/bower_components/leaflet.markercluster/dist/MarkerCluster.css',
            'www/bower_components/leaflet.markercluster/dist/MarkerCluster.Default.css',
            'www/bower_components/angular-ui-notification/dist/angular-ui-notification.min.css'
        ],
        core_scripts: [
            'www/bower_components/n52-sensorweb-client-core/src/js/Map/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Map/**/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Phenomenon/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Phenomenon/controller/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Provider/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Provider/controller/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Time/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Time/controller/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Time/directives/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Legend/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Legend/controller/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Legend/directives/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Styling/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Styling/controller/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Styling/directives/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Chart/*/*Mdul.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Chart/*/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Favorite/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Favorite/controller/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Favorite/directives/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Loading/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Loading/directives/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Table/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Table/controller/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Table/directives/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Settings/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Settings/controller/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Settings/directives/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/ListSelection/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/ListSelection/controller/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/ListSelection/directives/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/ListSelection/components/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/flotlib/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Menu/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Menu/controller/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Metadata/metadata.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Metadata/directives/procedureRawData.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Metadata/directives/procedureMetadata.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Metadata/directives/sosUrl.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/Metadata/directives/timeseriesRawData.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/SeriesInterface/*MDUL.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/SeriesInterface/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/base/module.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/base/**/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/startup/module.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/startup/**/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/helper/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/helper/controller/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/helper/service/*.js',
            'www/bower_components/n52-sensorweb-client-core/src/js/plugins/extendedGetTsData.js'
        ],
        app_js: [
            'www/app.js',
            'www/js/*.js',
            'www/js/*/*.js'
        ],
        app_styles: [
            'www/css/**/*.css'
        ],
        copy_files: [
            'settings.json',
            'templates/**/*.html',
            'templates/*.json',
            'i18n/*.json',
            'images/*',
            'css/images/*',
            'xslt/**.*'
        ],
        clean: ["dist/"],
        tags: {
            options: {
                scriptTemplate: '<script src="{{ path }}" type="text/javascript"></script>',
                linkTemplate: '<link href="{{ path }}" rel="stylesheet" type="text/css"/>'
            },
            build_lib_scripts: {
                options: {
                    openTag: '<!-- start lib script tags -->',
                    closeTag: '<!-- end lib script tags -->'
                },
                src: ['<%= lib_scripts %>'],
                dest: 'www/index.html'
            },
            build_client_scripts: {
                options: {
                    openTag: '<!-- start client script tags -->',
                    closeTag: '<!-- end client script tags -->'
                },
                src: ['<%= app_js %>'],
                dest: 'www/index.html'
            },
            build_core_scripts: {
                options: {
                    openTag: '<!-- start core script tags -->',
                    closeTag: '<!-- end core script tags -->'
                },
                src: ['<%= core_scripts %>'],
                dest: 'www/index.html'
            },
            build_lib_styles: {
                options: {
                    openTag: '<!-- start lib style tags -->',
                    closeTag: '<!-- end lib style tags -->'
                },
                src: ['<%= lib_styles %>'],
                dest: 'www/index.html'
            },
            build_client_styles: {
                options: {
                    openTag: '<!-- start client style tags -->',
                    closeTag: '<!-- end client style tags -->'
                },
                src: ['<%= app_styles %>'],
                dest: 'www/index.html'
            }
        },
        concat: {
            //core: {
            //    src: 'www/js/**/*.js',
            //    dest: 'dist/js/<%= name %>.js'
            //},
            libs: {
                src: ['<%= lib_scripts %>', '<%= core_scripts %>'],
                dest: 'dist/js/deps.<%= name %>.js'
            },
            app: {
                src: '<%= app_js %>',
                dest: 'dist/js/app.js'
            },
            styles: {
                src: 'www/css/**/*.css',
                dest: 'dist/css/<%= name %>.css'
            },
            libStyles: {
                src: '<%= lib_styles %>',
                dest: 'dist/css/deps.<%= name %>.css'
            }
        },
        babel: {
            options: {
                sourceMap: false,
                presets: ['es2015-script']
            },
            libs: {
                src: '<%= concat.libs.dest %>',
                dest: 'dist/js/deps.<%= name %>.min.js'
            },
            app: {
                src: '<%= concat.app.dest %>',
                dest: 'dist/app.js'
            }
        },
        uglify: {
            options: {
                banner: '/*! <%= name %> <%= grunt.template.today("yyyy-mm-dd HH:MM") %> */\n'
            },
            //core: {
            //    files: {
            //        'dist/js/<%= name %>.min.js': ['<%= concat.core.dest %>']
            //    }
            //},
            libIe9: {
                files: {
                    'dist/js/favoriteIE9ImExportCore.min.js': ['<%= lib_ie9_scripts %>']
                }
            },
            libs: {
                files: {
                    'dist/js/deps.<%= name %>.min.js': ['<%= babel.libs.dest %>']
                }
            },
            appJs: {
                files: {
                    'dist/app.js': ['<%= babel.app.dest %>']
                }
            }
        },
        cssmin: {
            options: {},
            styles: {
                files: {
                    'dist/css/<%= name %>.min.css': ['<%= concat.styles.dest %>']
                }
            },
            depStyles: {
                files: {
                    'dist/css/deps.<%= name %>.min.css': ['<%= concat.libStyles.dest %>']
                }
            }
        },
        copy: {
            depStyles: {
                files: [{
                    expand: true,
                    flatten: true,
                    src: ['www/bower_components/bootstrap/dist/fonts/*'],
                    dest: 'dist/fonts/',
                    filter: 'isFile'
                }]
            },
            locals: {
                files: [{
                    expand: true,
                    flatten: false,
                    cwd: 'www/',
                    src: '<%= copy_files %>',
                    dest: 'dist/',
                    filter: 'isFile'
                }]
            }
        },
        jshint: {
            files: ['gruntfile.js', 'www/js/**/*.js', 'test/**/*.js'],
            options: {
                reporterOutput: "",
                jshintrc: true
            }
        },
        processhtml: {
            options: {
                data: {
                    message: '<%= name %> - version <%= pkg.version %> - build at <%= grunt.template.today("yyyy-mm-dd HH:MM") %>',
                    buildTime: '<%= grunt.template.today() %>'
                }
            },
            index: {
                files: {
                    'dist/index.html': ['www/index.html']
                }
            }
        },
        watch: {
            jshint: {
                files: ['<%= jshint.files %>'],
                tasks: ['jshint']
            },
            less: {
                files: ['www/less/**/*.less'],
                tasks: ['less']
            }
        },
        less: {
            development: {
                options: {
                    paths: ['www/less/**/*.less']
                },
                files: {
                    'www/css/app.css': ['www/less/**/*.less']
                }
            }
        },
        war: {
            target: {
                options: {
                    war_dist_folder: 'build/',
                    war_name: '<%= context_name %>',
                    webxml_welcome: 'index.html',
                    webxml_display_name: '<%= name %> - version <%= pkg.version %> - build at <%= grunt.template.today("yyyy-mm-dd HH:MM") %>',
                    webxml_mime_mapping: [{
                        extension: 'woff',
                        mime_type: 'application/font-woff'
                    }]
                },
                files: [{
                    expand: true,
                    cwd: 'dist/',
                    src: ['**'],
                    dest: ''
                }]
            }
        }
    });

    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-cssmin');
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-contrib-less');
    grunt.loadNpmTasks('grunt-babel');
    grunt.loadNpmTasks('grunt-script-link-tags');
    grunt.loadNpmTasks('grunt-processhtml');
    grunt.loadNpmTasks('grunt-war');

    grunt.registerTask('test', ['jshint']);
    grunt.registerTask('env-build', ['tags']);
    grunt.registerTask('default', ['test', 'clean', 'less', 'concat', 'babel', 'uglify', 'cssmin', 'copy', 'processhtml']);

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


<commit_before>'use strict';

var

  _URL__GRUNT_CONFIG_FILE = './config/grunt.json',
  _URL__NPM_MANIFEST_FILE = './package.json',

  _gruntRegisterTasks = require('grunt-register-tasks'),
  _loadGruntTasks = require('load-grunt-tasks'),
  _timeGrunt = require('time-grunt');

module.exports = function ( $grunt ) {

    var

      _$grunt__file = $grunt.file,
      _$grunt__file__readJSON = _$grunt__file.readJSON,

      _plugins = [
          'grunt-contrib-*',
          'grunt-jsonlint'
        ],

      _config = {
          'cfg': _$grunt__file__readJSON( _URL__GRUNT_CONFIG_FILE ),
          'clean': {
              'dist': '<%= cfg.PATH__DIST %>'
            },
          'copy': {
              'src': {
                  'cwd': '<%= cfg.PATH__SRC %>',
                  'dest': '<%= cfg.PATH__DIST %>',
                  'expand': true,
                  'src': '<%= cfg.FILE__TEMPLATE_MUSTACHE %>'
                }
            },
          'jsonlint': {
              'config': [
                  '<%= cfg.PATH__CONFIG %>/<%= cfg.GLOB__JSON__RECURSIVE %>',
                  '<%= cfg.PATH__ROOT %>/<%= cfg.FILE__BOWERRC %>'
                ],
              'manifests': '<%= cfg.PATH__ROOT %>/<%= cfg.GLOB__MANIFESTS %>'
            },
          'pkg': _$grunt__file__readJSON( _URL__NPM_MANIFEST_FILE )
        },

      _tasks = {
          'default': [
              'jsonlint'
            ]
        };

    _timeGrunt( $grunt ),

    $grunt.initConfig( _config ),

    _loadGruntTasks(
      $grunt,
      {
        'pattern': _plugins,
        'scope': 'devDependencies'
      }
    ),

    _gruntRegisterTasks(
      $grunt,
      _tasks
    );

  };
<commit_msg>chore(grunt): add `build` task<commit_after>'use strict';

var

  _URL__GRUNT_CONFIG_FILE = './config/grunt.json',
  _URL__NPM_MANIFEST_FILE = './package.json',

  _gruntRegisterTasks = require('grunt-register-tasks'),
  _loadGruntTasks = require('load-grunt-tasks'),
  _timeGrunt = require('time-grunt');

module.exports = function ( $grunt ) {

    var

      _$grunt__file = $grunt.file,
      _$grunt__file__readJSON = _$grunt__file.readJSON,

      _plugins = [
          'grunt-contrib-*',
          'grunt-jsonlint'
        ],

      _config = {
          'cfg': _$grunt__file__readJSON( _URL__GRUNT_CONFIG_FILE ),
          'clean': {
              'dist': '<%= cfg.PATH__DIST %>'
            },
          'copy': {
              'src': {
                  'cwd': '<%= cfg.PATH__SRC %>',
                  'dest': '<%= cfg.PATH__DIST %>',
                  'expand': true,
                  'src': '<%= cfg.FILE__TEMPLATE_MUSTACHE %>'
                }
            },
          'jsonlint': {
              'config': [
                  '<%= cfg.PATH__CONFIG %>/<%= cfg.GLOB__JSON__RECURSIVE %>',
                  '<%= cfg.PATH__ROOT %>/<%= cfg.FILE__BOWERRC %>'
                ],
              'manifests': '<%= cfg.PATH__ROOT %>/<%= cfg.GLOB__MANIFESTS %>'
            },
          'pkg': _$grunt__file__readJSON( _URL__NPM_MANIFEST_FILE )
        },

      _tasks = {
          'build': [
              'default',
              'clean',
              'copy'
            ],
          'default': [
              'jsonlint'
            ]
        };

    _timeGrunt( $grunt ),

    $grunt.initConfig( _config ),

    _loadGruntTasks(
      $grunt,
      {
        'pattern': _plugins,
        'scope': 'devDependencies'
      }
    ),

    _gruntRegisterTasks(
      $grunt,
      _tasks
    );

  };
<|endoftext|>