<commit_before>var
  gulp = require('gulp'),
  jshint = require('gulp-jshint'),
  amdOptimize = require('gulp-amd-optimizer'),
  //concatSourcemap = require('gulp-concat-sourcemap'),
  uglify = require('gulp-uglify'),
  concat = require('gulp-concat'),
  csso = require('gulp-csso'),
  requireConfig,
  outDirJS,
  outDirCSS
;

outDirJS = 'public/assets/javascripts';
outDirCSS = 'public/assets/stylesheets';

requireConfig = {
  baseUrl: __dirname
};

gulp.task('Lint scripts', function () {
    return gulp.src(['src/js/**/*.js', 'libs/*.js', 'gulpfile.js'])
      .pipe(jshint('.jshintrc'))
      .pipe(jshint.reporter('jshint-stylish'));
});

gulp.task(
  'Concat modules',
  function () {
    return gulp.src('src/js/*.js')
      .pipe(amdOptimize(requireConfig, { umd: false }))
      .pipe(concat('modules.js'))
      .pipe(gulp.dest(outDirJS));
  }
);

gulp.task(
  'Concat libraries',
  function () {
    return gulp.src('libs/*.js')
      .pipe(concat('libs.js'))
      .pipe(gulp.dest(outDirJS));
  }
);

gulp.task(
  'Compress scripts',
  ['Concat modules', 'Concat libraries'],
  function() {
    return gulp.src([outDirJS + '/libs.js', outDirJS + '/modules.js'])
      .pipe(uglify())
      .pipe(concat('all.min.js'))
      .pipe(gulp.dest(outDirJS));
  }
);

gulp.task(
  'Compress stylesheets',
  function() {
    return gulp.src('src/css/*.css')
      .pipe(concat('all.min.css', {newLine: '\r\n'}))
      .pipe(csso())
      .pipe(gulp.dest(outDirCSS));
  }
);

gulp.task(
  'Copy index',
  function() {
    return gulp.src('src/index.html')
      .pipe(gulp.dest('./public'));
});

gulp.task(
  'Copy data directory',
  function() {
    return gulp.src('data/*.json')
      .pipe(gulp.dest('./public/data'));
});

gulp.task('default', [
  'Lint scripts',
  'Concat modules',
  'Concat libraries',
  'Compress scripts',
  'Compress stylesheets',
  'Copy index',
  'Copy data directory'
]);<commit_msg>some cleanup<commit_after>var
  gulp = require('gulp'),
  jshint = require('gulp-jshint'),
  amdOptimize = require('gulp-amd-optimizer'),
  //concatSourcemap = require('gulp-concat-sourcemap'),
  uglify = require('gulp-uglify'),
  concat = require('gulp-concat'),
  csso = require('gulp-csso')
;

var outDirJS = 'public/assets/javascripts';
var outDirCSS = 'public/assets/stylesheets';

var requireConfig = {
  baseUrl: __dirname
};

gulp.task('Lint scripts', function () {
    return gulp.src(['src/js/**/*.js', 'libs/*.js', 'gulpfile.js'])
      .pipe(jshint('.jshintrc'))
      .pipe(jshint.reporter('jshint-stylish'));
});

gulp.task(
  'Concat modules',
  function () {
    return gulp.src('src/js/*.js')
      .pipe(amdOptimize(requireConfig, { umd: false }))
      .pipe(concat('modules.js'))
      .pipe(gulp.dest(outDirJS));
  }
);

gulp.task(
  'Concat libraries',
  function () {
    return gulp.src('libs/*.js')
      .pipe(concat('libs.js'))
      .pipe(gulp.dest(outDirJS));
  }
);

gulp.task(
  'Compress scripts',
  ['Concat modules', 'Concat libraries'],
  function() {
    return gulp.src([outDirJS + '/libs.js', outDirJS + '/modules.js'])
      .pipe(uglify())
      .pipe(concat('all.min.js'))
      .pipe(gulp.dest(outDirJS));
  }
);

gulp.task(
  'Compress stylesheets',
  function() {
    return gulp.src('src/css/*.css')
      .pipe(concat('all.min.css', {newLine: '\r\n'}))
      .pipe(csso())
      .pipe(gulp.dest(outDirCSS));
  }
);

gulp.task(
  'Copy index',
  function() {
    return gulp.src('src/index.html')
      .pipe(gulp.dest('./public'));
});

gulp.task(
  'Copy data directory',
  function() {
    return gulp.src('data/*.json')
      .pipe(gulp.dest('./public/data'));
});

gulp.task('default', [
  'Lint scripts',
  'Concat modules',
  'Concat libraries',
  'Compress scripts',
  'Compress stylesheets',
  'Copy index',
  'Copy data directory'
]);<|endoftext|>


<commit_before>/*
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/

'use strict';

// Include promise polyfill for node 0.10 compatibility
require('es6-promise').polyfill();

// Include Gulp & tools we'll use
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var del = require('del');
var runSequence = require('run-sequence');
var browserSync = require('browser-sync');
var reload = browserSync.reload;
var merge = require('merge-stream');
var path = require('path');
var fs = require('fs');
var glob = require('glob-all');
var historyApiFallback = require('connect-history-api-fallback');
var packageJson = require('./package.json');
var crypto = require('crypto');
var ensureFiles = require('./tasks/ensure-files.js');

// var ghPages = require('gulp-gh-pages');

var AUTOPREFIXER_BROWSERS = [
  'ie >= 10',
  'ie_mob >= 10',
  'ff >= 30',
  'chrome >= 34',
  'safari >= 7',
  'opera >= 23',
  'ios >= 7',
  'android >= 4.4',
  'bb >= 10'
];

var DIST = 'dist';

var dist = function(subpath) {
  return !subpath ? DIST : path.join(DIST, subpath);
};

var styleTask = function(stylesPath, srcs) {
  return gulp.src(srcs.map(function(src) {
      return path.join('app', stylesPath, src);
    }))
    .pipe($.changed(stylesPath, {extension: '.css'}))
    .pipe($.autoprefixer(AUTOPREFIXER_BROWSERS))
    .pipe(gulp.dest('.tmp/' + stylesPath))
    .pipe($.minifyCss())
    .pipe(gulp.dest(dist(stylesPath)))
    .pipe($.size({title: stylesPath}));
};

var imageOptimizeTask = function(src, dest) {
  return gulp.src(src)
    .pipe($.imagemin({
      progressive: true,
      interlaced: true
    }))
    .pipe(gulp.dest(dest))
    .pipe($.size({title: 'images'}));
};

var optimizeHtmlTask = function(src, dest) {
  var assets = $.useref.assets({
    searchPath: ['.tmp', 'app']
  });

  return gulp.src(src)
    .pipe(assets)
    // Concatenate and minify JavaScript
    .pipe($.if('*.js', $.uglify({
      preserveComments: 'some'
    })))
    // Concatenate and minify styles
    // In case you are still using useref build blocks
    .pipe($.if('*.css', $.minifyCss()))
    .pipe(assets.restore())
    .pipe($.useref())
    // Minify any HTML
    .pipe($.if('*.html', $.minifyHtml({
      quotes: true,
      empty: true,
      spare: true
    })))
    // Output files
    .pipe(gulp.dest(dest))
    .pipe($.size({
      title: 'html'
    }));
};

// Compile and automatically prefix stylesheets
gulp.task('styles', function() {
  return styleTask('styles', ['**/*.css']);
});

// Ensure that we are not missing required files for the project
// "dot" files are specifically tricky due to them being hidden on
// some systems.
gulp.task('ensureFiles', function(cb) {
  var requiredFiles = ['.bowerrc'];

  ensureFiles(requiredFiles.map(function(p) {
    return path.join(__dirname, p);
  }), cb);
});

// Optimize images
gulp.task('images', function() {
  return imageOptimizeTask('app/images/**/*', dist('images'));
});

// Copy all files at the root level (app)
gulp.task('copy', function() {
  var app = gulp.src([
    'app/*',
    '!app/test',
    '!app/elements',
    '!app/bower_components',
    '!app/cache-config.json',
    '!**/.DS_Store'
  ], {
    dot: true
  }).pipe(gulp.dest(dist()));

  // Copy over only the bower_components we need
  // These are things which cannot be vulcanized
  var bower = gulp.src([
    'app/bower_components/{webcomponentsjs,platinum-sw,sw-toolbox,promise-polyfill}/**/*'
  ]).pipe(gulp.dest(dist('bower_components')));

  return merge(app, bower)
    .pipe($.size({
      title: 'copy'
    }));
});

// Copy web fonts to dist
gulp.task('fonts', function() {
  return gulp.src(['app/fonts/**'])
    .pipe(gulp.dest(dist('fonts')))
    .pipe($.size({
      title: 'fonts'
    }));
});

// Scan your HTML for assets & optimize them
gulp.task('html', function() {
  return optimizeHtmlTask(
    ['app/**/*.html', '!app/{elements,test,bower_components}/**/*.html'],
    dist());
});

// Vulcanize granular configuration
gulp.task('vulcanize', function() {
  return gulp.src('app/elements/elements.html')
    .pipe($.vulcanize({
      stripComments: true,
      inlineCss: true,
      inlineScripts: true
    }))
    .pipe(gulp.dest(dist('elements')))
    .pipe($.size({title: 'vulcanize'}));
});

// Generate config data for the <sw-precache-cache> element.
// This include a list of files that should be precached, as well as a (hopefully unique) cache
// id that ensure that multiple PSK projects don't share the same Cache Storage.
// This task does not run by default, but if you are interested in using service worker caching
// in your project, please enable it within the 'default' task.
// See https://github.com/PolymerElements/polymer-starter-kit#enable-service-worker-support
// for more context.
gulp.task('cache-config', function(callback) {
  var dir = dist();
  var config = {
    cacheId: packageJson.name || path.basename(__dirname),
    disabled: false
  };

  glob([
    'index.html',
    './',
    'bower_components/webcomponentsjs/webcomponents-lite.min.js',
    '{elements,scripts,styles}/**/*.*'],
    {cwd: dir}, function(error, files) {
    if (error) {
      callback(error);
    } else {
      config.precache = files;

      var md5 = crypto.createHash('md5');
      md5.update(JSON.stringify(config.precache));
      config.precacheFingerprint = md5.digest('hex');

      var configPath = path.join(dir, 'cache-config.json');
      fs.writeFile(configPath, JSON.stringify(config), callback);
    }
  });
});

// Clean output directory
gulp.task('clean', function() {
  return del(['.tmp', dist()]);
});

// Watch files for changes & reload
gulp.task('serve', ['styles'], function() {
  browserSync({
    port: 5000,
    notify: false,
    logPrefix: 'PSK',
    snippetOptions: {
      rule: {
        match: '',
        fn: function(snippet) {
          return snippet;
        }
      }
    },
    // Run as an https by uncommenting 'https: true'
    // Note: this uses an unsigned certificate which on first access
    //       will present a certificate warning in the browser.
    // https: true,
    server: {
      baseDir: ['.tmp', 'app'],
      middleware: [historyApiFallback()]
    }
  });

  gulp.watch(['app/**/*.html', '!app/bower_components/**/*.html'], reload);
  gulp.watch(['app/styles/**/*.css'], ['styles', reload]);
  gulp.watch(['app/scripts/**/*.js'], reload);
  gulp.watch(['app/images/**/*'], reload);
});

// Build and serve the output from the dist build
gulp.task('serve:dist', ['default'], function() {
  browserSync({
    port: 5001,
    notify: false,
    logPrefix: 'PSK',
    snippetOptions: {
      rule: {
        match: '',
        fn: function(snippet) {
          return snippet;
        }
      }
    },
    // Run as an https by uncommenting 'https: true'
    // Note: this uses an unsigned certificate which on first access
    //       will present a certificate warning in the browser.
    // https: true,
    server: dist(),
    middleware: [historyApiFallback()]
  });
});

// Build production files, the default task
gulp.task('default', ['clean'], function(cb) {
  // Uncomment 'cache-config' if you are going to use service workers.
  runSequence(
    ['ensureFiles', 'copy', 'styles'],
    ['images', 'fonts', 'html'],
    'vulcanize', // 'cache-config',
    cb);
});

// Build then deploy to GitHub pages gh-pages branch
gulp.task('build-deploy-gh-pages', function(cb) {
  runSequence(
    'default',
    'deploy-gh-pages',
    cb);
});

// Deploy to GitHub pages gh-pages branch
gulp.task('deploy-gh-pages', function() {
  return gulp.src(dist('**/*'))
    // Check if running task from Travis CI, if so run using GH_TOKEN
    // otherwise run using ghPages defaults.
    .pipe($.if(process.env.TRAVIS === 'true', $.ghPages({
      remoteUrl: 'https://$GH_TOKEN@github.com/polymerelements/polymer-starter-kit.git',
      silent: true,
      branch: 'gh-pages'
    }), $.ghPages()));
});

// Load tasks for web-component-tester
// Adds tasks for `gulp test:local` and `gulp test:remote`
require('web-component-tester').gulp.init(gulp);

// Load custom tasks from the `tasks` directory
try {
  require('require-dir')('tasks');
} catch (err) {
  // Do nothing
}
<commit_msg>calendar<commit_after>/*
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/

'use strict';

// Include promise polyfill for node 0.10 compatibility
require('es6-promise').polyfill();

// Include Gulp & tools we'll use
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var del = require('del');
var runSequence = require('run-sequence');
var browserSync = require('browser-sync');
var reload = browserSync.reload;
var merge = require('merge-stream');
var path = require('path');
var fs = require('fs');
var glob = require('glob-all');
var historyApiFallback = require('connect-history-api-fallback');
var packageJson = require('./package.json');
var crypto = require('crypto');
var ensureFiles = require('./tasks/ensure-files.js');

// var ghPages = require('gulp-gh-pages');

var AUTOPREFIXER_BROWSERS = [
  'ie >= 10',
  'ie_mob >= 10',
  'ff >= 30',
  'chrome >= 34',
  'safari >= 7',
  'opera >= 23',
  'ios >= 7',
  'android >= 4.4',
  'bb >= 10'
];

var DIST = 'dist';

var dist = function(subpath) {
  return !subpath ? DIST : path.join(DIST, subpath);
};

var styleTask = function(stylesPath, srcs) {
  return gulp.src(srcs.map(function(src) {
      return path.join('app', stylesPath, src);
    }))
    .pipe($.changed(stylesPath, {extension: '.css'}))
    .pipe($.autoprefixer(AUTOPREFIXER_BROWSERS))
    .pipe(gulp.dest('.tmp/' + stylesPath))
    .pipe($.minifyCss())
    .pipe(gulp.dest(dist(stylesPath)))
    .pipe($.size({title: stylesPath}));
};

var imageOptimizeTask = function(src, dest) {
  return gulp.src(src)
    .pipe($.imagemin({
      progressive: true,
      interlaced: true
    }))
    .pipe(gulp.dest(dest))
    .pipe($.size({title: 'images'}));
};

var optimizeHtmlTask = function(src, dest) {
  var assets = $.useref.assets({
    searchPath: ['.tmp', 'app']
  });

  return gulp.src(src)
    .pipe(assets)
    // Concatenate and minify JavaScript
    .pipe($.if('*.js', $.uglify({
      preserveComments: 'some'
    })))
    // Concatenate and minify styles
    // In case you are still using useref build blocks
    .pipe($.if('*.css', $.minifyCss()))
    .pipe(assets.restore())
    .pipe($.useref())
    // Minify any HTML
    .pipe($.if('*.html', $.minifyHtml({
      quotes: true,
      empty: true,
      spare: true
    })))
    // Output files
    .pipe(gulp.dest(dest))
    .pipe($.size({
      title: 'html'
    }));
};

// Compile and automatically prefix stylesheets
gulp.task('styles', function() {
  return styleTask('styles', ['**/*.css']);
});

// Ensure that we are not missing required files for the project
// "dot" files are specifically tricky due to them being hidden on
// some systems.
gulp.task('ensureFiles', function(cb) {
  var requiredFiles = ['.bowerrc'];

  ensureFiles(requiredFiles.map(function(p) {
    return path.join(__dirname, p);
  }), cb);
});

// Optimize images
gulp.task('images', function() {
  return imageOptimizeTask('app/images/**/*', dist('images'));
});

// Copy all files at the root level (app)
gulp.task('copy', function() {
  var app = gulp.src([
    'app/*',
    '!app/test',
    '!app/elements',
    '!app/bower_components',
    '!app/cache-config.json',
    '!**/.DS_Store'
  ], {
    dot: true
  }).pipe(gulp.dest(dist()));

  // Copy over only the bower_components we need
  // These are things which cannot be vulcanized
  var bower = gulp.src([
    'app/bower_components/{webcomponentsjs,underscore,font-awesome,platinum-sw,sw-toolbox,promise-polyfill}/**/*'
  ]).pipe(gulp.dest(dist('bower_components')));

  return merge(app, bower)
    .pipe($.size({
      title: 'copy'
    }));
});

// Copy web fonts to dist
gulp.task('fonts', function() {
  return gulp.src(['app/fonts/**'])
    .pipe(gulp.dest(dist('fonts')))
    .pipe($.size({
      title: 'fonts'
    }));
});

// Scan your HTML for assets & optimize them
gulp.task('html', function() {
  return optimizeHtmlTask(
    ['app/**/*.html', '!app/{elements,test,bower_components}/**/*.html'],
    dist());
});

// Vulcanize granular configuration
gulp.task('vulcanize', function() {
  return gulp.src('app/elements/elements.html')
    .pipe($.vulcanize({
      stripComments: true,
      inlineCss: true,
      inlineScripts: true
    }))
    .pipe(gulp.dest(dist('elements')))
    .pipe($.size({title: 'vulcanize'}));
});

// Generate config data for the <sw-precache-cache> element.
// This include a list of files that should be precached, as well as a (hopefully unique) cache
// id that ensure that multiple PSK projects don't share the same Cache Storage.
// This task does not run by default, but if you are interested in using service worker caching
// in your project, please enable it within the 'default' task.
// See https://github.com/PolymerElements/polymer-starter-kit#enable-service-worker-support
// for more context.
gulp.task('cache-config', function(callback) {
  var dir = dist();
  var config = {
    cacheId: packageJson.name || path.basename(__dirname),
    disabled: false
  };

  glob([
    'index.html',
    './',
    'bower_components/webcomponentsjs/webcomponents-lite.min.js',
    '{elements,scripts,styles}/**/*.*'],
    {cwd: dir}, function(error, files) {
    if (error) {
      callback(error);
    } else {
      config.precache = files;

      var md5 = crypto.createHash('md5');
      md5.update(JSON.stringify(config.precache));
      config.precacheFingerprint = md5.digest('hex');

      var configPath = path.join(dir, 'cache-config.json');
      fs.writeFile(configPath, JSON.stringify(config), callback);
    }
  });
});

// Clean output directory
gulp.task('clean', function() {
  return del(['.tmp', dist()]);
});

// Watch files for changes & reload
gulp.task('serve', ['styles'], function() {
  browserSync({
    port: 5000,
    notify: false,
    logPrefix: 'PSK',
    snippetOptions: {
      rule: {
        match: '',
        fn: function(snippet) {
          return snippet;
        }
      }
    },
    // Run as an https by uncommenting 'https: true'
    // Note: this uses an unsigned certificate which on first access
    //       will present a certificate warning in the browser.
    // https: true,
    server: {
      baseDir: ['.tmp', 'app'],
      middleware: [historyApiFallback()]
    }
  });

  gulp.watch(['app/**/*.html', '!app/bower_components/**/*.html'], reload);
  gulp.watch(['app/styles/**/*.css'], ['styles', reload]);
  gulp.watch(['app/scripts/**/*.js'], reload);
  gulp.watch(['app/images/**/*'], reload);
});

// Build and serve the output from the dist build
gulp.task('serve:dist', ['default'], function() {
  browserSync({
    port: 5001,
    notify: false,
    logPrefix: 'PSK',
    snippetOptions: {
      rule: {
        match: '',
        fn: function(snippet) {
          return snippet;
        }
      }
    },
    // Run as an https by uncommenting 'https: true'
    // Note: this uses an unsigned certificate which on first access
    //       will present a certificate warning in the browser.
    // https: true,
    server: dist(),
    middleware: [historyApiFallback()]
  });
});

// Build production files, the default task
gulp.task('default', ['clean'], function(cb) {
  // Uncomment 'cache-config' if you are going to use service workers.
  runSequence(
    ['ensureFiles', 'copy', 'styles'],
    ['images', 'fonts', 'html'],
    'vulcanize', // 'cache-config',
    cb);
});

// Build then deploy to GitHub pages gh-pages branch
gulp.task('build-deploy-gh-pages', function(cb) {
  runSequence(
    'default',
    'deploy-gh-pages',
    cb);
});

// Deploy to GitHub pages gh-pages branch
gulp.task('deploy-gh-pages', function() {
  return gulp.src(dist('**/*'))
    // Check if running task from Travis CI, if so run using GH_TOKEN
    // otherwise run using ghPages defaults.
    .pipe($.if(process.env.TRAVIS === 'true', $.ghPages({
      remoteUrl: 'https://$GH_TOKEN@github.com/polymerelements/polymer-starter-kit.git',
      silent: true,
      branch: 'gh-pages'
    }), $.ghPages()));
});

// Load tasks for web-component-tester
// Adds tasks for `gulp test:local` and `gulp test:remote`
require('web-component-tester').gulp.init(gulp);

// Load custom tasks from the `tasks` directory
try {
  require('require-dir')('tasks');
} catch (err) {
  // Do nothing
}
<|endoftext|>


<commit_before>'use strict';

/////////////////////////////////////////////////////////////////////////
//                      PLUGINS & MODULES                              //
/////////////////////////////////////////////////////////////////////////

let gulp            = require('gulp'),
    autoprefixer    = require('gulp-autoprefixer'),
    concat          = require('gulp-concat'),
    connect         = require('gulp-connect'),
    csscomb         = require('gulp-csscomb'),
    csso            = require('gulp-csso'),
    eslint          = require('gulp-eslint'),
    htmlhint        = require('gulp-htmlhint'),
    htmlmin         = require('gulp-htmlmin'),
    imagemin        = require('gulp-imagemin'),
    sass            = require('gulp-sass'),
    stripDebug      = require('gulp-strip-debug'),
    uglify          = require('gulp-uglify'),
    util            = require('gulp-util');

/////////////////////////////////////////////////////////////////////////
//                              PATH                                   //
/////////////////////////////////////////////////////////////////////////

let path = {};

path.dev    = {};
path.public = {};

path.dev.app = "dev/app/";

let assets   = "dev/assets/";
path.dev.fonts = assets + "fonts/";
path.dev.img   = assets + "img/";
path.dev.lib   = assets + "lib/";

let pbl = "public/";

path.public.css       = pbl + "css/";
path.public.fonts     = pbl + "fonts/";
path.public.img       = pbl + "img/";
path.public.js        = pbl + "js/";
path.public.lib       = pbl + "lib/";
path.public.templates = pbl + "templates/";

let production = util.env.type === 'prod';

/////////////////////////////////////////////////////////////////////////
//                            SOURCE                                   //
/////////////////////////////////////////////////////////////////////////

let appJs       = [ path.dev.app + "app.js", path.dev.app + "**/*.js",
                    path.dev.app  + "**/*.*.js" ],
    vendorJs    = [ path.dev.lib + "jQuery/*.js",
    				path.dev.lib + "jquery-validate/jquery-validate.js",
    				path.dev.lib + "jquery-validate/*.js",
    			    path.dev.lib + "angular/*.js",
    				path.dev.lib + "**/*.js" ],
    fonts       = [ path.dev.fonts + "*.ttf", path.dev.fonts + "*.woff",
                    path.dev.fonts + "*.woff2", path.dev.fonts + "*.eot" ],
    vendorCss   = [ path.dev.lib + "**/*.css", path.dev.lib + "**/*.*.css" ],
    sassSrc     = [ path.dev.app + "**/*.scss" ],
    templateSrc = [ path.dev.app + "**/*.html", path.dev.app + "**/*.*.html" ],
    imgSrc      = [ path.dev.img + "*.jpg", path.dev.img + "*.png" ];

/////////////////////////////////////////////////////////////////////////
//                         CONNECT TASKS                               //
/////////////////////////////////////////////////////////////////////////

gulp.task ('connect', () => {
	connect.server({
    root: 'public/',
    port: 3000,
    livereload: true
  });
});

/////////////////////////////////////////////////////////////////////////
//                            JS TASKS                                 //
/////////////////////////////////////////////////////////////////////////

gulp.task ( 'app-js', () => {
	return gulp.src( appJs )
		.pipe(eslint({
			rules: {
				'strict': 1,
				'comma-dangle': 2,
				'no-unreachable': 2,
				'vars-on-top': 1,
				'block-spacing': 1,
				'comma-spacing': 1,
				'array-bracket-spacing': 1,
				'comma-style': 1,
				'space-infix-ops': 1,
				'space-before-func-paren': 1,
				'space-before-blocks': 1
			},
			env: {
				es6: true
			}
		}))
        .pipe(eslint.format())
		.pipe( concat('bundle.js') )
		.pipe( production ? uglify() : util.noop() )
		.pipe( production ? stripDebug() : util.noop() )
		.pipe( gulp.dest(path.public.js) )
		.pipe( connect.reload() );
} );

gulp.task ( 'vendor-js', () => {
	return gulp.src( vendorJs )
		.pipe( concat('vendor.js') )
		.pipe( production ? uglify() : util.noop() )
		.pipe( gulp.dest(path.public.lib) )
		.pipe( connect.reload() );
} );

/////////////////////////////////////////////////////////////////////////
//                            CSS TASKS                                //
/////////////////////////////////////////////////////////////////////////

gulp.task ( 'css', () => {
	return gulp.src ( sassSrc )
		.pipe( sass() )
		.pipe( concat('style.css') )
		.pipe( csso (
			{
	            restructure: production,
	            sourceMap: !production,
	            debug: !production
        	}
        ))
		.pipe( production ? util.noop() : csscomb() )
		.pipe( autoprefixer( { browsers: [ "> 0%" ] } ) )
		.pipe( gulp.dest(path.public.css) )
		.pipe( connect.reload() );
} );

gulp.task ( 'vendor-css', () => {
	return gulp.src ( vendorCss )
		.pipe( concat('vendor.css') )
		.pipe( csso (
			{
	            restructure: production,
	            sourceMap: !production,
	            debug: !production
        	}
        ))
		.pipe( production ? util.noop() : csscomb() )
		.pipe( gulp.dest(path.public.lib) )
		.pipe( connect.reload() );
} );

/////////////////////////////////////////////////////////////////////////
//                           HTML TASKS                                //
/////////////////////////////////////////////////////////////////////////

gulp.task ( 'templates', () => {
	return gulp.src( templateSrc )
		.pipe( htmlmin( { collapseWhitespace: true } ) )
		.pipe( htmlhint() )
		.pipe( gulp.dest( path.public.templates ) )
		.pipe( connect.reload() );
} );

gulp.task( 'reload-index', () => {
	return gulp.src("public/index.html")
		.pipe(connect.reload());
} );

/////////////////////////////////////////////////////////////////////////
//                       RESOURCES TASKS                               //
/////////////////////////////////////////////////////////////////////////

gulp.task ( 'img', () => {
	return gulp.src( imgSrc )
		.pipe( imagemin() )
		.pipe( gulp.dest( path.public.img ) )
		.pipe( connect.reload() );
} );

gulp.task ( 'fonts', () => {
	return gulp.src( fonts )
		.pipe( gulp.dest(path.public.fonts) )
		.pipe( connect.reload() );
} );

/////////////////////////////////////////////////////////////////////////
//                              WATCH                                  //
/////////////////////////////////////////////////////////////////////////

gulp.task ( 'watch', () => {
	gulp.watch ( appJs, ['app-js'] );
	gulp.watch ( vendorJs, ['vendor-js'] );
	gulp.watch ( vendorCss, ['vendor-css'] );
	gulp.watch ( sassSrc, ['css'] );
	gulp.watch ( templateSrc, ['templates'] );
	gulp.watch ( imgSrc, ['img'] );
	gulp.watch ( fonts, ['fonts'] );
	gulp.watch ( "public/index.html", ['reload-index'] );
} );

/////////////////////////////////////////////////////////////////////////
//                            DEFAULT                                  //
/////////////////////////////////////////////////////////////////////////

gulp.task ( 'default', [ 'vendor-js', 'app-js', 'vendor-css', 'css',
                         'img', 'fonts', 'templates' ] );<commit_msg>Remove unreachable rule from eslint<commit_after>'use strict';

/////////////////////////////////////////////////////////////////////////
//                      PLUGINS & MODULES                              //
/////////////////////////////////////////////////////////////////////////

let gulp            = require('gulp'),
    autoprefixer    = require('gulp-autoprefixer'),
    concat          = require('gulp-concat'),
    connect         = require('gulp-connect'),
    csscomb         = require('gulp-csscomb'),
    csso            = require('gulp-csso'),
    eslint          = require('gulp-eslint'),
    htmlhint        = require('gulp-htmlhint'),
    htmlmin         = require('gulp-htmlmin'),
    imagemin        = require('gulp-imagemin'),
    sass            = require('gulp-sass'),
    stripDebug      = require('gulp-strip-debug'),
    uglify          = require('gulp-uglify'),
    util            = require('gulp-util');

/////////////////////////////////////////////////////////////////////////
//                              PATH                                   //
/////////////////////////////////////////////////////////////////////////

let path = {};

path.dev    = {};
path.public = {};

path.dev.app = "dev/app/";

let assets   = "dev/assets/";
path.dev.fonts = assets + "fonts/";
path.dev.img   = assets + "img/";
path.dev.lib   = assets + "lib/";

let pbl = "public/";

path.public.css       = pbl + "css/";
path.public.fonts     = pbl + "fonts/";
path.public.img       = pbl + "img/";
path.public.js        = pbl + "js/";
path.public.lib       = pbl + "lib/";
path.public.templates = pbl + "templates/";

let production = util.env.type === 'prod';

/////////////////////////////////////////////////////////////////////////
//                            SOURCE                                   //
/////////////////////////////////////////////////////////////////////////

let appJs       = [ path.dev.app + "app.js", path.dev.app + "**/*.js",
                    path.dev.app  + "**/*.*.js" ],
    vendorJs    = [ path.dev.lib + "jQuery/*.js",
    				path.dev.lib + "jquery-validate/jquery-validate.js",
    				path.dev.lib + "jquery-validate/*.js",
    			    path.dev.lib + "angular/*.js",
    				path.dev.lib + "**/*.js" ],
    fonts       = [ path.dev.fonts + "*.ttf", path.dev.fonts + "*.woff",
                    path.dev.fonts + "*.woff2", path.dev.fonts + "*.eot" ],
    vendorCss   = [ path.dev.lib + "**/*.css", path.dev.lib + "**/*.*.css" ],
    sassSrc     = [ path.dev.app + "**/*.scss" ],
    templateSrc = [ path.dev.app + "**/*.html", path.dev.app + "**/*.*.html" ],
    imgSrc      = [ path.dev.img + "*.jpg", path.dev.img + "*.png" ];

/////////////////////////////////////////////////////////////////////////
//                         CONNECT TASKS                               //
/////////////////////////////////////////////////////////////////////////

gulp.task ('connect', () => {
	connect.server({
    root: 'public/',
    port: 3000,
    livereload: true
  });
});

/////////////////////////////////////////////////////////////////////////
//                            JS TASKS                                 //
/////////////////////////////////////////////////////////////////////////

gulp.task ( 'app-js', () => {
	return gulp.src( appJs )
		.pipe(eslint({
			rules: {
				'strict': 1,
				'comma-dangle': 2,
				'vars-on-top': 1,
				'block-spacing': 1,
				'comma-spacing': 1,
				'array-bracket-spacing': 1,
				'comma-style': 1,
				'space-infix-ops': 1,
				'space-before-func-paren': 1,
				'space-before-blocks': 1
			},
			env: {
				es6: true
			}
		}))
        .pipe(eslint.format())
		.pipe( concat('bundle.js') )
		.pipe( production ? uglify() : util.noop() )
		.pipe( production ? stripDebug() : util.noop() )
		.pipe( gulp.dest(path.public.js) )
		.pipe( connect.reload() );
} );

gulp.task ( 'vendor-js', () => {
	return gulp.src( vendorJs )
		.pipe( concat('vendor.js') )
		.pipe( production ? uglify() : util.noop() )
		.pipe( gulp.dest(path.public.lib) )
		.pipe( connect.reload() );
} );

/////////////////////////////////////////////////////////////////////////
//                            CSS TASKS                                //
/////////////////////////////////////////////////////////////////////////

gulp.task ( 'css', () => {
	return gulp.src ( sassSrc )
		.pipe( sass() )
		.pipe( concat('style.css') )
		.pipe( csso (
			{
	            restructure: production,
	            sourceMap: !production,
	            debug: !production
        	}
        ))
		.pipe( production ? util.noop() : csscomb() )
		.pipe( autoprefixer( { browsers: [ "> 0%" ] } ) )
		.pipe( gulp.dest(path.public.css) )
		.pipe( connect.reload() );
} );

gulp.task ( 'vendor-css', () => {
	return gulp.src ( vendorCss )
		.pipe( concat('vendor.css') )
		.pipe( csso (
			{
	            restructure: production,
	            sourceMap: !production,
	            debug: !production
        	}
        ))
		.pipe( production ? util.noop() : csscomb() )
		.pipe( gulp.dest(path.public.lib) )
		.pipe( connect.reload() );
} );

/////////////////////////////////////////////////////////////////////////
//                           HTML TASKS                                //
/////////////////////////////////////////////////////////////////////////

gulp.task ( 'templates', () => {
	return gulp.src( templateSrc )
		.pipe( htmlmin( { collapseWhitespace: true } ) )
		.pipe( htmlhint() )
		.pipe( gulp.dest( path.public.templates ) )
		.pipe( connect.reload() );
} );

gulp.task( 'reload-index', () => {
	return gulp.src("public/index.html")
		.pipe(connect.reload());
} );

/////////////////////////////////////////////////////////////////////////
//                       RESOURCES TASKS                               //
/////////////////////////////////////////////////////////////////////////

gulp.task ( 'img', () => {
	return gulp.src( imgSrc )
		.pipe( imagemin() )
		.pipe( gulp.dest( path.public.img ) )
		.pipe( connect.reload() );
} );

gulp.task ( 'fonts', () => {
	return gulp.src( fonts )
		.pipe( gulp.dest(path.public.fonts) )
		.pipe( connect.reload() );
} );

/////////////////////////////////////////////////////////////////////////
//                              WATCH                                  //
/////////////////////////////////////////////////////////////////////////

gulp.task ( 'watch', () => {
	gulp.watch ( appJs, ['app-js'] );
	gulp.watch ( vendorJs, ['vendor-js'] );
	gulp.watch ( vendorCss, ['vendor-css'] );
	gulp.watch ( sassSrc, ['css'] );
	gulp.watch ( templateSrc, ['templates'] );
	gulp.watch ( imgSrc, ['img'] );
	gulp.watch ( fonts, ['fonts'] );
	gulp.watch ( "public/index.html", ['reload-index'] );
} );

/////////////////////////////////////////////////////////////////////////
//                            DEFAULT                                  //
/////////////////////////////////////////////////////////////////////////

gulp.task ( 'default', [ 'vendor-js', 'app-js', 'vendor-css', 'css',
                         'img', 'fonts', 'templates' ] );<|endoftext|>


<commit_before>var gulp = require('gulp');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
var concat = require('gulp-concat');
var notify = require('gulp-notify');
var htmlreplace = require('gulp-html-replace');
var minifiy_css = require('gulp-minify-css');
var main_bower = require('main-bower-files');
var filter = require('gulp-filter');

var bower_dir = 'public/js/lib/vendor/bower_components';

/**
Starting point for gulp... the default task is a blank task depending on the array passed in
*/
gulp.task('default', ['minify-js', 'replace-js', 'minify-css', 'replace-css', 'minify-bower', 'replace-bower', 'minify-libs', 'replace-libs']);

/****************************************
                 Minify
*****************************************/

/**
These are all js files from winstonApp
*/
gulp.task('minify-js', function() {
  return gulp.src(['public/js/app.js', 'public/js/controllers/*.js', 'public/js/services/*.js'])
  	.pipe(concat('app.min.js'))
  	.pipe(uglify())
  	.pipe(gulp.dest('public/js/app-min'))
  	.pipe(notify({ message: 'Finished minifying app (excluding bower)'}));
});

/**
Make sure to manually add new css libs here
*/
gulp.task('minify-css', function() {
  return gulp.src([bower_dir + '/normalize.css/normalize.css',
    bower_dir + '/bootstrap/dist/css/bootstrap.css',
    bower_dir + '/angular-material/angular-material.css',
    bower_dir + '/fullcalendar/dist/fullcalendar.css',
    '//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css',
    bower_dir + '/ngprogress-lite/ngprogress-lite.css',
    bower_dir + '/angular-socialshare/angular-socialshare.css',
    'public/css/style.css'])
  .pipe(concat('css.min.css'))
  .pipe(minifiy_css())
  .pipe(gulp.dest('public/css/css-min'))
  .pipe(notify({ message: 'Finished minifying css'}));
});

/**
This grabs all main bower js files...if its in bower, its included in here
*/
gulp.task('minify-bower', function() {
  var jsFilter = filter('*.js')
  return gulp.src(main_bower())
    .pipe(jsFilter)
    .pipe(concat('bower.min.js'))
    .pipe(uglify())
    .pipe(gulp.dest('public/js/bower/bower-min'))
    .pipe(notify({ message: 'Finished minifying bower'}))
    .pipe(jsFilter.restore());
});

/**
Make sure to manually add new libs into this!
*/
gulp.task('minify-libs', function() {
  return gulp.src(['public/js/lib/calendar.js',
    'public/js/lib/filterStabilize.js',
    'public/js/lib/fuse.min.js',
    'public/js/lib/memoize.js',
    'public/js/lib/twitter.min.js'
    ])
  .pipe(concat('libs.min.js'))
  .pipe(uglify())
  .pipe(gulp.dest('public/js/libs/libs-min'))
  .pipe(notify({ message: 'Finished minifying libs'}));
});

/****************************************
                  Replace
*****************************************/

gulp.task('replace-libs', ['minify-libs'], function() {
  return gulp.src('views/libs.html')
  .pipe(htmlreplace({
    'js': 'js/libs/libs-min/libs.min.js'
  }))
  .pipe(notify({ message: 'Finished replacing libs in html'}))
  .pipe(gulp.dest('views/build'));
})

gulp.task('replace-bower', ['minify-bower'], function() {
  gulp.src('views/bower.html')
  .pipe(htmlreplace({
    'js': 'js/bower/bower-min/bower.min.js'
  }))
  .pipe(notify({ message: 'Finished replacing bower in html'}))
  .pipe(gulp.dest('views/build'));
});

gulp.task('replace-js', ['minify-js'], function() {
	gulp.src('views/includes.html')
	.pipe(htmlreplace({
  		'js': 'js/app-min/app.min.js'
  	}))
  .pipe(notify({ message: 'Finished replacing js in html'}))
  .pipe(gulp.dest('views/build'));
});

gulp.task('replace-css', ['minify-css'], function() {
  gulp.src('views/styles.html')
  .pipe(htmlreplace({
    'css': 'css/css-min/css.min.css'
  }))
  .pipe(notify({ message: 'Finished replacing css in html'}))
  .pipe(gulp.dest('views/build'));
});

<commit_msg>fix: use font awesome version 4.2 instead of 4.3<commit_after>var gulp = require('gulp');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
var concat = require('gulp-concat');
var notify = require('gulp-notify');
var htmlreplace = require('gulp-html-replace');
var minifiy_css = require('gulp-minify-css');
var main_bower = require('main-bower-files');
var filter = require('gulp-filter');

var bower_dir = 'public/js/lib/vendor/bower_components';

/**
Starting point for gulp... the default task is a blank task depending on the array passed in
*/
gulp.task('default', ['minify-js', 'replace-js', 'minify-css', 'replace-css', 'minify-bower', 'replace-bower', 'minify-libs', 'replace-libs']);

/****************************************
                 Minify
*****************************************/

/**
These are all js files from winstonApp
*/
gulp.task('minify-js', function() {
  return gulp.src(['public/js/app.js', 'public/js/controllers/*.js', 'public/js/services/*.js'])
  	.pipe(concat('app.min.js'))
  	.pipe(uglify())
  	.pipe(gulp.dest('public/js/app-min'))
  	.pipe(notify({ message: 'Finished minifying app (excluding bower)'}));
});

/**
Make sure to manually add new css libs here
*/
gulp.task('minify-css', function() {
  return gulp.src([bower_dir + '/normalize.css/normalize.css',
    bower_dir + '/bootstrap/dist/css/bootstrap.css',
    bower_dir + '/angular-material/angular-material.css',
    bower_dir + '/fullcalendar/dist/fullcalendar.css',
    '//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css',
    bower_dir + '/ngprogress-lite/ngprogress-lite.css',
    bower_dir + '/angular-socialshare/angular-socialshare.css',
    'public/css/style.css'])
  .pipe(concat('css.min.css'))
  .pipe(minifiy_css())
  .pipe(gulp.dest('public/css/css-min'))
  .pipe(notify({ message: 'Finished minifying css'}));
});

/**
This grabs all main bower js files...if its in bower, its included in here
*/
gulp.task('minify-bower', function() {
  var jsFilter = filter('*.js')
  return gulp.src(main_bower())
    .pipe(jsFilter)
    .pipe(concat('bower.min.js'))
    .pipe(uglify())
    .pipe(gulp.dest('public/js/bower/bower-min'))
    .pipe(notify({ message: 'Finished minifying bower'}))
    .pipe(jsFilter.restore());
});

/**
Make sure to manually add new libs into this!
*/
gulp.task('minify-libs', function() {
  return gulp.src(['public/js/lib/calendar.js',
    'public/js/lib/filterStabilize.js',
    'public/js/lib/fuse.min.js',
    'public/js/lib/memoize.js',
    'public/js/lib/twitter.min.js'
    ])
  .pipe(concat('libs.min.js'))
  .pipe(uglify())
  .pipe(gulp.dest('public/js/libs/libs-min'))
  .pipe(notify({ message: 'Finished minifying libs'}));
});

/****************************************
                  Replace
*****************************************/

gulp.task('replace-libs', ['minify-libs'], function() {
  return gulp.src('views/libs.html')
  .pipe(htmlreplace({
    'js': 'js/libs/libs-min/libs.min.js'
  }))
  .pipe(notify({ message: 'Finished replacing libs in html'}))
  .pipe(gulp.dest('views/build'));
})

gulp.task('replace-bower', ['minify-bower'], function() {
  gulp.src('views/bower.html')
  .pipe(htmlreplace({
    'js': 'js/bower/bower-min/bower.min.js'
  }))
  .pipe(notify({ message: 'Finished replacing bower in html'}))
  .pipe(gulp.dest('views/build'));
});

gulp.task('replace-js', ['minify-js'], function() {
	gulp.src('views/includes.html')
	.pipe(htmlreplace({
  		'js': 'js/app-min/app.min.js'
  	}))
  .pipe(notify({ message: 'Finished replacing js in html'}))
  .pipe(gulp.dest('views/build'));
});

gulp.task('replace-css', ['minify-css'], function() {
  gulp.src('views/styles.html')
  .pipe(htmlreplace({
    'css': 'css/css-min/css.min.css'
  }))
  .pipe(notify({ message: 'Finished replacing css in html'}))
  .pipe(gulp.dest('views/build'));
});

<|endoftext|>


<commit_before>let Cc = Components.classes;
let Ci = Components.interfaces;

let prompts = Cc['@mozilla.org/embedcomp/prompt-service;1'].getService(Ci.nsIPromptService);
let adban = Cc['@ad-ban.appspot.com/adban;1'].getService().wrappedJSObject;
let logging = adban.logging;
let pref_branch = adban.pref_branch;

let $ = function(id) {
  return document.getElementById(id);
};

let _ = function(id, params) {
  const adban_strings = $('adban-strings');
  if (params) {
    return adban_strings.getFormattedString(id, params);
  }
  return adban_strings.getString(id);
};

let conditionalAlert = function(alert_name, msg) {
  alert_name = 'alert-states.' + alert_name;
  if (pref_branch.prefHasUserValue(alert_name) &&
      pref_branch.getBoolPref(alert_name)) {
    logging.info('the alert [%s] is disabled in preferences', alert_name);
    return;
  }
  const state_obj = {
      value: false,
  };
  prompts.alertCheck(window, 'AdBan', msg, _('dont-show-this-message-again'), state_obj);
  if (state_obj.value) {
    logging.info('disabling the alert [%s] in preferences', alert_name);
    pref_branch.setBoolPref(alert_name, true);
  }
};

let openTab = function(url) {
  logging.info('opening the tab with url=[%s]', url);
  // use this hack, otherwise firefox 3.6 can skip the tab
  // if another tab is immediately opened after this tab.
  const open_tab_callback = function() {
    gBrowser.selectedTab = gBrowser.addTab(url);
  }
  setTimeout(open_tab_callback, 10);
};

let firstRun = function() {
  openTab(adban.FIRST_RUN_URL);

  const nav_bar = $('nav-bar');
  if (!nav_bar) {
    logging.warning('there is no navigation bar in the current window');
    return;
  }
  if ($('adban-complaint-button')) {
    logging.warning('the adban-complaint-button is already installed (though it is unclear how it is possible)');
    return;
  }
  if ($('adban-button')) {
    logging.warning('the adban-button is already installed (though it is unclear how it is possble)');
    return;
  }

  logging.info('adding adban buttons to navigation bar');
  nav_bar.insertItem('adban-complaint-button', null, null, false);
  nav_bar.insertItem('adban-button', null, null, false);

  // this 'magic' is necessary for stupid FF, which can't properly handle
  // toolbar.insertItem().
  // See http://forums.mozillazine.org/viewtopic.php?t=189667 .
  nav_bar.setAttribute('currentset', nav_bar.currentSet);
  document.persist('nav-bar', 'currentset');
  logging.info('adban buttons must be added to navigation bar');
};

let verifyFirstRun = function(verification_complete_callback) {
  const extensions_getter_callback = function(extensions) {
    const extension = extensions.get(adban.EXTENSION_ID);
    if (extension.firstRun) {
      logging.info('the AdBan first run');
      firstRun();
    }
    verification_complete_callback();
  };
  if (Application.extensions) {
    // Firefox 3.6
    extensions_getter_callback(Application.extensions);
  }
  else {
    // Firefox 4+
    Application.getExtensions(extensions_getter_callback);
  }
};

let stateToggle = function(from, to) {
  to.setAttribute('disabled', 'true');
  from.removeAttribute('disabled');
};

let onStateChange = function(is_active) {
  const cmd_adban_stop = $('cmd-adban-stop');
  const cmd_adban_start = $('cmd-adban-start');
  const adban_button = $('adban-button');
  if (!adban_button) {
    logging.warning('it looks like the adban button has been removed from visible toolbars');
    return;
  }
  if (is_active) {
    stateToggle(cmd_adban_stop, cmd_adban_start);
    adban_button.label = 'AdBan ' + _('on');
  }
  else {
    stateToggle(cmd_adban_start, cmd_adban_stop);
    adban_button.label = 'AdBan ' + _('off');
  }
};

let cmdStop = function() {
  adban.stop();
  conditionalAlert('adban-stopped', _('adban-stopped'));
};

let cmdStart = function() {
  adban.start();
  conditionalAlert('adban-started', _('adban-started'));
};

let cmdComplaint = function() {
  const complaint_callback = function(site_url, comment) {
    const success_callback = function() {
      conditionalAlert('complaint-sent', _('complaint-sent', [site_url]));
    };
    adban.sendUrlComplaint(site_url, comment, success_callback);
  };
  const initial_site_url = gBrowser.currentURI.spec;
  // const initial_site_url = $('urlbar').value;
  const complaint_window = window.openDialog('chrome://adban/content/report-ads-dialog.xul',
      'adban-complaint-window', '', complaint_callback, initial_site_url);
  complaint_window.focus();
};

let cmdHelp = function() {
  openTab(adban.HELP_URL);
};

let state_listener_id;

let init = function() {
  logging.info('initializing browser-overlay');
  const first_run_verification_complete = function() {
    // Subscribe to adban state change only after firstRun verification
    // is complete. Otherwise FF4+ won't find adban-button on first run.
    state_listener_id = adban.subscribeToStateChange(onStateChange);
  };
  // defer first run verification due to stupid FF bug, which prevents from
  // toolbar updating immediately in the window.onload event handler.
  // Read more at http://blog.pearlcrescent.com/archives/24 .
  const first_run_callback = function() {
    verifyFirstRun(first_run_verification_complete);
  };
  window.setTimeout(first_run_callback, 10);

  $('cmd-adban-stop').addEventListener('command', cmdStop, false);
  $('cmd-adban-start').addEventListener('command', cmdStart, false);
  $('cmd-adban-complaint').addEventListener('command', cmdComplaint, false);
  $('cmd-adban-help').addEventListener('command', cmdHelp, false);

  // DOMFrameContentLoaded doesn't work as expected,
  // while DOMContentLoaded catches iframes and frames.
  // see https://developer.mozilla.org/en/Gecko-Specific_DOM_Events .
  gBrowser.addEventListener('DOMContentLoaded', adban, true);

  window.addEventListener('unload', shutdown, false);
  logging.info('browser-overlay has been initialized');
};

let shutdown = function() {
  logging.info('shutting down browser-overlay');
  adban.unsubscribeFromStateChange(state_listener_id);
  gBrowser.removeEventListener('DOMContentLoaded', adban, true);

  $('cmd-adban-stop').removeEventListener('command', cmdStop, false);
  $('cmd-adban-start').removeEventListener('command', cmdStart, false);
  $('cmd-adban-complaint').removeEventListener('command', cmdComplaint, false);
  $('cmd-adban-help').removeEventListener('command', cmdHelp, false);

  window.removeEventListener('load', init, false);
  window.removeEventListener('unload', shutdown, false);
  logging.info('browser-overlay has been shut down');
};

window.addEventListener('load', init, false);

<commit_msg>don't use FUEL, since it is unavailable in Fennec - see https://wiki.mozilla.org/Mobile/Fennec/Extensions#The_Basics<commit_after>let Cc = Components.classes;
let Ci = Components.interfaces;

let prompts = Cc['@mozilla.org/embedcomp/prompt-service;1'].getService(Ci.nsIPromptService);
let adban = Cc['@ad-ban.appspot.com/adban;1'].getService().wrappedJSObject;
let logging = adban.logging;
let pref_branch = adban.pref_branch;

let $ = function(id) {
  return document.getElementById(id);
};

let _ = function(id, params) {
  const adban_strings = $('adban-strings');
  if (params) {
    return adban_strings.getFormattedString(id, params);
  }
  return adban_strings.getString(id);
};

let conditionalAlert = function(alert_name, msg) {
  alert_name = 'alert-states.' + alert_name;
  if (pref_branch.prefHasUserValue(alert_name) &&
      pref_branch.getBoolPref(alert_name)) {
    logging.info('the alert [%s] is disabled in preferences', alert_name);
    return;
  }
  const state_obj = {
      value: false,
  };
  prompts.alertCheck(window, 'AdBan', msg, _('dont-show-this-message-again'), state_obj);
  if (state_obj.value) {
    logging.info('disabling the alert [%s] in preferences', alert_name);
    pref_branch.setBoolPref(alert_name, true);
  }
};

let openTab = function(url) {
  logging.info('opening the tab with url=[%s]', url);
  // use this hack, otherwise firefox 3.6 can skip the tab
  // if another tab is immediately opened after this tab.
  const open_tab_callback = function() {
    gBrowser.selectedTab = gBrowser.addTab(url);
  }
  setTimeout(open_tab_callback, 10);
};

let firstRunSetup = function() {
  openTab(adban.FIRST_RUN_URL);

  const nav_bar = $('nav-bar');
  if (!nav_bar) {
    logging.warning('there is no navigation bar in the current window');
    return;
  }
  if ($('adban-complaint-button')) {
    logging.warning('the adban-complaint-button is already installed (though it is unclear how it is possible)');
    return;
  }
  if ($('adban-button')) {
    logging.warning('the adban-button is already installed (though it is unclear how it is possble)');
    return;
  }

  logging.info('adding adban buttons to navigation bar');
  nav_bar.insertItem('adban-complaint-button', null, null, false);
  nav_bar.insertItem('adban-button', null, null, false);

  // this 'magic' is necessary for stupid FF, which can't properly handle
  // toolbar.insertItem().
  // See http://forums.mozillazine.org/viewtopic.php?t=189667 .
  nav_bar.setAttribute('currentset', nav_bar.currentSet);
  document.persist('nav-bar', 'currentset');
  logging.info('adban buttons must be added to navigation bar');
};

let stateToggle = function(from, to) {
  to.setAttribute('disabled', 'true');
  from.removeAttribute('disabled');
};

let onStateChange = function(is_active) {
  const cmd_adban_stop = $('cmd-adban-stop');
  const cmd_adban_start = $('cmd-adban-start');
  const adban_button = $('adban-button');
  if (!adban_button) {
    logging.warning('it looks like the adban button has been removed from visible toolbars');
    return;
  }
  if (is_active) {
    stateToggle(cmd_adban_stop, cmd_adban_start);
    adban_button.label = 'AdBan ' + _('on');
  }
  else {
    stateToggle(cmd_adban_start, cmd_adban_stop);
    adban_button.label = 'AdBan ' + _('off');
  }
};

let cmdStop = function() {
  adban.stop();
  conditionalAlert('adban-stopped', _('adban-stopped'));
};

let cmdStart = function() {
  adban.start();
  conditionalAlert('adban-started', _('adban-started'));
};

let cmdComplaint = function() {
  const complaint_callback = function(site_url, comment) {
    const success_callback = function() {
      conditionalAlert('complaint-sent', _('complaint-sent', [site_url]));
    };
    adban.sendUrlComplaint(site_url, comment, success_callback);
  };
  const initial_site_url = gBrowser.currentURI.spec;
  // const initial_site_url = $('urlbar').value;
  const complaint_window = window.openDialog('chrome://adban/content/report-ads-dialog.xul',
      'adban-complaint-window', '', complaint_callback, initial_site_url);
  complaint_window.focus();
};

let cmdHelp = function() {
  openTab(adban.HELP_URL);
};

let state_listener_id;

let init = function() {
  logging.info('initializing browser-overlay');
  // defer first run verification due to stupid FF bug, which prevents from
  // toolbar updating immediately in the window.onload event handler.
  // Read more at http://blog.pearlcrescent.com/archives/24 .
  // Also adban-button isn't accessible via $('adban-button') during
  // the first run.
  const first_run_callback = function() {
    if (!pref_branch.prefHasUserValue('first-run')) {
      logging.info('first run of AdBan');
      firstRunSetup();
      pref_branch.setBoolPref('first-run', true);
    }
    state_listener_id = adban.subscribeToStateChange(onStateChange);
  };
  window.setTimeout(first_run_callback, 10);

  $('cmd-adban-stop').addEventListener('command', cmdStop, false);
  $('cmd-adban-start').addEventListener('command', cmdStart, false);
  $('cmd-adban-complaint').addEventListener('command', cmdComplaint, false);
  $('cmd-adban-help').addEventListener('command', cmdHelp, false);

  // DOMFrameContentLoaded doesn't work as expected,
  // while DOMContentLoaded catches iframes and frames.
  // see https://developer.mozilla.org/en/Gecko-Specific_DOM_Events .
  gBrowser.addEventListener('DOMContentLoaded', adban, true);

  window.addEventListener('unload', shutdown, false);
  logging.info('browser-overlay has been initialized');
};

let shutdown = function() {
  logging.info('shutting down browser-overlay');
  adban.unsubscribeFromStateChange(state_listener_id);
  gBrowser.removeEventListener('DOMContentLoaded', adban, true);

  $('cmd-adban-stop').removeEventListener('command', cmdStop, false);
  $('cmd-adban-start').removeEventListener('command', cmdStart, false);
  $('cmd-adban-complaint').removeEventListener('command', cmdComplaint, false);
  $('cmd-adban-help').removeEventListener('command', cmdHelp, false);

  window.removeEventListener('load', init, false);
  window.removeEventListener('unload', shutdown, false);
  logging.info('browser-overlay has been shut down');
};

window.addEventListener('load', init, false);

<|endoftext|>


<commit_before>'use strict';
//node modules
var path = require('path');

// node_modules modules
var _ = require('lodash');
var browserify  = require("browserify");
var browserSync = require("browser-sync");
var bsreload = browserSync.reload;
var del = require('del');
var mergeStream = require('merge-stream');
var q = require('q');
var source = require('vinyl-source-stream');
var watchify = require('watchify');

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

// kickstart modules
var assemble = require('kickstart-assemble');

// user project configuration
var config = require('./config.js');

// error handler
var onError = function (err, cb) {
    plugins.util.beep();
    plugins.util.log(plugins.util.colors.red(err));

    if (typeof this.emit === 'function') this.emit('end');
};

// clean task
gulp.task('clean', function (cb) {
    del([
        config.dest.base
    ], cb);
});

// styles task
gulp.task('styles', function () {
    return gulp.src(config.src.styles)
        .pipe(plugins.plumber({ errorHandler: onError }))
        .pipe(plugins.sass(config.sass.settings))
        .pipe(plugins.if(!config.dev, plugins.combineMediaQueries()))
        .pipe(plugins.autoprefixer(config.sass.autoprefixer))
        .pipe(plugins.if(!config.dev, plugins.csso()))
        .pipe(gulp.dest(config.dest.styles))
        .pipe(plugins.if(config.dev, bsreload({ stream: true })));
});

// scripts task
gulp.task('scripts', function () {

    var browserifyTask = function () {

        var browserifyThis = function (bundleConfig) {
            if (config.dev) {
                _.extend(config.src.scriptBundles, watchify.args, { debug: true });

                bundleConfig = _.omit(bundleConfig, ['external', 'require']);
            }

            var b = browserify(bundleConfig);

            var bundle = function () {

                return b
                    .bundle()
                    .on('error', onError)
                    .pipe(source(bundleConfig.outputName))
                    .pipe(gulp.dest(bundleConfig.dest))
                    .pipe(plugins.if(config.dev, bsreload({ stream: true })));
            };

            if (config.dev) {
                b = watchify(b);
                b.on('update', bundle);
            } else {
                if (bundleConfig.require) b.require(bundleConfig.require);
                if (bundleConfig.external) b.external(bundleConfig.external);
            }

            return bundle();
        };

        return mergeStream.apply(gulp, _.map(config.scriptBundles, browserifyThis));

    }

    return browserifyTask();

});

// images task
gulp.task('images', function () {
    return gulp.src(config.src.images)
        .pipe(plugins.changed(config.dest.images))
        .pipe(plugins.if(!config.dev, plugins.imagemin(config.images)))
        .pipe(gulp.dest(config.dest.images))
        .pipe(plugins.if(config.dev, bsreload({ stream: true })));
});

// fonts task
gulp.task('fonts', function () {
    return gulp.src(config.src.fonts)
        .pipe(gulp.dest(config.dest.fonts));
});

// copy extra files task
gulp.task('copy:extras', function (done) {
    return gulp.src('./src/*.{ico,txt}')
        .pipe(gulp.dest(config.dest.base));
});

gulp.task('templates', function(done) {
    var opts = {
        assets: config.dest.base + '/assets',
        data: [config.src.data],
        production: false,
        layout: 'default-layout',
        layouts: 'src/layouts/*.html',
        partials: 'src/includes/**/*.html',
        pages: 'src/pages/**/*.html',
        dest: config.dest.base
    };

    assemble.templates(opts, done);
});

gulp.task('styleguide', function(done) {
  var base = 'src/includes/patterns';
  var opts = {
    data: [config.src.data],
    patterns: {
        components: [base + '/components/**/*.{hbs,html}'],
        modules: [base + '/modules/**/*.{hbs,html}'],
        strutures: [base + '/structures/**/*.{hbs,html}'],
        templates: [base + '/templates/**/*.{hbs,html}']
    },
    src: base + '/**/*.{hbs,html}',
    dest: config.dest.base + '/styleguide'
  };

  assemble.styleguide(opts);
  done();
});

gulp.task('browserSync', function () {
    return browserSync(config.browserSync);
});

// watch task
gulp.task('watch', function () {
    // plugins.watch(config.src.html, function () {
    //     plugins.sequence('compile', function() {
    //         bsreload();
    //     });
    // });
    plugins.watch(config.src.styles, function () {
        gulp.start('styles:app')
    });

    plugins.watch(config.src.images, function () {
        gulp.start('images:app')
    });
});

// test performance task
gulp.task('test:performance', function () {
    //TODO: write the performance tasks
});

// performance task entry point
gulp.task('perf', ['test:performance']);

// compile task
gulp.task('compile', ['templates', 'styleguide']);

// production build task
gulp.task('build:production', ['clean'], function (cb) {
    plugins.sequence(
        ['fonts', 'images', 'styles', 'scripts'],
        ['compile', 'copy:extras'],
        done
    );
});

gulp.task('default', ['clean'], function(done) {
    plugins.sequence(
        ['fonts', 'images', 'styles', 'scripts'],
        ['compile', 'copy:extras'],
        ['browserSync', 'watch'],
        done
    );
});

<commit_msg>[chore] add build task and point default task to build task<commit_after>'use strict';
//node modules
var path = require('path');

// node_modules modules
var _ = require('lodash');
var browserify  = require("browserify");
var browserSync = require("browser-sync");
var bsreload = browserSync.reload;
var del = require('del');
var mergeStream = require('merge-stream');
var q = require('q');
var source = require('vinyl-source-stream');
var watchify = require('watchify');

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

// kickstart modules
var assemble = require('kickstart-assemble');

// user project configuration
var config = require('./config.js');

// error handler
var onError = function (err, cb) {
    plugins.util.beep();
    plugins.util.log(plugins.util.colors.red(err));

    if (typeof this.emit === 'function') this.emit('end');
};

// clean task
gulp.task('clean', function (cb) {
    del([
        config.dest.base
    ], cb);
});

// styles task
gulp.task('styles', function () {
    return gulp.src(config.src.styles)
        .pipe(plugins.plumber({ errorHandler: onError }))
        .pipe(plugins.sass(config.sass.settings))
        .pipe(plugins.if(!config.dev, plugins.combineMediaQueries()))
        .pipe(plugins.autoprefixer(config.sass.autoprefixer))
        .pipe(plugins.if(!config.dev, plugins.csso()))
        .pipe(gulp.dest(config.dest.styles))
        .pipe(plugins.if(config.dev, bsreload({ stream: true })));
});

// scripts task
gulp.task('scripts', function () {

    var browserifyTask = function () {

        var browserifyThis = function (bundleConfig) {
            if (config.dev) {
                _.extend(config.src.scriptBundles, watchify.args, { debug: true });

                bundleConfig = _.omit(bundleConfig, ['external', 'require']);
            }

            var b = browserify(bundleConfig);

            var bundle = function () {

                return b
                    .bundle()
                    .on('error', onError)
                    .pipe(source(bundleConfig.outputName))
                    .pipe(gulp.dest(bundleConfig.dest))
                    .pipe(plugins.if(config.dev, bsreload({ stream: true })));
            };

            if (config.dev) {
                b = watchify(b);
                b.on('update', bundle);
            } else {
                if (bundleConfig.require) b.require(bundleConfig.require);
                if (bundleConfig.external) b.external(bundleConfig.external);
            }

            return bundle();
        };

        return mergeStream.apply(gulp, _.map(config.scriptBundles, browserifyThis));

    }

    return browserifyTask();

});

// images task
gulp.task('images', function () {
    return gulp.src(config.src.images)
        .pipe(plugins.changed(config.dest.images))
        .pipe(plugins.if(!config.dev, plugins.imagemin(config.images)))
        .pipe(gulp.dest(config.dest.images))
        .pipe(plugins.if(config.dev, bsreload({ stream: true })));
});

// fonts task
gulp.task('fonts', function () {
    return gulp.src(config.src.fonts)
        .pipe(gulp.dest(config.dest.fonts));
});

// copy extra files task
gulp.task('copy:extras', function (done) {
    return gulp.src('./src/*.{ico,txt}')
        .pipe(gulp.dest(config.dest.base));
});

gulp.task('templates', function(done) {
    var opts = {
        assets: config.dest.base + '/assets',
        data: [config.src.data],
        production: false,
        layout: 'default-layout',
        layouts: 'src/layouts/*.html',
        partials: 'src/includes/**/*.html',
        pages: 'src/pages/**/*.html',
        dest: config.dest.base
    };

    assemble.templates(opts, done);
});

gulp.task('styleguide', function(done) {
  var base = 'src/includes/patterns';
  var opts = {
    data: [config.src.data],
    patterns: {
        components: [base + '/components/**/*.{hbs,html}'],
        modules: [base + '/modules/**/*.{hbs,html}'],
        strutures: [base + '/structures/**/*.{hbs,html}'],
        templates: [base + '/templates/**/*.{hbs,html}']
    },
    src: base + '/**/*.{hbs,html}',
    dest: config.dest.base + '/styleguide'
  };

  assemble.styleguide(opts);
  done();
});

gulp.task('browserSync', function () {
    return browserSync(config.browserSync);
});

// watch task
gulp.task('watch', function () {
    // plugins.watch(config.src.html, function () {
    //     plugins.sequence('compile', function() {
    //         bsreload();
    //     });
    // });
    plugins.watch(config.src.styles, function () {
        gulp.start('styles:app')
    });

    plugins.watch(config.src.images, function () {
        gulp.start('images:app')
    });
});

// test performance task
gulp.task('test:performance', function () {
    //TODO: write the performance tasks
});

// performance task entry point
gulp.task('perf', ['test:performance']);

// compile task
gulp.task('compile', ['templates', 'styleguide']);

// production build task
gulp.task('build:production', ['clean'], function (cb) {
    plugins.sequence(
        ['fonts', 'images', 'styles', 'scripts'],
        ['compile', 'copy:extras'],
        done
    );
});

gulp.task('build', ['clean'], function(done) {
    plugins.sequence(
        ['fonts', 'images', 'styles', 'scripts'],
        ['compile', 'copy:extras'],
        ['browserSync', 'watch'],
        done
    );
});

gulp.task('default', ['build']);

<|endoftext|>


<commit_before>var gulp        = require('gulp');
var browserSync = require('browser-sync');       // refresh browser
var del         = require('del');                // delete files
var rename      = require('gulp-rename');        // rename files
var concat      = require('gulp-concat');        // concat files
var changed     = require('gulp-changed');       // changed files
var imagemin    = require('gulp-imagemin');      // minify images
var pngquant    = require('imagemin-pngquant');  // minify PNG
var uglify      = require('gulp-uglify');        // minify JS
var minifycss   = require('gulp-minify-css');    // minify CSS
var minifyhtml  = require('gulp-htmlmin');       // minify HTML
var stylus      = require('gulp-stylus');        // stylus
var jade        = require('gulp-jade');          // Jade templates

// path configuration --------------------------------------------------------

var paths =
{
    source:
    {
        root     : './source/*',                 // paths.source.root
        fonts    : './source/fonts/*',           // paths.source.fonts
        images   : './source/images/*',          // paths.source.images
        scripts  : './source/scripts/*',         // paths.source.scripts
        styles   : './source/styles/*'           // paths.source.styles
    },
    public:
    {
        root     : './public/',                  // paths.public.root
        fonts    : './public/fonts/',            // paths.public.fonts
        images   : './public/images/',           // paths.public.images
        scripts  : './public/scripts/',          // paths.public.scripts
        styles   : './public/styles/'            // paths.public.styles
    }
};

// options configuration -----------------------------------------------------

var config =
{
    // browsersync -----------------------------------------------------------
    // http://www.browsersync.io/docs/options/
    browsersync:                                 // config.browsersync
    {
        ui:                                      // bool, access interface
        {
            port                : 8080           // interface port
        },
        files                   : paths.source.root + '*/*', // files to watch
        watchOptions:                            // watch options for gaze
        {
            interval            : 500,           // fs.watchFile interval (ms)
            debounceDelay       : 500,           // event delay (ms)
            mode: 'auto'                         // auto, watch, poll
        },
        server:                                  // static server
        {
            baseDir             : paths.public.root, // serve files from here
            directory           : false          // directory listing
        },
        port                    : 8888,          // server port
        https                   : false,         // static HTTPS
        ghostMode:                               // mirror inputs
        {
            clicks              : true,          // mouse clicks
            forms               : true,          // form interactions
            scroll              : true           // scroll events
        },
        logLevel                : 'info',        // info, debug, warn, silent
        logPrefix               : '',            // console logging prefix
        logConnections          : true,          // display connected browsers
        logFileChanges          : true,          // display info about changes
        logSnippet              : true,          // log the snippet to console
        tunnel                  : true,          // bool/localtunnel.me prefix
        online                  : undefined,     // bool to check connectivity
        open                    : false,         // bool, external, tunnel
        browser                 : 'google chrome', // array of browsers
        reloadOnRestart         : true,          // reload each browser upon restart
        notify                  : false,         // bubble notifications
        scrollProportionally    : true,          // sync viewport to top
        scrollThrottle          : 0,             // scroll event interval (ms)
        reloadDelay             : 0,             // pause before reload (ms)
        injectChanges           : true,          // inject CSS changes/refresh
        startPath               : null,          // path to open browser at
        minify                  : false,         // minify client side JS
        host                    : null,          // host override (string IP)
        codeSync                : true,          // change events to browsers
        timestamps              : true           // append timestamps to files
    },
    // minifycss -------------------------------------------------------------
    // https://github.com/jonathanepollack/gulp-minify-css
    minifycss:                                   // config.minifycss
    {
        advanced                : true,          // advanced optimizations
        aggressiveMerging       : true,          // aggressive merging of properties
        benchmark               : false,         // time spent cleaning up
        compatibility           : false,         // compatibility mode
        debug                   : false,         // minification statistics
        inliner                 : false,         // @import inliner hash
        keepBreaks              : false,         // keep line breaks
        keepSpecialComments     : false,         // * all, 1 first, 0 none
        processImport           : false,         // process @import rules
        rebase                  : false,         // URL rebasing
        relativeTo              : null,          // abs @import rules path
        restructuring           : false,         // adv optimizations
        root                    : null,          // rel @import rules path
        roundingPrecision       : 2,             // default 2, disable -1
        shorthandCompacting     : true,          // shorthand compacting
        sourceMap               : false,         // exposes source map
        sourceMapInlineSources  : false,         // source map inline sources
        target                  : null           // rebase path
    },
    // imagemin --------------------------------------------------------------
    // https://github.com/sindresorhus/gulp-imagemin
    imagemin:                                    // config.imagemin
    {
        optimizationLevel       : 3,             // for PNG files
        progressive             : true,          // for JPG files
        interlaced              : false,         // for GIF files
        multipass               : false,         // for SVG files
        svgoPlugins: [{removeViewBox: false}],   // svgo plugins
        use: [pngquant()]                        // additional plugins
    },
    // stylus ----------------------------------------------------------------
    // https://github.com/stevelacy/gulp-stylus
    stylus:                                      // config.stylus
    {},
    // jade ------------------------------------------------------------------
    // http://jade-lang.com/api/
    jade:
    {
        pretty                  : true
    },
    // uglify ----------------------------------------------------------------
    // https://github.com/terinjokes/gulp-uglify
    uglify:
    {
        preserveComments               : 'all'  // some, all, function()
    },
    // minifyhtml ------------------------------------------------------------
    // https://github.com/kangax/html-minifier
    minifyhtml:
    {
        removeComments                 : false,  // remove comments
        removeCommentsFromCDATA        : false,  // comments (scripts/styles)
        removeCDATASectionsFromCDATA   : false,  // CDATA (scripts/styles)
        collapseWhitespace             : true,   // remove white space
        conservativeCollapse           : false,  // white space -> 1 space
        preserveLineBreaks             : false,  // white space -> 1 line
        collapseBooleanAttributes      : false,  // remove bools attrib values
        removeAttributeQuotes          : false,  // remove attribs quotes
        removeRedundantAttributes      : false,  // remove default's attribs
        preventAttributesEscaping      : false,  // no attrib values escaping
        useShortDoctype                : true,   // doctype -> HTML5 doctype
        removeEmptyAttributes          : false,  // remove whitespace attribs
        removeScriptTypeAttributes     : false,  // remove script type attrib
        removeStyleLinkTypeAttributes  : false,  // remove style type attrib
        removeOptionalTags             : false,  // remove unrequired tags
        removeIgnored                  : false,  // remove <%, %>, <?, ?>
        removeEmptyElements            : false,  // remove empty elements
        lint                           : false,  // toggle linting
        keepClosingSlash               : false,  // keep trailing slash on singleton elems
        caseSensitive                  : false,  // case sensitive attribs
        minifyJS                       : false,  // UglifyJS minification
        minifyCSS                      : false,  // clean-css minification
        minifyURLs                     : false,  // URL minification
        ignoreCustomComments           : [],     // ignore comments (regex)
        processScripts                 : [],     // script type minification
        maxLineLength                  : undefined // maximum line length
    }
};

// individual tasks -----------------------------------------------------------

gulp.task('stylus', function() {
    return gulp.src(paths.source.styles)
        .pipe(changed(paths.public.styles))
        .pipe(stylus(config.stylus))
        .pipe(gulp.dest(paths.public.styles))
        .pipe(browserSync.reload({stream: true}));
});

gulp.task('scripts', function() {
    return gulp.src(paths.source.scripts)
        .pipe(changed(paths.public.styles))
        .pipe(gulp.dest(paths.public.scripts))
        .pipe(browserSync.reload({stream: true}));
});

gulp.task('uglify', function() {
    return gulp.src(paths.source.scripts)
        .pipe(changed(paths.public.styles))
        .pipe(concat('main.js'))
        .pipe(uglify(config.uglify))
        .pipe(gulp.dest(paths.public.scripts))
        .pipe(browserSync.reload({stream: true}));
});

gulp.task('minifycss', function() {
    return gulp.src(paths.public.styles + '*.css')
        .pipe(changed(paths.public.styles))
        .pipe(minifycss(config.minifycss))
        .pipe(gulp.dest(paths.public.styles))
        .pipe(browserSync.reload({stream: true}));
});

gulp.task('jade', function() {
    return gulp.src(paths.source.root + '*.jade')
        .pipe(changed(paths.public.root))
        .pipe(jade(config.jade))
        .pipe(gulp.dest(paths.public.root))
        .pipe(browserSync.reload({stream: true}));
});

gulp.task('minifyhtml', function() {
    return gulp.src(paths.public.root + '*.html')
        .pipe(changed(paths.public.root))
        .pipe(minifyhtml(config.minifyhtml))
        .pipe(gulp.dest(paths.public.root))
        .pipe(browserSync.reload({stream: true}));
});

gulp.task('imagemin', function() {
    return gulp.src(paths.source.images)
        .pipe(changed(paths.public.images))
        .pipe(imagemin(config.imagemin))
        .pipe(gulp.dest(paths.public.images))
        .pipe(browserSync.reload({stream: true}));
});

gulp.task('clean', function() {
    del(paths.public.root);
});

gulp.task('info', function() {
    console.log('');
    console.log('                  ,╥╦╓                                    ');
    console.log('                ╦╬╙` ╙╬           ,╬                      ');
    console.log('              ╓╬╨                 ╬²                      ');
    console.log('             ╔╬²    ╓╕           ╬╜                       ');
    console.log('            ╓╬*    ,╬²  ╬╛  ╔å  ╬╝   ╬╓≡╨╬╬               ');
    console.log('            ╬╬    ╔╬╝  ╬╜  ╔╬  ╠╝  ,╫╬^ ╔å .╦*            ');
    console.log('            ╬╬,╓╦╝╠╬  ╔╬,╓╝╠╕,╥╬,╦#╠å ┌╬▒╓#╙              ');
    console.log('             ╙╙^  ╬^   "^` ^"` "^`╦╬  `╙^`                ');
    console.log('                  ²              ╦╬                       ');
    console.log('                                -╝`                       ');
    console.log('╔════════════════════════════════════════════════════════╗');
    console.log('║                  Available commands:                   ║');
    console.log('╟────────────────────────────────────────────────────────╢');
    console.log('║             gulp           gulp minify                 ║');
    console.log('║             gulp clean     gulp minifycss              ║');
    console.log('║             gulp jade      gulp minifyhtml             ║');
    console.log('║             gulp stylus    gulp uglify                 ║');
    console.log('║             gulp scripts   gulp imagemin               ║');
    console.log('║             gulp serve                                 ║');
    console.log('╚════════════════════════════════════════════════════════╝');
    console.log('');
});

gulp.task('serve', function() {
    browserSync(config.browsersync);
    gulp.watch(paths.source.root, ['jade']);
    gulp.watch(paths.source.styles, ['stylus']);
});

// main tasks ----------------------------------------------------------------

gulp.task('minify', ['minifycss', 'minifyhtml', 'uglify', 'imagemin']);
gulp.task('default', ['info', 'clean', 'jade', 'stylus', 'scripts', 'serve']);<commit_msg>Revert "Fix 79 char line length"<commit_after>var gulp        = require('gulp');
var browserSync = require('browser-sync');       // refresh browser
var del         = require('del');                // delete files
var rename      = require('gulp-rename');        // rename files
var concat      = require('gulp-concat');        // concat files
var changed     = require('gulp-changed');       // changed files
var imagemin    = require('gulp-imagemin');      // minify images
var pngquant    = require('imagemin-pngquant');  // minify PNG
var uglify      = require('gulp-uglify');        // minify JS
var minifycss   = require('gulp-minify-css');    // minify CSS
var minifyhtml  = require('gulp-htmlmin');       // minify HTML
var stylus      = require('gulp-stylus');        // stylus
var jade        = require('gulp-jade');          // Jade templates

// path configuration ---------------------------------------------------------

var paths =
{
    source:
    {
        root     : './source/*',                 // paths.source.root
        fonts    : './source/fonts/*',           // paths.source.fonts
        images   : './source/images/*',          // paths.source.images
        scripts  : './source/scripts/*',         // paths.source.scripts
        styles   : './source/styles/*'           // paths.source.styles
    },
    public:
    {
        root     : './public/',                  // paths.public.root
        fonts    : './public/fonts/',            // paths.public.fonts
        images   : './public/images/',           // paths.public.images
        scripts  : './public/scripts/',          // paths.public.scripts
        styles   : './public/styles/'            // paths.public.styles
    }
};

// options configuration ------------------------------------------------------

var config =
{
    // browsersync ------------------------------------------------------------
    // http://www.browsersync.io/docs/options/
    browsersync:                                 // config.browsersync
    {
        ui:                                      // bool, access interface
        {
            port                : 8080           // interface port
        },
        files                   : paths.source.root + '*/*', // files to watch
        watchOptions:                            // watch options for gaze
        {
            interval            : 500,           // fs.watchFile interval (ms)
            debounceDelay       : 500,           // event delay (ms)
            mode: 'auto'                         // auto, watch, poll
        },
        server:                                  // static server
        {
            baseDir             : paths.public.root, // serve files from here
            directory           : false          // directory listing
        },
        port                    : 8888,          // server port
        https                   : false,         // static HTTPS
        ghostMode:                               // mirror inputs
        {
            clicks              : true,          // mouse clicks
            forms               : true,          // form interactions
            scroll              : true           // scroll events
        },
        logLevel                : 'info',        // info, debug, warn, silent
        logPrefix               : '',            // console logging prefix
        logConnections          : true,          // display connected browsers
        logFileChanges          : true,          // display info about file changes
        logSnippet              : true,          // log the snippet to the console
        tunnel                  : true,          // bool or localtunnel.me prefix
        online                  : undefined,     // bool to check connectivity
        open                    : false,         // bool, external, tunnel
        browser                 : 'google chrome', // array of browsers
        reloadOnRestart         : true,          // reload each browser upon restart
        notify                  : false,         // bubble notifications
        scrollProportionally    : true,          // sync viewport to top
        scrollThrottle          : 0,             // scroll event interval (ms)
        reloadDelay             : 0,             // pause before reload (ms)
        injectChanges           : true,          // inject CSS changes or refresh
        startPath               : null,          // path to open browser at
        minify                  : false,         // minify client side JS
        host                    : null,          // override host detection (string IP)
        codeSync                : true,          // send file-change events to browsers
        timestamps              : true           // append timestamps to injected files
    },
    // minifycss --------------------------------------------------------------
    // https://github.com/jonathanepollack/gulp-minify-css
    minifycss:                                   // config.minifycss
    {
        advanced                : true,          // advanced optimizations
        aggressiveMerging       : true,          // aggressive merging of properties
        benchmark               : false,         // measures time spent cleaning up
        compatibility           : false,         // compatibility mode
        debug                   : false,         // minification statistics
        inliner                 : false,         // hash of options for @import inliner
        keepBreaks              : false,         // keep line breaks
        keepSpecialComments     : false,         // * = all, 1 = first, 0 = none
        processImport           : false,         // process @import rules
        rebase                  : false,         // URL rebasing
        relativeTo              : null,          // path to resolve rel @import rules/URLs
        restructuring           : false,         // restructuring in adv optimizations
        root                    : null,          // path to resolve abs @import rules/URLs
        roundingPrecision       : 2,             // default 2, disable -1
        shorthandCompacting     : true,          // shorthand compacting
        sourceMap               : false,         // exposes source map
        sourceMapInlineSources  : false,         // inline sources inside a source map
        target                  : null           // path to which rebase all URLs
    },
    // imagemin ---------------------------------------------------------------
    // https://github.com/sindresorhus/gulp-imagemin
    imagemin:                                    // config.imagemin
    {
        optimizationLevel       : 3,             // for PNG files
        progressive             : true,          // for JPG files
        interlaced              : false,         // for GIF files
        multipass               : false,         // for SVG files
        svgoPlugins: [{removeViewBox: false}],   // svgo plugins
        use: [pngquant()]                        // additional plugins
    },
    // stylus -----------------------------------------------------------------
    // https://github.com/stevelacy/gulp-stylus
    stylus:                                      // config.stylus
    {},
    // jade -------------------------------------------------------------------
    // http://jade-lang.com/api/
    jade:
    {
        pretty                  : true
    },
    // uglify -----------------------------------------------------------------
    // https://github.com/terinjokes/gulp-uglify
    uglify:
    {
        preserveComments               : 'all'  // some, all, function()
    },
    // minifyhtml -------------------------------------------------------------
    // https://github.com/kangax/html-minifier
    minifyhtml:
    {
        removeComments                 : false,  // remove comments
        removeCommentsFromCDATA        : false,  // remove comments from scripts + styles
        removeCDATASectionsFromCDATA   : false,  // remove CDATA from scripts + styles
        collapseWhitespace             : true,   // remove white space
        conservativeCollapse           : false,  // remove white space to 1 space
        preserveLineBreaks             : false,  // remove white space to 1 line
        collapseBooleanAttributes      : false,  // remove attrib values from bools
        removeAttributeQuotes          : false,  // remove quotes around attribs
        removeRedundantAttributes      : false,  // remove attribs when value is default
        preventAttributesEscaping      : false,  // prevent attrib values escaping
        useShortDoctype                : true,   // replaces doctype with HTML5 doctype
        removeEmptyAttributes          : false,  // remove attribs with whitespace values
        removeScriptTypeAttributes     : false,  // remove 'type="text/javascript"'
        removeStyleLinkTypeAttributes  : false,  // remove 'type="test/css"'
        removeOptionalTags             : false,  // remove unrequired tags
        removeIgnored                  : false,  // remove <%, %>, <?, ?>
        removeEmptyElements            : false,  // remove empty elements
        lint                           : false,  // toggle linting
        keepClosingSlash               : false,  // keep trailing slash on singleton elems
        caseSensitive                  : false,  // treat attribs as case sensitive
        minifyJS                       : false,  // minify JavaScript using UglifyJS
        minifyCSS                      : false,  // minify CSS using clean-css
        minifyURLs                     : false,  // minify URLs
        ignoreCustomComments           : [],     // ignore comments array of regexes
        processScripts                 : [],     // minify types of script elements
        maxLineLength                  : undefined // maximum line length
    }
};

// individual tasks -----------------------------------------------------------

gulp.task('stylus', function() {
    return gulp.src(paths.source.styles)
        .pipe(changed(paths.public.styles))
        .pipe(stylus(config.stylus))
        .pipe(gulp.dest(paths.public.styles))
        .pipe(browserSync.reload({stream: true}));
});

gulp.task('scripts', function() {
    return gulp.src(paths.source.scripts)
        .pipe(changed(paths.public.styles))
        .pipe(gulp.dest(paths.public.scripts))
        .pipe(browserSync.reload({stream: true}));
});

gulp.task('uglify', function() {
    return gulp.src(paths.source.scripts)
        .pipe(changed(paths.public.styles))
        .pipe(concat('main.js'))
        .pipe(uglify(config.uglify))
        .pipe(gulp.dest(paths.public.scripts))
        .pipe(browserSync.reload({stream: true}));
});

gulp.task('minifycss', function() {
    return gulp.src(paths.public.styles + '*.css')
        .pipe(changed(paths.public.styles))
        .pipe(minifycss(config.minifycss))
        .pipe(gulp.dest(paths.public.styles))
        .pipe(browserSync.reload({stream: true}));
});

gulp.task('jade', function() {
    return gulp.src(paths.source.root + '*.jade')
        .pipe(changed(paths.public.root))
        .pipe(jade(config.jade))
        .pipe(gulp.dest(paths.public.root))
        .pipe(browserSync.reload({stream: true}));
});

gulp.task('minifyhtml', function() {
    return gulp.src(paths.public.root + '*.html')
        .pipe(changed(paths.public.root))
        .pipe(minifyhtml(config.minifyhtml))
        .pipe(gulp.dest(paths.public.root))
        .pipe(browserSync.reload({stream: true}));
});

gulp.task('imagemin', function() {
    return gulp.src(paths.source.images)
        .pipe(changed(paths.public.images))
        .pipe(imagemin(config.imagemin))
        .pipe(gulp.dest(paths.public.images))
        .pipe(browserSync.reload({stream: true}));
});

gulp.task('clean', function() {
    del(paths.public.root);
});

gulp.task('info', function() {
    console.log('');
    console.log('                   ,╥╦╓                                     ');
    console.log('                 ╦╬╙` ╙╬           ,╬                       ');
    console.log('               ╓╬╨                 ╬²                       ');
    console.log('              ╔╬²    ╓╕           ╬╜                        ');
    console.log('             ╓╬*    ,╬²  ╬╛  ╔å  ╬╝   ╬╓≡╨╬╬                ');
    console.log('             ╬╬    ╔╬╝  ╬╜  ╔╬  ╠╝  ,╫╬^ ╔å .╦*             ');
    console.log('             ╬╬,╓╦╝╠╬  ╔╬,╓╝╠╕,╥╬,╦#╠å ┌╬▒╓#╙               ');
    console.log('              ╙╙^  ╬^   "^` ^"` "^`╦╬  `╙^`                 ');
    console.log('                   ²              ╦╬                        ');
    console.log('                                 -╝`                        ');
    console.log('╔══════════════════════════════════════════════════════════╗');
    console.log('║                   Available commands:                    ║');
    console.log('╟-─────────────────────────────────────────────────────────╢');
    console.log('║              gulp           gulp minify                  ║');
    console.log('║              gulp clean     gulp minifycss               ║');
    console.log('║              gulp jade      gulp minifyhtml              ║');
    console.log('║              gulp stylus    gulp uglify                  ║');
    console.log('║              gulp scripts   gulp imagemin                ║');
    console.log('║              gulp serve                                  ║');
    console.log('╚══════════════════════════════════════════════════════════╝');
    console.log('');
});

gulp.task('serve', function() {
    browserSync(config.browsersync);
    gulp.watch(paths.source.root, ['jade']);
    gulp.watch(paths.source.styles, ['stylus']);
});

// main tasks -----------------------------------------------------------------

gulp.task('minify', ['minifycss', 'minifyhtml', 'uglify', 'imagemin']);
gulp.task('default', ['info', 'clean', 'jade', 'stylus', 'scripts', 'serve']);<|endoftext|>