<commit_before>/*
 * Jakefile for Rimu Markup (http://github.com/srackham/rimu).
 */
'use strict';

var pkg = require('./package.json');
var shelljs = require('shelljs');
var child_process = require('child_process');

/* Inputs and outputs */

var RIMU_VAR_LIB = 'bin/rimu-var.js';  // Script tag library format.
var RIMU_VAR_LIB_MIN = 'bin/rimu-var.min.js';
var RIMU_COMMONJS2_LIB = 'bin/rimu-commonjs2.js';  // Npm library format.
var MAIN_TS = 'src/main.ts';
var MAIN_JS = 'out/main.js';
var SOURCE = shelljs.ls('src/*.ts');
var TESTS = shelljs.ls('test/*.js');
var GH_PAGES_DIR = './gh-pages/';
var RIMUC = './bin/rimuc.js';

var DOCS = [
  {src: 'README.md', dst: 'doc/index.html', title: 'Rimu Markup', hasToc: true},
  {src: 'CHANGELOG.md', dst: 'doc/CHANGELOG.html', title: 'Rimu Change Log', hasToc: true},
  {src: 'doc/reference.rmu', dst: 'doc/reference.html', title: 'Rimu Reference', hasToc: true},
  {src: 'doc/tips.rmu', dst: 'doc/tips.html', title: 'Rimu Tips', hasToc: true},
  {src: 'doc/rimuplayground.rmu', dst: 'doc/rimuplayground.html', title: 'Rimu Playground', hasToc: true}
];

var HTML = [];
DOCS.forEach(function(doc) {
  HTML.push(doc.dst);
});

/* Utility functions. */

/*
 Execute shell commands in parallel then run the callback when they have all finished.
 `callback` defaults to the Jake async `complete` function.
 Abort if an error occurs.
 Write command output to the inherited stdout (unless the Jake --quiet option is set).
 Print a status message when each command starts and finishes (unless the Jake --quiet option is set).

 NOTE: This function is similar to the built-in jake.exec function but is twice as fast.
 */
function exec(commands, callback) {
  if (typeof commands === 'string') {
    commands = [commands];
  }
  callback = callback || complete;
  var remaining = commands.length;
  if (remaining === 0) {
    callback();
  } else {
    commands.forEach(function(command) {
      jake.logger.log('Starting: ' + command);
      child_process.exec(command, function(error, stdout, stderr) {
        if (!jake.program.opts.quiet) {
          process.stdout.write(stdout);
        }
        if (error !== null) {
          fail(error, error.code);
        }
        jake.logger.log('Finished: ' + command);
        remaining--;
        if (remaining === 0) {
          callback();
        }
      });
    });
  }
}

/*
 Tasks

 All tasks are synchronous (another task will not run until the current task has completed).
 Consequently all task dependencies are executed asynchronously in declaration order.
 The `exec` function ensures shell commands within each task run in parallel.
 */

desc('Run test task.');
task('default', ['test']);

desc('compile, jslint, test, tslint, build-gh-pages, validate-html.');
task('build', ['test', 'tslint', 'build-gh-pages', 'validate-html']);

desc('Update version number, tag and push to Github and npm. Use vers=x.y.z argument to set a new version number. Finally, rebuild and publish docs website.');
task('release', ['build', 'version', 'tag', 'publish', 'release-gh-pages']);

desc('Lint Javascript and JSON files.');
task('jslint', {async: true}, function() {
  var commands = TESTS.concat([RIMUC]).map(function(file) {
    return 'jshint ' + file;
  });
  commands.push('jsonlint --quiet package.json');
  exec(commands);
});

desc('Lint TypeScript source files.');
task('tslint', {async: true}, function() {
  complete(); return  // TODO: Uncomment when tslint is compatible with TypeScript 1.5.
  var commands = SOURCE.map(function(file) {
    return 'tslint -f ' + file;
  });
  exec(commands);
});

desc('Run tests (recompile if necessary).');
task('test', ['compile', 'jslint'], {async: true}, function() {
  var commands = TESTS.map(function(file) {
    return 'nodeunit ' + file;
  });
  exec(commands);
});

// TODO: Fix me.
desc('Compile Typescript to JavaScript then bundle CommonJS and scriptable libraries.');
task('compile', [MAIN_JS, RIMU_VAR_LIB, RIMU_COMMONJS2_LIB, RIMU_VAR_LIB_MIN]);

file(MAIN_JS, SOURCE, {async: true}, function() {
  shelljs.rm('./out/*');
  exec('tsc --project .');
});

file(RIMU_COMMONJS2_LIB, [MAIN_JS], {async: true}, function() {
  exec('webpack');
});

file(RIMU_VAR_LIB, [MAIN_JS], {async: true}, function() {
  exec('webpack --output-library-target var --output-file ' + RIMU_VAR_LIB);
});

function minify(src, dst) {
  var preamble = '/* ' + pkg.name + ' ' + pkg.version + ' (' + pkg.repository.url + ') */';
  var command = 'uglifyjs  --preamble "' + preamble + '" --output ' + dst + ' ' + src;
  exec(command);
};

file(RIMU_VAR_LIB_MIN, [RIMU_VAR_LIB], {async: true}, function() {
  minify(RIMU_VAR_LIB, RIMU_VAR_LIB_MIN)
});

desc('Generate HTML documentation');
task('html-docs', {async: true}, function() {
  var commands = DOCS.map(function(doc) {
    return 'node ./bin/rimuc.js' +
      ' --styled --debug --no-rimurc' +
      ' --output "' + doc.dst + '"' +
      ' --title "' + doc.title + '"' +
      (doc.hasToc ? ' --toc' : '' ) +
      ' ./examples/.rimurc ./doc/doc-header.rmu ' + doc.src;
  });
  exec(commands);
});

desc('Validate HTML documents with W3C Validator.');
task('validate-html', {async: true}, function() {
  var commands = HTML.map(function(file) {
    return 'html-validator --file ' + file + ' >/dev/null';
  });
  exec(commands);
});

desc('Display or update the project version number. Use vers=x.y.z argument to set a new version number.');
task('version', {async: true}, function() {
  var version = process.env.vers;
  if (!version) {
    console.log('\nversion: ' + pkg.version);
    complete();
  }
  else {
    if (!version.match(/^\d+\.\d+\.\d+$/)) {
      fail('Invalid version number: ' + version + '\n');
    }
    shelljs.sed('-i', /(\n\s*"version"\s*:\s*)"\d+\.\d+\.\d+"/, '$1' + '"' + version + '"', 'package.json');
    pkg.version = version;
    exec('git commit -m "Bump version number." package.json');
  }
});

desc('Create tag ' + pkg.version);
task('tag', ['test'], {async: true}, function() {
  exec('git tag -a -m "Tag ' + pkg.version + '" ' + pkg.version);
});

desc('Commit changes to local Git repo.');
task('commit', ['test'], {async: true}, function() {
  jake.exec('git commit -a', {interactive: true}, complete);
});

desc('push, publish-npm.');
task('publish', ['push', 'publish-npm']);

desc('Push local commits to Github.');
task('push', ['test'], {async: true}, function() {
  exec('git push -u --tags origin master');
});

desc('Publish to npm.');
task('publish-npm', {async: true}, ['test'], function() {
  exec('npm publish');
});

desc('Rebuild and validate documentation then commit and publish to GitHub Pages');
task('release-gh-pages', ['build-gh-pages', 'commit-gh-pages', 'push-gh-pages']);

desc('Generate documentation and copy to gh-pages repo');
task('build-gh-pages', ['html-docs', 'validate-html'], function() {
  shelljs.cp('-f', HTML.concat(RIMU_VAR_LIB), GH_PAGES_DIR)
});

desc('Commit changes to local Github Pages repo. Use msg=\'commit message\' to set a custom commit message.');
task('commit-gh-pages', ['test'], {async: true}, function() {
  var msg = process.env.msg;
  if (!msg) {
    msg = 'rebuilt project website';
  }
  shelljs.cd(GH_PAGES_DIR);
  exec('git commit -a -m "' + msg + '"', function () {
    shelljs.cd('..');
    complete();
  });
});

desc('Push Github Pages commits to Github.');
task('push-gh-pages', ['test'], {async: true}, function() {
  shelljs.cd(GH_PAGES_DIR);
  exec('git push origin gh-pages', function () {
    shelljs.cd('..');
    complete();
  });
});
<commit_msg>chore: Build published documentation with rimuc --debug off.<commit_after>/*
 * Jakefile for Rimu Markup (http://github.com/srackham/rimu).
 */
'use strict';

var pkg = require('./package.json');
var shelljs = require('shelljs');
var child_process = require('child_process');

/* Inputs and outputs */

var RIMU_VAR_LIB = 'bin/rimu-var.js';  // Script tag library format.
var RIMU_VAR_LIB_MIN = 'bin/rimu-var.min.js';
var RIMU_COMMONJS2_LIB = 'bin/rimu-commonjs2.js';  // Npm library format.
var MAIN_TS = 'src/main.ts';
var MAIN_JS = 'out/main.js';
var SOURCE = shelljs.ls('src/*.ts');
var TESTS = shelljs.ls('test/*.js');
var GH_PAGES_DIR = './gh-pages/';
var RIMUC = './bin/rimuc.js';

var DOCS = [
  {src: 'README.md', dst: 'doc/index.html', title: 'Rimu Markup', hasToc: true},
  {src: 'CHANGELOG.md', dst: 'doc/CHANGELOG.html', title: 'Rimu Change Log', hasToc: true},
  {src: 'doc/reference.rmu', dst: 'doc/reference.html', title: 'Rimu Reference', hasToc: true},
  {src: 'doc/tips.rmu', dst: 'doc/tips.html', title: 'Rimu Tips', hasToc: true},
  {src: 'doc/rimuplayground.rmu', dst: 'doc/rimuplayground.html', title: 'Rimu Playground', hasToc: true}
];

var HTML = [];
DOCS.forEach(function(doc) {
  HTML.push(doc.dst);
});

/* Utility functions. */

/*
 Execute shell commands in parallel then run the callback when they have all finished.
 `callback` defaults to the Jake async `complete` function.
 Abort if an error occurs.
 Write command output to the inherited stdout (unless the Jake --quiet option is set).
 Print a status message when each command starts and finishes (unless the Jake --quiet option is set).

 NOTE: This function is similar to the built-in jake.exec function but is twice as fast.
 */
function exec(commands, callback) {
  if (typeof commands === 'string') {
    commands = [commands];
  }
  callback = callback || complete;
  var remaining = commands.length;
  if (remaining === 0) {
    callback();
  } else {
    commands.forEach(function(command) {
      jake.logger.log('Starting: ' + command);
      child_process.exec(command, function(error, stdout, stderr) {
        if (!jake.program.opts.quiet) {
          process.stdout.write(stdout);
        }
        if (error !== null) {
          fail(error, error.code);
        }
        jake.logger.log('Finished: ' + command);
        remaining--;
        if (remaining === 0) {
          callback();
        }
      });
    });
  }
}

/*
 Tasks

 All tasks are synchronous (another task will not run until the current task has completed).
 Consequently all task dependencies are executed asynchronously in declaration order.
 The `exec` function ensures shell commands within each task run in parallel.
 */

desc('Run test task.');
task('default', ['test']);

desc('compile, lint and test.');
task('build', ['test', 'tslint']);

desc('Update version number, tag and push to Github and npm. Use vers=x.y.z argument to set a new version number. Finally, rebuild and publish docs website.');
task('release', ['build','build-gh-pages', 'version', 'tag', 'publish', 'release-gh-pages']);

desc('Lint Javascript and JSON files.');
task('jslint', {async: true}, function() {
  var commands = TESTS.concat([RIMUC]).map(function(file) {
    return 'jshint ' + file;
  });
  commands.push('jsonlint --quiet package.json');
  exec(commands);
});

desc('Lint TypeScript source files.');
task('tslint', {async: true}, function() {
  complete(); return  // TODO: Uncomment when tslint is compatible with TypeScript 1.5.
  var commands = SOURCE.map(function(file) {
    return 'tslint -f ' + file;
  });
  exec(commands);
});

desc('Run tests (recompile if necessary).');
task('test', ['compile', 'jslint'], {async: true}, function() {
  var commands = TESTS.map(function(file) {
    return 'nodeunit ' + file;
  });
  exec(commands);
});

// TODO: Fix me.
desc('Compile Typescript to JavaScript then bundle CommonJS and scriptable libraries.');
task('compile', [MAIN_JS, RIMU_VAR_LIB, RIMU_COMMONJS2_LIB, RIMU_VAR_LIB_MIN]);

file(MAIN_JS, SOURCE, {async: true}, function() {
  shelljs.rm('./out/*');
  exec('tsc --project .');
});

file(RIMU_COMMONJS2_LIB, [MAIN_JS], {async: true}, function() {
  exec('webpack');
});

file(RIMU_VAR_LIB, [MAIN_JS], {async: true}, function() {
  exec('webpack --output-library-target var --output-file ' + RIMU_VAR_LIB);
});

function minify(src, dst) {
  var preamble = '/* ' + pkg.name + ' ' + pkg.version + ' (' + pkg.repository.url + ') */';
  var command = 'uglifyjs  --preamble "' + preamble + '" --output ' + dst + ' ' + src;
  exec(command);
};

file(RIMU_VAR_LIB_MIN, [RIMU_VAR_LIB], {async: true}, function() {
  minify(RIMU_VAR_LIB, RIMU_VAR_LIB_MIN)
});

// Return array of rimuc commands to generate HTML documentation files.
function htmlDocCommands(debug) {
  return DOCS.map(function(doc) {
    return 'node ./bin/rimuc.js' +
      ' --styled --no-rimurc' +
      (debug ? ' --debug' : '') +
      ' --output "' + doc.dst + '"' +
      ' --title "' + doc.title + '"' +
      (doc.hasToc ? ' --toc' : '' ) +
      ' ./examples/.rimurc ./doc/doc-header.rmu ' + doc.src;
  });
}

desc('Generate HTML documentation');
task('html-docs', {async: true}, function() {
  exec(htmlDocCommands());
});

desc('Generate HTML documentation with rimuc --debug option');
task('html-docs-debug', {async: true}, function() {
  exec(htmlDocCommands(true));
});

desc('Validate HTML documents with W3C Validator.');
task('validate-html', {async: true}, function() {
  var commands = HTML.map(function(file) {
    return 'html-validator --file ' + file + ' >/dev/null';
  });
  exec(commands);
});

desc('Build HTML documentation with rimuc --debug option');
task('build-docs', ['build', 'html-docs-debug', 'validate-html']);

desc('Display or update the project version number. Use vers=x.y.z argument to set a new version number.');
task('version', {async: true}, function() {
  var version = process.env.vers;
  if (!version) {
    console.log('\nversion: ' + pkg.version);
    complete();
  }
  else {
    if (!version.match(/^\d+\.\d+\.\d+$/)) {
      fail('Invalid version number: ' + version + '\n');
    }
    shelljs.sed('-i', /(\n\s*"version"\s*:\s*)"\d+\.\d+\.\d+"/, '$1' + '"' + version + '"', 'package.json');
    pkg.version = version;
    exec('git commit -m "Bump version number." package.json');
  }
});

desc('Create tag ' + pkg.version);
task('tag', ['test'], {async: true}, function() {
  exec('git tag -a -m "Tag ' + pkg.version + '" ' + pkg.version);
});

desc('Commit changes to local Git repo.');
task('commit', ['test'], {async: true}, function() {
  jake.exec('git commit -a', {interactive: true}, complete);
});

desc('push, publish-npm.');
task('publish', ['push', 'publish-npm']);

desc('Push local commits to Github.');
task('push', ['test'], {async: true}, function() {
  exec('git push -u --tags origin master');
});

desc('Publish to npm.');
task('publish-npm', {async: true}, ['test'], function() {
  exec('npm publish');
});

desc('Rebuild and validate documentation then commit and publish to GitHub Pages');
task('release-gh-pages', ['build-gh-pages', 'commit-gh-pages', 'push-gh-pages']);

desc('Generate documentation and copy to local gh-pages repo');
task('build-gh-pages', ['html-docs', 'validate-html'], function() {
  shelljs.cp('-f', HTML.concat(RIMU_VAR_LIB), GH_PAGES_DIR)
});

desc('Commit changes to local gh-pages repo. Use msg=\'commit message\' to set a custom commit message.');
task('commit-gh-pages', ['test'], {async: true}, function() {
  var msg = process.env.msg;
  if (!msg) {
    msg = 'rebuilt project website';
  }
  shelljs.cd(GH_PAGES_DIR);
  exec('git commit -a -m "' + msg + '"', function () {
    shelljs.cd('..');
    complete();
  });
});

desc('Push gh-pages commits to Github.');
task('push-gh-pages', ['test'], {async: true}, function() {
  shelljs.cd(GH_PAGES_DIR);
  exec('git push origin gh-pages', function () {
    shelljs.cd('..');
    complete();
  });
});
<|endoftext|>


<commit_before>// Copyright (c) 2012 Titanium I.T. LLC. All rights reserved. See LICENSE.txt for details.
/*global desc, task, jake, fail, complete, directory, require, console, process */
(function () {
	"use strict";

	var REQUIRED_BROWSERS = [
//		"IE 8.0",
//		"IE 9.0",
//		"Firefox 19.0",
//		"Chrome 25.0",
//		"Safari 6.0"
	];

	var lint = require("./build/util/lint_runner.js");
	var testacular = require("./build/util/testacular_runner.js");

	desc("Lint and test");
	task("default", ["lint", "test"], function() {
		console.log("\n\nOK");
	});

	desc("Start Testacular server -- run this first");
	task("testacular", function() {
		testacular.serve(complete, fail);
	}, {async: true});

	desc("Lint everything");
	task("lint", [], function () {
		var passed = lint.validateFileList(browserFilesToLint(), browserLintOptions(), {});
		if (!passed) fail("Lint failed");
	});

	desc("Test browser code");
	task("test", function() {
		testacular.runTests(REQUIRED_BROWSERS, complete, fail);
	}, {async: true});

	function browserFilesToLint() {
		var files = new jake.FileList();
		files.include("src/client/**/*.js");
		return files.toArray();
	}

	function globalLintOptions() {
		return {
			bitwise:true,
			curly:false,
			eqeqeq:true,
			forin:true,
			immed:true,
			latedef:false,
			newcap:true,
			noarg:true,
			noempty:true,
			nonew:true,
			regexp:true,
			undef:true,
			strict:true,
			trailing:true
		};
	}

	function browserLintOptions() {
		var options = globalLintOptions();
		options.browser = true;
		return options;
	}

}());<commit_msg>Tweaked Jakfile task descriptions<commit_after>// Copyright (c) 2012 Titanium I.T. LLC. All rights reserved. See LICENSE.txt for details.
/*global desc, task, jake, fail, complete, directory, require, console, process */
(function () {
	"use strict";

	var REQUIRED_BROWSERS = [
//		"IE 8.0",
//		"IE 9.0",
//		"Firefox 19.0",
//		"Chrome 25.0",
//		"Safari 6.0"
	];

	var lint = require("./build/util/lint_runner.js");
	var testacular = require("./build/util/testacular_runner.js");

	desc("Lint and test");
	task("default", ["lint", "test"], function() {
		console.log("\n\nOK");
	});

	desc("Start Testacular server -- run this first");
	task("testacular", function() {
		testacular.serve(complete, fail);
	}, {async: true});

	desc("Lint everything");
	task("lint", [], function () {
		var passed = lint.validateFileList(browserFilesToLint(), browserLintOptions(), {});
		if (!passed) fail("Lint failed");
	});

	desc("Test everything");
	task("test", function() {
		testacular.runTests(REQUIRED_BROWSERS, complete, fail);
	}, {async: true});

	function browserFilesToLint() {
		var files = new jake.FileList();
		files.include("src/client/**/*.js");
		return files.toArray();
	}

	function globalLintOptions() {
		return {
			bitwise:true,
			curly:false,
			eqeqeq:true,
			forin:true,
			immed:true,
			latedef:false,
			newcap:true,
			noarg:true,
			noempty:true,
			nonew:true,
			regexp:true,
			undef:true,
			strict:true,
			trailing:true
		};
	}

	function browserLintOptions() {
		var options = globalLintOptions();
		options.browser = true;
		return options;
	}

}());<|endoftext|>


<commit_before>/*
 * Jakefile for Rimu Markup (http://github.com/srackham/rimu).
 */
'use strict';

var shelljs = require('shelljs');

/* Inputs and outputs */

var JAKEFILE = 'Jakefile.js';
var RIMU_JS = 'bin/rimu.js';
var RIMU_TS = 'src/rimu.ts';
var RIMU_MIN_JS = 'bin/rimu.min.js';
var RIMUC_JS = 'bin/rimuc.js';

var SOURCE = [
  'src/references.ts',
  'src/helpers.ts',
  'src/rimu.ts',
  'src/options.ts',
  'src/io.ts',
  'src/macros.ts',
  'src/lineblocks.ts',
  'src/delimitedblocks.ts',
  'src/lists.ts',
  'src/spans.ts',
  'src/quotes.ts',
  'src/replacements.ts'
];

var TESTS = shelljs.ls('test/*.js');

var DOCS = [
  {src: 'README.md', dst: 'doc/index.html', title: 'Rimu Markup'},
  {src: 'doc/tips.rmu', dst: 'doc/tips.html', title: 'Rimu Tips'},
  {src: 'doc/showcase.rmu', dst: 'doc/showcase.html', title: 'Rimu Showcase'}
];

var HTML = ['bin/rimuplayground.html'];
DOCS.forEach(function(doc) {
  HTML.push(doc.dst);
});

var PKG = JSON.parse(shelljs.cat('package.json'));

/* Utility functions. */

// shelljs.exec() wrapper.
// I don't use jake.exec() because it runs asynchronously and has no synchronous option.
function exec(command, options) {
  options = options || {};
  if (jake.program.opts.quiet) {
    options.silent = true; // Honor --quiet flag.
  }
  var result = shelljs.exec(command, options);
  if (result.code != 0) {
    if (options.silent) {
      shelljs.echo(result.output);
    }
    var msg = options.errorMessage || 'Error executing: ' + command;
    fail(msg, result.code);
  }
  return result;
}

/* Tasks */

desc('Run test task.');
task('default', ['test']);

desc('compile, lint, test, docs, validate-html.');
task('build', ['test', 'docs', 'validate-html']);

desc('Lint Javascript and JSON files.');
task('lint', function() {
  exec('jshint ' + TESTS.join(' ') + ' ' + RIMUC_JS);
  exec('jsonlint --quiet package.json');
});

desc('Run tests (recompile if necessary).');
task('test', ['compile', 'lint'], function() {
  TESTS.forEach(function(file) {
    // Use the TAP reporter because the default color terminal reporter intermittently
    // omits output when invoked with shelljs.exec().
    exec('nodeunit --reporter tap ' + file, {silent: true});
  });
});

desc('Compile Typescript to JavaScript then uglify');
task('compile', [RIMU_JS, RIMU_MIN_JS]);

file(RIMU_JS, SOURCE.concat(JAKEFILE), function() {
  exec('tsc --noImplicitAny --declaration --out ' + RIMU_JS + ' ' + RIMU_TS);
});

file(RIMU_MIN_JS, [RIMU_JS], function() {
  var preamble = '/* ' + PKG.name + ' ' + PKG.version + ' (' + PKG.repository.url + ') */';
  exec('uglifyjs  --preamble "' + preamble + '" --output ' + RIMU_MIN_JS + ' ' + RIMU_JS);
});

desc('Generate HTML documentation');
task('docs', function() {
  DOCS.forEach(function(doc) {
    exec('node ./bin/rimuc.js --output ' + doc.dst
            + ' --prepend "{--title}=\'' + doc.title + '\'"'
            + ' doc/doc-header.rmu ' + doc.src + ' doc/doc-footer.rmu'
    )
  });
});

desc('Validate HTML file with W3C Validator.');
task('validate-html', function() {
  HTML.forEach(function(file) {
    exec('w3cjs validate ' + file, {silent: true, errorMessage: 'Invalid HTML: ' + file});
  });
});

desc('Display or update the project version number. Use vers=x.y.z syntax to set a new version number.');
task('version', function() {
  var version = process.env.vers;
  if (!version) {
    shelljs.echo('\nversion: ' + PKG.version);
  }
  else {
    if (!version.match(/^\d+\.\d+\.\d+$/)) {
      fail('Invalid version number: ' + version + '\n');
    }
    ['package.json', 'smart.json'].forEach(function(file) {
      shelljs.sed('-i', /(\n\s*"version"\s*:\s*)"\d+\.\d+\.\d+"/, '$1' + '"' + version + '"', file);
    });
  }
});

var tag = 'v' + PKG.version;  // The 'v' prefix is required by Meteor package management (https://groups.google.com/forum/#!topic/meteor-talk/Q6fAH9tR27Q).
desc('Create tag ' + tag);
task('tag', ['test'], function() {
  shelljs.echo('git tag -a -m "Tag ' + tag + '" ' + tag);
});

desc('Commit changes to local Git repo. Use message="commit message" syntax to set the commit message.');
task('commit', ['test'], function() {
  var commit_message = process.env.message;
  if (!commit_message) {
    fail('Missing message environment variable: message="commit message"\n');
  }
  exec('git commit -a -m "' + commit_message + '"');
});

desc('push, publish-npm, publish-meteor.');
task('publish', ['push', 'publish-npm', 'publish-meteor']);

desc('Push local commits to Github.');
task('push', ['test'], function() {
  exec('git push -u --tags origin master');
});

desc('Publish to npm.');
task('publish-npm', ['test'], function() {
  exec('npm publish');
});

desc('Publish to Meteor.');
task('publish-meteor', ['test'], function() {
  exec('mrt publish .');
});

<commit_msg>JakeFile: Simplify source files array  generation.<commit_after>/*
 * Jakefile for Rimu Markup (http://github.com/srackham/rimu).
 */
'use strict';

var shelljs = require('shelljs');

/* Inputs and outputs */

var JAKEFILE = 'Jakefile.js';
var RIMU_JS = 'bin/rimu.js';
var RIMU_TS = 'src/rimu.ts';
var RIMU_MIN_JS = 'bin/rimu.min.js';
var RIMUC_JS = 'bin/rimuc.js';
var SOURCE = shelljs.ls('src/*.ts');
var TESTS = shelljs.ls('test/*.js');

var DOCS = [
  {src: 'README.md', dst: 'doc/index.html', title: 'Rimu Markup'},
  {src: 'doc/tips.rmu', dst: 'doc/tips.html', title: 'Rimu Tips'},
  {src: 'doc/showcase.rmu', dst: 'doc/showcase.html', title: 'Rimu Showcase'}
];

var HTML = ['bin/rimuplayground.html'];
DOCS.forEach(function(doc) {
  HTML.push(doc.dst);
});

var PKG = JSON.parse(shelljs.cat('package.json'));

/* Utility functions. */

// shelljs.exec() wrapper.
// I don't use jake.exec() because it runs asynchronously and has no synchronous option.
function exec(command, options) {
  options = options || {};
  if (jake.program.opts.quiet) {
    options.silent = true; // Honor --quiet flag.
  }
  var result = shelljs.exec(command, options);
  if (result.code != 0) {
    if (options.silent) {
      shelljs.echo(result.output);
    }
    var msg = options.errorMessage || 'Error executing: ' + command;
    fail(msg, result.code);
  }
  return result;
}

/* Tasks */

desc('Run test task.');
task('default', ['test']);

desc('compile, lint, test, docs, validate-html.');
task('build', ['test', 'docs', 'validate-html']);

desc('Lint Javascript and JSON files.');
task('lint', function() {
  exec('jshint ' + TESTS.join(' ') + ' ' + RIMUC_JS);
  exec('jsonlint --quiet package.json');
});

desc('Run tests (recompile if necessary).');
task('test', ['compile', 'lint'], function() {
  TESTS.forEach(function(file) {
    // Use the TAP reporter because the default color terminal reporter intermittently
    // omits output when invoked with shelljs.exec().
    exec('nodeunit --reporter tap ' + file, {silent: true});
  });
});

desc('Compile Typescript to JavaScript then uglify');
task('compile', [RIMU_JS, RIMU_MIN_JS]);

file(RIMU_JS, SOURCE.concat(JAKEFILE), function() {
  exec('tsc --noImplicitAny --declaration --out ' + RIMU_JS + ' ' + RIMU_TS);
});

file(RIMU_MIN_JS, [RIMU_JS], function() {
  var preamble = '/* ' + PKG.name + ' ' + PKG.version + ' (' + PKG.repository.url + ') */';
  exec('uglifyjs  --preamble "' + preamble + '" --output ' + RIMU_MIN_JS + ' ' + RIMU_JS);
});

desc('Generate HTML documentation');
task('docs', function() {
  DOCS.forEach(function(doc) {
    exec('node ./bin/rimuc.js --output ' + doc.dst
            + ' --prepend "{--title}=\'' + doc.title + '\'"'
            + ' doc/doc-header.rmu ' + doc.src + ' doc/doc-footer.rmu'
    )
  });
});

desc('Validate HTML file with W3C Validator.');
task('validate-html', function() {
  HTML.forEach(function(file) {
    exec('w3cjs validate ' + file, {silent: true, errorMessage: 'Invalid HTML: ' + file});
  });
});

desc('Display or update the project version number. Use vers=x.y.z syntax to set a new version number.');
task('version', function() {
  var version = process.env.vers;
  if (!version) {
    shelljs.echo('\nversion: ' + PKG.version);
  }
  else {
    if (!version.match(/^\d+\.\d+\.\d+$/)) {
      fail('Invalid version number: ' + version + '\n');
    }
    ['package.json', 'smart.json'].forEach(function(file) {
      shelljs.sed('-i', /(\n\s*"version"\s*:\s*)"\d+\.\d+\.\d+"/, '$1' + '"' + version + '"', file);
    });
  }
});

var tag = 'v' + PKG.version;  // The 'v' prefix is required by Meteor package management (https://groups.google.com/forum/#!topic/meteor-talk/Q6fAH9tR27Q).
desc('Create tag ' + tag);
task('tag', ['test'], function() {
  shelljs.echo('git tag -a -m "Tag ' + tag + '" ' + tag);
});

desc('Commit changes to local Git repo. Use message="commit message" syntax to set the commit message.');
task('commit', ['test'], function() {
  var commit_message = process.env.message;
  if (!commit_message) {
    fail('Missing message environment variable: message="commit message"\n');
  }
  exec('git commit -a -m "' + commit_message + '"');
});

desc('push, publish-npm, publish-meteor.');
task('publish', ['push', 'publish-npm', 'publish-meteor']);

desc('Push local commits to Github.');
task('push', ['test'], function() {
  exec('git push -u --tags origin master');
});

desc('Publish to npm.');
task('publish-npm', ['test'], function() {
  exec('npm publish');
});

desc('Publish to Meteor.');
task('publish-meteor', ['test'], function() {
  exec('mrt publish .');
});

<|endoftext|>


<commit_before>let contentfulConfig
try {
  contentfulConfig = require('./.contentful')
} catch (e) {
  contentfulConfig = {
    production: {
      spaceId: process.env.SPACE_ID,
      accessToken: process.env.ACCESS_TOKEN,
    },
  }
} finally {
  const { spaceId, accessToken } = contentfulConfig.production
  if (!spaceId || !accessToken) {
    throw new Error('Contentful space ID and access token need to be provided.')
  }
}

module.exports = {
  siteMetadata: {
    title: 'I AM MATTHIAS',
    description: 'A personal portfolio project',
    siteUrl: 'https://iammatthias.com',
    menuLinks: [
      {
        name: 'Home',
        slug: '/',
      },
      {
        name: 'Photography',
        slug: '/photography/',
      },
      {
        name: 'Blog',
        slug: '/blog/',
      },
      {
        name: 'About',
        slug: '/about/',
      },
    ],
    postsPerFirstPage: 6,
    postsPerPage: 6,
    basePath: '/',
  },
  plugins: [
    'gatsby-plugin-emotion',
    'gatsby-plugin-theme-ui',

    'gatsby-plugin-react-helmet',
    {
      resolve: `gatsby-plugin-printer`,
      options: {
        puppeteerLaunchOptions: {
          headless: true,
        },
      },
    },
    {
      resolve: `gatsby-plugin-google-fonts`,
      options: {
        fonts: [`Montserrat:400,900`, `Crimson Text`, `Inconsolata`],
        display: 'swap',
      },
    },
    {
      resolve: `gatsby-plugin-mdx`,
      options: {
        remarkPlugins: [`gatsby-remark-emojis`],
      },
    },
    {
      resolve: `gatsby-transformer-remark`,
      options: {
        plugins: [
          {
            resolve: `gatsby-remark-prismjs`,
          },
          `gatsby-remark-emojis`,
          `gatsby-remark-autolink-headers`,
          {
            resolve: `gatsby-remark-images-contentful`,
            options: {
              maxWidth: 650,
              backgroundColor: 'white',
              linkImagesToOriginal: false,
            },
          },
        ],
      },
    },
    `gatsby-plugin-catch-links`,
    {
      resolve: 'gatsby-source-contentful',
      options:
        process.env.NODE_ENV === 'development'
          ? contentfulConfig.development
          : contentfulConfig.production,
    },
    {
      resolve: `gatsby-plugin-segment-js`,
      options: {
        prodKey: process.env.SEGMENT,
        trackPage: true,
      },
    },
    'gatsby-plugin-sitemap',
    {
      resolve: 'gatsby-plugin-manifest',
      options: {
        name: 'I AM MATTIAS',
        short_name: 'IAM',
        start_url: '/',
        background_color: '#140D00',
        theme_color: '#140D00',
        display: 'minimal-ui',
        icon: './static/images/favicon.png',
      },
    },
    'gatsby-plugin-offline',
    {
      resolve: `gatsby-plugin-schema-snapshot`,
      options: {
        path: `./src/gatsby/schema/schema.gql`,
        update: process.env.GATSBY_UPDATE_SCHEMA_SNAPSHOT,
      },
    },
    'gatsby-plugin-netlify',
  ],
}
<commit_msg>Remark stuff<commit_after>let contentfulConfig
try {
  contentfulConfig = require('./.contentful')
} catch (e) {
  contentfulConfig = {
    production: {
      spaceId: process.env.SPACE_ID,
      accessToken: process.env.ACCESS_TOKEN,
    },
  }
} finally {
  const { spaceId, accessToken } = contentfulConfig.production
  if (!spaceId || !accessToken) {
    throw new Error('Contentful space ID and access token need to be provided.')
  }
}

module.exports = {
  siteMetadata: {
    title: 'I AM MATTHIAS',
    description: 'A personal portfolio project',
    siteUrl: 'https://iammatthias.com',
    menuLinks: [
      {
        name: 'Home',
        slug: '/',
      },
      {
        name: 'Photography',
        slug: '/photography/',
      },
      {
        name: 'Blog',
        slug: '/blog/',
      },
      {
        name: 'About',
        slug: '/about/',
      },
    ],
    postsPerFirstPage: 6,
    postsPerPage: 6,
    basePath: '/',
  },
  plugins: [
    'gatsby-plugin-emotion',
    'gatsby-plugin-theme-ui',

    'gatsby-plugin-react-helmet',
    {
      resolve: `gatsby-plugin-printer`,
      options: {
        puppeteerLaunchOptions: {
          headless: true,
        },
      },
    },
    {
      resolve: `gatsby-plugin-google-fonts`,
      options: {
        fonts: [`Montserrat:400,900`, `Crimson Text`, `Inconsolata`],
        display: 'swap',
      },
    },
    {
      resolve: `gatsby-plugin-mdx`,
    },
    {
      resolve: `gatsby-transformer-remark`,
      options: {
        plugins: [
          {
            resolve: `gatsby-remark-prismjs`,
          },
          `gatsby-remark-emojis`,
          `gatsby-remark-autolink-headers`,
          {
            resolve: `gatsby-remark-images-contentful`,
            options: {
              maxWidth: 650,
              backgroundColor: 'white',
              linkImagesToOriginal: false,
            },
          },
        ],
      },
    },
    `gatsby-plugin-catch-links`,
    {
      resolve: 'gatsby-source-contentful',
      options:
        process.env.NODE_ENV === 'development'
          ? contentfulConfig.development
          : contentfulConfig.production,
    },
    {
      resolve: `gatsby-plugin-segment-js`,
      options: {
        prodKey: process.env.SEGMENT,
        trackPage: true,
      },
    },
    'gatsby-plugin-sitemap',
    {
      resolve: 'gatsby-plugin-manifest',
      options: {
        name: 'I AM MATTIAS',
        short_name: 'IAM',
        start_url: '/',
        background_color: '#140D00',
        theme_color: '#140D00',
        display: 'minimal-ui',
        icon: './static/images/favicon.png',
      },
    },
    'gatsby-plugin-offline',
    {
      resolve: `gatsby-plugin-schema-snapshot`,
      options: {
        path: `./src/gatsby/schema/schema.gql`,
        update: process.env.GATSBY_UPDATE_SCHEMA_SNAPSHOT,
      },
    },
    'gatsby-plugin-netlify',
  ],
}
<|endoftext|>


<commit_before>module.exports = {
  linkPrefix: '/posm.io',
  siteMetadata: {
    title: 'POSM - Portable OpenStreetMap',
  },
  plugins: [
    {
      resolve: `gatsby-source-filesystem`,
      options: {
        path: `${__dirname}/src/images`,
        name: 'images',
      },
    },
    {
      resolve: `gatsby-source-filesystem`,
      options: {
        path: `${__dirname}/src/pages`,
        name: 'pages',
      },
    },
    `gatsby-transformer-remark`,
    `gatsby-transformer-sharp`,
    {
      resolve: `gatsby-typegen-remark`,
      options: {
        plugins: [
          {
            resolve: `gatsby-typegen-remark-responsive-image`,
            options: {
              maxWidth: 1000,
            },
          },
          'gatsby-typegen-remark-prismjs',
          'gatsby-typegen-remark-copy-linked-files',
          'gatsby-typegen-remark-smartypants',
        ],
      },
    },
    `gatsby-typegen-filesystem`,
    `gatsby-typegen-sharp`,
    `gatsby-plugin-sharp`,
  ],
}
<commit_msg>Drop prefix<commit_after>module.exports = {
  siteMetadata: {
    title: 'POSM - Portable OpenStreetMap',
  },
  plugins: [
    {
      resolve: `gatsby-source-filesystem`,
      options: {
        path: `${__dirname}/src/images`,
        name: 'images',
      },
    },
    {
      resolve: `gatsby-source-filesystem`,
      options: {
        path: `${__dirname}/src/pages`,
        name: 'pages',
      },
    },
    `gatsby-transformer-remark`,
    `gatsby-transformer-sharp`,
    {
      resolve: `gatsby-typegen-remark`,
      options: {
        plugins: [
          {
            resolve: `gatsby-typegen-remark-responsive-image`,
            options: {
              maxWidth: 1000,
            },
          },
          'gatsby-typegen-remark-prismjs',
          'gatsby-typegen-remark-copy-linked-files',
          'gatsby-typegen-remark-smartypants',
        ],
      },
    },
    `gatsby-typegen-filesystem`,
    `gatsby-typegen-sharp`,
    `gatsby-plugin-sharp`,
  ],
}
<|endoftext|>


<commit_before>module.exports = {
  siteMetadata: {
    title: `holdonnn`,
  },
  plugins: [
    {
      resolve: `gatsby-source-filesystem`,
      options: {
        name: `src`,
        path: `${__dirname}/src/`,
      },
    },
    `gatsby-plugin-react-helmet`,
    `gatsby-transformer-remark`,
  ],
}
<commit_msg>add 'gatsby-plugin-styled-components'<commit_after>module.exports = {
  siteMetadata: {
    title: `holdonnn`,
  },
  plugins: [
    {
      resolve: `gatsby-source-filesystem`,
      options: {
        name: `src`,
        path: `${__dirname}/src/`,
      },
    },
    `gatsby-plugin-react-helmet`,
    `gatsby-transformer-remark`,
    `gatsby-plugin-styled-components`,
  ],
}
<|endoftext|>


<commit_before>const lost = require('lost')
const pxtorem = require('postcss-pxtorem')

module.exports = {
  siteMetadata: {
    url: 'https://www.nicoespeon.com',
    title: "@nicoespeon's blog",
    subtitles: {
      en:
        'I write about web development, agile practices and personal organization.',
      fr:
        'J’écris sur le développement web, les pratiques agiles et l’organisation personnelle.',
    },
    greetings: {
      en: "Hi, I'm Nicolas 👋",
      fr: 'Salut, je suis Nicolas 👋',
    },
    menus: {
      en: [
        {
          label: 'Articles',
          path: '/',
        },
        {
          label: 'Talks',
          path: '/talks',
        },
        {
          label: 'Side projects',
          path: '/projects',
        },
        {
          label: 'Who I am',
          path: '/about',
        },
        {
          label: 'My recommendations',
          path: '/worth-reading',
        },
        {
          label: 'TIL (Today I learned)',
          path: '/tags/til',
        },
      ],
      fr: [
        {
          label: 'Articles',
          path: '/fr/',
        },
        {
          label: 'Talks',
          path: '/fr/talks',
        },
        {
          label: 'Projets personnels',
          path: '/fr/projects',
        },
        {
          label: 'Qui je suis',
          path: '/fr/about',
        },
        {
          label: 'Mes recommandations',
          path: '/fr/worth-reading',
        },
      ],
    },
    author: {
      name: 'Nicolas Carlo',
      email: 'nicolascarlo.espeon@gmail.com',
      twitter: 'nicoespeon',
      github: 'nicoespeon',
      linkedin: 'nicolas-carlo-095b243b',
      rss: '/feed.xml',
    },
    feedDescription:
      'I write about web development, agile practices and personal organization.',
  },
  plugins: [
    {
      resolve: 'gatsby-source-filesystem',
      options: {
        path: `${__dirname}/src/pages`,
        name: 'pages',
      },
    },
    {
      resolve: 'gatsby-plugin-feed',
      options: {
        query: `
          {
            site {
              siteMetadata {
                site_url: url
                title
                description: feedDescription
              }
            }
          }
        `,
        feeds: [
          {
            serialize: ({ query: { site, allMarkdownRemark } }) =>
              allMarkdownRemark.edges.map(edge =>
                Object.assign({}, edge.node.frontmatter, {
                  description: edge.node.frontmatter.description,
                  date: edge.node.frontmatter.date,
                  url: site.siteMetadata.site_url + edge.node.fields.slug,
                  guid: site.siteMetadata.site_url + edge.node.fields.slug,
                  custom_elements: [{ 'content:encoded': edge.node.html }],
                })
              ),
            query: `
              {
                allMarkdownRemark(
                  limit: 1000,
                  sort: { order: DESC, fields: [frontmatter___date] },
                  filter: { frontmatter: { layout: { eq: "post" }, draft: { ne: true } } }
                ) {
                  edges {
                    node {
                      html
                      fields {
                        slug
                      }
                      frontmatter {
                        title
                        date
                        layout
                        draft
                        description
                      }
                    }
                  }
                }
              }
            `,
            output: '/feed.xml',
          },
        ],
      },
    },
    {
      resolve: 'gatsby-transformer-remark',
      options: {
        plugins: [
          {
            resolve: 'gatsby-remark-images',
            options: {
              maxWidth: 960,
            },
          },
          {
            resolve: 'gatsby-remark-responsive-iframe',
            options: { wrapperStyle: 'margin-bottom: 1.0725rem' },
          },
          'gatsby-remark-autolink-headers',
          'gatsby-remark-prismjs',
          'gatsby-remark-copy-linked-files',
          'gatsby-remark-smartypants',
        ],
      },
    },
    'gatsby-transformer-sharp',
    'gatsby-plugin-sharp',
    {
      resolve: 'gatsby-plugin-google-analytics',
      options: { trackingId: 'UA-39957541-2' },
    },
    {
      resolve: 'gatsby-plugin-google-fonts',
      options: {
        fonts: ['roboto:400,400i,500,700'],
      },
    },
    {
      resolve: 'gatsby-plugin-sitemap',
      options: {
        query: `
            {
              site {
                siteMetadata {
                  url
                }
              }
              allSitePage(
                filter: {
                  path: { regex: "/^(?!/404/|/404.html|/dev-404-page/)/" }
                }
              ) {
                edges {
                  node {
                    path
                  }
                }
              }
          }`,
        output: '/sitemap.xml',
        serialize: ({ site, allSitePage }) =>
          allSitePage.edges.map(edge => {
            return {
              url: site.siteMetadata.url + edge.node.path,
              changefreq: 'daily',
              priority: 0.7,
            }
          }),
      },
    },
    'gatsby-plugin-offline',
    'gatsby-plugin-catch-links',
    'gatsby-plugin-react-helmet',
    {
      resolve: 'gatsby-plugin-sass',
      options: {
        postCssPlugins: [
          lost(),
          pxtorem({
            rootValue: 16,
            unitPrecision: 5,
            propList: [
              'font',
              'font-size',
              'line-height',
              'letter-spacing',
              'margin',
              'margin-top',
              'margin-left',
              'margin-bottom',
              'margin-right',
              'padding',
              'padding-top',
              'padding-left',
              'padding-bottom',
              'padding-right',
              'border-radius',
              'width',
              'max-width',
            ],
            selectorBlackList: [],
            replace: true,
            mediaQuery: false,
            minPixelValue: 0,
          }),
        ],
        precision: 8,
      },
    },
    'gatsby-plugin-favicon',
  ],
}
<commit_msg>Update my main description<commit_after>const lost = require('lost')
const pxtorem = require('postcss-pxtorem')

module.exports = {
  siteMetadata: {
    url: 'https://www.nicoespeon.com',
    title: "@nicoespeon's blog",
    subtitles: {
      en: 'I write about VS Code, web development and life in general.',
      fr:
        'J’écris à propos de VS Code, du développement web et de la vie en général.',
    },
    greetings: {
      en: "Hi, I'm Nicolas 👋",
      fr: 'Salut, je suis Nicolas 👋',
    },
    menus: {
      en: [
        {
          label: 'Articles',
          path: '/',
        },
        {
          label: 'Talks',
          path: '/talks',
        },
        {
          label: 'Side projects',
          path: '/projects',
        },
        {
          label: 'Who I am',
          path: '/about',
        },
        {
          label: 'My recommendations',
          path: '/worth-reading',
        },
        {
          label: 'TIL (Today I learned)',
          path: '/tags/til',
        },
      ],
      fr: [
        {
          label: 'Articles',
          path: '/fr/',
        },
        {
          label: 'Talks',
          path: '/fr/talks',
        },
        {
          label: 'Projets personnels',
          path: '/fr/projects',
        },
        {
          label: 'Qui je suis',
          path: '/fr/about',
        },
        {
          label: 'Mes recommandations',
          path: '/fr/worth-reading',
        },
      ],
    },
    author: {
      name: 'Nicolas Carlo',
      email: 'nicolascarlo.espeon@gmail.com',
      twitter: 'nicoespeon',
      github: 'nicoespeon',
      linkedin: 'nicolas-carlo-095b243b',
      rss: '/feed.xml',
    },
    feedDescription:
      'I write about web development, agile practices and personal organization.',
  },
  plugins: [
    {
      resolve: 'gatsby-source-filesystem',
      options: {
        path: `${__dirname}/src/pages`,
        name: 'pages',
      },
    },
    {
      resolve: 'gatsby-plugin-feed',
      options: {
        query: `
          {
            site {
              siteMetadata {
                site_url: url
                title
                description: feedDescription
              }
            }
          }
        `,
        feeds: [
          {
            serialize: ({ query: { site, allMarkdownRemark } }) =>
              allMarkdownRemark.edges.map(edge =>
                Object.assign({}, edge.node.frontmatter, {
                  description: edge.node.frontmatter.description,
                  date: edge.node.frontmatter.date,
                  url: site.siteMetadata.site_url + edge.node.fields.slug,
                  guid: site.siteMetadata.site_url + edge.node.fields.slug,
                  custom_elements: [{ 'content:encoded': edge.node.html }],
                })
              ),
            query: `
              {
                allMarkdownRemark(
                  limit: 1000,
                  sort: { order: DESC, fields: [frontmatter___date] },
                  filter: { frontmatter: { layout: { eq: "post" }, draft: { ne: true } } }
                ) {
                  edges {
                    node {
                      html
                      fields {
                        slug
                      }
                      frontmatter {
                        title
                        date
                        layout
                        draft
                        description
                      }
                    }
                  }
                }
              }
            `,
            output: '/feed.xml',
          },
        ],
      },
    },
    {
      resolve: 'gatsby-transformer-remark',
      options: {
        plugins: [
          {
            resolve: 'gatsby-remark-images',
            options: {
              maxWidth: 960,
            },
          },
          {
            resolve: 'gatsby-remark-responsive-iframe',
            options: { wrapperStyle: 'margin-bottom: 1.0725rem' },
          },
          'gatsby-remark-autolink-headers',
          'gatsby-remark-prismjs',
          'gatsby-remark-copy-linked-files',
          'gatsby-remark-smartypants',
        ],
      },
    },
    'gatsby-transformer-sharp',
    'gatsby-plugin-sharp',
    {
      resolve: 'gatsby-plugin-google-analytics',
      options: { trackingId: 'UA-39957541-2' },
    },
    {
      resolve: 'gatsby-plugin-google-fonts',
      options: {
        fonts: ['roboto:400,400i,500,700'],
      },
    },
    {
      resolve: 'gatsby-plugin-sitemap',
      options: {
        query: `
            {
              site {
                siteMetadata {
                  url
                }
              }
              allSitePage(
                filter: {
                  path: { regex: "/^(?!/404/|/404.html|/dev-404-page/)/" }
                }
              ) {
                edges {
                  node {
                    path
                  }
                }
              }
          }`,
        output: '/sitemap.xml',
        serialize: ({ site, allSitePage }) =>
          allSitePage.edges.map(edge => {
            return {
              url: site.siteMetadata.url + edge.node.path,
              changefreq: 'daily',
              priority: 0.7,
            }
          }),
      },
    },
    'gatsby-plugin-offline',
    'gatsby-plugin-catch-links',
    'gatsby-plugin-react-helmet',
    {
      resolve: 'gatsby-plugin-sass',
      options: {
        postCssPlugins: [
          lost(),
          pxtorem({
            rootValue: 16,
            unitPrecision: 5,
            propList: [
              'font',
              'font-size',
              'line-height',
              'letter-spacing',
              'margin',
              'margin-top',
              'margin-left',
              'margin-bottom',
              'margin-right',
              'padding',
              'padding-top',
              'padding-left',
              'padding-bottom',
              'padding-right',
              'border-radius',
              'width',
              'max-width',
            ],
            selectorBlackList: [],
            replace: true,
            mediaQuery: false,
            minPixelValue: 0,
          }),
        ],
        precision: 8,
      },
    },
    'gatsby-plugin-favicon',
  ],
}
<|endoftext|>


<commit_before>module.exports = {
  siteMetadata: {
    title: `Gaëtan Kueny`,
    description: `Développeur depuis maintenant 2 ans et demi, j'ai une grande affinité avec le front-end et les tests bien fait. Pas full-stack mais touche à tout, je suis également à l'aise sur du Symfony / php.`,
    author: `@gkueny`,
  },
  plugins: [
    {
      resolve: `gatsby-plugin-sass`,
      options: {
        postCssPlugins: [
          require("tailwindcss"),
          require("./tailwind.config.js"),
        ],
      },
    },
    `gatsby-plugin-react-helmet`,
    {
      resolve: `gatsby-source-filesystem`,
      options: {
        name: `images`,
        path: `${__dirname}/src/images`,
      },
    },
    `gatsby-transformer-sharp`,
    `gatsby-plugin-sharp`,
    {
      resolve: `gatsby-plugin-manifest`,
      options: {
        name: `gatsby-starter-default`,
        short_name: `starter`,
        start_url: `/`,
        background_color: `#fff`,
        theme_color: `#fff`,
        display: `minimal-ui`,
        icon: `src/images/profil.jpg`,
      },
    },
    `gatsby-plugin-offline`,
    {
      resolve: "gatsby-source-grav",
      options: {
        url: "https://gkueny-admin.herokuapp.com",
      },
    },
  ],
};
<commit_msg>Update pwa config<commit_after>module.exports = {
  siteMetadata: {
    title: `Gaëtan Kueny`,
    description: `Développeur depuis maintenant 2 ans et demi, j'ai une grande affinité avec le front-end et les tests bien fait. Pas full-stack mais touche à tout, je suis également à l'aise sur du Symfony / php.`,
    author: `@gkueny`,
  },
  plugins: [
    {
      resolve: `gatsby-plugin-sass`,
      options: {
        postCssPlugins: [
          require("tailwindcss"),
          require("./tailwind.config.js"),
        ],
      },
    },
    `gatsby-plugin-react-helmet`,
    {
      resolve: `gatsby-source-filesystem`,
      options: {
        name: `images`,
        path: `${__dirname}/src/images`,
      },
    },
    `gatsby-transformer-sharp`,
    `gatsby-plugin-sharp`,
    {
      resolve: `gatsby-plugin-manifest`,
      options: {
        name: `gkueny`,
        short_name: `gkueny`,
        start_url: `/`,
        background_color: `#fff`,
        theme_color: `#fff`,
        display: `minimal-ui`,
        icon: `src/images/profil.jpg`,
      },
    },
    `gatsby-plugin-offline`,
    {
      resolve: "gatsby-source-grav",
      options: {
        url: "https://gkueny-admin.herokuapp.com",
      },
    },
  ],
};
<|endoftext|>


<commit_before>const siteConfig = require("./content/data.json");
const regexExcludeRobots = /^(?!\/(dev-404-page|404|offline-plugin-app-shell-fallback|tags|categories)).*$/;

module.exports = {
  siteMetadata: {
    url: siteConfig.url,
    siteUrl: siteConfig.url,
    name: siteConfig.name,
    description: siteConfig.description
  },
  plugins: [
    "gatsby-plugin-react-helmet",
    "gatsby-plugin-typescript",
    "gatsby-plugin-sass",
    {
      resolve: "gatsby-source-filesystem",
      options: {
        name: "content",
        path: `${__dirname}/${siteConfig.paths.content}`
      }
    },
    {
      resolve: "gatsby-transformer-remark",
      options: {
        plugins: [
          {
            resolve: "gatsby-remark-images",
            options: {
              maxWidth: 1200
            }
          },
          {
            resolve: "gatsby-remark-responsive-iframe"
          },
          "gatsby-remark-prismjs",
          {
            resolve: "gatsby-remark-copy-linked-files",
            options: {
              destinationDir: `${__dirname}/public/static`
            }
          }
        ]
      }
    },
    "gatsby-plugin-netlify",
    {
      resolve: "gatsby-plugin-google-analytics",
      options: {
        trackingId: siteConfig.ids.google
      }
    },
    {
      resolve: "gatsby-plugin-nprogress",
      options: {
        color: "#55B4D4"
      }
    },
    "gatsby-transformer-json",
    "gatsby-transformer-sharp",
    "gatsby-plugin-sharp",
    "gatsby-plugin-catch-links",
    "gatsby-plugin-twitter",
    {
      resolve: "gatsby-plugin-sitemap",
      options: {
        output: "/sitemap.xml",
        query: `
          {
            site {
              siteMetadata {
                siteUrl
              }
            }
            allSitePage(
              filter: {
                path: {
                  regex: "${regexExcludeRobots}"
                }
              }
            ) {
              edges {
                node {
                  path
                }
              }
            }
        }`
      }
    },
    {
      resolve: "gatsby-plugin-manifest",
      options: {
        name: siteConfig.title,
        short_name: siteConfig.title,
        description: siteConfig.description,
        start_url: "",
        background_color: "#FAFAFA",
        theme_color: "#FF6A00",
        display: "minimal-ui",
        icons: [
          {
            src: "/logos/logo-192.png",
            sizes: "192x192",
            type: "image/png"
          },
          {
            src: "/logos/logo-512.png",
            sizes: "512x512",
            type: "image/png"
          }
        ]
      }
    },
    "gatsby-plugin-offline",
    {
      resolve: "@andrew-codes/gatsby-plugin-elasticlunr-search",
      options: {
        fields: ["title", "category", "tags"],
        resolvers: {
          MarkdownRemark: {
            url: node => node.fields.slug,
            date: node => node.frontmatter.date,
            title: node => node.frontmatter.title,
            style: node => node.frontmatter.style,
            abstract: node => node.frontmatter.abstract,
            category: node => node.frontmatter.category,
            tags: node => node.frontmatter.tags
          }
        }
      }
    },
    {
      resolve: "gatsby-plugin-copy-files",
      options: {
        source: `${__dirname}/content/public/static`,
        destination: "/static"
      }
    },
    {
      resolve: "gatsby-plugin-copy-files",
      options: {
        source: `${__dirname}/content/public`,
        destination: "/"
      }
    }
    /*
    {
      resolve: "gatsby-plugin-feed",
      options: {
        setup(ref) {
          const ret = ref.query.site.siteMetadata.rssMetadata;
          ret.allMarkdownRemark = ref.query.allMarkdownRemark;
          ret.generator = "GatsbyJS Material Starter";
          return ret;
        },
        query: `
        {
          site {
            siteMetadata {
              rssMetadata {
                site_url
                feed_url
                title
                description
                image_url
                author
                copyright
              }
            }
          }
        }
      `,
        feeds: [
          {
            serialize(ctx) {
              const rssMetadata = ctx.query.site.siteMetadata.rssMetadata;
              return ctx.query.allMarkdownRemark.edges.map(edge => ({
                categories: edge.node.frontmatter.tags,
                date: edge.node.frontmatter.date,
                title: edge.node.frontmatter.title,
                description: edge.node.excerpt,
                author: rssMetadata.author,
                url: rssMetadata.site_url + edge.node.fields.slug,
                guid: rssMetadata.site_url + edge.node.fields.slug,
                custom_elements: [{ "content:encoded": edge.node.html }]
              }));
            },
            query: `
            {
              allMarkdownRemark(
                limit: 1000,
                sort: { order: DESC, fields: [frontmatter___date] },
              ) {
                edges {
                  node {
                    excerpt
                    html
                    timeToRead
                    fields { slug }
                    frontmatter {
                      title
                      cover
                      date
                      category
                      tags
                    }
                  }
                }
              }
            }
          `,
            output: config.siteRss
          }
        ]
      }
    }
    */
  ]
};
<commit_msg>Move google analytics code to head<commit_after>const siteConfig = require("./content/data.json");
const regexExcludeRobots = /^(?!\/(dev-404-page|404|offline-plugin-app-shell-fallback|tags|categories)).*$/;

module.exports = {
  siteMetadata: {
    url: siteConfig.url,
    siteUrl: siteConfig.url,
    name: siteConfig.name,
    description: siteConfig.description
  },
  plugins: [
    "gatsby-plugin-react-helmet",
    "gatsby-plugin-typescript",
    "gatsby-plugin-sass",
    {
      resolve: "gatsby-source-filesystem",
      options: {
        name: "content",
        path: `${__dirname}/${siteConfig.paths.content}`
      }
    },
    {
      resolve: "gatsby-transformer-remark",
      options: {
        plugins: [
          {
            resolve: "gatsby-remark-images",
            options: {
              maxWidth: 1200
            }
          },
          {
            resolve: "gatsby-remark-responsive-iframe"
          },
          "gatsby-remark-prismjs",
          {
            resolve: "gatsby-remark-copy-linked-files",
            options: {
              destinationDir: `${__dirname}/public/static`
            }
          }
        ]
      }
    },
    "gatsby-plugin-netlify",
    {
      resolve: "gatsby-plugin-google-analytics",
      options: {
        trackingId: siteConfig.ids.google,
        head: true
      }
    },
    {
      resolve: "gatsby-plugin-nprogress",
      options: {
        color: "#55B4D4"
      }
    },
    "gatsby-transformer-json",
    "gatsby-transformer-sharp",
    "gatsby-plugin-sharp",
    "gatsby-plugin-catch-links",
    "gatsby-plugin-twitter",
    {
      resolve: "gatsby-plugin-sitemap",
      options: {
        output: "/sitemap.xml",
        query: `
          {
            site {
              siteMetadata {
                siteUrl
              }
            }
            allSitePage(
              filter: {
                path: {
                  regex: "${regexExcludeRobots}"
                }
              }
            ) {
              edges {
                node {
                  path
                }
              }
            }
        }`
      }
    },
    {
      resolve: "gatsby-plugin-manifest",
      options: {
        name: siteConfig.title,
        short_name: siteConfig.title,
        description: siteConfig.description,
        start_url: "",
        background_color: "#FAFAFA",
        theme_color: "#FF6A00",
        display: "minimal-ui",
        icons: [
          {
            src: "/logos/logo-192.png",
            sizes: "192x192",
            type: "image/png"
          },
          {
            src: "/logos/logo-512.png",
            sizes: "512x512",
            type: "image/png"
          }
        ]
      }
    },
    "gatsby-plugin-offline",
    {
      resolve: "@andrew-codes/gatsby-plugin-elasticlunr-search",
      options: {
        fields: ["title", "category", "tags"],
        resolvers: {
          MarkdownRemark: {
            url: node => node.fields.slug,
            date: node => node.frontmatter.date,
            title: node => node.frontmatter.title,
            style: node => node.frontmatter.style,
            abstract: node => node.frontmatter.abstract,
            category: node => node.frontmatter.category,
            tags: node => node.frontmatter.tags
          }
        }
      }
    },
    {
      resolve: "gatsby-plugin-copy-files",
      options: {
        source: `${__dirname}/content/public/static`,
        destination: "/static"
      }
    },
    {
      resolve: "gatsby-plugin-copy-files",
      options: {
        source: `${__dirname}/content/public`,
        destination: "/"
      }
    }
    /*
    {
      resolve: "gatsby-plugin-feed",
      options: {
        setup(ref) {
          const ret = ref.query.site.siteMetadata.rssMetadata;
          ret.allMarkdownRemark = ref.query.allMarkdownRemark;
          ret.generator = "GatsbyJS Material Starter";
          return ret;
        },
        query: `
        {
          site {
            siteMetadata {
              rssMetadata {
                site_url
                feed_url
                title
                description
                image_url
                author
                copyright
              }
            }
          }
        }
      `,
        feeds: [
          {
            serialize(ctx) {
              const rssMetadata = ctx.query.site.siteMetadata.rssMetadata;
              return ctx.query.allMarkdownRemark.edges.map(edge => ({
                categories: edge.node.frontmatter.tags,
                date: edge.node.frontmatter.date,
                title: edge.node.frontmatter.title,
                description: edge.node.excerpt,
                author: rssMetadata.author,
                url: rssMetadata.site_url + edge.node.fields.slug,
                guid: rssMetadata.site_url + edge.node.fields.slug,
                custom_elements: [{ "content:encoded": edge.node.html }]
              }));
            },
            query: `
            {
              allMarkdownRemark(
                limit: 1000,
                sort: { order: DESC, fields: [frontmatter___date] },
              ) {
                edges {
                  node {
                    excerpt
                    html
                    timeToRead
                    fields { slug }
                    frontmatter {
                      title
                      cover
                      date
                      category
                      tags
                    }
                  }
                }
              }
            }
          `,
            output: config.siteRss
          }
        ]
      }
    }
    */
  ]
};
<|endoftext|>


<commit_before>/**********************************************************************
    Freeciv-web - the web version of Freeciv. http://play.freeciv.org/
    Copyright (C) 2009-2015  The Freeciv-web project

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Affero General Public License for more details.

    You should have received a copy of the GNU Affero General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

***********************************************************************/

var toplevel_menu_items = ["help_terrain", "help_economy", "help_cities",
    "help_city_improvements", "help_wonders_of_the_world", "help_units",
    "help_combat", "help_technology"];
var hidden_menu_items = ["help_connecting", "help_languages", "help_governor",
    "help_chatline", "help_about", "help_worklist_editor"];

/**************************************************************************
 Show the Freeciv-web Help Dialog
**************************************************************************/
function show_help()
{
  $("#tabs-hel").show();
  $("#help_menu").remove();
  $("#help_info_page").remove();
  $("

").appendTo("#tabs-hel");
  for (var sec_id in helpdata_order) {
    var key = helpdata_order[sec_id];
    var sec_name = helpdata[key]['name'];
    if (hidden_menu_items.indexOf(key) > -1) {
      continue;
    } else if (key.indexOf("help_gen") != -1) {
      generate_help_menu(key);
    } else if (toplevel_menu_items.indexOf(key) > -1) {
      generate_help_toplevel(key);
    } else {
      var parent_key = find_parent_help_key(key);
      $("
"
        + helpdata_tag_to_title(key) + "
").appendTo(parent_key);
    }
  }

  $("#help_menu").menu({
    select: function( event, ui ) {handle_help_menu_select(ui); }
  });

  show_help_intro();
  $("#tabs-hel").css("height", $(window).height() - 60);
  $("#help_info_page").css("max-width", $(window).width() - $("#help_menu").width() - 60);

}

/**************************************************************************
...
**************************************************************************/
function show_help_intro()
{
  $.get( "/docs/help_intro.txt", function( data ) {
      $("#help_info_page").html(data);
  });
}

/**************************************************************************
...
**************************************************************************/
function generate_help_menu(key)
{
  var impr_id;
  var improvement;
  if (key == "help_gen_terrain") {
    for (var terrain_id in terrains) {
      var terrain = terrains[terrain_id];
      $("
"
        + terrain['name'] + "
").appendTo("#help_terrain_ul");
    }
  } else if (key == "help_gen_improvements") {
    for (impr_id in improvements) {
      improvement = improvements[impr_id];
      if (is_wonder(improvement)) continue;
      $("
"
        + improvement['name'] + "
").appendTo("#help_city_improvements_ul");
    }
  } else if (key == "help_gen_wonders") {
    for (impr_id in improvements) {
      improvement = improvements[impr_id];
      if (!is_wonder(improvement)) continue;
      $("
"
        + improvement['name'] + "
").appendTo("#help_wonders_of_the_world_ul");
    }
  } else if (key == "help_gen_units") {
    for (var i = 0; i < unittype_ids_alphabetic().length; i++) {
      var unit_id = unittype_ids_alphabetic()[i];
      var punit_type = unit_types[unit_id];

       $("
"
          + punit_type['name'] + "
").appendTo("#help_units_ul");
    }
  } else if (key == "help_gen_techs") {
    for (var tech_id in techs) {
      var tech = techs[tech_id];
      if (tech_id == 0) continue;
      $("
"
          + tech['name'] + "
").appendTo("#help_technology_ul");
    }
  } else if (key == "help_gen_ruleset") {
    $("
"
       + "About Current Ruleset" + "
").appendTo(
          find_parent_help_key(key));
  }
}

/**************************************************************************
...
**************************************************************************/
function render_sprite(sprite)
{
  var msg = "

";
  return msg;
}

/**************************************************************************
...
**************************************************************************/
function generate_help_toplevel(key)
{
  var parent_key = find_parent_help_key(key);
  $("
"
     + helpdata_tag_to_title(key) + "
").appendTo(parent_key);
  $("

").appendTo("#" + key);

}

/**************************************************************************
...
**************************************************************************/
function find_parent_help_key(key)
{
  if (key == "help_terrain_alterations") {
    return "#help_terrain_ul";
  } else if (key == "help_villages" || key == "help_borders") {
    return "#help_terrain_ul";
  } else if (key == "help_food" || key == "help_production" || key == "help_trade") {
    return "#help_economy_ul";
  } else if (key == "help_specialists" || key == "help_happiness" || key == "help_pollution"
        || key == "help_plague" || key == "help_migration") {
    return "#help_cities_ul";
  } else if (key == "help_combat_example_1" || key == "help_combat_example_2") {
    return "#help_combat_ul";
  } else  {
    return "#help_menu";
  }
}
/**************************************************************************
...
**************************************************************************/
function handle_help_menu_select( ui )
{
  var selected_tag = $(ui.item).data("helptag");
  if (selected_tag.indexOf("help_gen") != -1) {
    generate_help_text(selected_tag);
  } else if (selected_tag == "help_copying") {
    $.get( "/docs/LICENSE.txt", function( data ) {
      $("#help_info_page").html("
Freeciv-Web License
" + data.replace(/\n/g, "
"));
    });
  } else if (selected_tag == "help_controls") {
    $.get( "/docs/controls.txt", function( data ) {
      $("#help_info_page").html(data.replace(/\n/g, "
"));
    });
  } else {
    var msg = "
" + helpdata_tag_to_title(selected_tag) + "
" + helpdata[selected_tag]['text'];
    $("#help_info_page").html(msg);
  }

  $("#help_info_page").focus();
}

/**************************************************************************
...
**************************************************************************/
function generate_help_text(key)
{
  var rulesetdir = ruledir_from_ruleset_name(ruleset_control['name'], "");
  var msg = "";

  if (key.indexOf("help_gen_terrain") != -1) {
    var terrain = terrains[parseInt(key.replace("help_gen_terrain_", ""))];
    msg = "
" + terrain['name'] + "
" + terrain['helptext']
	    + "

Movement cost: " + terrain['movement_cost']
	    + "
Defense bonus: " + terrain['defense_bonus']
	    + "
Food/Prod/Trade: " + terrain['output'][0] + "/"
	    + terrain['output'][1] + "/" + terrain['output'][2];
  } else if (key.indexOf("help_gen_improvements") != -1 || key.indexOf("help_gen_wonders") != -1) {
    var improvement = improvements[parseInt(key.replace("help_gen_wonders_", "").replace("help_gen_improvements_", ""))];
    msg = "
" + improvement['name'] + "
"
	    + render_sprite(get_improvement_image_sprite(improvement)) + "
"
	    + improvement['helptext']
            + "

Cost: " + improvement['build_cost']
            + "
Upkeep: " + improvement['upkeep'];
    var reqs = get_improvement_requirements(improvement['id']);
    if (reqs != null) {
      msg += "
Requirements: ";
      for (var n = 0; n < reqs.length; n++) {
       msg += techs[reqs[n]]['name'] + " ";
      }
    }
    msg += "

<button class='help_button' onclick=\"show_wikipedia_dialog('" + improvement['name'] + "');\">Wikipedia on "
	    + improvement['name'] +  "</button>";
  } else if (key.indexOf("help_gen_units") != -1) {
    var punit_type = unit_types[parseInt(key.replace("help_gen_units_", ""))];
    msg = "
" + punit_type['name'] + "
";
    msg += render_sprite(get_unit_type_image_sprite(punit_type));
    msg += "
";
    msg += "
"
    msg += "Cost: " + punit_type['build_cost'];
            /*+ "
Upkeep: " + improvement['upkeep'];*/
    msg += "
Attack: " + punit_type['attack_strength'];
    msg += "
Defense: " + punit_type['defense_strength'];
    msg += "
Firepower: " + punit_type['firepower'];
    msg += "
Hitpoints: " + punit_type['hp'];
    msg += "
Moves: " + move_points_text(punit_type['move_rate']);
    msg += "
Vision: " + punit_type['vision_radius_sq'];

    var ireqs = get_improvement_requirements(punit_type['impr_requirement']);
    if (ireqs != null && techs[ireqs] != null) {
      msg += "
Building Requirements: ";
      for (var m = 0; m < ireqs.length; m++) {
        msg += techs[ireqs[m]]['name'] + " ";
      }
    }
    var treq = punit_type['tech_requirement'];
    if (treq != null && techs[treq] != null) {
      msg += "
Tech Requirements: " + techs[treq]['name'];
    }
    msg += "
"

    msg += "

" + punit_type['helptext'] + "

";

    msg += "<button class='help_button' onclick=\"show_wikipedia_dialog('"
        + punit_type['name'] + "');\">Wikipedia on " + punit_type['name']
        +  "</button>";
  } else if (key.indexOf("help_gen_techs") != -1) {
    var tech = techs[parseInt(key.replace("help_gen_techs_", ""))];
    msg = "
" + tech['name'] + "
"
	    + render_sprite(get_technology_image_sprite(tech)) + "
"
	    + get_advances_text(tech['id']);
    msg += "

<button class='help_button' onclick=\"show_wikipedia_dialog('" + tech['name'] + "');\">Wikipedia on "
	    + tech['name'] +  "</button>";
  } else if (key == "help_gen_ruleset") {
    msg = "
" + ruleset_control['name'] + "
";
    if (ruleset_summary != null) {
      msg += "
" + ruleset_summary.replace(/\n/g, "
") + "
";
    }
    if (ruleset_description != null) {
      msg += "
" + ruleset_description.replace(/\n/g, "
") + "
";
    }
  }

  $("#help_info_page").html(msg);

  /* Freeciv has code that generates certain help texts based on the
   * ruleset. This code is written in C. It is huge. Replicating it in
   * JavaScript would be a huge task and probably introduce bugs. Even if
   * someone did it it would be hard to keep the replicated code in sync as
   * the corresponding Freeciv C code kept evolving.
   *
   * Freeciv has the tool freeciv-manual. It can use the ruleset based auto
   * help text generation. It can output HTML. Some of its HTML output is
   * machine readable enough to be usable for Freeciv-web.
   *
   * Use the machine readable and wanted parts of freeciv-manual's output to
   * add auto generated help texts for the current ruleset. */
  if (rulesetdir.length != 0) {
    if (key.indexOf("help_gen_units") != -1) {
      var utype_id = parseInt(key.replace("help_gen_units_", ""));

      /* Add the auto generated unit type facts freeciv-manual prepends to
       * the unit type's help text. */
      $("#helptext").load("../man/" + rulesetdir + "7.html #utype"
                          + utype_id + " .helptext");
    }
  }

  $(".help_button").button();
}

/**************************************************************************
...
**************************************************************************/
function helpdata_tag_to_title(tag)
{
  var result = tag.replace("_of_the_world", "").replace("help_", "").replace("gen_", "").replace("misc_", "").replace(/_/g, " ");
  return to_title_case(result);

}
<commit_msg>manual: show help for individual governments.<commit_after>/**********************************************************************
    Freeciv-web - the web version of Freeciv. http://play.freeciv.org/
    Copyright (C) 2009-2015  The Freeciv-web project

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Affero General Public License for more details.

    You should have received a copy of the GNU Affero General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

***********************************************************************/

var toplevel_menu_items = ["help_terrain", "help_economy", "help_cities",
    "help_city_improvements", "help_wonders_of_the_world", "help_units",
    "help_combat", "help_technology", "help_government"];
var hidden_menu_items = ["help_connecting", "help_languages", "help_governor",
    "help_chatline", "help_about", "help_worklist_editor"];

/**************************************************************************
 Show the Freeciv-web Help Dialog
**************************************************************************/
function show_help()
{
  $("#tabs-hel").show();
  $("#help_menu").remove();
  $("#help_info_page").remove();
  $("

").appendTo("#tabs-hel");
  for (var sec_id in helpdata_order) {
    var key = helpdata_order[sec_id];
    var sec_name = helpdata[key]['name'];
    if (hidden_menu_items.indexOf(key) > -1) {
      continue;
    } else if (key.indexOf("help_gen") != -1) {
      generate_help_menu(key);
    } else if (toplevel_menu_items.indexOf(key) > -1) {
      generate_help_toplevel(key);
    } else {
      var parent_key = find_parent_help_key(key);
      $("
"
        + helpdata_tag_to_title(key) + "
").appendTo(parent_key);
    }
  }

  $("#help_menu").menu({
    select: function( event, ui ) {handle_help_menu_select(ui); }
  });

  show_help_intro();
  $("#tabs-hel").css("height", $(window).height() - 60);
  $("#help_info_page").css("max-width", $(window).width() - $("#help_menu").width() - 60);

}

/**************************************************************************
...
**************************************************************************/
function show_help_intro()
{
  $.get( "/docs/help_intro.txt", function( data ) {
      $("#help_info_page").html(data);
  });
}

/**************************************************************************
...
**************************************************************************/
function generate_help_menu(key)
{
  var impr_id;
  var improvement;
  if (key == "help_gen_terrain") {
    for (var terrain_id in terrains) {
      var terrain = terrains[terrain_id];
      $("
"
        + terrain['name'] + "
").appendTo("#help_terrain_ul");
    }
  } else if (key == "help_gen_improvements") {
    for (impr_id in improvements) {
      improvement = improvements[impr_id];
      if (is_wonder(improvement)) continue;
      $("
"
        + improvement['name'] + "
").appendTo("#help_city_improvements_ul");
    }
  } else if (key == "help_gen_wonders") {
    for (impr_id in improvements) {
      improvement = improvements[impr_id];
      if (!is_wonder(improvement)) continue;
      $("
"
        + improvement['name'] + "
").appendTo("#help_wonders_of_the_world_ul");
    }
  } else if (key == "help_gen_units") {
    for (var i = 0; i < unittype_ids_alphabetic().length; i++) {
      var unit_id = unittype_ids_alphabetic()[i];
      var punit_type = unit_types[unit_id];

       $("
"
          + punit_type['name'] + "
").appendTo("#help_units_ul");
    }
  } else if (key == "help_gen_techs") {
    for (var tech_id in techs) {
      var tech = techs[tech_id];
      if (tech_id == 0) continue;
      $("
"
          + tech['name'] + "
").appendTo("#help_technology_ul");
    }
  } else if (key == "help_gen_governments") {
    for (var gov_id in governments) {
      var pgov = governments[gov_id];

      $("
"
          + pgov['name'] + "
").appendTo("#help_government_ul");
    }
  } else if (key == "help_gen_ruleset") {
    $("
"
       + "About Current Ruleset" + "
").appendTo(
          find_parent_help_key(key));
  }
}

/**************************************************************************
...
**************************************************************************/
function render_sprite(sprite)
{
  var msg = "

";
  return msg;
}

/**************************************************************************
...
**************************************************************************/
function generate_help_toplevel(key)
{
  var parent_key = find_parent_help_key(key);
  $("
"
     + helpdata_tag_to_title(key) + "
").appendTo(parent_key);
  $("

").appendTo("#" + key);

}

/**************************************************************************
...
**************************************************************************/
function find_parent_help_key(key)
{
  if (key == "help_terrain_alterations") {
    return "#help_terrain_ul";
  } else if (key == "help_villages" || key == "help_borders") {
    return "#help_terrain_ul";
  } else if (key == "help_food" || key == "help_production" || key == "help_trade") {
    return "#help_economy_ul";
  } else if (key == "help_specialists" || key == "help_happiness" || key == "help_pollution"
        || key == "help_plague" || key == "help_migration") {
    return "#help_cities_ul";
  } else if (key == "help_combat_example_1" || key == "help_combat_example_2") {
    return "#help_combat_ul";
  } else  {
    return "#help_menu";
  }
}
/**************************************************************************
...
**************************************************************************/
function handle_help_menu_select( ui )
{
  var selected_tag = $(ui.item).data("helptag");
  if (selected_tag.indexOf("help_gen") != -1) {
    generate_help_text(selected_tag);
  } else if (selected_tag == "help_copying") {
    $.get( "/docs/LICENSE.txt", function( data ) {
      $("#help_info_page").html("
Freeciv-Web License
" + data.replace(/\n/g, "
"));
    });
  } else if (selected_tag == "help_controls") {
    $.get( "/docs/controls.txt", function( data ) {
      $("#help_info_page").html(data.replace(/\n/g, "
"));
    });
  } else {
    var msg = "
" + helpdata_tag_to_title(selected_tag) + "
" + helpdata[selected_tag]['text'];
    $("#help_info_page").html(msg);
  }

  $("#help_info_page").focus();
}

/**************************************************************************
...
**************************************************************************/
function generate_help_text(key)
{
  var rulesetdir = ruledir_from_ruleset_name(ruleset_control['name'], "");
  var msg = "";

  if (key.indexOf("help_gen_terrain") != -1) {
    var terrain = terrains[parseInt(key.replace("help_gen_terrain_", ""))];
    msg = "
" + terrain['name'] + "
" + terrain['helptext']
	    + "

Movement cost: " + terrain['movement_cost']
	    + "
Defense bonus: " + terrain['defense_bonus']
	    + "
Food/Prod/Trade: " + terrain['output'][0] + "/"
	    + terrain['output'][1] + "/" + terrain['output'][2];
  } else if (key.indexOf("help_gen_improvements") != -1 || key.indexOf("help_gen_wonders") != -1) {
    var improvement = improvements[parseInt(key.replace("help_gen_wonders_", "").replace("help_gen_improvements_", ""))];
    msg = "
" + improvement['name'] + "
"
	    + render_sprite(get_improvement_image_sprite(improvement)) + "
"
	    + improvement['helptext']
            + "

Cost: " + improvement['build_cost']
            + "
Upkeep: " + improvement['upkeep'];
    var reqs = get_improvement_requirements(improvement['id']);
    if (reqs != null) {
      msg += "
Requirements: ";
      for (var n = 0; n < reqs.length; n++) {
       msg += techs[reqs[n]]['name'] + " ";
      }
    }
    msg += "

<button class='help_button' onclick=\"show_wikipedia_dialog('" + improvement['name'] + "');\">Wikipedia on "
	    + improvement['name'] +  "</button>";
  } else if (key.indexOf("help_gen_units") != -1) {
    var punit_type = unit_types[parseInt(key.replace("help_gen_units_", ""))];
    msg = "
" + punit_type['name'] + "
";
    msg += render_sprite(get_unit_type_image_sprite(punit_type));
    msg += "
";
    msg += "
"
    msg += "Cost: " + punit_type['build_cost'];
            /*+ "
Upkeep: " + improvement['upkeep'];*/
    msg += "
Attack: " + punit_type['attack_strength'];
    msg += "
Defense: " + punit_type['defense_strength'];
    msg += "
Firepower: " + punit_type['firepower'];
    msg += "
Hitpoints: " + punit_type['hp'];
    msg += "
Moves: " + move_points_text(punit_type['move_rate']);
    msg += "
Vision: " + punit_type['vision_radius_sq'];

    var ireqs = get_improvement_requirements(punit_type['impr_requirement']);
    if (ireqs != null && techs[ireqs] != null) {
      msg += "
Building Requirements: ";
      for (var m = 0; m < ireqs.length; m++) {
        msg += techs[ireqs[m]]['name'] + " ";
      }
    }
    var treq = punit_type['tech_requirement'];
    if (treq != null && techs[treq] != null) {
      msg += "
Tech Requirements: " + techs[treq]['name'];
    }
    msg += "
"

    msg += "

" + punit_type['helptext'] + "

";

    msg += "<button class='help_button' onclick=\"show_wikipedia_dialog('"
        + punit_type['name'] + "');\">Wikipedia on " + punit_type['name']
        +  "</button>";
  } else if (key.indexOf("help_gen_techs") != -1) {
    var tech = techs[parseInt(key.replace("help_gen_techs_", ""))];
    msg = "
" + tech['name'] + "
"
	    + render_sprite(get_technology_image_sprite(tech)) + "
"
	    + get_advances_text(tech['id']);
    msg += "

<button class='help_button' onclick=\"show_wikipedia_dialog('" + tech['name'] + "');\">Wikipedia on "
	    + tech['name'] +  "</button>";
  } else if (key == "help_gen_ruleset") {
    msg = "
" + ruleset_control['name'] + "
";
    if (ruleset_summary != null) {
      msg += "
" + ruleset_summary.replace(/\n/g, "
") + "
";
    }
    if (ruleset_description != null) {
      msg += "
" + ruleset_description.replace(/\n/g, "
") + "
";
    }
  } else if (key.indexOf("help_gen_governments") != -1) {
    var pgov = governments[parseInt(key.replace("help_gen_governments_",
                                                ""))];

    msg = "
" + pgov['name'] + "
";
    msg += "

" + pgov['helptext'] + "

";
  }

  $("#help_info_page").html(msg);

  /* Freeciv has code that generates certain help texts based on the
   * ruleset. This code is written in C. It is huge. Replicating it in
   * JavaScript would be a huge task and probably introduce bugs. Even if
   * someone did it it would be hard to keep the replicated code in sync as
   * the corresponding Freeciv C code kept evolving.
   *
   * Freeciv has the tool freeciv-manual. It can use the ruleset based auto
   * help text generation. It can output HTML. Some of its HTML output is
   * machine readable enough to be usable for Freeciv-web.
   *
   * Use the machine readable and wanted parts of freeciv-manual's output to
   * add auto generated help texts for the current ruleset. */
  if (rulesetdir.length != 0) {
    if (key.indexOf("help_gen_units") != -1) {
      var utype_id = parseInt(key.replace("help_gen_units_", ""));

      /* Add the auto generated unit type facts freeciv-manual prepends to
       * the unit type's help text. */
      $("#helptext").load("../man/" + rulesetdir + "7.html #utype"
                          + utype_id + " .helptext");
    } else if (key.indexOf("help_gen_governments") != -1) {
      var gov_id = parseInt(key.replace("help_gen_governments_", ""));

      /* Add the auto generated government facts freeciv-manual prepends to
       * the government type's help text. */
      $("#helptext").load("../man/" + rulesetdir + "6.html #gov"
                          + gov_id + " .helptext");
    }
  }

  $(".help_button").button();
}

/**************************************************************************
...
**************************************************************************/
function helpdata_tag_to_title(tag)
{
  var result = tag.replace("_of_the_world", "").replace("help_", "").replace("gen_", "").replace("misc_", "").replace(/_/g, " ");
  return to_title_case(result);

}
<|endoftext|>


<commit_before>/*global angular*/
/*jslint bitwise: true, plusplus: true, regexp: true*/

( function() {'use strict';

    angular.module('em.base64', []);

    angular.module('em.base64').factory('base64', function() {
      var keyStr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
      return {
        encode : function(input) {
          var output, chr1, chr2, chr3, enc1, enc2, enc3, enc4, i;
          output = '';
          enc4 = '';
          i = 0;

          while (i < input.length) {
            chr1 = input.charCodeAt(i++);
            chr2 = input.charCodeAt(i++);
            chr3 = input.charCodeAt(i++);

            enc1 = chr1 >> 2;
            enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
            enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
            enc4 = chr3 & 63;

            if (isNaN(chr2)) {
              enc3 = enc4 = 64;
            } else if (isNaN(chr3)) {
              enc4 = 64;
            }

            output = output + keyStr.charAt(enc1) + keyStr.charAt(enc2) + keyStr.charAt(enc3) + keyStr.charAt(enc4);
            chr1 = chr2 = chr3 = '';
            enc1 = enc2 = enc3 = enc4 = '';
          }
          return output;
        },

        decode : function(input) {
          var output, chr1, chr2, chr3, enc1, enc2, enc3, enc4, base64test, i;
          output = '';
          enc4 = '';
          i = 0;

          // remove all characters that are not A-Z, a-z, 0-9, +, /, or =
          base64test = /[^A-Za-z0-9\+\/\=]/g;
          if (base64test.exec(input)) {
            alert("There were invalid base64 characters in the input text.\n" + "Valid base64 characters are A-Z, a-z, 0-9, '+', '/',and '='\n" + "Expect errors in decoding.");
          }
          input = input.replace(/[^A-Za-z0-9\+\/\=]/g, '');

          while (i < input.length) {
            enc1 = keyStr.indexOf(input.charAt(i++));
            enc2 = keyStr.indexOf(input.charAt(i++));
            enc3 = keyStr.indexOf(input.charAt(i++));
            enc4 = keyStr.indexOf(input.charAt(i++));

            chr1 = (enc1 << 2) | (enc2 >> 4);
            chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
            chr3 = ((enc3 & 3) << 6) | enc4;

            output = output + String.fromCharCode(chr1);

            if (enc3 !== 64) {
              output = output + String.fromCharCode(chr2);
            }
            if (enc4 !== 64) {
              output = output + String.fromCharCode(chr3);
            }

            chr1 = chr2 = chr3 = '';
            enc1 = enc2 = enc3 = enc4 = '';
          }
          return output;
        }
      };
    });
  }());
<commit_msg>Removed function wrap from em.base64 module.<commit_after>/*global alert */
/*jslint bitwise: true, regexp: true, white: true */
'use strict';

angular.module('em.base64', []);

angular.module('em.base64').factory('base64', function() {
  var keyStr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  return {
    encode : function(input) {
      var output, chr1, chr2, chr3, enc1, enc2, enc3, enc4, i;
      output = '';
      enc4 = '';
      i = 0;

      while (i < input.length) {
        chr1 = input.charCodeAt(i++);
        chr2 = input.charCodeAt(i++);
        chr3 = input.charCodeAt(i++);

        enc1 = chr1 >> 2;
        enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
        enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
        enc4 = chr3 & 63;

        if (isNaN(chr2)) {
          enc3 = enc4 = 64;
        } else if (isNaN(chr3)) {
          enc4 = 64;
        }

        output = output + keyStr.charAt(enc1) + keyStr.charAt(enc2) + keyStr.charAt(enc3) + keyStr.charAt(enc4);
        chr1 = chr2 = chr3 = '';
        enc1 = enc2 = enc3 = enc4 = '';
      }
      return output;
    },

    decode : function(input) {
      var output, chr1, chr2, chr3, enc1, enc2, enc3, enc4, base64test, i;
      output = '';
      enc4 = '';
      i = 0;

      // remove all characters that are not A-Z, a-z, 0-9, +, /, or =
      base64test = /[^A-Za-z0-9\+\/\=]/g;
      if (base64test.exec(input)) {
        alert("There were invalid base64 characters in the input text.\n" + "Valid base64 characters are A-Z, a-z, 0-9, '+', '/',and '='\n" + "Expect errors in decoding.");
      }
      input = input.replace(/[^A-Za-z0-9\+\/\=]/g, '');

      while (i < input.length) {
        enc1 = keyStr.indexOf(input.charAt(i++));
        enc2 = keyStr.indexOf(input.charAt(i++));
        enc3 = keyStr.indexOf(input.charAt(i++));
        enc4 = keyStr.indexOf(input.charAt(i++));

        chr1 = (enc1 << 2) | (enc2 >> 4);
        chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
        chr3 = ((enc3 & 3) << 6) | enc4;

        output = output + String.fromCharCode(chr1);

        if (enc3 !== 64) {
          output = output + String.fromCharCode(chr2);
        }
        if (enc4 !== 64) {
          output = output + String.fromCharCode(chr3);
        }

        chr1 = chr2 = chr3 = '';
        enc1 = enc2 = enc3 = enc4 = '';
      }
      return output;
    }
  };
});
<|endoftext|>