<commit_before>/* Connect/Express Session Store for PostgreSQL */

/* for node-lint */
/*global Buffer: false, clearInterval: false, clearTimeout: false, console: false, global: false, module: false, process: false, querystring: false, require: false, setInterval: false, setTimeout: false, util: false, __filename: false, __dirname: false */

/* FIXME: update expiration so that the session does not expire when user is using the system! */

var debug = require('nor-debug');
var util = require('util');
var NoPg = require('nor-nopg');
var Store = require('connect').session.Store;

function NoPgStore(options) {
	debug.log('NoPgStore(options=', options, ')');
	options = options || {};
	//Store.call(this, options);
	var self = this;

	if(!options.pg) { throw TypeError("No postgresql configuration! pg=" + util.inspect(options.pg)); }

	self._type = options.type || 'Session';
	self._pg = options.pg;

	// FIXME: Implement rollback if connection fails
	// FIXME: Currently the app will UPDATE the type each time the NoPgStore instance is created. Maybe not do that if nothing is changed.
	self._type_promise = NoPg.start(self._pg).then(function(db) {
		return db.createOrReplaceType(self._type)({"$schema":{"type": "object"}}).commit();
	}).then(function(db) {
		return db.fetch();
	});
}

NoPgStore.prototype = new Store();

/** Get session data */
NoPgStore.prototype.get = function(sid, callback) {
	var self = this, sessions, _db;
	try {
		debug.log("NoPgStore.prototype.get(", sid, ") with sid=", sid);

		self._type_promise.then(function(session_type) {
			return NoPg.start(self._pg).then(function(db) {
				return _db = db;
			}).search(session_type)({"sid":sid}).then(function nopgstore_get_save_result(db) {
				sessions = db.fetch();
				return db;
			}).commit();
		}).then(function nopgstore_get_success() {
			var session;
			debug.log("NoPgStore.prototype.get(", sid, ") succeeds with sessions: ", sessions);
			if(!sessions) {
				callback(null);
			} else {
				session = sessions.shift();
				if(session && session.data) {
					callback(null, session.data);
				} else {
					//throw new TypeError('Failed to read session #' + sid);
					callback(null);
				}
			}
		}).fail(function nopgstore_get_fail(err) {
			debug.log("NoPgStore.prototype.get(", sid, ") failed: ", err);
			if(_db) {
				_db.rollback().fail(function(err) {
					console.error("Error while rollback: " + err);
				}).done();
			}
			callback(err);
		}).done();
	} catch(e) {
		callback(e);
	}
};

/** Set session data */
NoPgStore.prototype.set = function(sid, session_data, callback) {
	var self = this, _db;

	try {

		if(typeof callback !== 'function') {
			callback = function(err) {
				if(err) {
					console.error('Error: ' + util.inspect(err) );
				}
			};
		}

		debug.log("[NoPgStore.prototype.set] session = " + session_data);
		debug.log("[NoPgStore.prototype.set] sid = " + sid);

		self._type_promise.then(function(session_type) {
			return NoPg.start(self._config).then(function(db) {
				return _db = db;
			}).search(session_type)({"sid":sid}).then(function(db) {
				var sessions = db.fetch(), session;
				debug.log("[NoPgStore.prototype.set(", sid, "] sessions = ", sessions);

				if(sessions) {
					session = sessions.shift();
					debug.log("[NoPgStore.prototype.set(", sid, "] before db.update(); session = ", session);
					return db.update(session, {"data":session_data, "sid":sid});
				}

				debug.log("[NoPgStore.prototype.set(", sid, "] before db.create(); session = ", session);
				return db.create(session_type)({"data":session_data, "sid":sid});
			}).commit();
		}).then(function() {
			callback();
		}).fail(function(err) {
			debug.log("NoPgStore.prototype.set(", sid, ") failed: ", err);
			if(_db) {
				_db.rollback().fail(function(err) {
					console.error("Error while rollback: " + err);
				}).done();
			}
			callback(err);
		}).done();

	} catch(e) {
		if(callback) {
			callback(e);
		} else {
			console.error('Error: ' + util.inspect(e) );
		}
	}
};

/** Destroy session data */
NoPgStore.prototype.destroy = function(sid, callback) {
	var self = this, _db;

	if(typeof callback !== 'function') {
		callback = function(err) {
			if(err) {
				console.error('Error: ' + util.inspect(err) );
			}
		};
	}

	debug.log("[NoPgStore.prototype.destroy] self._obj = ", self._obj);

	self._type_promise.then(function(session_type) {
		NoPg.start(self._pg).then(function(db) {
			return _db = db;
		}).del(session_type)(self._obj).commit();
	}).then(function() {
		callback();
	}).fail(function() {
		debug.log("NoPgStore.prototype.destroy(", sid, ") failed: ", err);
		if(_db) {
			_db.rollback().fail(function(err) {
				console.error("Error while rollback: " + err);
			}).done();
		}
		callback(err);
	}).done();
};

/*
NoPgStore.prototype.length = function(fn){
	this.client.dbsize(fn);
};

NoPgStore.prototype.clear = function(fn){
	this.client.flushdb(fn);
};
*/

module.exports = NoPgStore;

/* EOF */
<commit_msg>Fixed error<commit_after>/* Connect/Express Session Store for PostgreSQL */

/* for node-lint */
/*global Buffer: false, clearInterval: false, clearTimeout: false, console: false, global: false, module: false, process: false, querystring: false, require: false, setInterval: false, setTimeout: false, util: false, __filename: false, __dirname: false */

/* FIXME: update expiration so that the session does not expire when user is using the system! */

var debug = require('nor-debug');
var util = require('util');
var NoPg = require('nor-nopg');
var Store = require('connect').session.Store;

function NoPgStore(options) {
	debug.log('NoPgStore(options=', options, ')');
	options = options || {};
	//Store.call(this, options);
	var self = this;

	if(!options.pg) { throw TypeError("No postgresql configuration! pg=" + util.inspect(options.pg)); }

	self._type = options.type || 'Session';
	self._pg = options.pg;

	// FIXME: Implement rollback if connection fails
	// FIXME: Currently the app will UPDATE the type each time the NoPgStore instance is created. Maybe not do that if nothing is changed.
	self._type_promise = NoPg.start(self._pg).then(function(db) {
		return db.createOrReplaceType(self._type)({"$schema":{"type": "object"}}).commit();
	}).then(function(db) {
		return db.fetch();
	});
}

NoPgStore.prototype = new Store();

/** Get session data */
NoPgStore.prototype.get = function(sid, callback) {
	var self = this, sessions, _db;
	try {
		debug.log("NoPgStore.prototype.get(", sid, ") with sid=", sid);

		self._type_promise.then(function(session_type) {
			return NoPg.start(self._pg).then(function(db) {
				return _db = db;
			}).search(session_type)({"sid":sid}).then(function nopgstore_get_save_result(db) {
				sessions = db.fetch();
				return db;
			}).commit();
		}).then(function nopgstore_get_success() {
			var session;
			debug.log("NoPgStore.prototype.get(", sid, ") succeeds with sessions: ", sessions);
			if(!sessions) {
				callback(null);
			} else {
				session = sessions.shift();
				if(session && session.data) {
					callback(null, session.data);
				} else {
					//throw new TypeError('Failed to read session #' + sid);
					callback(null);
				}
			}
		}).fail(function nopgstore_get_fail(err) {
			debug.log("NoPgStore.prototype.get(", sid, ") failed: ", err);
			if(_db) {
				_db.rollback().fail(function(err) {
					console.error("Error while rollback: " + err);
				}).done();
			}
			callback(err);
		}).done();
	} catch(e) {
		callback(e);
	}
};

/** Set session data */
NoPgStore.prototype.set = function(sid, session_data, callback) {
	var self = this, _db;

	try {

		if(typeof callback !== 'function') {
			callback = function(err) {
				if(err) {
					console.error('Error: ' + util.inspect(err) );
				}
			};
		}

		debug.log("[NoPgStore.prototype.set] session = " + session_data);
		debug.log("[NoPgStore.prototype.set] sid = " + sid);

		self._type_promise.then(function(session_type) {
			return NoPg.start(self._pg).then(function(db) {
				return _db = db;
			}).search(session_type)({"sid":sid}).then(function(db) {
				var sessions = db.fetch(), session;
				debug.log("[NoPgStore.prototype.set(", sid, "] sessions = ", sessions);

				if(sessions) {
					session = sessions.shift();
					debug.log("[NoPgStore.prototype.set(", sid, "] before db.update(); session = ", session);
					return db.update(session, {"data":session_data, "sid":sid});
				}

				debug.log("[NoPgStore.prototype.set(", sid, "] before db.create(); session = ", session);
				return db.create(session_type)({"data":session_data, "sid":sid});
			}).commit();
		}).then(function() {
			callback();
		}).fail(function(err) {
			debug.log("NoPgStore.prototype.set(", sid, ") failed: ", err);
			if(_db) {
				_db.rollback().fail(function(err) {
					console.error("Error while rollback: " + err);
				}).done();
			}
			callback(err);
		}).done();

	} catch(e) {
		if(callback) {
			callback(e);
		} else {
			console.error('Error: ' + util.inspect(e) );
		}
	}
};

/** Destroy session data */
NoPgStore.prototype.destroy = function(sid, callback) {
	var self = this, _db;

	if(typeof callback !== 'function') {
		callback = function(err) {
			if(err) {
				console.error('Error: ' + util.inspect(err) );
			}
		};
	}

	debug.log("[NoPgStore.prototype.destroy] self._obj = ", self._obj);

	self._type_promise.then(function(session_type) {
		NoPg.start(self._pg).then(function(db) {
			return _db = db;
		}).del(session_type)(self._obj).commit();
	}).then(function() {
		callback();
	}).fail(function() {
		debug.log("NoPgStore.prototype.destroy(", sid, ") failed: ", err);
		if(_db) {
			_db.rollback().fail(function(err) {
				console.error("Error while rollback: " + err);
			}).done();
		}
		callback(err);
	}).done();
};

/*
NoPgStore.prototype.length = function(fn){
	this.client.dbsize(fn);
};

NoPgStore.prototype.clear = function(fn){
	this.client.flushdb(fn);
};
*/

module.exports = NoPgStore;

/* EOF */
<|endoftext|>


<commit_before>"use strict";
require("../styles/doc.css");
require("../styles/style.css");
require("../styles/font-awesome.min.css");
require.context("../images", true, /\.(jpg|png)$/);
require("es5-shim");
require(" html5shiv");

var React = require("react/addons");
var app_router = require("../../src/AppRouter");

React.render(
  app_router,
  document.getElementById('react-root')
);
<commit_msg>fix(index.js): fix wrong space<commit_after>"use strict";
require("../styles/doc.css");
require("../styles/style.css");
require("../styles/font-awesome.min.css");
require.context("../images", true, /\.(jpg|png)$/);
require("es5-shim");
require("html5shiv");

var React = require("react/addons");
var app_router = require("../../src/AppRouter");

React.render(
  app_router,
  document.getElementById('react-root')
);
<|endoftext|>


<commit_before>import Vue from 'vue'
import Vuex from 'vuex'
import appDrawerItems from './objects/app-drawer-items'

Vue.use(Vuex)

export function createStore () {
  const api = require('@/api/api.js')

  return new Vuex.Store({
    state: {
      api,
      appDrawer: null,
      appDrawerItems,
      appFooter: true,
      appToolbar: null,
      currentVersion: null,
      isFullscreen: false,
      fullscreenRoutes: ['/', '/404', '/store', '/theme-generator'],
      loadedLangs: [],
      releases: [],
      stateless: false,
      supporters: {
        diamond: [
          {
            title: 'LMAX Exchange',
            size: 70,
            href: 'https://careers.lmax.com/?utm_source=vuetify&utm_medium=logo-link&utm_campaign=lmax-careers',
            src: 'backers/lmax-exchange.png'
          },
          {
            title: 'Intygrate',
            size: 70,
            href: 'http://intygrate.com/',
            src: 'backers/intygrate.png'
          }
        ],
        palladium: [
          { title: 'Eikos Partners', size: 50, href: 'http://www.eikospartners.com/', src: 'backers/eikos-partners.webp' },
          { title: 'rateGenius', size: 50, href: 'https://application.rategenius.com/', src: 'backers/rate-genius.png' },
          { title: 'quitt.ch', size: 50, href: 'https://quitt.ch', src: 'backers/quitt.png' }
        ],
        gold: [
          { title: 'Deister Software', href: 'http://www.deister.es/', src: 'backers/deister-logo-light.png' },
          { title: 'Cocoatech', href: 'https://cocoatech.com/', src: 'backers/cocoatechlogo.png' },
          { title: 'Cycloid', href: 'https://www.cycloid.io/', src: 'backers/cycloid.png' },
          { title: 'Live Casino', href: 'https://livecasino.com/', src: 'backers/casino.webp', dark: true },
          { title: 'Nate Controls', href: 'http://www.natecontrols.com/', src: 'backers/n8controls.png' },
          { title: 'Trek10', href: 'https://www.trek10.com/', src: 'backers/trek10.svg' },
          { title: 'Zweidenker', href: 'http://zweidenker.de/', src: 'backers/zweidenker-logo-grey.svg' }
        ],
        affiliates: [
          {
            title: 'VueJobs',
            href: 'https://vuejobs.com/?utm_source=vuejobs&utm_medium=affiliates&utm_campaign=linking',
            noref: true,
            src: 'affiliates/vuejobs-logo.svg'
          },
          { title: 'Made with Vue.js', href: 'https://madewithvuejs.com', src: 'affiliates/madewithvuejs.png' },
          { title: 'Vue.js Radar', href: 'https://vuejsradar.com', src: 'affiliates/vueradar2.png' }
        ],
        sponsors: [
          { title: 'BrowserStack', size: 35, href: 'https://www.browserstack.com/', src: 'browser-stack.png' },
          { title: 'Cloudflare', size: 35, href: 'https://www.cloudflare.com/', src: 'cloudflare.svg' }
        ]
      }
    },

    actions: {},

    mutations: {
      ['app/STATELESS'] (state, payload) {
        state.stateless = payload
      },
      ['app/DRAWER'] (state, payload) {
        state.appDrawer = payload
      },
      ['app/DRAWER_TOGGLE'] (state) {
        state.appDrawer = !state.appDrawer
      },
      ['app/RELEASES'] (state, payload) {
        state.releases = payload
      },
      ['app/LOAD_LANG'] (state, payload) {
        state.loadedLangs.push(payload)
      },
      ['app/FULLSCREEN'] (state, payload) {
        state.isFullscreen = payload
        state.stateless = payload
        state.appDrawer = !payload && null
        state.appToolbar = !payload
      }
    },

    getters: {}
  })
}
<commit_msg>updated sponsors<commit_after>import Vue from 'vue'
import Vuex from 'vuex'
import appDrawerItems from './objects/app-drawer-items'

Vue.use(Vuex)

export function createStore () {
  const api = require('@/api/api.js')

  return new Vuex.Store({
    state: {
      api,
      appDrawer: null,
      appDrawerItems,
      appFooter: true,
      appToolbar: null,
      currentVersion: null,
      isFullscreen: false,
      fullscreenRoutes: ['/', '/404', '/store', '/theme-generator'],
      loadedLangs: [],
      releases: [],
      stateless: false,
      supporters: {
        diamond: [
          {
            title: 'LMAX Exchange',
            size: 70,
            href: 'https://careers.lmax.com/?utm_source=vuetify&utm_medium=logo-link&utm_campaign=lmax-careers',
            src: 'backers/lmax-exchange.png'
          },
          {
            title: 'Intygrate',
            size: 70,
            href: 'http://intygrate.com/',
            src: 'backers/intygrate.png'
          }
        ],
        palladium: [
          { title: 'Eikos Partners', size: 50, href: 'http://www.eikospartners.com/', src: 'backers/eikos-partners.webp' },
          { title: 'rateGenius', size: 50, href: 'https://application.rategenius.com/', src: 'backers/rate-genius.png' },
          { title: 'quitt.ch', size: 50, href: 'https://quitt.ch', src: 'backers/quitt.png' }
        ],
        gold: [
          { title: 'Deister Software', href: 'http://www.deister.es/', src: 'backers/deister-logo-light.png' },
          { title: 'Cocoatech', href: 'https://cocoatech.com/', src: 'backers/cocoatechlogo.png' },
          { title: 'Cycloid', href: 'https://www.cycloid.io/', src: 'backers/cycloid.png' },
          { title: 'Live Casino', href: 'https://livecasino.com/', src: 'backers/casino.webp', dark: true },
          { title: 'Nate Controls', href: 'http://www.natecontrols.com/', src: 'backers/n8controls.png' },
          { title: 'Trek10', href: 'https://www.trek10.com/', src: 'backers/trek10.svg' },
          { title: 'Zweidenker', href: 'http://zweidenker.de/', src: 'backers/zweidenker-logo-grey.svg' }
        ],
        affiliates: [
          {
            title: 'VueJobs',
            href: 'https://vuejobs.com/?utm_source=vuejobs&utm_medium=affiliates&utm_campaign=linking',
            noref: true,
            src: 'affiliates/vuejobs-logo.svg'
          },
          { title: 'Made with Vue.js', href: 'https://madewithvuejs.com', src: 'affiliates/madewithvuejs.png' },
          { title: 'Vue.js Radar', href: 'https://vuejsradar.com', src: 'affiliates/vueradar2.png' }
        ],
        sponsors: [
          { title: 'Cloudflare', size: 35, href: 'https://www.cloudflare.com/', src: 'cloudflare.svg' }
        ]
      }
    },

    actions: {},

    mutations: {
      ['app/STATELESS'] (state, payload) {
        state.stateless = payload
      },
      ['app/DRAWER'] (state, payload) {
        state.appDrawer = payload
      },
      ['app/DRAWER_TOGGLE'] (state) {
        state.appDrawer = !state.appDrawer
      },
      ['app/RELEASES'] (state, payload) {
        state.releases = payload
      },
      ['app/LOAD_LANG'] (state, payload) {
        state.loadedLangs.push(payload)
      },
      ['app/FULLSCREEN'] (state, payload) {
        state.isFullscreen = payload
        state.stateless = payload
        state.appDrawer = !payload && null
        state.appToolbar = !payload
      }
    },

    getters: {}
  })
}
<|endoftext|>


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

  'use strict';

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

  var path = require('path');
  var config = {

    /**
     * Pull in the package.json file so we can read its metadata.
     */
    pkg: grunt.file.readJSON('bower.json'),

    /**
     * Set some src and dist location variables.
     */
    loc: {
      src: 'src',
      dist: '.'
    },

    /**
     * Bower: https://github.com/yatskevich/grunt-bower-task
     *
     * Set up Bower packages and migrate static assets.
     */
    bower: {
      cf: {
        options: {
          targetDir: '<%= loc.src %>/vendor/',
          install: false,
          verbose: true,
          cleanTargetDir: false,
          layout: function(type, component) {
            if (type === 'img') {
              return path.join('../static/img');
            } else if (type === 'fonts') {
              return path.join('../static/fonts');
            } else {
              return path.join(component);
            }
          }
        }
      }
    },

    /**
     * Concat: https://github.com/gruntjs/grunt-contrib-concat
     *
     * Concatenate cf-* Less files prior to compiling them.
     */
    concat: {
      'cf-less': {
        src: [
          '<%= loc.src %>/vendor/cf-*/*.less',
          '!<%= loc.src %>/vendor/cf-core/*.less',
          '<%= loc.src %>/vendor/cf-core/cf-core.less',
          '<%= loc.src %>!vendor/cf-concat/cf.less'
        ],
        dest: '<%= loc.src %>/vendor/cf-concat/cf.less'
      },
      js: {
        src: [
          '<%= loc.src %>/vendor/jquery/jquery.js',
          '<%= loc.src %>/vendor/jquery.easing/jquery.easing.js',
          '<%= loc.src %>/vendor/cf-*/*.js',
          '!<%= loc.src %>/vendor/cf-*/Gruntfile.js',
          '<%= loc.src %>/static/js/app.js'
        ],
        dest: '<%= loc.dist %>/static/js/main.js'
      },
      topdocIcons: {
        src: [
          'src/topdoc-templates/includes/filter-components-without-markup.jade',
          'src/topdoc-templates/icons/src.jade'
        ],
        dest: 'src/topdoc-templates/icons/index.jade'
      }
    },

    /**
     * Less: https://github.com/gruntjs/grunt-contrib-less
     *
     * Compile Less files to CSS.
     */
    less: {
      main: {
        options: {
          // The src/vendor paths are needed to find the CF components' files.
          // Feel free to add additional paths to the array passed to `concat`.
          paths: grunt.file.expand('src/vendor/*').concat([])
        },
        files: {
          '<%= loc.dist %>/static/css/main.css': ['<%= loc.src %>/static/css/main.less']
        }
      }
    },

    /**
     * Autoprefixer: https://github.com/nDmitry/grunt-autoprefixer
     *
     * Parse CSS and add vendor-prefixed CSS properties using the Can I Use database.
     */
    autoprefixer: {
      options: {
        // Options we might want to enable in the future.
        diff: false,
        map: false
      },
      main: {
        // Prefix `static/css/main.css` and overwrite.
        expand: true,
        src: ['<%= loc.dist %>/static/css/main.css']
      },
    },

    /**
     * Uglify: https://github.com/gruntjs/grunt-contrib-uglify
     *
     * Minify JS files.
     * Make sure to add any other JS libraries/files you'll be using.
     * You can exclude files with the ! pattern.
     */
    uglify: {
      options: {
        preserveComments: 'some',
        sourceMap: true
      },
      // headScripts: {
      //   src: 'vendor/html5shiv/html5shiv-printshiv.js',
      //   dest: 'static/js/html5shiv-printshiv.js'
      // },
      js: {
        src: ['<%= loc.dist %>/static/js/main.js'],
        dest: '<%= loc.dist %>/static/js/main.min.js'
      }
    },

    /**
     * Banner: https://github.com/mattstyles/grunt-banner
     *
     * Here's a banner with some template variables.
     * We'll be inserting it at the top of minified assets.
     */
    banner:
      '/*!\n' +
      ' *  <%= pkg.name %> - v<%= pkg.version %>\n' +
      ' *  <%= pkg.homepage %>\n' +
      ' *  Licensed <%= pkg.license %> by <%= pkg.author.name %> <<%= pkg.author.email %>>\n' +
      ' */',

    usebanner: {
      css: {
        options: {
          position: 'top',
          banner: '<%= banner %>',
          linebreak: true
        },
        files: {
          src: ['<%= loc.dist %>/static/css/*.min.css']
        }
      },
      js: {
        options: {
          position: 'top',
          banner: '<%= banner %>',
          linebreak: true
        },
        files: {
          src: ['<%= loc.dist %>/static/js/*.min.js']
        }
      }
    },

    /**
     * CSS Min: https://github.com/gruntjs/grunt-contrib-cssmin
     *
     * Compress CSS files.
     */
    cssmin: {
      main: {
        options: {
          processImport: false
        },
        files: {
          '<%= loc.dist %>/static/css/main.min.css': ['<%= loc.dist %>/static/css/main.css'],
        }
      },
      'ie-alternate': {
        options: {
          processImport: false
        },
        files: {
          '<%= loc.dist %>/static/css/main.ie.min.css': ['<%= loc.dist %>/static/css/main.ie.css'],
        }
      }
    },

    /**
     * Legacssy: https://github.com/robinpokorny/grunt-legacssy
     *
     * Fix your CSS for legacy browsers.
     */
    legacssy: {
      'ie-alternate': {
        options: {
          // Flatten all media queries with a min-width over 960 or lower.
          // All media queries over 960 will be excluded fromt he stylesheet.
          // EM calculation: 960 / 16 = 60
          legacyWidth: 60
        },
        files: {
          '<%= loc.dist %>/static/css/main.ie.css': '<%= loc.dist %>/static/css/main.css'
        }
      }
    },

    /**
     * Copy: https://github.com/gruntjs/grunt-contrib-copy
     *
     * Copy files and folders.
     */
    copy: {
      main: {
        files: [
          {
            expand: true,
            cwd: '<%= loc.src %>',
            src: [
              // HTML files
              '*.html',
            ],
            dest: '<%= loc.dist %>'
          },
          {
            expand: true,
            cwd: '<%= loc.src %>/static',
            src: [
              // Fonts
              'fonts/*'
            ],
            dest: '<%= loc.dist %>/static'
          },
          {
            expand: true,
            cwd: '<%= loc.src %>/static',
            src: [
              // Images
              'img/**'
            ],
            dest: '<%= loc.dist %>/static'
          },
          {
            expand: true,
            cwd: '<%= loc.src %>',
            src: [
              // Vendor files
              'vendor/html5shiv/html5shiv-printshiv.min.js',
              'vendor/box-sizing-polyfill/boxsizing.htc'
            ],
            dest: '<%= loc.dist %>/static'
          }
        ]
      }
    },

    /**
     * JSHint: https://github.com/gruntjs/grunt-contrib-jshint
     *
     * Validate files with JSHint.
     * Below are options that conform to idiomatic.js standards.
     * Feel free to add/remove your favorites: http://www.jshint.com/docs/#options
     */
    jshint: {
      options: {
        camelcase: false,
        curly: true,
        forin: true,
        immed: true,
        latedef: true,
        newcap: true,
        noarg: true,
        quotmark: true,
        sub: true,
        boss: true,
        strict: true,
        evil: true,
        eqnull: true,
        browser: true,
        plusplus: false,
        globals: {
          jQuery: true,
          $: true,
          module: true,
          require: true,
          define: true,
          console: true,
          EventEmitter: true
        }
      },
      all: ['<%= loc.src %>/static/js/app.js']
    },

    /**
     * Topdoc: https://github.com/topcoat/topdoc
     *
     * A command line tool for generating usage docs based on css comments
     */
    topdoc: {
      icons: {
        options: {
          source: 'static/css/',
          destination: '_includes/identity/icons/',
          template: 'src/topdoc-templates/icons/index.jade',
          templateData: {
            family: 'cf-icons'
          }
        }
      }
    },

    /**
     * Watch: https://github.com/gruntjs/grunt-contrib-watch
     *
     * Run predefined tasks whenever watched file patterns are added, changed or deleted.
     * Add files to monitor below.
     */
    watch: {
      default: {
        files: ['Gruntfile.js', '<%= loc.src %>/static/css/**/*.less', '<%= loc.src %>/static/js/**/*.js'],
        tasks: ['default']
      }
    }

  };

  /**
   * Initialize a configuration object for the current project.
   */
  grunt.initConfig(config);

  grunt.registerTask(
    'cleanUpAfterTopdoc',
    'Topdoc runs on all non-minified CSS files, including .ie.css files. We need to delete those.',
    function() {
      grunt.file.delete(grunt.file.expand('_includes/**/**/main.ie.html'));
    }
  );

  /**
   * Create custom task aliases and combinations.
   */
  grunt.registerTask('compile-cf', ['bower:cf', 'concat:cf-less', 'concat:topdocIcons']);
  grunt.registerTask('css', ['less', 'autoprefixer', 'legacssy', 'cssmin', 'usebanner:css']);
  grunt.registerTask('js', ['concat:js', 'uglify', 'usebanner:js']);
  grunt.registerTask('test', ['jshint']);
  grunt.registerTask('build', ['test', 'css', 'js', 'copy']);
  grunt.registerTask('default', ['build']);
  grunt.registerTask('build-partials-from-cf-docs', ['topdoc', 'cleanUpAfterTopdoc']);

};<commit_msg>Update Grunt watch to be useful<commit_after>module.exports = function(grunt) {

  'use strict';

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

  var path = require('path');
  var config = {

    /**
     * Pull in the package.json file so we can read its metadata.
     */
    pkg: grunt.file.readJSON('bower.json'),

    /**
     * Set some src and dist location variables.
     */
    loc: {
      src: 'src',
      dist: '.'
    },

    /**
     * Bower: https://github.com/yatskevich/grunt-bower-task
     *
     * Set up Bower packages and migrate static assets.
     */
    bower: {
      cf: {
        options: {
          targetDir: '<%= loc.src %>/vendor/',
          install: false,
          verbose: true,
          cleanTargetDir: false,
          layout: function(type, component) {
            if (type === 'img') {
              return path.join('../static/img');
            } else if (type === 'fonts') {
              return path.join('../static/fonts');
            } else {
              return path.join(component);
            }
          }
        }
      }
    },

    /**
     * Concat: https://github.com/gruntjs/grunt-contrib-concat
     *
     * Concatenate cf-* Less files prior to compiling them.
     */
    concat: {
      'cf-less': {
        src: [
          '<%= loc.src %>/vendor/cf-*/*.less',
          '!<%= loc.src %>/vendor/cf-core/*.less',
          '<%= loc.src %>/vendor/cf-core/cf-core.less',
          '<%= loc.src %>!vendor/cf-concat/cf.less'
        ],
        dest: '<%= loc.src %>/vendor/cf-concat/cf.less'
      },
      js: {
        src: [
          '<%= loc.src %>/vendor/jquery/jquery.js',
          '<%= loc.src %>/vendor/jquery.easing/jquery.easing.js',
          '<%= loc.src %>/vendor/cf-*/*.js',
          '!<%= loc.src %>/vendor/cf-*/Gruntfile.js',
          '<%= loc.src %>/static/js/app.js'
        ],
        dest: '<%= loc.dist %>/static/js/main.js'
      },
      topdocIcons: {
        src: [
          'src/topdoc-templates/includes/filter-components-without-markup.jade',
          'src/topdoc-templates/icons/src.jade'
        ],
        dest: 'src/topdoc-templates/icons/index.jade'
      }
    },

    /**
     * Less: https://github.com/gruntjs/grunt-contrib-less
     *
     * Compile Less files to CSS.
     */
    less: {
      main: {
        options: {
          // The src/vendor paths are needed to find the CF components' files.
          // Feel free to add additional paths to the array passed to `concat`.
          paths: grunt.file.expand('src/vendor/*').concat([])
        },
        files: {
          '<%= loc.dist %>/static/css/main.css': ['<%= loc.src %>/static/css/main.less']
        }
      }
    },

    /**
     * Autoprefixer: https://github.com/nDmitry/grunt-autoprefixer
     *
     * Parse CSS and add vendor-prefixed CSS properties using the Can I Use database.
     */
    autoprefixer: {
      options: {
        // Options we might want to enable in the future.
        diff: false,
        map: false
      },
      main: {
        // Prefix `static/css/main.css` and overwrite.
        expand: true,
        src: ['<%= loc.dist %>/static/css/main.css']
      },
    },

    /**
     * Uglify: https://github.com/gruntjs/grunt-contrib-uglify
     *
     * Minify JS files.
     * Make sure to add any other JS libraries/files you'll be using.
     * You can exclude files with the ! pattern.
     */
    uglify: {
      options: {
        preserveComments: 'some',
        sourceMap: true
      },
      // headScripts: {
      //   src: 'vendor/html5shiv/html5shiv-printshiv.js',
      //   dest: 'static/js/html5shiv-printshiv.js'
      // },
      js: {
        src: ['<%= loc.dist %>/static/js/main.js'],
        dest: '<%= loc.dist %>/static/js/main.min.js'
      }
    },

    /**
     * Banner: https://github.com/mattstyles/grunt-banner
     *
     * Here's a banner with some template variables.
     * We'll be inserting it at the top of minified assets.
     */
    banner:
      '/*!\n' +
      ' *  <%= pkg.name %> - v<%= pkg.version %>\n' +
      ' *  <%= pkg.homepage %>\n' +
      ' *  Licensed <%= pkg.license %> by <%= pkg.author.name %> <<%= pkg.author.email %>>\n' +
      ' */',

    usebanner: {
      css: {
        options: {
          position: 'top',
          banner: '<%= banner %>',
          linebreak: true
        },
        files: {
          src: ['<%= loc.dist %>/static/css/*.min.css']
        }
      },
      js: {
        options: {
          position: 'top',
          banner: '<%= banner %>',
          linebreak: true
        },
        files: {
          src: ['<%= loc.dist %>/static/js/*.min.js']
        }
      }
    },

    /**
     * CSS Min: https://github.com/gruntjs/grunt-contrib-cssmin
     *
     * Compress CSS files.
     */
    cssmin: {
      main: {
        options: {
          processImport: false
        },
        files: {
          '<%= loc.dist %>/static/css/main.min.css': ['<%= loc.dist %>/static/css/main.css'],
        }
      },
      'ie-alternate': {
        options: {
          processImport: false
        },
        files: {
          '<%= loc.dist %>/static/css/main.ie.min.css': ['<%= loc.dist %>/static/css/main.ie.css'],
        }
      }
    },

    /**
     * Legacssy: https://github.com/robinpokorny/grunt-legacssy
     *
     * Fix your CSS for legacy browsers.
     */
    legacssy: {
      'ie-alternate': {
        options: {
          // Flatten all media queries with a min-width over 960 or lower.
          // All media queries over 960 will be excluded fromt he stylesheet.
          // EM calculation: 960 / 16 = 60
          legacyWidth: 60
        },
        files: {
          '<%= loc.dist %>/static/css/main.ie.css': '<%= loc.dist %>/static/css/main.css'
        }
      }
    },

    /**
     * Copy: https://github.com/gruntjs/grunt-contrib-copy
     *
     * Copy files and folders.
     */
    copy: {
      main: {
        files: [
          {
            expand: true,
            cwd: '<%= loc.src %>',
            src: [
              // HTML files
              '*.html',
            ],
            dest: '<%= loc.dist %>'
          },
          {
            expand: true,
            cwd: '<%= loc.src %>/static',
            src: [
              // Fonts
              'fonts/*'
            ],
            dest: '<%= loc.dist %>/static'
          },
          {
            expand: true,
            cwd: '<%= loc.src %>/static',
            src: [
              // Images
              'img/**'
            ],
            dest: '<%= loc.dist %>/static'
          },
          {
            expand: true,
            cwd: '<%= loc.src %>',
            src: [
              // Vendor files
              'vendor/html5shiv/html5shiv-printshiv.min.js',
              'vendor/box-sizing-polyfill/boxsizing.htc'
            ],
            dest: '<%= loc.dist %>/static'
          }
        ]
      }
    },

    /**
     * JSHint: https://github.com/gruntjs/grunt-contrib-jshint
     *
     * Validate files with JSHint.
     * Below are options that conform to idiomatic.js standards.
     * Feel free to add/remove your favorites: http://www.jshint.com/docs/#options
     */
    jshint: {
      options: {
        camelcase: false,
        curly: true,
        forin: true,
        immed: true,
        latedef: true,
        newcap: true,
        noarg: true,
        quotmark: true,
        sub: true,
        boss: true,
        strict: true,
        evil: true,
        eqnull: true,
        browser: true,
        plusplus: false,
        globals: {
          jQuery: true,
          $: true,
          module: true,
          require: true,
          define: true,
          console: true,
          EventEmitter: true
        }
      },
      all: ['<%= loc.src %>/static/js/app.js']
    },

    /**
     * Topdoc: https://github.com/topcoat/topdoc
     *
     * A command line tool for generating usage docs based on css comments
     */
    topdoc: {
      icons: {
        options: {
          source: 'static/css/',
          destination: '_includes/identity/icons/',
          template: 'src/topdoc-templates/icons/index.jade',
          templateData: {
            family: 'cf-icons'
          }
        }
      }
    },

    /**
     * Watch: https://github.com/gruntjs/grunt-contrib-watch
     *
     * Run predefined tasks whenever watched file patterns are added, changed or deleted.
     * Add files to monitor below.
     */
    watch: {
      css: {
        files: ['<%= loc.src %>/static/css/**/*.less'],
        tasks: ['css']
      },
      js: {
        files: ['Gruntfile.js', '<%= loc.src %>/static/js/**/*.js'],
        tasks: ['js']
      },
      content: {
        files: ['**/*.html', '/downloads/*.md', '/guides/*.md', '/identity/*.md', '/ui-toolkit/*.md'],
        tasks: ['copy']
      }
    }

  };

  /**
   * Initialize a configuration object for the current project.
   */
  grunt.initConfig(config);

  grunt.registerTask(
    'cleanUpAfterTopdoc',
    'Topdoc runs on all non-minified CSS files, including .ie.css files. We need to delete those.',
    function() {
      grunt.file.delete(grunt.file.expand('_includes/**/**/main.ie.html'));
    }
  );

  /**
   * Create custom task aliases and combinations.
   */
  grunt.registerTask('compile-cf', ['bower:cf', 'concat:cf-less', 'concat:topdocIcons']);
  grunt.registerTask('css', ['less', 'autoprefixer', 'legacssy', 'cssmin', 'usebanner:css', 'copy']);
  grunt.registerTask('js', ['concat:js', 'uglify', 'usebanner:js', 'copy']);
  grunt.registerTask('test', ['jshint']);
  grunt.registerTask('build', ['test', 'css', 'js', 'copy']);
  grunt.registerTask('default', ['build']);
  grunt.registerTask('build-partials-from-cf-docs', ['topdoc', 'cleanUpAfterTopdoc']);

};<|endoftext|>


<commit_before>/**
 * GruntFile.js
 * @author  Paul Massey
 */

var testJSON = "test.json";

module.exports = function (grunt)
{
	/**
	 * Ensures single-digit bump occurs
	 * @param part
	 * @returns {string}
	 */

	function autoBump (part) {

		if (part === "build") return ["bump:" + part];

		var pkg = grunt.file.readJSON (testJSON),
			versionData = pkg.version.split (".");

		if (part === "patch" && parseInt (versionData[2], 10) + 1 >= 10) part = "minor";
		if (part === "minor" && parseInt (versionData[1], 10) + 1 >= 10) part = "major";

		return part;
	}

	grunt.initConfig ({
		pkg: grunt.file.readJSON (testJSON),
		bump: {
			build: {
				options: {
					part: "build"
				},
				src: [testJSON]
			},
			patch: {
				options: {
					part: autoBump ("patch", pkg)
				},
				src: [testJSON]
			},
			minor: {
				options: {
					part: autoBump ("minor", pkg)
				},
				src: [testJSON]
			},
			major: {
				options: {
					part: "major"
				},
				src: [testJSON]
			}
		},
		codename: {
			all: {
				options: {
					patch: true,
					data: grunt.file.readJSON ("codenames.json")
				},
				src: [testJSON]
			}
		}
	});

	grunt.loadNpmTasks ("grunt-bumpx");
	grunt.loadNpmTasks ("grunt-codename");

	// Default - Check code, concat, uglify and bump the build version.
	grunt.registerTask ("default", ["bump:patch", "codename"]);
};
<commit_msg>Updated comments in GruntFile.js<commit_after>/*
* GruntFile.js example.
*
* grunt-codename
* https://github.com/scriptwerx/grunt-codename
*
* Copyright (c) 2013 scriptwerx
* Licensed under the MIT license.
*/

var testJSON = "test.json";

module.exports = function (grunt)
{
	/**
	 * Ensures single-digit bump occurs
	 * @param part
	 * @returns {string}
	 */

	function autoBump (part) {

		if (part === "build") return ["bump:" + part];

		var pkg = grunt.file.readJSON (testJSON),
			versionData = pkg.version.split (".");

		if (part === "patch" && parseInt (versionData[2], 10) + 1 >= 10) part = "minor";
		if (part === "minor" && parseInt (versionData[1], 10) + 1 >= 10) part = "major";

		return part;
	}

	grunt.initConfig ({
		pkg: grunt.file.readJSON (testJSON),
		bump: {
			build: {
				options: {
					part: "build"
				},
				src: [testJSON]
			},
			patch: {
				options: {
					part: autoBump ("patch", pkg)
				},
				src: [testJSON]
			},
			minor: {
				options: {
					part: autoBump ("minor", pkg)
				},
				src: [testJSON]
			},
			major: {
				options: {
					part: "major"
				},
				src: [testJSON]
			}
		},
		codename: {
			all: {
				options: {
					patch: true,
					data: grunt.file.readJSON ("codenames.json")
				},
				src: [testJSON]
			}
		}
	});

	grunt.loadNpmTasks ("grunt-bumpx");
	grunt.loadNpmTasks ("grunt-codename");

	// Default - Check code, concat, uglify and bump the build version.
	grunt.registerTask ("default", ["bump:patch", "codename"]);
};
<|endoftext|>


<commit_before>'use strict';

var IDBAdapter = require('deltadb-orm-nosql/scripts/adapters/indexed-db'),
  MemAdapter = require('deltadb-orm-nosql/scripts/adapters/mem'),
  idbUtils = require('deltadb-orm-nosql/scripts/adapters/indexed-db/utils'),
  adapterStore = require('./adapter-store');

// Create a store based on the availibility of whether we are using a browser or not
adapterStore.newAdapter = function () {
  if (global.window && idbUtils.indexedDB()) { // in browser and have IndexedDB?
    return new IDBAdapter();
  } else {
    return new MemAdapter();
  }
};
<commit_msg>test(auto-adapter): ignore for now<commit_after>'use strict';

var IDBAdapter = require('deltadb-orm-nosql/scripts/adapters/indexed-db'),
  MemAdapter = require('deltadb-orm-nosql/scripts/adapters/mem'),
  idbUtils = require('deltadb-orm-nosql/scripts/adapters/indexed-db/utils'),
  adapterStore = require('./adapter-store');

// Create a store based on the availibility of whether we are using a browser or not
adapterStore.newAdapter = function () {
  // TODO: test
  /* istanbul ignore next */
  if (global.window && idbUtils.indexedDB()) { // in browser and have IndexedDB?
    return new IDBAdapter();
  } else {
    return new MemAdapter();
  }
};
<|endoftext|>


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

    // Define Sass implmentation (Dart-Sass).
    const sass = require('sass');

    // Load all Grunt tasks.
    require('load-grunt-tasks')(grunt);

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

        // Set up paths.
        paths: {
            src: {
                sass: 'src/style/Textpattern/sass/',
                js: 'src/style/Textpattern/js/',
                templates: 'src/style/Textpattern/'
            },
            dest: {
                css: 'public/style/Textpattern/css/',
                js: 'public/style/Textpattern/js/',
                templates: 'public/style/Textpattern/'
            }
        },

        // Set up timestamp.
        opt : {
            timestamp: '<%= new Date().getTime() %>'
        },

        // Bundle up the JavaScript.
        browserify: {
            development: {
                src: [
                    '<%= paths.src.js %>app.js'
                ],
                dest: '<%= paths.dest.js %>app.js',
                options: {
                    browserifyOptions: {
                        debug: false
                    },
                    transform: [[
                        'babelify', {
                            'presets': ['@babel/preset-env']
                        }
                    ]]
                }
            }
        },

        // Clean distribution directory to start afresh.
        clean: [
            'public/style/'
        ],

        // Run some tasks in parallel to speed up the build process.
        concurrent: {
            dist: [
                'browserify',
                'copy:branding',
                'css',
                'jshint',
                'theme'
            ]
        },

        // Copy files from `src/` and `node_modules/` to `public/`.
        copy: {
            branding: {
                files: [
                    {
                        expand: true,
                        cwd: 'node_modules/textpattern-branding/assets/img/',
                        src: '**',
                        dest: 'public/style/Textpattern/img/branding/'
                    },
                    {
                        expand: true,
                        cwd: 'node_modules/textpattern-branding/assets/img/apple-touch-icon/textpattern/',
                        src: '**',
                        dest: 'public/'
                    },
                    {
                        expand: true,
                        cwd: 'node_modules/textpattern-branding/assets/img/favicon/textpattern/',
                        src: '**',
                        dest: 'public/'
                    },
                    {
                        expand: true,
                        cwd: 'node_modules/textpattern-branding/assets/img/windows-site-tile/textpattern/',
                        src: '**',
                        dest: 'public/'
                    }
                ]
            },
            theme: {
                files: [
                    {
                        expand: true,
                        cwd: 'src/style/',
                        src: ['Textpattern.css', '.htaccess'],
                        dest: 'public/style/'
                    },
                    {
                        expand: true,
                        cwd: '<%= paths.src.templates %>',
                        src: ['**', '!*.tpl', '!sass/**', '!js/**'],
                        dest: '<%= paths.dest.templates %>'
                    },
                    {
                        expand: true,
                        cwd: 'src/lib/',
                        src: '**',
                        dest: 'public/lib/'
                    },
                ]
            }
        },

        // Check code quality of Gruntfile.js and site-specific JavaScript using JSHint.
        jshint: {
            options: {
                bitwise: true,
                browser: true,
                curly: true,
                eqeqeq: true,
                esversion: 6,
                forin: true,
                globals: {
                    module: true,
                    require: true,
                    Prism: true
                },
                latedef: true,
                noarg: true,
                nonew: true,
                strict: true,
                undef: true,
                unused: false
            },
            files: [
                'Gruntfile.js',
                'src/style/Textpattern/js/app.js'
            ]
        },

        // Add vendor prefixed styles and other post-processing transformations.
        postcss: {
            options: {
                processors: [
                    require('autoprefixer'),
                    require("css-mqpacker"),
                    require('cssnano')
                ]
            },
            dist: {
                src: '<%= paths.dest.css %>*.css'
            }
        },

        // Generate latest timestamp within theme template files.
        replace: {
            theme: {
                options: {
                    patterns: [
                        {
                            match: 'timestamp',
                            replacement: '<%= opt.timestamp %>'
                        },
                        {
                            match: 'year',
                            replacement: '<%= new Date().getFullYear() %>'
                        }
                    ]
                },
                files: [
                    {
                        expand: true,
                        cwd: '<%= paths.src.templates %>',
                        src: ['*.tpl'],
                        dest: '<%= paths.dest.templates %>'
                    },
                    {
                        expand: true,
                        cwd: 'src/',
                        src: ['*.html'],
                        dest: 'public/'
                    }
                ]
            }
        },

        // Sass configuration.
        sass: {
            options: {
                implementation: sass,
                outputStyle: 'expanded', // outputStyle = expanded, nested, compact or compressed.
                sourceMap: false
            },
            dist: {
                files: [
                    {'<%= paths.dest.css %>style.css': '<%= paths.src.sass %>style.scss'}
                ]
            }
        },

        // Validate Sass files via sass-lint.
        sasslint: {
            options: {
                configFile: '.sass-lint.yml'
            },
            target: ['<%= paths.src.sass %>**/*.scss']
        },

        // Run forum setup and postsetup scripts.
        shell: {
            setup: {
                command: [
                    'php src/setup/setup.php'
                ].join('&&'),
                options: {
                    stdout: true
                }
            },
            postsetup: {
                command: [
                    'php src/setup/post.php'
                ].join('&&'),
                options: {
                    stdout: true
                }
            }
        },

        // Minify `app.js`.
        uglify: {
            dist: {
                files: [
                    {
                        '<%= paths.dest.js %>app.js': ['<%= paths.dest.js %>app.js']
                    }
                ]
            }
        },

        // Directories watched and tasks performed by invoking `grunt watch`.
        watch: {
            sass: {
                files: '<%= paths.src.sass %>**/*.scss',
                tasks: 'css'
            },
            js: {
                files: '<%= paths.src.js %>**',
                tasks: [
                    'jshint',
                    'browserify',
                    'uglify'
                ]
            },
            theme: {
                files: [
                    '!src/style/*/sass/**',
                    '!src/style/*/js/**',
                    'src/style/*/**',
                    'src/*.html'
                ],
                tasks: 'theme'
            }
        }
    });

    // Register tasks.
    grunt.registerTask('build', ['clean', 'concurrent', 'uglify']);
    grunt.registerTask('default', ['watch']);
    grunt.registerTask('postsetup', ['shell:postsetup']);
    grunt.registerTask('css', ['sasslint', 'sass', 'postcss']);
    grunt.registerTask('setup', ['shell:setup', 'build']);
    grunt.registerTask('theme', ['copy:theme', 'replace']);
    grunt.registerTask('travis', ['build']);
};
<commit_msg>Simplify<commit_after>module.exports = function (grunt)
{
    'use strict';

    // Load all Grunt tasks.
    require('load-grunt-tasks')(grunt);

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

        // Set up paths.
        paths: {
            src: {
                sass: 'src/style/Textpattern/sass/',
                js: 'src/style/Textpattern/js/',
                templates: 'src/style/Textpattern/'
            },
            dest: {
                css: 'public/style/Textpattern/css/',
                js: 'public/style/Textpattern/js/',
                templates: 'public/style/Textpattern/'
            }
        },

        // Set up timestamp.
        opt : {
            timestamp: '<%= new Date().getTime() %>'
        },

        // Bundle up the JavaScript.
        browserify: {
            development: {
                src: [
                    '<%= paths.src.js %>app.js'
                ],
                dest: '<%= paths.dest.js %>app.js',
                options: {
                    browserifyOptions: {
                        debug: false
                    },
                    transform: [[
                        'babelify', {
                            'presets': ['@babel/preset-env']
                        }
                    ]]
                }
            }
        },

        // Clean distribution directory to start afresh.
        clean: [
            'public/style/'
        ],

        // Run some tasks in parallel to speed up the build process.
        concurrent: {
            dist: [
                'browserify',
                'copy:branding',
                'css',
                'jshint',
                'theme'
            ]
        },

        // Copy files from `src/` and `node_modules/` to `public/`.
        copy: {
            branding: {
                files: [
                    {
                        expand: true,
                        cwd: 'node_modules/textpattern-branding/assets/img/',
                        src: '**',
                        dest: 'public/style/Textpattern/img/branding/'
                    },
                    {
                        expand: true,
                        cwd: 'node_modules/textpattern-branding/assets/img/apple-touch-icon/textpattern/',
                        src: '**',
                        dest: 'public/'
                    },
                    {
                        expand: true,
                        cwd: 'node_modules/textpattern-branding/assets/img/favicon/textpattern/',
                        src: '**',
                        dest: 'public/'
                    },
                    {
                        expand: true,
                        cwd: 'node_modules/textpattern-branding/assets/img/windows-site-tile/textpattern/',
                        src: '**',
                        dest: 'public/'
                    }
                ]
            },
            theme: {
                files: [
                    {
                        expand: true,
                        cwd: 'src/style/',
                        src: ['Textpattern.css', '.htaccess'],
                        dest: 'public/style/'
                    },
                    {
                        expand: true,
                        cwd: '<%= paths.src.templates %>',
                        src: ['**', '!*.tpl', '!sass/**', '!js/**'],
                        dest: '<%= paths.dest.templates %>'
                    },
                    {
                        expand: true,
                        cwd: 'src/lib/',
                        src: '**',
                        dest: 'public/lib/'
                    },
                ]
            }
        },

        // Check code quality of Gruntfile.js and site-specific JavaScript using JSHint.
        jshint: {
            options: {
                bitwise: true,
                browser: true,
                curly: true,
                eqeqeq: true,
                esversion: 6,
                forin: true,
                globals: {
                    module: true,
                    require: true,
                    Prism: true
                },
                latedef: true,
                noarg: true,
                nonew: true,
                strict: true,
                undef: true,
                unused: false
            },
            files: [
                'Gruntfile.js',
                'src/style/Textpattern/js/app.js'
            ]
        },

        // Add vendor prefixed styles and other post-processing transformations.
        postcss: {
            options: {
                processors: [
                    require('autoprefixer'),
                    require("css-mqpacker"),
                    require('cssnano')
                ]
            },
            dist: {
                src: '<%= paths.dest.css %>*.css'
            }
        },

        // Generate latest timestamp within theme template files.
        replace: {
            theme: {
                options: {
                    patterns: [
                        {
                            match: 'timestamp',
                            replacement: '<%= opt.timestamp %>'
                        },
                        {
                            match: 'year',
                            replacement: '<%= new Date().getFullYear() %>'
                        }
                    ]
                },
                files: [
                    {
                        expand: true,
                        cwd: '<%= paths.src.templates %>',
                        src: ['*.tpl'],
                        dest: '<%= paths.dest.templates %>'
                    },
                    {
                        expand: true,
                        cwd: 'src/',
                        src: ['*.html'],
                        dest: 'public/'
                    }
                ]
            }
        },

        // Sass configuration.
        sass: {
            options: {
                implementation: require('sass'),
                outputStyle: 'expanded', // outputStyle = expanded, nested, compact or compressed.
                sourceMap: false
            },
            dist: {
                files: [
                    {'<%= paths.dest.css %>style.css': '<%= paths.src.sass %>style.scss'}
                ]
            }
        },

        // Validate Sass files via sass-lint.
        sasslint: {
            options: {
                configFile: '.sass-lint.yml'
            },
            target: ['<%= paths.src.sass %>**/*.scss']
        },

        // Run forum setup and postsetup scripts.
        shell: {
            setup: {
                command: [
                    'php src/setup/setup.php'
                ].join('&&'),
                options: {
                    stdout: true
                }
            },
            postsetup: {
                command: [
                    'php src/setup/post.php'
                ].join('&&'),
                options: {
                    stdout: true
                }
            }
        },

        // Minify `app.js`.
        uglify: {
            dist: {
                files: [
                    {
                        '<%= paths.dest.js %>app.js': ['<%= paths.dest.js %>app.js']
                    }
                ]
            }
        },

        // Directories watched and tasks performed by invoking `grunt watch`.
        watch: {
            sass: {
                files: '<%= paths.src.sass %>**/*.scss',
                tasks: 'css'
            },
            js: {
                files: '<%= paths.src.js %>**',
                tasks: [
                    'jshint',
                    'browserify',
                    'uglify'
                ]
            },
            theme: {
                files: [
                    '!src/style/*/sass/**',
                    '!src/style/*/js/**',
                    'src/style/*/**',
                    'src/*.html'
                ],
                tasks: 'theme'
            }
        }
    });

    // Register tasks.
    grunt.registerTask('build', ['clean', 'concurrent', 'uglify']);
    grunt.registerTask('default', ['watch']);
    grunt.registerTask('postsetup', ['shell:postsetup']);
    grunt.registerTask('css', ['sasslint', 'sass', 'postcss']);
    grunt.registerTask('setup', ['shell:setup', 'build']);
    grunt.registerTask('theme', ['copy:theme', 'replace']);
    grunt.registerTask('travis', ['build']);
};
<|endoftext|>


<commit_before>var fs = require('fs');
var LettersSequence = require('./letters_sequence');

var lettersMatrix;
var dimension;
var referenceWordsList;
var serializedSequences;
var sequences;

var directions = {
  'up':         [ 0, -1],
  'up-right':   [ 1, -1],
  'right':      [ 1,  0],
  'right-down': [ 1,  1],
  'down':       [ 0,  1],
  'down-left':  [-1,  1],
  'left':       [-1,  0],
  'left-up':    [-1, -1]
};

function getReferenceWordsList(){
  var data = fs.readFileSync('data/dict_en.txt');
  return data.toString().split(/\W+/);
}

function setSerializedSequences(){
  var data = fs.readFileSync('data/3-4-5-6-7-letter-sequences.json');
  return JSON.parse(data, function(key, value){
    if(value instanceof Array){
      return value;
    }else{
      return LettersSequence(JSON.parse(value));
    }
  });
}

function findAllLettersSequences(){
  var sequences = [];
  for(var i = 0; i < getDimension(); i++){
    for(var j = 0; j < getDimension(); j++){
      sequences = sequences.concat( radiatedSequences( [[i, j]] ));
    }
  }

  // max of 6-letter words for now (otherwise too slow)
  var threeLetterWords = sequences.reduce(function(memo, c){
    return memo.concat( radiatedSequences(c.getPositions()) );
  }, []);

  var fourLetterWords = threeLetterWords.reduce(function(memo, c){
    return memo.concat( radiatedSequences(c.getPositions()) );
  }, []);

  console.log('about to generate 5-letter sequences');
  var fiveLetterWords = fourLetterWords.reduce(function(memo, c){
    return memo.concat( radiatedSequences(c.getPositions()) );
  }, []);
  console.log('about to generate 6-letter sequences');

  var sixLetterWords = fiveLetterWords.reduce(function(memo, c){
    return memo.concat( radiatedSequences(c.getPositions()) );
  }, []);
  console.log('about to generate 7-letter sequences');

  var sevenLetterWords = sixLetterWords.reduce(function(memo, c){
    return memo.concat( radiatedSequences(c.getPositions()) );
  }, []);

  return sequences.concat(threeLetterWords, fourLetterWords, fiveLetterWords, sixLetterWords, sevenLetterWords);
}

function getLettersMatrix(){
  return lettersMatrix;
}

function getDimension(){
  return dimension;
}

function removeLongSequences(sequences){
  return sequences.filter(function(w){
    return w.longEnough();
  });
}

function removeDuplicateSequences(sequences){
  var set = [];
  var word;
  return sequences.filter(function(sequence) {
    word = sequence.getLetters( getLettersMatrix() );
    if( set.indexOf(word) == -1 ) {
      set.push(word);
      return true;
    }else{
      return false;
    }
  });
}

function binarySearch(array, key) {
  var lo = 0,
  hi = array.length - 1,
  mid, element;

  while (lo <= hi) {
    mid = ((lo + hi) >> 1);
    element = array[mid];
    if (element < key) {
      lo = mid + 1;
    } else if (element > key) {
      hi = mid - 1;
    } else {
      return mid;
    }
  }
  return -1;
}

function keepExistingSequences(sequences){
  return sequences.filter(function(sequence) {
    return binarySearch(referenceWordsList, sequence.getLetters(getLettersMatrix()) ) != -1;
  });
}

function sortSequences(sequences){
  return sequences.sort(function(comb1, comb2){
    if ( comb1.getLetters(getLettersMatrix()) > comb2.getLetters(getLettersMatrix()) ){
      return 1;
    }else{
      return -1;
    }
  });
}

function insideMatrix(position){
  return (position[0] > -1 && position[1] > -1 && position[0] < getDimension() && position[1] < getDimension() );
}

function addLetter(sequence, direction){
  var current_position = sequence.getLastPosition();
  var new_position = [current_position[0] + direction[0], current_position[1] + direction[1]];
  if( insideMatrix(new_position) && !sequence.positionExists(new_position)){
    sequence.addPosition(new_position);
    return sequence;
  }
}

function radiatedSequences(positions){
  var sequences = [];

  for(var d in directions){
    var candidate = addLetter( LettersSequence(positions), directions[d] );
    if(candidate){
      sequences.push(candidate);
    }
  }
  return sequences;
}

// exports public interface

exports.initialize = function initialize(){
  referenceWordsList = getReferenceWordsList();
};

exports.findWords = function(lettersMat){
  dimension = lettersMat.length;
  lettersMatrix = lettersMat;

  if(serializedSequences){
    sequences = serializedSequences;
  }else {
    serializedSequences = setSerializedSequences();
    sequences = serializedSequences.slice(0);
    // sequences = findAllLettersSequences();
    // sequences = removeLongSequences(sequences);
    // fs.writeFileSync('data/3-4-5-6-7-letter-sequences.json', JSON.stringify(sequences));
    // serializedSequences = sequences.slice(0);
  }

  sequences = keepExistingSequences(sequences);
  sequences = removeDuplicateSequences(sequences);
  sequences = sortSequences(sequences);

  return sequences.map(function(s){
    return [s.getLetters(getLettersMatrix()), s.getPositions()];
  });
};
<commit_msg>cleaning: removes useless white space<commit_after>var fs = require('fs');
var LettersSequence = require('./letters_sequence');

var lettersMatrix;
var dimension;
var referenceWordsList;
var serializedSequences;
var sequences;

var directions = {
  'up':         [ 0, -1],
  'up-right':   [ 1, -1],
  'right':      [ 1,  0],
  'right-down': [ 1,  1],
  'down':       [ 0,  1],
  'down-left':  [-1,  1],
  'left':       [-1,  0],
  'left-up':    [-1, -1]
};

function getReferenceWordsList(){
  var data = fs.readFileSync('data/dict_en.txt');
  return data.toString().split(/\W+/);
}

function setSerializedSequences(){
  var data = fs.readFileSync('data/3-4-5-6-7-letter-sequences.json');
  return JSON.parse(data, function(key, value){
    if(value instanceof Array){
      return value;
    }else{
      return LettersSequence(JSON.parse(value));
    }
  });
}

function findAllLettersSequences(){
  var sequences = [];
  for(var i = 0; i < getDimension(); i++){
    for(var j = 0; j < getDimension(); j++){
      sequences = sequences.concat( radiatedSequences( [[i, j]] ));
    }
  }

  // max of 6-letter words for now (otherwise too slow)
  var threeLetterWords = sequences.reduce(function(memo, c){
    return memo.concat( radiatedSequences(c.getPositions()) );
  }, []);

  var fourLetterWords = threeLetterWords.reduce(function(memo, c){
    return memo.concat( radiatedSequences(c.getPositions()) );
  }, []);

  console.log('about to generate 5-letter sequences');
  var fiveLetterWords = fourLetterWords.reduce(function(memo, c){
    return memo.concat( radiatedSequences(c.getPositions()) );
  }, []);
  console.log('about to generate 6-letter sequences');

  var sixLetterWords = fiveLetterWords.reduce(function(memo, c){
    return memo.concat( radiatedSequences(c.getPositions()) );
  }, []);
  console.log('about to generate 7-letter sequences');

  var sevenLetterWords = sixLetterWords.reduce(function(memo, c){
    return memo.concat( radiatedSequences(c.getPositions()) );
  }, []);

  return sequences.concat(threeLetterWords, fourLetterWords, fiveLetterWords, sixLetterWords, sevenLetterWords);
}

function getLettersMatrix(){
  return lettersMatrix;
}

function getDimension(){
  return dimension;
}

function removeLongSequences(sequences){
  return sequences.filter(function(w){
    return w.longEnough();
  });
}

function removeDuplicateSequences(sequences){
  var set = [];
  var word;
  return sequences.filter(function(sequence) {
    word = sequence.getLetters( getLettersMatrix() );
    if( set.indexOf(word) == -1 ) {
      set.push(word);
      return true;
    }else{
      return false;
    }
  });
}

function binarySearch(array, key) {
  var lo = 0,
  hi = array.length - 1,
  mid, element;

  while (lo <= hi) {
    mid = ((lo + hi) >> 1);
    element = array[mid];
    if (element < key) {
      lo = mid + 1;
    } else if (element > key) {
      hi = mid - 1;
    } else {
      return mid;
    }
  }
  return -1;
}

function keepExistingSequences(sequences){
  return sequences.filter(function(sequence) {
    return binarySearch(referenceWordsList, sequence.getLetters(getLettersMatrix()) ) != -1;
  });
}

function sortSequences(sequences){
  return sequences.sort(function(comb1, comb2){
    if ( comb1.getLetters(getLettersMatrix()) > comb2.getLetters(getLettersMatrix()) ){
      return 1;
    }else{
      return -1;
    }
  });
}

function insideMatrix(position){
  return (position[0] > -1 && position[1] > -1 && position[0] < getDimension() && position[1] < getDimension() );
}

function addLetter(sequence, direction){
  var current_position = sequence.getLastPosition();
  var new_position = [current_position[0] + direction[0], current_position[1] + direction[1]];
  if( insideMatrix(new_position) && !sequence.positionExists(new_position)){
    sequence.addPosition(new_position);
    return sequence;
  }
}

function radiatedSequences(positions){
  var sequences = [];

  for(var d in directions){
    var candidate = addLetter( LettersSequence(positions), directions[d] );
    if(candidate){
      sequences.push(candidate);
    }
  }
  return sequences;
}

// exports public interface

exports.initialize = function initialize(){
  referenceWordsList = getReferenceWordsList();
};

exports.findWords = function(lettersMat){
  dimension = lettersMat.length;
  lettersMatrix = lettersMat;

  if(serializedSequences){
    sequences = serializedSequences;
  }else {
    serializedSequences = setSerializedSequences();
    sequences = serializedSequences.slice(0);
    // sequences = findAllLettersSequences();
    // sequences = removeLongSequences(sequences);
    // fs.writeFileSync('data/3-4-5-6-7-letter-sequences.json', JSON.stringify(sequences));
    // serializedSequences = sequences.slice(0);
  }

  sequences = keepExistingSequences(sequences);
  sequences = removeDuplicateSequences(sequences);
  sequences = sortSequences(sequences);

  return sequences.map(function(s){
    return [s.getLetters(getLettersMatrix()), s.getPositions()];
  });
};
<|endoftext|>


<commit_before>import test from 'ava';
import { tree, Rule, Property, Value } from '../lib';
<commit_msg>Add lib/tree.js test<commit_after>import test from 'ava';
import { tree, Rule, Property, Value } from '../lib';

test('"tree" function', ({same, true: isTrue}) => {
  // Create uncirculated tree
  let prop = new Property('margin', [
    new Value(10, 'px'),
    new Value(2, 'em')
  ]),

  doc = [
    new Rule('.foo', [
      prop
    ]),

    new Rule('.bar', [
      new Property('margin', [
        new Value(5, 'px'),
        new Value(1, 'em')
      ])
    ])
  ];

  // Circulate tree
  doc = tree(doc);

  // Test that tree is circulated
  isTrue(doc.circulated);

  // Test parent link
  same(doc[0].items[0], prop);
});
<|endoftext|>


<commit_before>/**
 * Copyright (c) 2016 CA. All rights reserved.
 * This software may be modified and distributed under the terms
 * of the MIT license. See the LICENSE file for details.
 */

/* eslint-disable no-param-reassign */

import path from 'path';
import merge from 'merge';

export default function (options) {
  const env = process.env.NODE_ENV;
  const development = options.development || env === 'development';

  options = merge.recursive({

    /* Environment */
    name: 'main',
    development,
    env,

    /* HMR */
    domain: process.env.APP_URL,
    hot: options.devServer || development,

    /* devServer */
    indexPage: '/index.html',
    contentBase: process.env.APP_URL,

    /* Filenames and paths */
    filenames: development ? '[name]' : '[name].[hash]',
    devServer: 'http://localhost:8080',
    sourcePath: 'src',
    outputPath: 'lib',

    /* Frameworks */
    react: true,

    /* Other options */
    linting: false,
    inlineLimit: 50000,

    /* Loaders */
    loaders: {
      js: 'babel-loader',
      css: development ? 'css-loader?sourceMap' : 'css-loader!postcss-loader',
    },
  }, options);

  /* Uniformize source path and entry point */
  options.entry = options.sourcePath;
  options.sourcePath = path.resolve(path.dirname(options.sourcePath));

  return options;
}
<commit_msg>refactor: change to public output<commit_after>/**
 * Copyright (c) 2016 CA. All rights reserved.
 * This software may be modified and distributed under the terms
 * of the MIT license. See the LICENSE file for details.
 */

/* eslint-disable no-param-reassign */

import path from 'path';
import merge from 'merge';

export default function (options) {
  const env = process.env.NODE_ENV;
  const development = options.development || env === 'development';

  options = merge.recursive({

    /* Environment */
    name: 'main',
    development,
    env,

    /* HMR */
    domain: process.env.APP_URL,
    hot: options.devServer || development,

    /* devServer */
    indexPage: '/index.html',
    contentBase: process.env.APP_URL,

    /* Filenames and paths */
    filenames: development ? '[name]' : '[name].[hash]',
    devServer: 'http://localhost:8080',
    sourcePath: 'src',
    outputPath: 'public',

    /* Frameworks */
    react: true,

    /* Other options */
    linting: false,
    inlineLimit: 50000,

    /* Loaders */
    loaders: {
      js: 'babel-loader',
      css: development ? 'css-loader?sourceMap' : 'css-loader!postcss-loader',
    },
  }, options);

  /* Uniformize source path and entry point */
  options.entry = options.sourcePath;
  options.sourcePath = path.resolve(path.dirname(options.sourcePath));

  return options;
}
<|endoftext|>