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

angular.module('mm.addons.grades')

/**
 * Assign submission controller.
 *
 * @module mm.addons.mod_assign
 * @ngdoc controller
 * @name mmaModAssignSubmissionCtrl
 */
.controller('mmaGradesSubmissionCtrl', function($scope, $mmFilepool, $mmFS, mmaGradingInfo, $stateParams, $mmaGrades, $ionicPopup, $mmSite, $mmApp) {

    var submission = $stateParams.submission || {};
    var userid = $stateParams.userid;
    var assign = $stateParams.assign;
    var courseid = $stateParams.courseid;
    $scope.title = submission.userfullname;
    $scope.submission = submission;
    $scope.component = $mmaGrades;
    $scope.isPluginAvailable = isSubmissionPluginAvailable();
    $scope.send = false;

    // console.log($mmFS.getFile(file)); //get the file
    // console.log(file);
    // console.log($mmApp.getDB().getAll(mmaGradingInfo));
    // console.log($mmFilepool.getFileDownloadId(submission.attachments[0].filepath, submission.attachments[0].fileurl));
    // console.log($mmFilepool._getFilePath($mmSite.getId(), $mmFilepool._getFileIdByUrl(submission.attachments[0].fileurl)));
    // console.log($mmFilepool._getFileIdByUrl(submission.attachments[0].fileurl));
    // console.log($mmApp.getDB());

    function isSubmissionPluginAvailable() {
      var available = false;
      angular.forEach(submission.plugins, function(plugin) {
        if(plugin.type == "comments") {
          available = true;
        }
      });
      return available;
    }

    $scope.saveGrade = function(note, comment) {
      $scope.send = true;
      var file = $mmaGrades.getLocalSubmissionFile(submission);
      $mmaGrades.saveGrade(courseid + "_" + userid + "_" + submission.id, userid, note, comment, submission.id, file);
      console.log($mmApp.getDB().getAll('grading_info'));
    };

    $scope.addGrade = function() {
      var grades = [];
      var Ids = [];
      return $mmApp.getDB().getAll(mmaGradingInfo).then(function(grade) {
          grade.forEach(function(data) {
              grades[grades.length] = {
                  userid: data.userid,
                  grade: data.grade,
                  attemptnumber: -1,
                  addattempt: 0,
                  workflowstate: "",
                  plugindata: {
                    assignfeedbackcomments_editor: {
                      text:  data.comment,
                      format: 4
                    },
                    files_filemanager: data.files_filemanager // itemId
                  }
              };
              Ids[Ids.length] = {
                uniqueid: data.uniqueId
              };

              data.file.forEach(function(attach) {
                $mmaGrades.uploadFiles(attach, submission.id);
              });
          });
          $mmaGrades.addGrade(assign, grades, Ids);
      });
    };

    $scope.showAlert = function() {
      var alertPopup = $ionicPopup.alert({
        title: 'Grade',
        template: 'Submission as been graded'
      });
      alertPopup.then(function() {
        console.log('Success grading');
      });
    };
});
<commit_msg>no message<commit_after>// (C) Copyright 2015 Martin Dougiamas
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

angular.module('mm.addons.grades')

/**
 * Assign submission controller.
 *
 * @module mm.addons.mod_assign
 * @ngdoc controller
 * @name mmaModAssignSubmissionCtrl
 */
.controller('mmaGradesSubmissionCtrl', function($scope, $mmFilepool, $mmFS, mmaGradingInfo, $stateParams, $mmaGrades, $ionicPopup, $mmSite, $mmApp) {

    var submission = $stateParams.submission || {};
    var userid = $stateParams.userid;
    var assign = $stateParams.assign;
    var courseid = $stateParams.courseid;
    $scope.title = submission.userfullname;
    $scope.submission = submission;
    $scope.component = $mmaGrades;
    $scope.isPluginAvailable = isSubmissionPluginAvailable();
    $scope.send = false;

    // console.log($mmFS.getFile(file)); //get the file
    // console.log(file);
    // console.log($mmApp.getDB().getAll(mmaGradingInfo));
    // console.log($mmFilepool);
    // console.log($mmFilepool._getFilePath($mmSite.getId(), $mmFilepool._getFileIdByUrl(submission.attachments[0].fileurl)));
    // console.log($mmFilepool._getFileIdByUrl(submission.attachments[0].fileurl));

    function isSubmissionPluginAvailable() {
      var available = false;
      angular.forEach(submission.plugins, function(plugin) {
        if(plugin.type == "comments") {
          available = true;
        }
      });
      return available;
    }

    $scope.saveGrade = function(note, comment) {
      $scope.send = true;
      var file = $mmaGrades.getLocalSubmissionFile(submission);
      $mmaGrades.saveGrade(courseid + "_" + userid + "_" + submission.id, userid, note, comment, submission.id, file);
      console.log($mmApp.getDB().getAll('grading_info'));
    };

    $scope.addGrade = function() {
      var grades = [];
      var Ids = [];
      return $mmApp.getDB().getAll(mmaGradingInfo).then(function(grade) {
          grade.forEach(function(data) {
              grades[grades.length] = {
                  userid: data.userid,
                  grade: data.grade,
                  attemptnumber: -1,
                  addattempt: 0,
                  workflowstate: "",
                  plugindata: {
                    assignfeedbackcomments_editor: {
                      text:  data.comment,
                      format: 4
                    },
                    files_filemanager: data.files_filemanager // itemId
                  }
              };
              Ids[Ids.length] = {
                uniqueid: data.uniqueId
              };

              data.file.forEach(function(attach) {
                $mmaGrades.uploadFiles(attach, submission.id);
              });
          });
          $mmaGrades.addGrade(assign, grades, Ids);
      });
    };

    $scope.showAlert = function() {
      var alertPopup = $ionicPopup.alert({
        title: 'Grade',
        template: 'Submission as been graded'
      });
      alertPopup.then(function() {
        console.log('Success grading');
      });
    };
});
<|endoftext|>


<commit_before>jQuery(function($) {
    // Used for code highlighting
    hljs.initHighlightingOnLoad();
});<commit_msg>Forgot gallery js<commit_after>jQuery(function ($) {
    // Used for code highlighting
    hljs.initHighlightingOnLoad();

    var colorbox_params = {
        reposition: true,
        scalePhotos: true,
        scrolling: false,
        previous: '',
        next: '',
        close: '×',
        current: '{current} of {total}',
        maxWidth: '100%',
        maxHeight: '100%',
        onOpen: function () {
            document.body.style.overflow = 'hidden';
        },
        onClosed: function () {
            document.body.style.overflow = 'auto';
        },
        onComplete: function () {
            $.colorbox.resize();
        }
    };

    $('.ace-thumbnails [data-rel="colorbox"]').colorbox(colorbox_params);

    $("#cboxLoadingGraphic").append(""); //let's add a custom loading icon
});<|endoftext|>


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

	var handlebars = require('handlebars'),
		moment = require('moment'),
		pkg = grunt.file.readJSON('package.json'),
		semver = require('semver');

	// TODO: Remove Handlebars dependency and use the built-in grunt templating
	// Handlebars helpers
	handlebars.registerHelper('if', function(conditional, options) {
		if (options.hash.desired === options.hash.test) {
			return options.fn(this);
		}
	});

	// Project config
	grunt.initConfig({
		pkg: pkg,
		clean: {
			docs: ['docs/src-temp'],
			'github-pages': {
				options: { force: true },
				src: ['../gh-pages/src']
			},
			'F2-examples': {
				options: { force: true },
				src: ['./F2-examples.zip']
			}
		},
		copy: {
			docs: {
				files: [
					{
						expand: true,
						cwd: 'docs/src/',
						src: ['**'],
						dest: 'docs/src-temp/',
						filter: function(src) {
							if ( !(/twbootstrap/).test(src) ){//don't touch submodule
								return (/(.html|.md)$/i).test(src);
							}
						}
					}
				],
				options: {
					processContent: function(content, srcpath) {
						// TODO: Remove Handlebars dependency and use the built-in grunt
						// templating compile and run the Handlebars template
						return (handlebars.compile(content))(pkg);
					}
				}
			},
			'github-pages': {
				files: [
					{
						expand: true,
						cwd: 'docs/',
						src: ['**'],
						dest: '../gh-pages'
					}
				]
			},
			'F2-examples': {
				files: [
					{
						expand: true,
						cwd: './',
						src: ['F2-examples.zip'],
						dest: '../gh-pages'
					}
				]
			}
		},
		compress: {
			main: {
				options: {
					archive: 'F2-examples.zip',
					pretty: true
				},
				files: [
					{
						expand: true,
						cwd: 'examples/',
						src: ['**']
					}
				]
			}
		},
		concat: {
			options: {
				process: { data: pkg },
				separator: '\n',
				stripBanners: false
			},
			'no-third-party': {
				src: [
					'sdk/src/template/header.js.tmpl',
					'<%= jshint.files %>',
					'sdk/src/template/footer.js.tmpl'
				],
				dest: 'sdk/f2.no-third-party.js'
			},
			dist: {
				src: [
					'sdk/src/template/header.js.tmpl',
					'sdk/src/third-party/json2.js',
					'sdk/src/third-party/jquery.js',
					'sdk/src/third-party/bootstrap-modal.js',
					'sdk/src/third-party/jquery.noconflict.js',
					'sdk/src/third-party/eventemitter2.js',
					'sdk/src/third-party/easyXDM/easyXDM.js',
					'<%= jshint.files %>',
					'sdk/src/template/footer.js.tmpl'
				],
				dest: 'sdk/f2.debug.js'
			}
		},
		/**
		 * Need to downgrade forever-monitor to v1.1 because of:
		 * https://github.com/blai/grunt-express/issues/12
		 * cd node_modules/grunt-express; npm uninstall forever-monitor; npm install forever-monitor@1.1;
		 */
		express: {
			server: {
				options: {
					bases: './',
					port: 8080,
					server: (require('path')).resolve('./tests/server')
				}
			}
		},
		jasmine: {
			'non-amd': {
				options: {
					host: 'http://localhost:8080/tests/',
					outfile: 'index.html'
				}
			},
			'amd': {
				options: {
					host: 'http://localhost:8080/tests/',
					outfile: 'index-amd.html'
				}
			}
		},
		jshint: {
			options: {
				jshintrc: '.jshintrc'
			},
			files: [
				'sdk/src/F2.js',
				'sdk/src/app_handlers.js',
				'sdk/src/classes.js',
				'sdk/src/constants.js',
				'sdk/src/events.js',
				'sdk/src/rpc.js',
				'sdk/src/ui.js',
				'sdk/src/container.js'
			]
		},
		less: {
			dist: {
				options: {
					compress: true
				},
				files: {
					'./docs/css/F2.css': './docs/src/template/less/bootstrap.less',
					'./docs/css/F2.Docs.css': './docs/src/template/less/bootstrap-docs.less',
					'./docs/css/F2.Sdk.css': './docs/src/template/less/bootstrap-sdk.less'
				}
			}
		},
		uglify: {
			options: {
				preserveComments: function(node, comment) {
					return (/^!/).test(comment.value);
				}
			},
			dist: {
				files: {'sdk/f2.min.js' : ['sdk/f2.debug.js']},
				options: {
					report: 'gzip'
				}
			},
			sourcemap: {
				files: '<%= uglify.dist.files %>',
				options: {
					sourceMap: function(fileName) {
						return fileName.replace(/\.js$/, '.map');
					},
					sourceMapPrefix: 1,
					sourceMappingURL: function(path) {
						return path.replace(grunt.config('sourcemap.options.prefix'), '').replace(/\.js$/, '.map');
					}
				}
			}
		},
		sourcemap: {
			options: {
				src: 'sdk/f2.min.js',
				prefix: 'sdk/'
			}
		}
	});

	// Load plugins
	grunt.loadNpmTasks('grunt-contrib-clean');
	grunt.loadNpmTasks('grunt-contrib-copy');
	grunt.loadNpmTasks('grunt-contrib-concat');
	grunt.loadNpmTasks('grunt-contrib-compress');
	grunt.loadNpmTasks('grunt-contrib-jasmine');
	grunt.loadNpmTasks('grunt-contrib-jshint');
	grunt.loadNpmTasks('grunt-contrib-less');
	grunt.loadNpmTasks('grunt-contrib-uglify');
	grunt.loadNpmTasks('grunt-express');

	// Register tasks
	grunt.registerTask('fix-sourcemap', 'Fixes the source map file', function() {
		var uglifyOptions = grunt.config('uglify.sourcemap.options'),
			options = grunt.config('sourcemap.options'),
			dest = uglifyOptions.sourceMap(options.src),
			rawMap = grunt.file.read(dest);

		rawMap = rawMap.replace(options.prefix, '');
		grunt.file.write(dest, rawMap);
	});

	grunt.registerTask('markitdown', 'Compiles the spec documentation with Markitdown', function() {
		var done = this.async(),
			log = grunt.log.write('Generating spec documentation...');
		grunt.util.spawn(
			{
				cmd: 'markitdown',
				args: [
					'./',
					'--output-path', '../',
					'--docTemplate', './template/baseTemplate.html',
					'--header', './template/header.html',
					'--footer', './template/footer.html',
					'--head', './template/style.html',
					'--title', 'F2'
				],
				opts: {
					cwd: './docs/src-temp'
				}
			},
			function(error, result, code) {
				if (error) {
					grunt.fail.fatal(error);
				} else {
					log.ok();
					done();
				}
			}
		);
	});

	grunt.registerTask('nuget', 'Builds the NuGet package for distribution on NuGet.org', function() {
		var done = this.async(),
			log = grunt.log.write('Creating NuSpec file...'),
			nuspec = grunt.file.read('./sdk/f2.nuspec.tmpl');

		nuspec = grunt.template.process(nuspec, { data: pkg });
		grunt.file.write('./sdk/f2.nuspec', nuspec);
		log.ok();

		log = grunt.log.write('Creating NuGet package...');
		grunt.util.spawn(
			{
				cmd: 'nuget',
				args: ['pack', 'f2.nuspec'],
				opts: {
					cwd: './sdk'
				}
			},
			function(error, result, code){
				if (error){
					grunt.fail.fatal(error);
				} else {
					grunt.file.delete('./sdk/f2.nuspec');
					log.ok();
					done();
				}
			}
		);
	});

	grunt.registerTask('release', 'Prepares the code for release (merge into master)', function(releaseType) {
		if (!/^major|minor|patch$/i.test(releaseType) && !semver.valid(releaseType)) {
			grunt.log.error('"' + releaseType + '" is not a valid release type (major, minor, or patch) or SemVer version');
			return;
		}

		pkg.version = semver.valid(releaseType) ? releaseType : String(semver.inc(pkg.version, releaseType)).replace(/\-\w+$/, '');
		pkg._releaseDate = new Date().toJSON();
		pkg._releaseDateFormatted = moment(pkg._releaseDate).format('D MMMM YYYY');

		grunt.file.write('./package.json', JSON.stringify(pkg, null, '\t'));
		grunt.config.set('pkg', pkg);

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

	grunt.registerTask('version', 'Displays version information for F2', function() {
		grunt.log.writeln(grunt.template.process(
			'This copy of F2 is at version <%= version %> with a release date of <%= _releaseDateFormatted %>',
			{ data: pkg }
		));
	});

	grunt.registerTask('yuidoc', 'Builds the reference documentation with YUIDoc', function() {

		var builder,
			docOptions = {
				quiet: true,
				norecurse: true,
				paths: ['./sdk/src'],
				outdir: './docs/sdk/',
				themedir: './docs/src/sdk-template'
			},
			done = this.async(),
			json,
			log = grunt.log.write('Generating reference documentation...'),
			readmeMd = grunt.file.read('README.md'),
			Y = require('yuidocjs');

		json = (new Y.YUIDoc(docOptions)).run();
		// massage in some meta information from F2.json
		json.project = {
			docsAssets: '../',
			version: pkg.version,
			releaseDateFormatted: pkg._releaseDateFormatted
		};
		docOptions = Y.Project.mix(json, docOptions);

		// hasClassMembers
		// ensures that the class has members and isn't just an empty namespace
		Y.Handlebars.registerHelper('hasClassMembers', function() {

			for (var i = 0, len = json.classitems.length; i < len; i++) {
				//console.log(json.classitems[i].class, this.name);
				if (json.classitems[i].class === this.name) {
					return '';
				}
			}

			return 'hide';
		});

		// title tag
		Y.Handlebars.registerHelper('htmlTitle',function () {
			var name  = this.displayName || this.name,
					title = name;

			if (title) {
				title = 'F2 - ' + title;
			} else {
				title = 'F2 - The Open Financial Framework';
			}

			return title;
		});

		// handle any member names that have periods in them
		Y.Handlebars.registerHelper('memberNameAsId', function() {
			return String(this.name).replace('.', '_');
		});

		// insert readme markdown
		Y.Handlebars.registerHelper('readme', function() {
			return builder.markdown(readmeMd, true);
		});

		builder = new Y.DocBuilder(docOptions, json);
		builder.compile(function() {
			log.ok();
			done();
		});
	});

	grunt.registerTask('docs', ['less', 'yuidoc', 'copy:docs', 'markitdown', 'clean:docs']);
	grunt.registerTask('github-pages', ['copy:github-pages', 'clean:github-pages']);
	grunt.registerTask('zip', ['compress', 'copy:F2-examples', 'clean:F2-examples']);
	grunt.registerTask('js', ['jshint', 'concat', 'uglify:dist', 'sourcemap']);
	grunt.registerTask('sourcemap', ['uglify:sourcemap', 'fix-sourcemap']);
	grunt.registerTask('test', ['jshint', 'express', 'jasmine'/*, 'express-keepalive'*/]);
	grunt.registerTask('travis', ['test']);

	// the default task
	grunt.registerTask('default', ['test', 'js', 'docs', 'zip']);
};<commit_msg>Adding task to copy f2.js to root during build<commit_after>module.exports = function(grunt) {

	var handlebars = require('handlebars'),
		moment = require('moment'),
		pkg = grunt.file.readJSON('package.json'),
		semver = require('semver');

	// TODO: Remove Handlebars dependency and use the built-in grunt templating
	// Handlebars helpers
	handlebars.registerHelper('if', function(conditional, options) {
		if (options.hash.desired === options.hash.test) {
			return options.fn(this);
		}
	});

	// Project config
	grunt.initConfig({
		pkg: pkg,
		clean: {
			docs: ['docs/src-temp'],
			'github-pages': {
				options: { force: true },
				src: ['../gh-pages/src']
			},
			'F2-examples': {
				options: { force: true },
				src: ['./F2-examples.zip']
			}
		},
		copy: {
			docs: {
				files: [
					{
						expand: true,
						cwd: 'docs/src/',
						src: ['**'],
						dest: 'docs/src-temp/',
						filter: function(src) {
							if ( !(/twbootstrap/).test(src) ){//don't touch submodule
								return (/(.html|.md)$/i).test(src);
							}
						}
					}
				],
				options: {
					processContent: function(content, srcpath) {
						// TODO: Remove Handlebars dependency and use the built-in grunt
						// templating compile and run the Handlebars template
						return (handlebars.compile(content))(pkg);
					}
				}
			},
			'f2ToRoot': {
				files: [
					{
						expand: true,
						cwd: 'sdk/',
						src: 'f2.min.js',
						dest: './',
						rename: function(dest,src){
							return './f2.js';
						}
					}
				]
			},
			'github-pages': {
				files: [
					{
						expand: true,
						cwd: 'docs/',
						src: ['**'],
						dest: '../gh-pages'
					}
				]
			},
			'F2-examples': {
				files: [
					{
						expand: true,
						cwd: './',
						src: ['F2-examples.zip'],
						dest: '../gh-pages'
					}
				]
			}
		},
		compress: {
			main: {
				options: {
					archive: 'F2-examples.zip',
					pretty: true
				},
				files: [
					{
						expand: true,
						cwd: 'examples/',
						src: ['**']
					}
				]
			}
		},
		concat: {
			options: {
				process: { data: pkg },
				separator: '\n',
				stripBanners: false
			},
			'no-third-party': {
				src: [
					'sdk/src/template/header.js.tmpl',
					'<%= jshint.files %>',
					'sdk/src/template/footer.js.tmpl'
				],
				dest: 'sdk/f2.no-third-party.js'
			},
			dist: {
				src: [
					'sdk/src/template/header.js.tmpl',
					'sdk/src/third-party/json2.js',
					'sdk/src/third-party/jquery.js',
					'sdk/src/third-party/bootstrap-modal.js',
					'sdk/src/third-party/jquery.noconflict.js',
					'sdk/src/third-party/eventemitter2.js',
					'sdk/src/third-party/easyXDM/easyXDM.js',
					'<%= jshint.files %>',
					'sdk/src/template/footer.js.tmpl'
				],
				dest: 'sdk/f2.debug.js'
			}
		},
		/**
		 * Need to downgrade forever-monitor to v1.1 because of:
		 * https://github.com/blai/grunt-express/issues/12
		 * cd node_modules/grunt-express; npm uninstall forever-monitor; npm install forever-monitor@1.1;
		 */
		express: {
			server: {
				options: {
					bases: './',
					port: 8080,
					server: (require('path')).resolve('./tests/server')
				}
			}
		},
		jasmine: {
			'non-amd': {
				options: {
					host: 'http://localhost:8080/tests/',
					outfile: 'index.html'
				}
			},
			'amd': {
				options: {
					host: 'http://localhost:8080/tests/',
					outfile: 'index-amd.html'
				}
			}
		},
		jshint: {
			options: {
				jshintrc: '.jshintrc'
			},
			files: [
				'sdk/src/F2.js',
				'sdk/src/app_handlers.js',
				'sdk/src/classes.js',
				'sdk/src/constants.js',
				'sdk/src/events.js',
				'sdk/src/rpc.js',
				'sdk/src/ui.js',
				'sdk/src/container.js'
			]
		},
		less: {
			dist: {
				options: {
					compress: true
				},
				files: {
					'./docs/css/F2.css': './docs/src/template/less/bootstrap.less',
					'./docs/css/F2.Docs.css': './docs/src/template/less/bootstrap-docs.less',
					'./docs/css/F2.Sdk.css': './docs/src/template/less/bootstrap-sdk.less'
				}
			}
		},
		uglify: {
			options: {
				preserveComments: function(node, comment) {
					return (/^!/).test(comment.value);
				}
			},
			dist: {
				files: {'sdk/f2.min.js' : ['sdk/f2.debug.js']},
				options: {
					report: 'gzip'
				}
			},
			sourcemap: {
				files: '<%= uglify.dist.files %>',
				options: {
					sourceMap: function(fileName) {
						return fileName.replace(/\.js$/, '.map');
					},
					sourceMapPrefix: 1,
					sourceMappingURL: function(path) {
						return path.replace(grunt.config('sourcemap.options.prefix'), '').replace(/\.js$/, '.map');
					}
				}
			}
		},
		sourcemap: {
			options: {
				src: 'sdk/f2.min.js',
				prefix: 'sdk/'
			}
		}
	});

	// Load plugins
	grunt.loadNpmTasks('grunt-contrib-clean');
	grunt.loadNpmTasks('grunt-contrib-copy');
	grunt.loadNpmTasks('grunt-contrib-concat');
	grunt.loadNpmTasks('grunt-contrib-compress');
	grunt.loadNpmTasks('grunt-contrib-jasmine');
	grunt.loadNpmTasks('grunt-contrib-jshint');
	grunt.loadNpmTasks('grunt-contrib-less');
	grunt.loadNpmTasks('grunt-contrib-uglify');
	grunt.loadNpmTasks('grunt-express');

	// Register tasks
	grunt.registerTask('fix-sourcemap', 'Fixes the source map file', function() {
		var uglifyOptions = grunt.config('uglify.sourcemap.options'),
			options = grunt.config('sourcemap.options'),
			dest = uglifyOptions.sourceMap(options.src),
			rawMap = grunt.file.read(dest);

		rawMap = rawMap.replace(options.prefix, '');
		grunt.file.write(dest, rawMap);
	});

	grunt.registerTask('markitdown', 'Compiles the spec documentation with Markitdown', function() {
		var done = this.async(),
			log = grunt.log.write('Generating spec documentation...');
		grunt.util.spawn(
			{
				cmd: 'markitdown',
				args: [
					'./',
					'--output-path', '../',
					'--docTemplate', './template/baseTemplate.html',
					'--header', './template/header.html',
					'--footer', './template/footer.html',
					'--head', './template/style.html',
					'--title', 'F2'
				],
				opts: {
					cwd: './docs/src-temp'
				}
			},
			function(error, result, code) {
				if (error) {
					grunt.fail.fatal(error);
				} else {
					log.ok();
					done();
				}
			}
		);
	});

	grunt.registerTask('nuget', 'Builds the NuGet package for distribution on NuGet.org', function() {
		var done = this.async(),
			log = grunt.log.write('Creating NuSpec file...'),
			nuspec = grunt.file.read('./sdk/f2.nuspec.tmpl');

		nuspec = grunt.template.process(nuspec, { data: pkg });
		grunt.file.write('./sdk/f2.nuspec', nuspec);
		log.ok();

		log = grunt.log.write('Creating NuGet package...');
		grunt.util.spawn(
			{
				cmd: 'nuget',
				args: ['pack', 'f2.nuspec'],
				opts: {
					cwd: './sdk'
				}
			},
			function(error, result, code){
				if (error){
					grunt.fail.fatal(error);
				} else {
					grunt.file.delete('./sdk/f2.nuspec');
					log.ok();
					done();
				}
			}
		);
	});

	grunt.registerTask('release', 'Prepares the code for release (merge into master)', function(releaseType) {
		if (!/^major|minor|patch$/i.test(releaseType) && !semver.valid(releaseType)) {
			grunt.log.error('"' + releaseType + '" is not a valid release type (major, minor, or patch) or SemVer version');
			return;
		}

		pkg.version = semver.valid(releaseType) ? releaseType : String(semver.inc(pkg.version, releaseType)).replace(/\-\w+$/, '');
		pkg._releaseDate = new Date().toJSON();
		pkg._releaseDateFormatted = moment(pkg._releaseDate).format('D MMMM YYYY');

		grunt.file.write('./package.json', JSON.stringify(pkg, null, '\t'));
		grunt.config.set('pkg', pkg);

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

	grunt.registerTask('version', 'Displays version information for F2', function() {
		grunt.log.writeln(grunt.template.process(
			'This copy of F2 is at version <%= version %> with a release date of <%= _releaseDateFormatted %>',
			{ data: pkg }
		));
	});

	grunt.registerTask('yuidoc', 'Builds the reference documentation with YUIDoc', function() {

		var builder,
			docOptions = {
				quiet: true,
				norecurse: true,
				paths: ['./sdk/src'],
				outdir: './docs/sdk/',
				themedir: './docs/src/sdk-template'
			},
			done = this.async(),
			json,
			log = grunt.log.write('Generating reference documentation...'),
			readmeMd = grunt.file.read('README.md'),
			Y = require('yuidocjs');

		json = (new Y.YUIDoc(docOptions)).run();
		// massage in some meta information from F2.json
		json.project = {
			docsAssets: '../',
			version: pkg.version,
			releaseDateFormatted: pkg._releaseDateFormatted
		};
		docOptions = Y.Project.mix(json, docOptions);

		// hasClassMembers
		// ensures that the class has members and isn't just an empty namespace
		Y.Handlebars.registerHelper('hasClassMembers', function() {

			for (var i = 0, len = json.classitems.length; i < len; i++) {
				//console.log(json.classitems[i].class, this.name);
				if (json.classitems[i].class === this.name) {
					return '';
				}
			}

			return 'hide';
		});

		// title tag
		Y.Handlebars.registerHelper('htmlTitle',function () {
			var name  = this.displayName || this.name,
					title = name;

			if (title) {
				title = 'F2 - ' + title;
			} else {
				title = 'F2 - The Open Financial Framework';
			}

			return title;
		});

		// handle any member names that have periods in them
		Y.Handlebars.registerHelper('memberNameAsId', function() {
			return String(this.name).replace('.', '_');
		});

		// insert readme markdown
		Y.Handlebars.registerHelper('readme', function() {
			return builder.markdown(readmeMd, true);
		});

		builder = new Y.DocBuilder(docOptions, json);
		builder.compile(function() {
			log.ok();
			done();
		});
	});

	grunt.registerTask('docs', ['less', 'yuidoc', 'copy:docs', 'markitdown', 'clean:docs']);
	grunt.registerTask('github-pages', ['copy:github-pages', 'clean:github-pages']);
	grunt.registerTask('zip', ['compress', 'copy:F2-examples', 'clean:F2-examples']);
	grunt.registerTask('js', ['jshint', 'concat', 'uglify:dist', 'sourcemap', 'copy:f2ToRoot']);
	grunt.registerTask('sourcemap', ['uglify:sourcemap', 'fix-sourcemap']);
	grunt.registerTask('test', ['jshint', 'express', 'jasmine'/*, 'express-keepalive'*/]);
	grunt.registerTask('travis', ['test']);

	// the default task
	grunt.registerTask('default', ['test', 'js', 'docs', 'zip']);
};<|endoftext|>


<commit_before>module.exports = function (grunt) {
    grunt.initConfig({
        "pkg": grunt.file.readJSON("package.json"),
        "meta": {
            "paths": {
                "source": "Source",
                "dist": "Distribution"
            }
        },
        "tslint": {
            "options": {
                "configuration": grunt.file.readJSON("tslint.json")
            },
            "files": {
                "src": ["<%= meta.paths.source %>/<%= pkg.name %>.ts"]
            }
        },
        "tslint": {
            "options": {
                "configuration": grunt.file.readJSON("tslint.json")
            },
            "files": {
                "src": ["<%= meta.paths.source %>/<%= pkg.name %>.ts"]
            }
        },
        "typescript": {
            "base": {
                "src": "<%= meta.paths.source %>/<%= pkg.name %>.ts",
                "dest": "<%= meta.paths.dist %>/<%= pkg.name %>.js"
            }
        },
        "mocha": {
            "test": {
                "src": ["Tests/*.html"],
                "options": {
                    "run": true
                }
            }
        },
        "copy": {
            "default": {
                "files": [{
                    "src": "README.md",
                    "dest": "<%= meta.paths.dist %>/"
                }, {
                    "src": "LICENSE.txt",
                    "dest": "<%= meta.paths.dist %>/"
                }]
            }
        },
        "uglify": {
            "options": {
                "compress": true
            },
            "dist": {
                "files": {
                    "<%= meta.paths.dist %>/<%= pkg.name %>-<%= pkg.version %>.min.js": ["<%= meta.paths.dist %>/<%= pkg.name %>.js"],
                }
            }
        }
    });

    grunt.loadNpmTasks("grunt-contrib-copy");
    grunt.loadNpmTasks("grunt-contrib-uglify");
    grunt.loadNpmTasks("grunt-mocha");
    grunt.loadNpmTasks("grunt-tslint");
    grunt.loadNpmTasks("grunt-typescript");
    grunt.registerTask("default", [
        "tslint", "typescript", "copy", "uglify", "mocha"
    ]);
};<commit_msg>Moved to mocha_phantomjs<commit_after>module.exports = function (grunt) {
    grunt.initConfig({
        "pkg": grunt.file.readJSON("package.json"),
        "meta": {
            "paths": {
                "source": "Source",
                "dist": "Distribution"
            }
        },
        "tslint": {
            "options": {
                "configuration": grunt.file.readJSON("tslint.json")
            },
            "files": {
                "src": ["<%= meta.paths.source %>/<%= pkg.name %>.ts"]
            }
        },
        "tslint": {
            "options": {
                "configuration": grunt.file.readJSON("tslint.json")
            },
            "files": {
                "src": ["<%= meta.paths.source %>/<%= pkg.name %>.ts"]
            }
        },
        "typescript": {
            "base": {
                "src": "<%= meta.paths.source %>/<%= pkg.name %>.ts",
                "dest": "<%= meta.paths.dist %>/<%= pkg.name %>.js"
            }
        },
        "copy": {
            "default": {
                "files": [{
                    "src": "README.md",
                    "dest": "<%= meta.paths.dist %>/"
                }, {
                    "src": "LICENSE.txt",
                    "dest": "<%= meta.paths.dist %>/"
                }]
            }
        },
        "uglify": {
            "options": {
                "compress": true
            },
            "dist": {
                "files": {
                    "<%= meta.paths.dist %>/<%= pkg.name %>-<%= pkg.version %>.min.js": ["<%= meta.paths.dist %>/<%= pkg.name %>.js"],
                }
            }
        },
        "mocha_phantomjs": {
            "all": ["Tests/*.html"]
        }
    });

    grunt.loadNpmTasks("grunt-contrib-copy");
    grunt.loadNpmTasks("grunt-contrib-uglify");
    grunt.loadNpmTasks("grunt-mocha-phantomjs");
    grunt.loadNpmTasks("grunt-tslint");
    grunt.loadNpmTasks("grunt-typescript");
    grunt.registerTask("default", [
        "tslint", "typescript", "copy", "uglify", "mocha_phantomjs"
    ]);
};<|endoftext|>


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

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        dirs: {
            bower: 'bower_components',
            css: 'assets/css',
            js: 'assets/js',
            images: 'assets/images',
            icons: 'assets/icons'
        },

        // SCSS
        sass: {
            dev: {
                options: {
                    outputStyle: 'expanded',
                    loadPath: '.'
                },
                files: {
                    '<%= dirs.css %>/style.css': '<%= dirs.css %>/style.scss'
                }
            },
            build: {
                options: {
                    outputStyle: 'compressed',
                    loadPath: '.'
                },
                files: {
                    '<%= dirs.css %>/style.css': '<%= dirs.css %>/style.scss'
                }
            }
        },

        // CSS autoprefixer
        autoprefixer: {
            options: {
                browsers: ['last 2 versions']
            },
            dist: {
                files: {
                    '<%= dirs.css %>/style.css': '<%= dirs.css %>/style.css'
                }
            }
        },

        // Connect Server
        connect: {
            server: {
                options: {
                    port: 9001,
                    base: ''
                }
            }
        },

        // Concat
        concat: {
            options: {
                separator: ';',
            },
            dist: {
                src: [
                    '<%= dirs.bower %>/jquery/dist/jquery.js',
                    '<%= dirs.bower %>/AdminLTE/dist/js/app.js',
                    '<%= dirs.js %>/*.js',
                    '!<%= dirs.js %>/modernizr.js',
                    '!<%= dirs.js %>/build.js'
                ],
                dest: '<%= dirs.js %>/build.js',
            },
        },

        // JShint
        jshint: {
            all: [
                'Gruntfile.js',
                '<%= dirs.js %>/*.js',
                '!<%= dirs.js %>/modernizr.js',
                '!<%= dirs.js %>/build.js'
            ]
        },

        // HTMLhint
        htmlhint: {
            html: {
                options: {
                    'tag-pair': true
                },
                src: ['*.html']
            }
        },

        // Uglify
        uglify: {
            all: {
                files: {
                    '<%= dirs.js %>/build.js': ['<%= dirs.js %>/build.js'],
                    '<%= dirs.js %>/modernizr.js': ['<%= dirs.bower %>/modernizr/modernizr.js']
                }
            }
        },

        // Imagemin
        imagemin: {
            dynamic: {
                files: [{
                    expand: true,
                    cwd: '<%= dirs.images %>',
                    src: ['**/*.{png,jpg,gif}'],
                    dest: '<%= dirs.images %>'
                }]
            }
        },

        // Browser Sync
        browser_sync: {
            dev: {
                bsFiles: {
                    src : 'assets/css/style.css'
                },
                options: {
                    watchTask: true,
                    server: {
                        baseDir: ""
                    },
                    ghostMode: {
                        clicks: true,
                        scroll: true,
                        links: true,
                        forms: true
                    },
                }
            }
        },

        // Watch
        watch: {
            options: {
                livereload: true
            },
            sass: {
                files: ['<%= dirs.css %>/*.scss'],
                tasks: ['sass:dev', 'autoprefixer']
            },
            images: {
                files: ['<%= dirs.images %>/*.{png,jpg,gif}'],
                tasks: ['imagemin']
            },
            html: {
                files: ['*.html'],
                tasks: ['htmlhint']
            },
            scripts: {
                files: ['Gruntfile.js', '<%= dirs.js %>/*.js'],
                tasks: ['jshint', 'concat'],
                options: {
                    spawn: false
                }
            }
        }
    });

    grunt.registerTask('default', ['sass:build', 'autoprefixer', 'concat', 'uglify', 'imagemin']);
    grunt.registerTask('dev', ['connect', 'watch', 'notify']);
    grunt.registerTask('dev:sync', ['browser_sync', 'watch', 'notify']);
};
<commit_msg>Reindent<commit_after>module.exports = function(grunt) {
    require('load-grunt-tasks')(grunt);

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        dirs: {
            bower: 'bower_components',
            css: 'assets/css',
            fonts: 'assets/fonts',
            images: 'assets/images',
            icons: 'assets/icons',
            js: 'assets/js'
        },

        // SCSS
        sass: {
            dev: {
                options: {
                    outputStyle: 'expanded',
                    loadPath: '.'
                },
                files: {
                    '<%= dirs.css %>/style.css': '<%= dirs.css %>/style.scss'
                }
            },
            build: {
                options: {
                    outputStyle: 'compressed',
                    loadPath: '.'
                },
                files: {
                    '<%= dirs.css %>/style.css': '<%= dirs.css %>/style.scss'
                }
            }
        },

        // CSS autoprefixer
        autoprefixer: {
            options: {
                browsers: ['last 2 versions']
            },
            dist: {
                files: {
                    '<%= dirs.css %>/style.css': '<%= dirs.css %>/style.css'
                }
            }
        },

        // Connect Server
        connect: {
            server: {
                options: {
                    port: 9001,
                    base: ''
                }
            }
        },

        // Concat
        concat: {
            options: {
                separator: ';',
            },
            dist: {
                src: [
                '<%= dirs.bower %>/jquery/dist/jquery.js',
                '<%= dirs.bower %>/AdminLTE/dist/js/app.js',
                '<%= dirs.js %>/*.js',
                '!<%= dirs.js %>/modernizr.js',
                '!<%= dirs.js %>/build.js'
                ],
                dest: '<%= dirs.js %>/build.js',
            },
        },

        // JShint
        jshint: {
            all: [
            'Gruntfile.js',
            '<%= dirs.js %>/*.js',
            '!<%= dirs.js %>/modernizr.js',
            '!<%= dirs.js %>/build.js'
            ]
        },

        // HTMLhint
        htmlhint: {
            html: {
                options: {
                    'tag-pair': true
                },
                src: ['*.html']
            }
        },

        // Uglify
        uglify: {
            all: {
                files: {
                    '<%= dirs.js %>/build.js': ['<%= dirs.js %>/build.js'],
                    '<%= dirs.js %>/modernizr.js': ['<%= dirs.bower %>/modernizr/modernizr.js']
                }
            }
        },

        // Imagemin
        imagemin: {
            dynamic: {
                files: [{
                    expand: true,
                    cwd: '<%= dirs.images %>',
                    src: ['**/*.{png,jpg,gif}'],
                    dest: '<%= dirs.images %>'
                }]
            }
        },

        // Browser Sync
        browser_sync: {
            dev: {
                bsFiles: {
                    src : 'assets/css/style.css'
                },
                options: {
                    watchTask: true,
                    server: {
                        baseDir: ""
                    },
                    ghostMode: {
                        clicks: true,
                        scroll: true,
                        links: true,
                        forms: true
                    },
                }
            }
        },

        // Watch
        watch: {
            options: {
                livereload: true
            },
            sass: {
                files: ['<%= dirs.css %>/*.scss'],
                tasks: ['sass:dev', 'autoprefixer']
            },
            images: {
                files: ['<%= dirs.images %>/*.{png,jpg,gif}'],
                tasks: ['imagemin']
            },
            html: {
                files: ['*.html'],
                tasks: ['htmlhint']
            },
            scripts: {
                files: ['Gruntfile.js', '<%= dirs.js %>/*.js'],
                tasks: ['jshint', 'concat'],
                options: {
                    spawn: false
                }
            }
        }
    });

    grunt.registerTask('default', ['sass:build', 'autoprefixer', 'concat', 'uglify', 'imagemin']);
    grunt.registerTask('dev', ['connect', 'watch', 'notify']);
    grunt.registerTask('dev:sync', ['browser_sync', 'watch', 'notify']);
};
<|endoftext|>


<commit_before>var fs = require('fs');

// Detect windows
var isWin = /^win/.test(process.platform);

var appstormFiles = [
  'appstorm/a.js',

  'appstorm/core/mem.js',
  'appstorm/core/environment.js',
  'appstorm/core/debugger.js',
  'appstorm/core/console.js',
  'appstorm/core/message.js',
  'appstorm/core/parser.js',
  'appstorm/core/timer.js',
  'appstorm/core/dom.js',
  'appstorm/core/hash.js',
  'appstorm/core/ajax.js',
  'appstorm/core/loader.js',
  'appstorm/core/route.js',
  'appstorm/core/parameter.js',
  'appstorm/core/acl.js',
  'appstorm/core/mock.js',

  'appstorm/plugin/keyboard.js',
  'appstorm/plugin/callback.js',
  'appstorm/plugin/storage.js',
  'appstorm/plugin/translate.js',
  'appstorm/plugin/form.js',
  'appstorm/plugin/state.js',
  'appstorm/plugin/state.chain.js',
  'appstorm/plugin/state.type.js',
  'appstorm/plugin/state.protocol.js',
  'appstorm/plugin/binding.js',
  'appstorm/plugin/model.js',
  'appstorm/plugin/model.manager.js',
  'appstorm/plugin/model.pooler.js',
  'appstorm/plugin/model.template.js',
  'appstorm/plugin/template.js',

  // Last loaded - ready event
  'appstorm/r.js'
];

String.prototype.endsWith = function(suffix) {
  return this.indexOf(suffix, this.length - suffix.length) !== -1;
};

// Simple walker, taken at
// http://stackoverflow.com/questions/5827612/node-js-fs-readdir-recursive-directory-search
var walk = function(dir) {
    var results = [],
      list      = fs.readdirSync(dir);
    list.forEach(function(file) {
        file = dir + '/' + file;
        var stat = fs.statSync(file);
        if (stat && stat.isDirectory()) {
          results = results.concat(walk(file));
        } else {
          results.push(file);
        }
    });
    return results;
};

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

    bower: {
      install: {},
      options: {
        targetDir: 'appstorm/vendor'}
    },

    concat: {
      options: {
        separator: ';'
      },
      withDependencies: {
        src: [
          // Coming from Bower
          'appstorm/vendor/lodash/lodash.js',
          'appstorm/vendor/handlebars/handlebars.js',
          'appstorm/vendor/mousetrap/mousetrap.min.js',
          'appstorm/vendor/watch/watch.js',
        ].concat(appstormFiles),
        dest: './appstorm.concat.js',
        nonull: true,
      },
      withoutDependencies: {
        src: appstormFiles,
        dest: './appstorm-without-dependencies.concat.js'
      }
    },

    uglify: {
      options: {
        banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today("dd-mm-yyyy") %> */\n'
      },
      dist: {
        files: {
          './appstorm.min.js': ['<%= concat.withDependencies.dest %>'],
          './appstorm-without-dependencies.min.js': ['<%= concat.withoutDependencies.dest %>']
        }
      }
    },

    qunit: {
      files: ['unittest/index-concat.html'],
      options: {
        force: true
      }
    },

    jshint: {
      files: ['appstorm/core/*.js'],
      options: {
        // options here to override JSHint defaults
        globals: {
          console: true,
          document: true,
        },
        force: true
      }
    },

    watch: {
      files: ['<%= jshint.files %>'],
      tasks: ['jshint', 'qunit']
    },

    /*yuidoc: {
      compile: {
        name: '<%= pkg.name %>',
        description: '<%= pkg.description %>',
        version: '<%= pkg.version %>',
        url: '<%= pkg.homepage %>',
        options: {
          paths: 'appstorm',
          //themedir: 'path/to/custom/theme/', // What theme?
          outdir: 'appstorm/doc',
          exclude: 'doc,vendor,<%= concat.withDependencies.dest %>,<%= concat.withoutDependencies.dest %>,appstorm/appstorm.min.js'
        }
      }
    }*/

    mkdir: {
      doxx_html: {
        options: {
          create: ['docs', 'docs/core', 'docs/plugin']
        }
      },
      doxx_md: {
        options: {
          create: ['mds', 'mds/core', 'mds/plugin']
        }
      }
    },

    exec: {
      remove_doxx_html: {
        cmd: 'rm -rf ./docs'
      },
      install_doxx_html: {
        cmd: 'doxx --source appstorm --target docs --ignore vendor --target_extension html --template ./utils/doxx/html.jade'
      },
      rename_doxx_html: {
        cmd: function() {
          var results = walk('./docs');

          for (var i = 0, l = results.length; i < l; ++i) {
            var file = results[i];
            if (file.endsWith('.js.html')) {
              fs.renameSync(file, file.substr(0, file.length - 8) + '.html');
            }
          }

          if (isWin) {
            return 'dir > NUL';
          } else {
            return '/dev/null';
          }
        }
      },

      remove_doxx_md: {
        cmd: 'rm -rf ./mds'
      },
      install_doxx_md: {
        cmd: 'doxx --source appstorm --target mds --ignore vendor --target_extension md --template ./utils/doxx/md.jade'
      },
      rename_doxx_md: {
        cmd: function() {
          var results = walk('./mds');

          for (var i = 0, l = results.length; i < l; ++i) {
            var file = results[i];
            if (file.endsWith('.js.md')) {
              fs.renameSync(file, file.substr(0, file.length - 6) + '.md');
            }
          }

          // Also we don't need index at all...
          try { fs.unlinkSync('./mds/index.html');   } catch(e) {}

          // And also r.md
          try { fs.unlinkSync('./mds/r.md');   } catch(e) {}

          if (isWin) {
            return 'dir > NUL';
          } else {
            return '/dev/null';
          }
        }
      }
  }

  });

  // Code
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-qunit');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-bower-task');

  // Documentation
  //grunt.loadNpmTasks('grunt-contrib-yuidoc');
  grunt.loadNpmTasks('grunt-mkdir');
  grunt.loadNpmTasks('grunt-exec');

  /*
   * -----------------------
   *   TESTS
   * -----------------------
  */
  grunt.registerTask('hint', ['jshint']);
  grunt.registerTask('test', ['jshint', 'qunit']);

  /*
   * -----------------------
   *   DOCUMENTATION
   * -----------------------
  */
  //grunt.registerTask('doc', ['yuidoc']);
  grunt.registerTask('doc', ['exec:remove_doxx_html', 'mkdir:doxx_html', 'exec:install_doxx_html', 'exec:rename_doxx_html']);
  grunt.registerTask('doc_html', ['exec:remove_doxx_html', 'mkdir:doxx_html', 'exec:install_doxx_html', 'exec:rename_doxx_html']);

  grunt.registerTask('md', ['exec:remove_doxx_md', 'mkdir:doxx_md', 'exec:install_doxx_md', 'exec:rename_doxx_md']);
  grunt.registerTask('doc_md', ['exec:remove_doxx_md', 'mkdir:doxx_md', 'exec:install_doxx_md', 'exec:rename_doxx_md']);

  /*
   * -----------------------
   *   BUILD
   * -----------------------
  */
  // Different builds
  grunt.registerTask('with', ['bower', 'concat:withDependencies', 'uglify']);
  grunt.registerTask('without', ['bower', 'concat:withoutDependencies', 'uglify']);

  // Since complete is not ready to be used yet, define simpler default
  grunt.registerTask('default', ['bower', 'concat:withDependencies', 'uglify']);
};

<commit_msg>Include JSEP in build chain.<commit_after>var fs = require('fs');

// Detect windows
var isWin = /^win/.test(process.platform);

var appstormFiles = [
  'appstorm/a.js',

  'appstorm/core/mem.js',
  'appstorm/core/environment.js',
  'appstorm/core/debugger.js',
  'appstorm/core/console.js',
  'appstorm/core/message.js',
  'appstorm/core/parser.js',
  'appstorm/core/timer.js',
  'appstorm/core/dom.js',
  'appstorm/core/hash.js',
  'appstorm/core/ajax.js',
  'appstorm/core/loader.js',
  'appstorm/core/route.js',
  'appstorm/core/parameter.js',
  'appstorm/core/acl.js',
  'appstorm/core/mock.js',

  'appstorm/plugin/keyboard.js',
  'appstorm/plugin/callback.js',
  'appstorm/plugin/storage.js',
  'appstorm/plugin/translate.js',
  'appstorm/plugin/form.js',
  'appstorm/plugin/state.js',
  'appstorm/plugin/state.chain.js',
  'appstorm/plugin/state.type.js',
  'appstorm/plugin/state.protocol.js',
  'appstorm/plugin/binding.js',
  'appstorm/plugin/model.js',
  'appstorm/plugin/model.manager.js',
  'appstorm/plugin/model.pooler.js',
  'appstorm/plugin/model.template.js',
  'appstorm/plugin/template.js',

  // Last loaded - ready event
  'appstorm/r.js'
];

String.prototype.endsWith = function(suffix) {
  return this.indexOf(suffix, this.length - suffix.length) !== -1;
};

// Simple walker, taken at
// http://stackoverflow.com/questions/5827612/node-js-fs-readdir-recursive-directory-search
var walk = function(dir) {
    var results = [],
      list      = fs.readdirSync(dir);
    list.forEach(function(file) {
        file = dir + '/' + file;
        var stat = fs.statSync(file);
        if (stat && stat.isDirectory()) {
          results = results.concat(walk(file));
        } else {
          results.push(file);
        }
    });
    return results;
};

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

    bower: {
      install: {},
      options: {
        targetDir: 'appstorm/vendor'}
    },

    concat: {
      options: {
        separator: ';'
      },
      withDependencies: {
        src: [
          // Coming from Bower
          'appstorm/vendor/lodash/lodash.js',
          'appstorm/vendor/handlebars/handlebars.js',
          'appstorm/vendor/mousetrap/mousetrap.min.js',
          'appstorm/vendor/watch/watch.js',
          'appstorm/vendor/jsep/build/jsep.js'
        ].concat(appstormFiles),
        dest: './appstorm.concat.js',
        nonull: true,
      },
      withoutDependencies: {
        src: appstormFiles,
        dest: './appstorm-without-dependencies.concat.js'
      }
    },

    uglify: {
      options: {
        banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today("dd-mm-yyyy") %> */\n'
      },
      dist: {
        files: {
          './appstorm.min.js': ['<%= concat.withDependencies.dest %>'],
          './appstorm-without-dependencies.min.js': ['<%= concat.withoutDependencies.dest %>']
        }
      }
    },

    qunit: {
      files: ['unittest/index-concat.html'],
      options: {
        force: true
      }
    },

    jshint: {
      files: ['appstorm/core/*.js'],
      options: {
        // options here to override JSHint defaults
        globals: {
          console: true,
          document: true,
        },
        force: true
      }
    },

    watch: {
      files: ['<%= jshint.files %>'],
      tasks: ['jshint', 'qunit']
    },

    /*yuidoc: {
      compile: {
        name: '<%= pkg.name %>',
        description: '<%= pkg.description %>',
        version: '<%= pkg.version %>',
        url: '<%= pkg.homepage %>',
        options: {
          paths: 'appstorm',
          //themedir: 'path/to/custom/theme/', // What theme?
          outdir: 'appstorm/doc',
          exclude: 'doc,vendor,<%= concat.withDependencies.dest %>,<%= concat.withoutDependencies.dest %>,appstorm/appstorm.min.js'
        }
      }
    }*/

    mkdir: {
      doxx_html: {
        options: {
          create: ['docs', 'docs/core', 'docs/plugin']
        }
      },
      doxx_md: {
        options: {
          create: ['mds', 'mds/core', 'mds/plugin']
        }
      }
    },

    exec: {
      remove_doxx_html: {
        cmd: 'rm -rf ./docs'
      },
      install_doxx_html: {
        cmd: 'doxx --source appstorm --target docs --ignore vendor --target_extension html --template ./utils/doxx/html.jade'
      },
      rename_doxx_html: {
        cmd: function() {
          var results = walk('./docs');

          for (var i = 0, l = results.length; i < l; ++i) {
            var file = results[i];
            if (file.endsWith('.js.html')) {
              fs.renameSync(file, file.substr(0, file.length - 8) + '.html');
            }
          }

          if (isWin) {
            return 'dir > NUL';
          } else {
            return '/dev/null';
          }
        }
      },

      remove_doxx_md: {
        cmd: 'rm -rf ./mds'
      },
      install_doxx_md: {
        cmd: 'doxx --source appstorm --target mds --ignore vendor --target_extension md --template ./utils/doxx/md.jade'
      },
      rename_doxx_md: {
        cmd: function() {
          var results = walk('./mds');

          for (var i = 0, l = results.length; i < l; ++i) {
            var file = results[i];
            if (file.endsWith('.js.md')) {
              fs.renameSync(file, file.substr(0, file.length - 6) + '.md');
            }
          }

          // Also we don't need index at all...
          try { fs.unlinkSync('./mds/index.html');   } catch(e) {}

          // And also r.md
          try { fs.unlinkSync('./mds/r.md');   } catch(e) {}

          if (isWin) {
            return 'dir > NUL';
          } else {
            return '/dev/null';
          }
        }
      }
  }

  });

  // Code
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-qunit');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-bower-task');

  // Documentation
  //grunt.loadNpmTasks('grunt-contrib-yuidoc');
  grunt.loadNpmTasks('grunt-mkdir');
  grunt.loadNpmTasks('grunt-exec');

  /*
   * -----------------------
   *   TESTS
   * -----------------------
  */
  grunt.registerTask('hint', ['jshint']);
  grunt.registerTask('test', ['jshint', 'qunit']);

  /*
   * -----------------------
   *   DOCUMENTATION
   * -----------------------
  */
  //grunt.registerTask('doc', ['yuidoc']);
  grunt.registerTask('doc', ['exec:remove_doxx_html', 'mkdir:doxx_html', 'exec:install_doxx_html', 'exec:rename_doxx_html']);
  grunt.registerTask('doc_html', ['exec:remove_doxx_html', 'mkdir:doxx_html', 'exec:install_doxx_html', 'exec:rename_doxx_html']);

  grunt.registerTask('md', ['exec:remove_doxx_md', 'mkdir:doxx_md', 'exec:install_doxx_md', 'exec:rename_doxx_md']);
  grunt.registerTask('doc_md', ['exec:remove_doxx_md', 'mkdir:doxx_md', 'exec:install_doxx_md', 'exec:rename_doxx_md']);

  /*
   * -----------------------
   *   BUILD
   * -----------------------
  */
  // Different builds
  grunt.registerTask('with', ['bower', 'concat:withDependencies', 'uglify']);
  grunt.registerTask('without', ['bower', 'concat:withoutDependencies', 'uglify']);

  // Since complete is not ready to be used yet, define simpler default
  grunt.registerTask('default', ['bower', 'concat:withDependencies', 'uglify']);
};

<|endoftext|>


<commit_before>'use strict'

var path = require('path');

module.exports = function(grunt) {
    var _ = grunt.util._;

    // By default, we load all local tasks from the tasks directory.
    grunt.file.expand('tasks/*').forEach(function(task) {
        grunt.loadTasks(task);
    });

    // Populate the config object
    var config = {};
    grunt.file.expand('tasks/config/*').forEach(function(configPath) {
        // Get the grunt-task name to put in the config which is based on the
        // name of the config file
        var configName = configPath.match(/\/([^\/]*)\.js/)[1];
        var option = require(path.join(__dirname + '/' + configPath))(grunt);
        config[configName] = _.extend(config[configName] || {}, option);
    });

    grunt.initConfig(_.extend({
        pkg: grunt.file.readJSON('package.json'),
        releaseName: '<%= pkg.name %>-<%= pkg.version %>',
        releaseMessage: '<%= pkg.name %> release <%= pkg.version %>'
    }, config));

    // load npm tasks
    var npmTasks = [
        'grunt-contrib-uglify',
        'grunt-contrib-watch',
        'grunt-contrib-connect',
        'grunt-concurrent',
        'grunt-open',
        'grunt-shell',
        'grunt-contrib-clean',
        'grunt-contrib-copy',
        'grunt-mocha-phantomjs'
    ];

    npmTasks.forEach(function(taskName) {
        if (!grunt.task._tasks[taskName]) {
            grunt.loadNpmTasks(taskName);
        }
    });

    grunt.registerTask('lint', ['eslint']);

    grunt.registerTask('serve', ['build', 'connect:server', 'watch']);
    grunt.registerTask('build', ['lint', 'copy', 'uglify']);
    grunt.registerTask('test', ['build', 'connect:test', 'mocha_phantomjs']);
    grunt.registerTask('test:browser', ['build', 'concurrent:tests']);
    grunt.registerTask('default', 'build');
};
<commit_msg>💩 No need for grunt-shell<commit_after>'use strict'

var path = require('path');

module.exports = function(grunt) {
    var _ = grunt.util._;

    // By default, we load all local tasks from the tasks directory.
    grunt.file.expand('tasks/*').forEach(function(task) {
        grunt.loadTasks(task);
    });

    // Populate the config object
    var config = {};
    grunt.file.expand('tasks/config/*').forEach(function(configPath) {
        // Get the grunt-task name to put in the config which is based on the
        // name of the config file
        var configName = configPath.match(/\/([^\/]*)\.js/)[1];
        var option = require(path.join(__dirname + '/' + configPath))(grunt);
        config[configName] = _.extend(config[configName] || {}, option);
    });

    grunt.initConfig(_.extend({
        pkg: grunt.file.readJSON('package.json'),
        releaseName: '<%= pkg.name %>-<%= pkg.version %>',
        releaseMessage: '<%= pkg.name %> release <%= pkg.version %>'
    }, config));

    // load npm tasks
    var npmTasks = [
        'grunt-contrib-uglify',
        'grunt-contrib-watch',
        'grunt-contrib-connect',
        'grunt-concurrent',
        'grunt-open',
        'grunt-contrib-clean',
        'grunt-contrib-copy',
        'grunt-mocha-phantomjs'
    ];

    npmTasks.forEach(function(taskName) {
        if (!grunt.task._tasks[taskName]) {
            grunt.loadNpmTasks(taskName);
        }
    });

    grunt.registerTask('lint', ['eslint']);

    grunt.registerTask('serve', ['build', 'connect:server', 'watch']);
    grunt.registerTask('build', ['lint', 'copy', 'uglify']);
    grunt.registerTask('test', ['build', 'connect:test', 'mocha_phantomjs']);
    grunt.registerTask('test:browser', ['build', 'concurrent:tests']);
    grunt.registerTask('default', 'build');
};
<|endoftext|>


<commit_before>module.exports = function(grunt) {
  var pkg = grunt.file.readJSON('package.json');
  var betaVersion = pkg.version.toString() + "." + process.env.TRAVIS_BUILD_NUMBER;
  var firefoxBrowserSupport = {
    "gecko": {
      "id": "firefox@destinyitemmanager.com",
      "strict_min_version": "46.*"
    }
  };

  grunt.initConfig({
    pkg: pkg,

    sync: {
      chrome: {
        files: [{
          cwd: 'app/',
          src: [
            '**'
          ],
          dest: 'dist/chrome'
        }]
      },
      firefox: {
        files: [{
          cwd: 'app/',
          src: [
            '**'
          ],
          dest: 'dist/firefox'
        }]
      },
    },

    copy: {
      // Copy all files to a staging directory
      beta_icons_firefox: {
        cwd: 'icons/beta/',
        src: '**',
        dest: 'dist/firefox/',
        expand: true
      },
      beta_icons_chrome: {
        cwd: 'icons/beta/',
        src: '**',
        dest: 'dist/chrome/',
        expand: true
      }
    },

    compress: {
      // Zip up the extension
      firefox: {
        options: {
          archive: 'dist/firefox.zip'
        },
        files: [{
          expand: true,
          cwd: 'dist/firefox',
          src: ['**'],
          dest: '/',
          filter: 'isFile'
        }, ]
      },
      // Zip up the extension
      chrome: {
        options: {
          archive: 'dist/chrome.zip'
        },
        files: [{
          expand: true,
          cwd: 'dist/chrome',
          src: ['**'],
          dest: '/',
          filter: 'isFile'
        }, ]
      }
    },

    // Clean out generated extension files
    clean: ['dist'],

    replace: {
      // Replace all instances of $DIM_VERSION with the version number from package.json
      main_version: {
        src: ['dist/**/*.{json,html,js}'],
        overwrite: true,
        replacements: [{
          from: '$DIM_VERSION',
          to: pkg.version.toString()
        }]
      },
      // Replace all instances of $DIM_VERSION or the current version number (from package.json)
      // with a beta version based on the current time.
      beta_version: {
        src: ['dist/**/*.{json,html,js}'],
        overwrite: true,
        replacements: [{
          from: pkg.version.toString(),
          to: betaVersion
        }, {
          from: '$DIM_VERSION',
          to: betaVersion
        }]
      }
    },

    sass: {
      options: {
        sourceMap: true
      },
      dist: {
        files: {
          'app/styles/main.css': 'app/scss/main.scss'
        }
      }
    },

    postcss: {
      options: {
        map: true,
        processors: [
          require('autoprefixer')()
        ]
      },
      dist: {
        src: 'app/styles/main.css',
        dest: 'app/styles/main.css'
      }
    },

    watch: {
      app: {
        files: ['app/**.*'],
        tasks: ['sync']
      }
    },

    // See https://github.com/c301/grunt-webstore-upload
    webstore_upload: {
      accounts: {
        // This is set up by environment variables from Travis. To
        // push locally, create a file with these variables defined
        // and source it before running "grunt publish:beta". E.g.:
        //
        // ./beta_credentials:
        //
        // export CHROME_CLIENT_ID="foo"
        // export CHROME_SECRET="bar"
        // export CHROME_REFRESH_TOKEN="baz"
        //
        // Then run "source ./beta_credentials; grunt publish_chrome_beta"
        //
        // To set up these variables to be available in Travis:
        // travis encrypt CHROME_CLIENT_ID=super_secret --add env.matrix
        // travis encrypt CHROME_SECRET=super_secret --add env.matrix
        // travis encrypt CHROME_REFRESH_TOKEN=super_secret --add env.matrix
        default: { //account under this section will be used by default
          publish: true, //publish item right after uploading. default false
          client_id: process.env.CHROME_CLIENT_ID,
          client_secret: process.env.CHROME_SECRET,
          refresh_token: process.env.CHROME_REFRESH_TOKEN
        }
      },
      extensions: {
        DIM: {
          appID: "apghicjnekejhfancbkahkhdckhdagna",
          publish: false,
          zip: "dist/chrome.zip"
        },
        beta: {
          appID: "mkiipknpfaacbjdagdeppdacpgpdjklc",
          zip: "dist/chrome.zip"
        }
      }
    },

    eslint: {
      target: ["app/scripts/**/*.js"],
      options: {
        fix: true
      }
    }
  });

  grunt.loadNpmTasks('grunt-webstore-upload');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-contrib-compress');
  grunt.loadNpmTasks('grunt-text-replace');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-postcss');
  grunt.loadNpmTasks('grunt-sass');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-sync');
  grunt.loadNpmTasks("grunt-eslint");

  grunt.registerTask('css', ['sass', 'postcss']);

  grunt.registerTask('default', ['build','watch']);

  grunt.registerTask('build', ['clean','css', 'sync', 'update_firefox_manifest']);

  grunt.registerTask('update_firefox_manifest', function() {
    var manifest = grunt.file.readJSON('dist/firefox/manifest.json');
    manifest.applications = firefoxBrowserSupport;
    grunt.file.write('dist/firefox/manifest.json', JSON.stringify(manifest, null, '\t'));
  });

  grunt.registerTask('update_chrome_beta_manifest', function() {
    var manifest = grunt.file.readJSON('dist/chrome/manifest.json');
    manifest.name = manifest.name + " Beta";
    manifest.version = betaVersion;
    grunt.file.write('dist/extension/chrome/manifest.json', JSON.stringify(manifest));
  });

  grunt.registerTask('update_firefox_beta_manifest', function() {
    var manifest = grunt.file.readJSON('dist/extension/firefox/manifest.json');
    manifest.name = manifest.name + " Beta";
    manifest.version = betaVersion;
    grunt.file.write('dist/extension/firefox/manifest.json', JSON.stringify(manifest));
  });

  grunt.registerTask('publish_chrome_beta', [
    'build',
    'copy:beta_icons_chrome',
    'replace:beta_version',
    'compress:chrome',
    'webstore_upload:beta'
  ]);

  grunt.registerTask('publish_firefox_beta', [
    'build',
    'copy:beta_icons_firefox',
    'replace:beta_version',
    'compress:firefox'
  ]);

  // Builds release-able extensions in dist/
  grunt.registerTask('build_extension', [
    'build',
    'replace:main_version',
    'compress:chrome',
    'compress:firefox',
  ]);

  grunt.registerTask('log_beta_version', function() {
    grunt.log.ok("New Beta version is " + betaVersion);
  });
}
<commit_msg>Run eslint by default.<commit_after>module.exports = function(grunt) {
  var pkg = grunt.file.readJSON('package.json');
  var betaVersion = pkg.version.toString() + "." + process.env.TRAVIS_BUILD_NUMBER;
  var firefoxBrowserSupport = {
    "gecko": {
      "id": "firefox@destinyitemmanager.com",
      "strict_min_version": "46.*"
    }
  };

  grunt.initConfig({
    pkg: pkg,

    sync: {
      chrome: {
        files: [{
          cwd: 'app/',
          src: [
            '**'
          ],
          dest: 'dist/chrome'
        }]
      },
      firefox: {
        files: [{
          cwd: 'app/',
          src: [
            '**'
          ],
          dest: 'dist/firefox'
        }]
      },
    },

    copy: {
      // Copy all files to a staging directory
      beta_icons_firefox: {
        cwd: 'icons/beta/',
        src: '**',
        dest: 'dist/firefox/',
        expand: true
      },
      beta_icons_chrome: {
        cwd: 'icons/beta/',
        src: '**',
        dest: 'dist/chrome/',
        expand: true
      }
    },

    compress: {
      // Zip up the extension
      firefox: {
        options: {
          archive: 'dist/firefox.zip'
        },
        files: [{
          expand: true,
          cwd: 'dist/firefox',
          src: ['**'],
          dest: '/',
          filter: 'isFile'
        }, ]
      },
      // Zip up the extension
      chrome: {
        options: {
          archive: 'dist/chrome.zip'
        },
        files: [{
          expand: true,
          cwd: 'dist/chrome',
          src: ['**'],
          dest: '/',
          filter: 'isFile'
        }, ]
      }
    },

    // Clean out generated extension files
    clean: ['dist'],

    replace: {
      // Replace all instances of $DIM_VERSION with the version number from package.json
      main_version: {
        src: ['dist/**/*.{json,html,js}'],
        overwrite: true,
        replacements: [{
          from: '$DIM_VERSION',
          to: pkg.version.toString()
        }]
      },
      // Replace all instances of $DIM_VERSION or the current version number (from package.json)
      // with a beta version based on the current time.
      beta_version: {
        src: ['dist/**/*.{json,html,js}'],
        overwrite: true,
        replacements: [{
          from: pkg.version.toString(),
          to: betaVersion
        }, {
          from: '$DIM_VERSION',
          to: betaVersion
        }]
      }
    },

    sass: {
      options: {
        sourceMap: true
      },
      dist: {
        files: {
          'app/styles/main.css': 'app/scss/main.scss'
        }
      }
    },

    postcss: {
      options: {
        map: true,
        processors: [
          require('autoprefixer')()
        ]
      },
      dist: {
        src: 'app/styles/main.css',
        dest: 'app/styles/main.css'
      }
    },

    watch: {
      app: {
        files: ['app/**.*'],
        tasks: ['sync']
      }
    },

    // See https://github.com/c301/grunt-webstore-upload
    webstore_upload: {
      accounts: {
        // This is set up by environment variables from Travis. To
        // push locally, create a file with these variables defined
        // and source it before running "grunt publish:beta". E.g.:
        //
        // ./beta_credentials:
        //
        // export CHROME_CLIENT_ID="foo"
        // export CHROME_SECRET="bar"
        // export CHROME_REFRESH_TOKEN="baz"
        //
        // Then run "source ./beta_credentials; grunt publish_chrome_beta"
        //
        // To set up these variables to be available in Travis:
        // travis encrypt CHROME_CLIENT_ID=super_secret --add env.matrix
        // travis encrypt CHROME_SECRET=super_secret --add env.matrix
        // travis encrypt CHROME_REFRESH_TOKEN=super_secret --add env.matrix
        default: { //account under this section will be used by default
          publish: true, //publish item right after uploading. default false
          client_id: process.env.CHROME_CLIENT_ID,
          client_secret: process.env.CHROME_SECRET,
          refresh_token: process.env.CHROME_REFRESH_TOKEN
        }
      },
      extensions: {
        DIM: {
          appID: "apghicjnekejhfancbkahkhdckhdagna",
          publish: false,
          zip: "dist/chrome.zip"
        },
        beta: {
          appID: "mkiipknpfaacbjdagdeppdacpgpdjklc",
          zip: "dist/chrome.zip"
        }
      }
    },

    eslint: {
      target: ["app/scripts/**/*.js"],
      options: {
        fix: true
      }
    }
  });

  grunt.loadNpmTasks('grunt-webstore-upload');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-contrib-compress');
  grunt.loadNpmTasks('grunt-text-replace');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-postcss');
  grunt.loadNpmTasks('grunt-sass');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-sync');
  grunt.loadNpmTasks("grunt-eslint");

  grunt.registerTask('css', ['sass', 'postcss']);

  grunt.registerTask('default', ['eslint', 'build', 'watch']);

  grunt.registerTask('build', ['clean','css', 'sync', 'update_firefox_manifest']);

  grunt.registerTask('update_firefox_manifest', function() {
    var manifest = grunt.file.readJSON('dist/firefox/manifest.json');
    manifest.applications = firefoxBrowserSupport;
    grunt.file.write('dist/firefox/manifest.json', JSON.stringify(manifest, null, '\t'));
  });

  grunt.registerTask('update_chrome_beta_manifest', function() {
    var manifest = grunt.file.readJSON('dist/chrome/manifest.json');
    manifest.name = manifest.name + " Beta";
    manifest.version = betaVersion;
    grunt.file.write('dist/extension/chrome/manifest.json', JSON.stringify(manifest));
  });

  grunt.registerTask('update_firefox_beta_manifest', function() {
    var manifest = grunt.file.readJSON('dist/extension/firefox/manifest.json');
    manifest.name = manifest.name + " Beta";
    manifest.version = betaVersion;
    grunt.file.write('dist/extension/firefox/manifest.json', JSON.stringify(manifest));
  });

  grunt.registerTask('publish_chrome_beta', [
    'build',
    'copy:beta_icons_chrome',
    'replace:beta_version',
    'compress:chrome',
    'webstore_upload:beta'
  ]);

  grunt.registerTask('publish_firefox_beta', [
    'build',
    'copy:beta_icons_firefox',
    'replace:beta_version',
    'compress:firefox'
  ]);

  // Builds release-able extensions in dist/
  grunt.registerTask('build_extension', [
    'build',
    'replace:main_version',
    'compress:chrome',
    'compress:firefox',
  ]);

  grunt.registerTask('log_beta_version', function() {
    grunt.log.ok("New Beta version is " + betaVersion);
  });
}
<|endoftext|>


<commit_before>'use strict';

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

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    buildversion: '<%= pkg.version %>-' + grunt.template.today('yymmddHHMM'),
    clean : {
      dist : {
        files : [ {
          dot : true,
          src : [ 'dist/**' ]
        } ]
      },
      server : '.tmp'
    },
    ngAnnotate: {
      options: {
        singleQuotes: true,
      },
      dist: {
        files : {
          'dist/scrollable.js' : [
            'bower_components/iscroll/build/iscroll.js',
            'src/scrollable.js'
          ]
        }
      },
    },
    uglify: {
      options: {
        // Keep license informations
        preserveComments: 'some',
        sourceMap: true
      },
      dist: {
        files: { 'dist/scrollable.min.js': [ 'dist/scrollable.js' ] }
      }
    },
    jshint : {
      options : {
        jshintrc : '.jshintrc'
      },
      all : [ 'Gruntfile.js', 'src/*.js' ]
    },
    karma : {
      unit : {
        configFile : 'karma.conf.js',
        singleRun : true
      }
    },
    copy: {
      main: {
        files: [
          {expand: true, src: ['./*.md'], dest: 'dist/' , filter: 'isFile'}, // copy *.md
        ]
      }
    },
    'json-replace': {
      options: {
        space: '  ',
      },
      bowerdist: {
        options: {
          replace: {
            version: '<%= buildversion %>',
            devDependencies: '',
            scripts : '',
            homepage: 'https://github.com/wzr1337/bower-angular-momentum-scroll',
            repository: {
              'type': 'git',
              'url': 'git://github.com/wzr1337/bower-angular-momentum-scroll'
            },
            main: './scrollable.min.js'
          }
        },
        files: {'dist/bower.json': [ 'bower.json' ]}
      },
      bower: {
        options: {
          replace: {
            version: '<%= pkg.version %>'
          }
        },
        files: {'bower.json': [ 'bower.json' ]}
      }
    }
  });

  grunt.registerTask('build', [ 'clean:dist',
                                'jshint',
                                'ngAnnotate',
                                'uglify',
                                'copy',
                                'json-replace']);

  grunt.registerTask('test', ['karma']);

  grunt.registerTask('default', [ 'build' ]);
};
<commit_msg>chore(build): Added --pre-release flag<commit_after>'use strict';

module.exports = function(grunt) {

  var isPreReleaseBuild = grunt.option('pre-release') !== undefined;

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

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    buildversion: (isPreReleaseBuild) ? '<%= pkg.version %>-' + grunt.template.today('yymmddHHMM') : '<%= pkg.version %>',
    clean : {
      dist : {
        files : [ {
          dot : true,
          src : [ 'dist/**' ]
        } ]
      },
      server : '.tmp'
    },
    ngAnnotate: {
      options: {
        singleQuotes: true,
      },
      dist: {
        files : {
          'dist/scrollable.js' : [
            'bower_components/iscroll/build/iscroll.js',
            'src/scrollable.js'
          ]
        }
      },
    },
    uglify: {
      options: {
        // Keep license informations
        preserveComments: 'some',
        sourceMap: true
      },
      dist: {
        files: { 'dist/scrollable.min.js': [ 'dist/scrollable.js' ] }
      }
    },
    jshint : {
      options : {
        jshintrc : '.jshintrc'
      },
      all : [ 'Gruntfile.js', 'src/*.js' ]
    },
    karma : {
      unit : {
        configFile : 'karma.conf.js',
        singleRun : true
      }
    },
    copy: {
      main: {
        files: [
          {expand: true, src: ['./*.md'], dest: 'dist/' , filter: 'isFile'}, // copy *.md
        ]
      }
    },
    'json-replace': {
      options: {
        space: '  ',
      },
      bowerdist: {
        options: {
          replace: {
            version: '<%= buildversion %>',
            devDependencies: '',
            scripts : '',
            homepage: 'https://github.com/wzr1337/bower-angular-momentum-scroll',
            repository: {
              'type': 'git',
              'url': 'git://github.com/wzr1337/bower-angular-momentum-scroll'
            },
            main: './scrollable.min.js'
          }
        },
        files: {'dist/bower.json': [ 'bower.json' ]}
      },
      bower: {
        options: {
          replace: {
            version: '<%= pkg.version %>'
          }
        },
        files: {'bower.json': [ 'bower.json' ]}
      }
    }
  });

  grunt.registerTask('build', [ 'clean:dist',
                                'jshint',
                                'ngAnnotate',
                                'uglify',
                                'copy',
                                'json-replace']);

  grunt.registerTask('test', ['karma']);

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


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

  // Initialize global configuration variables.
  var config = grunt.file.readJSON('Gruntconfig.json');
  grunt.initConfig({
    config: config
  });

  // Load all included tasks.
  grunt.loadTasks(__dirname + '/tasks');

  // Define the default task to fully build and configure the project.
  var tasksDefault = [
    'clean:default',
    'mkdir:init',
    'drush:make',
    'symlink:profiles',
    'symlink:modules',
    'symlink:themes',
    'clean:sites',
    'symlink:sites',
    'mkdir:files',
    'copy:static'
  ];
  if (grunt.config.get(['composer', 'install'])) {
    tasksDefault.unshift('composer:install');
  }
  if (grunt.config.get('compass')) {
    tasksDefault.push('compass');
  }
  if (grunt.config.get('behat')) {
    tasksDefault.push('behat');
  }
  grunt.registerTask('default', tasksDefault);

};
<commit_msg>taking behat out of the default task to give us some more flexibility as to when it is run<commit_after>module.exports = function(grunt) {

  // Initialize global configuration variables.
  var config = grunt.file.readJSON('Gruntconfig.json');
  grunt.initConfig({
    config: config
  });

  // Load all included tasks.
  grunt.loadTasks(__dirname + '/tasks');

  // Define the default task to fully build and configure the project.
  var tasksDefault = [
    'clean:default',
    'mkdir:init',
    'drush:make',
    'symlink:profiles',
    'symlink:modules',
    'symlink:themes',
    'clean:sites',
    'symlink:sites',
    'mkdir:files',
    'copy:static'
  ];
  if (grunt.config.get(['composer', 'install'])) {
    tasksDefault.unshift('composer:install');
  }
  if (grunt.config.get('compass')) {
    tasksDefault.push('compass');
  }
  if (grunt.config.get('behat')) {
   // tasksDefault.push('behat');
  }
  grunt.registerTask('default', tasksDefault);

};
<|endoftext|>


<commit_before>var chessground = require('chessground');
var opposite = chessground.util.opposite;
var data = require('./data');
var analyse = require('./analyse');
var ground = require('./ground');
var keyboard = require('./keyboard');
var treePath = require('./path');
var actionMenu = require('./actionMenu').controller;
var autoplay = require('./autoplay');
var control = require('./control');
var promotion = require('./promotion');
var readDests = require('./util').readDests;
var throttle = require('./util').throttle;
var socket = require('./socket');
var m = require('mithril');

module.exports = function(opts) {

  this.data = data({}, opts.data);
  this.analyse = new analyse(this.data.steps);
  this.actionMenu = new actionMenu();
  this.autoplay = new autoplay(this);

  this.userId = opts.userId;

  var initialPath = opts.path ? treePath.read(opts.path) : treePath.default(this.analyse.firstPly());

  this.vm = {
    path: initialPath,
    pathStr: treePath.write(initialPath),
    step: null,
    cgConfig: null,
    comments: true,
    flip: false
  };

  this.flip = function() {
    this.vm.flip = !this.vm.flip;
    this.chessground.set({
      orientation: this.vm.flip ? this.data.opponent.color : this.data.player.color
    });
  }.bind(this);

  this.togglePlay = function(delay) {
    this.autoplay.toggle(delay);
    this.actionMenu.open = false;
  }.bind(this);

  var showGround = function() {
    var s;
    try {
      s = this.analyse.getStep(this.vm.path);
    } catch (e) {
      console.log(e);
    }
    if (!s) {
      this.vm.path = treePath.default(this.analyse.firstPly());
      this.vm.pathStr = treePath.write(this.vm.path);
      s = this.analyse.getStep(this.vm.path);
    }
    var color = s.ply % 2 === 0 ? 'white' : 'black';
    var dests = readDests(s.dests);
    var config = {
      fen: s.fen,
      turnColor: color,
      movable: {
        color: dests && Object.keys(dests).length > 0 ? color : null,
        dests: dests || {}
      },
      check: s.check,
      lastMove: s.uci ? [s.uci.substr(0, 2), s.uci.substr(2, 2)] : null,
    };
    if (!dests) {
      // premove while dests are loading from server
      config.turnColor = opposite(color);
      config.movable.color = color;
    }
    this.vm.step = s;
    this.vm.cgConfig = config;
    if (!this.chessground)
      this.chessground = ground.make(this.data, config, userMove);
    this.chessground.set(config);
    if (opts.onChange) opts.onChange(config.fen, this.vm.path);
    if (!dests) getDests();
  }.bind(this);

  var getDests = throttle(200, false, function() {
    if (this.vm.step.dests) return;
    this.socket.sendAnaDests({
      variant: this.data.game.variant.key,
      fen: this.vm.step.fen,
      path: this.vm.pathStr
    });
  }.bind(this));

  var sound = {
    move: throttle(50, false, $.sound.move),
    capture: throttle(50, false, $.sound.capture),
    check: throttle(50, false, $.sound.check)
  };

  this.jump = function(path) {
    this.vm.path = path;
    this.vm.pathStr = treePath.write(path);
    if (window.history.replaceState)
      window.history.replaceState(null, null, '#' + path[0].ply);
    showGround();
    if (this.vm.justPlayed !== this.vm.step.uci) {
      if (this.vm.step.san.indexOf('x') !== -1) sound.capture();
      else sound.move();
      this.vm.justPlayed = null;
    }
    if (/\+|\#/.test(this.vm.step.san)) sound.check();
  }.bind(this);

  this.userJump = function(path) {
    this.autoplay.stop();
    this.jump(path);
  }.bind(this);

  this.jumpToMain = function(ply) {
    this.userJump([{
      ply: ply,
      variation: null
    }]);
  }.bind(this);

  this.jumpToIndex = function(index) {
    this.jumpToMain(index + 1 + this.data.game.startedAtTurn);
  }.bind(this);

  var forsyth = function(role) {
    return role === 'knight' ? 'n' : role[0];
  };

  var userMove = function(orig, dest, capture) {
    this.vm.justPlayed = orig + dest;
    sound[capture ? 'capture' : 'move']();
    if (!promotion.start(this, orig, dest, sendMove)) sendMove(orig, dest);
  }.bind(this);

  var sendMove = function(orig, dest, prom) {
    var move = {
      orig: orig,
      dest: dest,
      variant: this.data.game.variant.key,
      fen: this.vm.step.fen,
      path: this.vm.pathStr
    };
    if (prom) move.promotion = prom;
    this.socket.sendAnaMove(move);
    // prepare premoving
    this.chessground.set({
      turnColor: this.chessground.data.movable.color,
      movable: {
        color: opposite(this.chessground.data.movable.color)
      }
    });
  }.bind(this);

  this.addStep = function(step, path) {
    var newPath = this.analyse.addStep(step, treePath.read(path));
    this.jump(newPath);
    m.redraw();
    this.chessground.playPremove();
  }.bind(this);

  this.addDests = function(dests, path) {
    this.analyse.addDests(dests, treePath.read(path));
    if (path === this.vm.pathStr) showGround();
    this.chessground.playPremove();
  }.bind(this);

  this.reset = function() {
    this.chessground.set(this.vm.situation);
    m.redraw();
  }.bind(this);

  this.socket = new socket(opts.socketSend, this);

  this.router = opts.routes;

  this.trans = function(key) {
    var str = opts.i18n[key] || key;
    Array.prototype.slice.call(arguments, 1).forEach(function(arg) {
      str = str.replace('%s', arg);
    });
    return str;
  };

  showGround();
  keyboard(this);
};
<commit_msg>dirty hack - closes #868<commit_after>var chessground = require('chessground');
var opposite = chessground.util.opposite;
var data = require('./data');
var analyse = require('./analyse');
var ground = require('./ground');
var keyboard = require('./keyboard');
var treePath = require('./path');
var actionMenu = require('./actionMenu').controller;
var autoplay = require('./autoplay');
var control = require('./control');
var promotion = require('./promotion');
var readDests = require('./util').readDests;
var throttle = require('./util').throttle;
var socket = require('./socket');
var m = require('mithril');

module.exports = function(opts) {

  this.data = data({}, opts.data);
  this.analyse = new analyse(this.data.steps);
  this.actionMenu = new actionMenu();
  this.autoplay = new autoplay(this);

  this.userId = opts.userId;

  var initialPath = opts.path ? treePath.read(opts.path) : treePath.default(this.analyse.firstPly());

  this.vm = {
    path: initialPath,
    pathStr: treePath.write(initialPath),
    step: null,
    cgConfig: null,
    comments: true,
    flip: false
  };

  this.flip = function() {
    this.vm.flip = !this.vm.flip;
    this.chessground.set({
      orientation: this.vm.flip ? this.data.opponent.color : this.data.player.color
    });
  }.bind(this);

  this.togglePlay = function(delay) {
    this.autoplay.toggle(delay);
    this.actionMenu.open = false;
  }.bind(this);

  var showGround = function() {
    var s;
    try {
      s = this.analyse.getStep(this.vm.path);
    } catch (e) {
      console.log(e);
    }
    if (!s) {
      this.vm.path = treePath.default(this.analyse.firstPly());
      this.vm.pathStr = treePath.write(this.vm.path);
      s = this.analyse.getStep(this.vm.path);
    }
    var color = s.ply % 2 === 0 ? 'white' : 'black';
    var dests = readDests(s.dests);
    var config = {
      fen: s.fen,
      turnColor: color,
      movable: {
        color: dests && Object.keys(dests).length > 0 ? color : null,
        dests: dests || {}
      },
      check: s.check,
      lastMove: s.uci ? [s.uci.substr(0, 2), s.uci.substr(2, 2)] : null,
    };
    if (!dests && !s.check) {
      // premove while dests are loading from server
      // can't use when in check because it highlights the wrong king
      config.turnColor = opposite(color);
      config.movable.color = color;
    }
    this.vm.step = s;
    this.vm.cgConfig = config;
    if (!this.chessground)
      this.chessground = ground.make(this.data, config, userMove);
    this.chessground.set(config);
    if (opts.onChange) opts.onChange(config.fen, this.vm.path);
    if (!dests) getDests();
  }.bind(this);

  var getDests = throttle(200, false, function() {
    if (this.vm.step.dests) return;
    this.socket.sendAnaDests({
      variant: this.data.game.variant.key,
      fen: this.vm.step.fen,
      path: this.vm.pathStr
    });
  }.bind(this));

  var sound = {
    move: throttle(50, false, $.sound.move),
    capture: throttle(50, false, $.sound.capture),
    check: throttle(50, false, $.sound.check)
  };

  this.jump = function(path) {
    this.vm.path = path;
    this.vm.pathStr = treePath.write(path);
    if (window.history.replaceState)
      window.history.replaceState(null, null, '#' + path[0].ply);
    showGround();
    if (this.vm.justPlayed !== this.vm.step.uci) {
      if (this.vm.step.san.indexOf('x') !== -1) sound.capture();
      else sound.move();
      this.vm.justPlayed = null;
    }
    if (/\+|\#/.test(this.vm.step.san)) sound.check();
  }.bind(this);

  this.userJump = function(path) {
    this.autoplay.stop();
    this.jump(path);
  }.bind(this);

  this.jumpToMain = function(ply) {
    this.userJump([{
      ply: ply,
      variation: null
    }]);
  }.bind(this);

  this.jumpToIndex = function(index) {
    this.jumpToMain(index + 1 + this.data.game.startedAtTurn);
  }.bind(this);

  var forsyth = function(role) {
    return role === 'knight' ? 'n' : role[0];
  };

  var userMove = function(orig, dest, capture) {
    this.vm.justPlayed = orig + dest;
    sound[capture ? 'capture' : 'move']();
    if (!promotion.start(this, orig, dest, sendMove)) sendMove(orig, dest);
  }.bind(this);

  var sendMove = function(orig, dest, prom) {
    var move = {
      orig: orig,
      dest: dest,
      variant: this.data.game.variant.key,
      fen: this.vm.step.fen,
      path: this.vm.pathStr
    };
    if (prom) move.promotion = prom;
    this.socket.sendAnaMove(move);
    // prepare premoving
    this.chessground.set({
      turnColor: this.chessground.data.movable.color,
      movable: {
        color: opposite(this.chessground.data.movable.color)
      }
    });
  }.bind(this);

  this.addStep = function(step, path) {
    var newPath = this.analyse.addStep(step, treePath.read(path));
    this.jump(newPath);
    m.redraw();
    this.chessground.playPremove();
  }.bind(this);

  this.addDests = function(dests, path) {
    this.analyse.addDests(dests, treePath.read(path));
    if (path === this.vm.pathStr) showGround();
    this.chessground.playPremove();
  }.bind(this);

  this.reset = function() {
    this.chessground.set(this.vm.situation);
    m.redraw();
  }.bind(this);

  this.socket = new socket(opts.socketSend, this);

  this.router = opts.routes;

  this.trans = function(key) {
    var str = opts.i18n[key] || key;
    Array.prototype.slice.call(arguments, 1).forEach(function(arg) {
      str = str.replace('%s', arg);
    });
    return str;
  };

  showGround();
  keyboard(this);
};
<|endoftext|>


<commit_before>// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt

frappe.provide('erpnext');

// add toolbar icon
$(document).bind('toolbar_setup', function() {
	frappe.app.name = "ERPNext";

	frappe.help_feedback_link = '
Feedback
'

	$('.navbar-home').html('');

	$('[data-link="docs"]').attr("href", "https://frappe.github.io/erpnext/")
	$('[data-link="issues"]').attr("href", "https://github.com/frappe/erpnext/issues")

	// default documentation goes to erpnext
	// $('[data-link-type="documentation"]').attr('data-path', '/erpnext/manual/index');

	// additional help links for erpnext
	var $help_menu = $('.dropdown-help ul .documentation-links');

	$('
'+__('User Forum')+'
').insertBefore($help_menu);
	$('
'+__('Chat')+'
').insertBefore($help_menu);
	$('
'+__('Report an Issue')+'
').insertBefore($help_menu);

});

// doctypes created via tree
$.extend(frappe.create_routes, {
	"Customer Group": "Tree/Customer Group",
	"Territory": "Tree/Territory",
	"Item Group": "Tree/Item Group",
	"Sales Person": "Tree/Sales Person",
	"Account": "Tree/Account",
	"Cost Center": "Tree/Cost Center"
});

// preferred modules for breadcrumbs
$.extend(frappe.breadcrumbs.preferred, {
	"Item Group": "Stock",
	"Customer Group": "Selling",
	"Supplier Group": "Buying",
	"Territory": "Selling",
	"Sales Person": "Selling",
	"Sales Partner": "Selling",
	"Brand": "Selling"
});
<commit_msg>Rename 'Chat' to 'Gitter Chat'<commit_after>// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt

frappe.provide('erpnext');

// add toolbar icon
$(document).bind('toolbar_setup', function() {
	frappe.app.name = "ERPNext";

	frappe.help_feedback_link = '
Feedback
'

	$('.navbar-home').html('');

	$('[data-link="docs"]').attr("href", "https://frappe.github.io/erpnext/")
	$('[data-link="issues"]').attr("href", "https://github.com/frappe/erpnext/issues")

	// default documentation goes to erpnext
	// $('[data-link-type="documentation"]').attr('data-path', '/erpnext/manual/index');

	// additional help links for erpnext
	var $help_menu = $('.dropdown-help ul .documentation-links');

	$('
'+__('User Forum')+'
').insertBefore($help_menu);
	$('
'+__('Gitter Chat')+'
').insertBefore($help_menu);
	$('
'+__('Report an Issue')+'
').insertBefore($help_menu);

});

// doctypes created via tree
$.extend(frappe.create_routes, {
	"Customer Group": "Tree/Customer Group",
	"Territory": "Tree/Territory",
	"Item Group": "Tree/Item Group",
	"Sales Person": "Tree/Sales Person",
	"Account": "Tree/Account",
	"Cost Center": "Tree/Cost Center"
});

// preferred modules for breadcrumbs
$.extend(frappe.breadcrumbs.preferred, {
	"Item Group": "Stock",
	"Customer Group": "Selling",
	"Supplier Group": "Buying",
	"Territory": "Selling",
	"Sales Person": "Selling",
	"Sales Partner": "Selling",
	"Brand": "Selling"
});
<|endoftext|>