<commit_before>// Generated on 2014-03-06 using generator-angular 0.7.1
'use strict';

// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to recursively match all subfolders:
// 'test/spec/**/*.js'

module.exports = function (grunt) {

  // Load grunt tasks automatically
  require('load-grunt-tasks')(grunt);

  // Time how long tasks take. Can help when optimizing build times
  require('time-grunt')(grunt);

  // Define the configuration for all the tasks
  grunt.initConfig({

    // Project settings
    yeoman: {
      // configurable paths
      app: require('./bower.json').appPath || 'app',
      dist: 'dist',
      tmp: '.tmp',
      test: '.test'
    },

    //transpilation to ES5
    babel: {
      options: {
        sourceMap: true,
        blacklist: ["strict"]
      },
      dev: {
        files: [{
          expand : true,
          cwd: '<%= yeoman.dist %>/scripts/',
          src: ['**/*.js'],
          dest: '<%= yeoman.dist %>/scripts/',
          ext: '.js'
        }]
      },
      dist: {
        files: [{
          expand : true,
          cwd: '<%= yeoman.tmp %>/concat/scripts',
          src: '*.js',
          dest: '<%= yeoman.tmp %>/concat/scripts',
          ext: '.js'
        }]
      }
    },

    // Watches files for changes and runs tasks based on the changed files
    watch: {
      js: {
        files: ['<%= yeoman.app %>/scripts/{,*/}*.js'],
        tasks: ['newer:eslint:all', 'newer:copy:dist','newer:babel:dev'],
        options: {
          livereload: true
        }
      },
      jsTest: {
        files: ['test/spec/{,*/}*.js'],
        tasks: ['newer:eslint:test', 'karma']
      },
      styles: {
        files: ['<%= yeoman.app %>/styles/{,*/}*.css'],
        tasks: ['newer:copy:styles', 'autoprefixer']
      },
      less: {
        files: ['<%= yeoman.app %>/styles/{,*/}*.less'],
        tasks: ['less:default']
      },
      gruntfile: {
        files: ['Gruntfile.js']
      },
      livereload: {
        options: {
          livereload: '<%= connect.options.livereload %>'
        },
        files: [
          '<%= yeoman.app %>/{,*/}*.html',
          '.tmp/styles/{,*/}*.{css,less}',
          '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
        ]
      }
    },

    // The actual grunt server settings
    connect: {
      options: {
        port: 9000,
        // Change this to '0.0.0.0' to access the server from outside.
        hostname: 'localhost',
        livereload: 35729
      },
      livereload: {
        options: {
          open: true,
          base: [
            '.tmp',
            '<%= yeoman.dist %>'
          ]
        }
      },
      test: {
        options: {
          port: 9001,
          base: [
            '.tmp',
            'test',
            '<%= yeoman.app %>'
          ]
        }
      },
      dist: {
        options: {
          base: '<%= yeoman.dist %>'
        }
      }
    },

    // Make sure code styles are up to par and there are no obvious mistakes
    eslint: {
      options: {
        config: '.eslintrc'
      },
      all: [
        'Gruntfile.js',
        '<%= yeoman.app %>/scripts/{,*/}*.js'
      ],
      test: {
        src: ['test/spec/{,*/}*.js']
      }
    },

    // Empties folders to start fresh
    clean: {
      dist: {
        files: [{
          dot: true,
          src: [
            '.tmp',
            '<%= yeoman.dist %>/*',
            '!<%= yeoman.dist %>/.git*'
          ]
        }]
      },
      server: '.tmp'
    },

    // Add vendor prefixed styles
    autoprefixer: {
      options: {
        browsers: ['last 1 version']
      },
      dist: {
        files: [{
          expand: true,
          cwd: '.tmp/styles/',
          src: '{,*/}*.css',
          dest: '.tmp/styles/'
        }]
      }
    },

    // Automatically inject Bower components into the app
    bowerInstall: {
        app: {
        src: '<%= yeoman.app %>/index.html',
        ignorePath: '<%= yeoman.app %>/'
      }
    },

    // Renames files for browser caching purposes
    rev: {
      dist: {
        files: {
          src: [
            '<%= yeoman.dist %>/scripts/{,*/}*.js',
            '<%= yeoman.dist %>/styles/{,*/}*.css',
            '<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
            '<%= yeoman.dist %>/styles/fonts/*'
          ]
        }
      }
    },

    // Reads HTML for usemin blocks to enable smart builds that automatically
    // concat, minify and revision files. Creates configurations in memory so
    // additional tasks can operate on them
    useminPrepare: {
      html: '<%= yeoman.app %>/index.html',
      options: {
        dest: '<%= yeoman.dist %>'
      }
    },

    // Performs rewrites based on rev and the useminPrepare configuration
    usemin: {
      html: ['<%= yeoman.dist %>/{,*/}*.html'],
      css: ['<%= yeoman.dist %>/styles/{,*/}*.css'],
      options: {
        assetsDirs: ['<%= yeoman.dist %>']
      }
    },

    // The following *-min tasks produce minified files in the dist folder
    imagemin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>/images',
          src: '{,*/}*.{png,jpg,jpeg,gif}',
          dest: '<%= yeoman.dist %>/images'
        }]
      }
    },
    svgmin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>/images',
          src: '{,*/}*.svg',
          dest: '<%= yeoman.dist %>/images'
        }]
      }
    },
    htmlmin: {
      dist: {
        options: {
          collapseWhitespace: true,
          collapseBooleanAttributes: true,
          removeCommentsFromCDATA: true,
          removeOptionalTags: true
        },
        files: [{
          expand: true,
          cwd: '<%= yeoman.dist %>',
          src: ['*.html', 'views/{,*/}*.html'],
          dest: '<%= yeoman.dist %>'
        }]
      }
    },

    // Allow the use of non-minsafe AngularJS files. Automatically makes it
    // minsafe compatible so Uglify does not destroy the ng references
    ngmin: {
      dist: {
        files: [{
          expand: true,
          cwd: '.tmp/concat/scripts',
          src: '*.js',
          dest: '.tmp/concat/scripts'
        }]
      }
    },

    // Replace Google CDN references
    cdnify: {
      dist: {
        html: ['<%= yeoman.dist %>/*.html']
      }
    },

    //less
    less: {
      default: {
        options: {
          paths: ['app/styles'],
          cleancss: true,
        },
        files: {
          '<%= yeoman.app %>/styles/style.css': '<%= yeoman.app %>/styles/style.less'
        }
      }
    },

    // Copies remaining files to places other tasks can use
    copy: {
      dist: {
        files: [{
          expand: true,
          dot: true,
          cwd: '<%= yeoman.app %>',
          dest: '<%= yeoman.dist %>',
          src: [
            '*.{ico,png,txt}',
            '.htaccess',
            '*.html',
            '/scripts/{,*/}*.js',
            'views/{,*/}*.html',
            'libs/**/*',
            'images/{,*/}*.{webp}',
            'fonts/*'
          ]
        }, {
          expand: true,
          cwd: '.tmp/images',
          dest: '<%= yeoman.dist %>/images',
          src: ['generated/*']
        }]
      },
      styles: {
        expand: true,
        cwd: '<%= yeoman.app %>/styles',
        dest: '.tmp/styles/',
        src: '{,*/}*.css'
      }
    },

    // Run some tasks in parallel to speed up the build process
    concurrent: {
      server: [
        'copy:styles',
        'svgmin'
      ],
      test: [
        'copy:styles'
      ],
      dist: [
        'copy:styles',
        'imagemin',
        'svgmin'
      ]
    },

    // By default, your `index.html`'s <!-- Usemin block --> will take care of
    // minification. These next options are pre-configured if you do not wish
    // to use the Usemin blocks.
    cssmin: {
      dist: {
        files: {
          '<%= yeoman.dist %>/styles/main.css': [
            '.tmp/styles/{,*/}*.css',
            '<%= yeoman.app %>/styles/{,*/}*.css'
          ]
        }
      }
    },
    uglify: {
      dist: {
        files: {
          '<%= yeoman.dist %>/scripts/scripts.js': [
            '<%= yeoman.dist %>/scripts/scripts.js'
          ]
        }
      }
    },
    concat: {
      dist: {}
    },

    shell: {
      updateSeleniumWebDriver: {
        command: 'node node_modules/protractor/bin/webdriver-manager update',
        options: {
          stdout: true
        }
      }
    },

    'protractor_webdriver': {
      options: {
        // Task-specific options go here.
      },
      run: {
        // Target-specific file lists and/or options go here.
      }
    },

    protractor: {
      options: {
        configFile: 'node_modules/protractor/referenceConf.js', // Default config file
        keepAlive: true, // If false, the grunt process stops when the test fails.
        noColor: false, // If true, protractor will not use colors in its output.
        args: {
          // Arguments passed to the command
        }
      },
      local: {
        options: {
          configFile: 'protractor.conf.js', // Target-specific config file
          args: {
            // Target-specific arguments
            seleniumPort : 9000
          }
        }
      }
    },

    // Test settings
    karma: {
      unit: {
        configFile: 'karma.conf.js',
        singleRun: true
      }
    }
  });

  // TASK CONFIGURATION //
  grunt.registerTask('serve', function (target) {
    if (target === 'dist') {
      return grunt.task.run(['build', 'connect:dist:keepalive']);
    }

    grunt.task.run([
      'clean:server',
      'bowerInstall',
      'concurrent:server',
      'autoprefixer',
      'copy:dist',
      'babel:dev',
      'connect:livereload',
      'watch'
    ]);
  });

  grunt.registerTask('server', function () {
    grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
    grunt.task.run(['serve']);
  });

  grunt.registerTask('test', [
    'clean:server',
    'concurrent:test',
    'autoprefixer',
    'connect:test',
    'karma',
    'shell:updateSeleniumWebDriver',
    'protractor_webdriver:run',
    'protractor:local'
  ]);

  grunt.registerTask('e2e', [
    'connect:dist',
    'shell:updateSeleniumWebDriver',
    'protractor_webdriver:run',
    'protractor:local'
  ]);

  grunt.registerTask('build', [
    'clean:dist',
    'bowerInstall',
    'useminPrepare',
    'concurrent:dist',
    'autoprefixer',
    'concat',
    'babel:dist',
    'ngmin',
    'less',
    'copy:dist',
    'cdnify',
    'cssmin',
    'uglify',
    'rev',
    'usemin',
    'htmlmin'
  ]);

  grunt.registerTask('default', [
    'newer:eslint',
    'test',
    'build'
  ]);
};
<commit_msg>optimize babel grunt config<commit_after>// Generated on 2014-03-06 using generator-angular 0.7.1
'use strict';

// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to recursively match all subfolders:
// 'test/spec/**/*.js'

module.exports = function (grunt) {

  // Load grunt tasks automatically
  require('load-grunt-tasks')(grunt);

  // Time how long tasks take. Can help when optimizing build times
  require('time-grunt')(grunt);

  // Define the configuration for all the tasks
  grunt.initConfig({

    // Project settings
    yeoman: {
      // configurable paths
      app: require('./bower.json').appPath || 'app',
      dist: 'dist',
      tmp: '.tmp',
      test: '.test'
    },

    //transpilation to ES5
    babel: {
      options: {
        sourceMap: true,
        blacklist: ["strict"]
      },
      dev: {
        files: [{
          expand : true,
          cwd: '<%= yeoman.app %>/scripts/',
          src: ['**/*.js'],
          dest: '<%= yeoman.dist %>/scripts/',
          ext: '.js'
        }]
      },
      dist: {
        files: [{
          expand : true,
          cwd: '<%= yeoman.tmp %>/concat/scripts',
          src: '*.js',
          dest: '<%= yeoman.tmp %>/concat/scripts',
          ext: '.js'
        }]
      }
    },

    // Watches files for changes and runs tasks based on the changed files
    watch: {
      js: {
        files: ['<%= yeoman.app %>/scripts/{,*/}*.js'],
        tasks: ['newer:eslint:all', 'newer:babel:dev'],
        options: {
          livereload: true
        }
      },
      html : {
        files: ['<%= yeoman.app %>/views/{,*/}*.html'],
        tasks: ['newer:copy:dist'],
      },
      jsTest: {
        files: ['test/spec/{,*/}*.js'],
        tasks: ['newer:eslint:test', 'karma']
      },
      styles: {
        files: ['<%= yeoman.app %>/styles/{,*/}*.css'],
        tasks: ['newer:copy:styles', 'autoprefixer']
      },
      less: {
        files: ['<%= yeoman.app %>/styles/{,*/}*.less'],
        tasks: ['less:default']
      },
      gruntfile: {
        files: ['Gruntfile.js']
      },
      livereload: {
        options: {
          livereload: '<%= connect.options.livereload %>'
        },
        files: [
          '<%= yeoman.app %>/{,*/}*.html',
          '.tmp/styles/{,*/}*.{css,less}',
          '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
        ]
      }
    },

    // The actual grunt server settings
    connect: {
      options: {
        port: 9000,
        // Change this to '0.0.0.0' to access the server from outside.
        hostname: 'localhost',
        livereload: 35729
      },
      livereload: {
        options: {
          open: true,
          base: [
            '.tmp',
            '<%= yeoman.dist %>'
          ]
        }
      },
      test: {
        options: {
          port: 9001,
          base: [
            '.tmp',
            'test',
            '<%= yeoman.dist %>'
          ]
        }
      },
      dist: {
        options: {
          base: '<%= yeoman.dist %>'
        }
      }
    },

    // Make sure code styles are up to par and there are no obvious mistakes
    eslint: {
      options: {
        config: '.eslintrc'
      },
      all: [
        'Gruntfile.js',
        '<%= yeoman.app %>/scripts/{,*/}*.js'
      ],
      test: {
        src: ['test/spec/{,*/}*.js']
      }
    },

    // Empties folders to start fresh
    clean: {
      dist: {
        files: [{
          dot: true,
          src: [
            '.tmp',
            '<%= yeoman.dist %>/*',
            '!<%= yeoman.dist %>/.git*'
          ]
        }]
      },
      server: '.tmp'
    },

    // Add vendor prefixed styles
    autoprefixer: {
      options: {
        browsers: ['last 1 version']
      },
      dist: {
        files: [{
          expand: true,
          cwd: '.tmp/styles/',
          src: '{,*/}*.css',
          dest: '.tmp/styles/'
        }]
      }
    },

    // Automatically inject Bower components into the app
    bowerInstall: {
        app: {
        src: '<%= yeoman.app %>/index.html',
        ignorePath: '<%= yeoman.app %>/'
      }
    },

    // Renames files for browser caching purposes
    rev: {
      dist: {
        files: {
          src: [
            '<%= yeoman.dist %>/scripts/{,*/}*.js',
            '<%= yeoman.dist %>/styles/{,*/}*.css',
            '<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
            '<%= yeoman.dist %>/styles/fonts/*'
          ]
        }
      }
    },

    // Reads HTML for usemin blocks to enable smart builds that automatically
    // concat, minify and revision files. Creates configurations in memory so
    // additional tasks can operate on them
    useminPrepare: {
      html: '<%= yeoman.app %>/index.html',
      options: {
        dest: '<%= yeoman.dist %>'
      }
    },

    // Performs rewrites based on rev and the useminPrepare configuration
    usemin: {
      html: ['<%= yeoman.dist %>/{,*/}*.html'],
      css: ['<%= yeoman.dist %>/styles/{,*/}*.css'],
      options: {
        assetsDirs: ['<%= yeoman.dist %>']
      }
    },

    // The following *-min tasks produce minified files in the dist folder
    imagemin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>/images',
          src: '{,*/}*.{png,jpg,jpeg,gif}',
          dest: '<%= yeoman.dist %>/images'
        }]
      }
    },
    svgmin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>/images',
          src: '{,*/}*.svg',
          dest: '<%= yeoman.dist %>/images'
        }]
      }
    },
    htmlmin: {
      dist: {
        options: {
          collapseWhitespace: true,
          collapseBooleanAttributes: true,
          removeCommentsFromCDATA: true,
          removeOptionalTags: true
        },
        files: [{
          expand: true,
          cwd: '<%= yeoman.dist %>',
          src: ['*.html', 'views/{,*/}*.html'],
          dest: '<%= yeoman.dist %>'
        }]
      }
    },

    // Allow the use of non-minsafe AngularJS files. Automatically makes it
    // minsafe compatible so Uglify does not destroy the ng references
    ngmin: {
      dist: {
        files: [{
          expand: true,
          cwd: '.tmp/concat/scripts',
          src: '*.js',
          dest: '.tmp/concat/scripts'
        }]
      }
    },

    // Replace Google CDN references
    cdnify: {
      dist: {
        html: ['<%= yeoman.dist %>/*.html']
      }
    },

    //less
    less: {
      default: {
        options: {
          paths: ['app/styles'],
          cleancss: true,
        },
        files: {
          '<%= yeoman.app %>/styles/style.css': '<%= yeoman.app %>/styles/style.less'
        }
      }
    },

    // Copies remaining files to places other tasks can use
    copy: {
      dist: {
        files: [{
          expand: true,
          dot: true,
          cwd: '<%= yeoman.app %>',
          dest: '<%= yeoman.dist %>',
          src: [
            '*.{ico,png,txt}',
            '.htaccess',
            '*.html',
            '/scripts/{,*/}*.js',
            'views/{,*/}*.html',
            'libs/**/*',
            'images/{,*/}*.{webp}',
            'fonts/*'
          ]
        }, {
          expand: true,
          cwd: '.tmp/images',
          dest: '<%= yeoman.dist %>/images',
          src: ['generated/*']
        }]
      },
      styles: {
        expand: true,
        cwd: '<%= yeoman.app %>/styles',
        dest: '.tmp/styles/',
        src: '{,*/}*.css'
      }
    },

    // Run some tasks in parallel to speed up the build process
    concurrent: {
      server: [
        'copy:styles',
        'svgmin'
      ],
      test: [
        'copy:styles'
      ],
      dist: [
        'copy:styles',
        'imagemin',
        'svgmin'
      ]
    },

    // By default, your `index.html`'s <!-- Usemin block --> will take care of
    // minification. These next options are pre-configured if you do not wish
    // to use the Usemin blocks.
    cssmin: {
      dist: {
        files: {
          '<%= yeoman.dist %>/styles/main.css': [
            '.tmp/styles/{,*/}*.css',
            '<%= yeoman.app %>/styles/{,*/}*.css'
          ]
        }
      }
    },
    uglify: {
      dist: {
        files: {
          '<%= yeoman.dist %>/scripts/scripts.js': [
            '<%= yeoman.dist %>/scripts/scripts.js'
          ]
        }
      }
    },
    concat: {
      dist: {}
    },

    shell: {
      updateSeleniumWebDriver: {
        command: 'node node_modules/protractor/bin/webdriver-manager update',
        options: {
          stdout: true
        }
      }
    },

    'protractor_webdriver': {
      options: {
        // Task-specific options go here.
      },
      run: {
        // Target-specific file lists and/or options go here.
      }
    },

    protractor: {
      options: {
        configFile: 'node_modules/protractor/referenceConf.js', // Default config file
        keepAlive: true, // If false, the grunt process stops when the test fails.
        noColor: false, // If true, protractor will not use colors in its output.
        args: {
          // Arguments passed to the command
        }
      },
      local: {
        options: {
          configFile: 'protractor.conf.js', // Target-specific config file
          args: {
            // Target-specific arguments
            seleniumPort : 9000
          }
        }
      }
    },

    // Test settings
    karma: {
      unit: {
        configFile: 'karma.conf.js',
        singleRun: true
      }
    }
  });

  // TASK CONFIGURATION //
  grunt.registerTask('serve', function (target) {
    if (target === 'dist') {
      return grunt.task.run(['build', 'connect:dist:keepalive']);
    }

    grunt.task.run([
      'clean:server',
      'bowerInstall',
      'concurrent:server',
      'autoprefixer',
      'copy:dist',
      'babel:dev',
      'connect:livereload',
      'watch'
    ]);
  });

  grunt.registerTask('server', function () {
    grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
    grunt.task.run(['serve']);
  });

  grunt.registerTask('test', [
    'clean:server',
    'concurrent:test',
    'autoprefixer',
    'babel:dev',
    'connect:test',
    'karma',
    'shell:updateSeleniumWebDriver',
    'protractor_webdriver:run',
    'protractor:local'
  ]);

  grunt.registerTask('e2e', [
    'connect:dist',
    'shell:updateSeleniumWebDriver',
    'protractor_webdriver:run',
    'protractor:local'
  ]);

  grunt.registerTask('build', [
    'clean:dist',
    'bowerInstall',
    'useminPrepare',
    'concurrent:dist',
    'autoprefixer',
    'concat',
    'babel:dist',
    'ngmin',
    'less',
    'copy:dist',
    'cdnify',
    'cssmin',
    'uglify',
    'rev',
    'usemin',
    'htmlmin'
  ]);

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


<commit_before>
var tasks = require('gulp-tasks');
var build_directory = "./site/";
var date_formats = ["YYYY-MM-DD", "YYYY-MM-DD-HHmmss"];

tasks.config({
    build_directory: build_directory,
    date_formats: date_formats,
    js_files: [
        "node_modules/fastclick/lib/fastclick.js",
        "node_modules/prismjs/components/prism-core.js",
        "node_modules/prismjs/components/prism-markup.js",
        "node_modules/prismjs/components/prism-twig.js",
        "node_modules/prismjs/components/prism-css.js",
        "node_modules/prismjs/components/prism-clike.js",
        "node_modules/prismjs/components/prism-javascript.js",
        "node_modules/prismjs/components/prism-php.js",
        "node_modules/prismjs/components/prism-scss.js",
        "js/prism-apacheconf.js",
        "js/site.js"
    ],
    css_files: [
        "css/site.css"
    ],
    icon_files: [
        "node_modules/geomicons-open/icons/calendar.svg",
        "node_modules/geomicons-open/icons/chevron-left.svg",
        "node_modules/geomicons-open/icons/chevron-right.svg",
        "node_modules/geomicons-open/icons/github.svg",
        "node_modules/geomicons-open/icons/home.svg",
        "node_modules/geomicons-open/icons/search.svg",
        "node_modules/geomicons-open/icons/twitter.svg"
    ],
    build: function() {

        var nunjucks = require('nunjucks');
        var engine = require('static-engine');
        var content = require('static-engine-content');
        var defaults = require('static-engine-defaults');
        var pager = require('static-engine-pager');
        var first = require('static-engine-first');
        var collection = require('static-engine-collection');
        var marked = require('static-engine-converter-marked');
        var site = engine(build_directory, nunjucks.render);

        content.configure('./content/', {
            converters: {
                md: marked()
            },
            date_formats: date_formats
        });

        nunjucks.configure('./templates/', {
            autoescape: true
        });

        site.route('/')
            .use(content('posts/*'))
            .use(pager())
            .use(first())
            .render('post.html');

        site.route('/posts/{slug}/')
            .alias('post')
            .use(content('posts/*'))
            .use(pager())
            .render('post.html');

        site.route('/posts/')
            .use(content('posts.md'))
            .use(collection('posts', content('posts/*')))
            .render('posts.html');

        site.route('/404.html')
            .use(content('404.md'))
            .render('404.html');

        site.after(defaults(site, './content/defaults.yml'));

        return site.build();
    }
});

tasks();
<commit_msg>Configure thumbnails<commit_after>
var tasks = require('gulp-tasks');
var build_directory = "./site/";
var date_formats = ["YYYY-MM-DD", "YYYY-MM-DD-HHmmss"];

tasks.config({
    build_directory: build_directory,
    date_formats: date_formats,
    js_files: [
        "node_modules/fastclick/lib/fastclick.js",
        "node_modules/prismjs/components/prism-core.js",
        "node_modules/prismjs/components/prism-markup.js",
        "node_modules/prismjs/components/prism-twig.js",
        "node_modules/prismjs/components/prism-css.js",
        "node_modules/prismjs/components/prism-clike.js",
        "node_modules/prismjs/components/prism-javascript.js",
        "node_modules/prismjs/components/prism-php.js",
        "node_modules/prismjs/components/prism-scss.js",
        "js/prism-apacheconf.js",
        "js/site.js"
    ],
    css_files: [
        "css/site.css"
    ],
    icon_files: [
        "node_modules/geomicons-open/icons/calendar.svg",
        "node_modules/geomicons-open/icons/chevron-left.svg",
        "node_modules/geomicons-open/icons/chevron-right.svg",
        "node_modules/geomicons-open/icons/github.svg",
        "node_modules/geomicons-open/icons/home.svg",
        "node_modules/geomicons-open/icons/search.svg",
        "node_modules/geomicons-open/icons/twitter.svg"
    ],
    thumbnails: [
        {
            directory: "thumbnails",
            width: 608,
            height: 0
        }
    ],
    build: function() {

        var nunjucks = require('nunjucks');
        var engine = require('static-engine');
        var content = require('static-engine-content');
        var defaults = require('static-engine-defaults');
        var pager = require('static-engine-pager');
        var first = require('static-engine-first');
        var collection = require('static-engine-collection');
        var marked = require('static-engine-converter-marked');
        var site = engine(build_directory, nunjucks.render);

        content.configure('./content/', {
            converters: {
                md: marked()
            },
            date_formats: date_formats
        });

        nunjucks.configure('./templates/', {
            autoescape: true
        });

        site.route('/')
            .use(content('posts/*'))
            .use(pager())
            .use(first())
            .render('post.html');

        site.route('/posts/{slug}/')
            .alias('post')
            .use(content('posts/*'))
            .use(pager())
            .render('post.html');

        site.route('/posts/')
            .use(content('posts.md'))
            .use(collection('posts', content('posts/*')))
            .render('posts.html');

        site.route('/404.html')
            .use(content('404.md'))
            .render('404.html');

        site.after(defaults(site, './content/defaults.yml'));

        return site.build();
    }
});

tasks();
<|endoftext|>


<commit_before>'use strict';

/**
 * @module dhsniem
 *
 * @description
 * Main module of the application.
 */
angular
  .module('dhsniem', [
    'ngAnimate',
    'ngCookies',
    'ui.router',
    'ngSanitize',
    'ngTouch',
    'ui.bootstrap'
  ])
  .config(function($urlRouterProvider) {
    $urlRouterProvider.when('', '/'); // redirect to root if the state is ''

    $urlRouterProvider.otherwise('/'); // redirect to root if state is not found
  });
<commit_msg>DN-250 scroll to top on state change<commit_after>'use strict';

/**
 * @module dhsniem
 *
 * @description
 * Main module of the application.
 */
angular
  .module('dhsniem', [
    'ngAnimate',
    'ngCookies',
    'ui.router',
    'ngSanitize',
    'ngTouch',
    'ui.bootstrap'
  ])
  .config(function($urlRouterProvider) {
    $urlRouterProvider.when('', '/'); // redirect to root if the state is ''

    $urlRouterProvider.otherwise('/'); // redirect to root if state is not found
  })

  .run(function($rootScope, $window) {
  $rootScope.$on('$stateChangeSuccess', function() {
    $window.scroll(0,0);
  });
});

<|endoftext|>


<commit_before>const environment = process.env.NODE_ENV || 'development'
const config = require('../../knexfile')[environment]
const knex = require('knex')(config)
const fs = require('fs')
const path = require('path')

process.stdout.write('Attempting to remove outdated migration filenames from database... ')
const migrations = fs.readdirSync(path.join(__dirname, '..'))
.filter(f => f.slice(-3) === '.js')

var newestMigrationTime

if (migrations.length > 0) {
  const timestamp = migrations[migrations.length - 1].split('_')[0]
  newestMigrationTime = new Date(
    timestamp.substring(0, 4),
    Number(timestamp.substring(4, 6)) - 1,
    timestamp.substring(6, 8),
    timestamp.substring(8, 10),
    timestamp.substring(10, 12),
    timestamp.substring(12, 14)
  )
} else {
  newestMigrationTime = new Date()
}

knex('knex_migrations')
.whereNotIn('name', migrations)
.where('migration_time', '<', newestMigrationTime)
.del()
.then(n => console.info(`${n} rows affected.`))
.then(() => knex.destroy())
.catch(console.error)
<commit_msg>Fix heroku build?<commit_after>const environment = process.env.NODE_ENV || 'development'
const config = require('../../knexfile')[environment]
const knex = require('knex')(config)
const fs = require('fs')
const path = require('path')

process.stdout.write('Attempting to remove outdated migration filenames from database... ')
const migrations = fs.readdirSync(path.join(__dirname, '..'))
.filter(f => f.slice(-3) === '.js')

var newestMigrationTime

if (migrations.length > 0) {
  const timestamp = migrations[migrations.length - 1].split('_')[0]
  newestMigrationTime = new Date(
    timestamp.substring(0, 4),
    Number(timestamp.substring(4, 6)) - 1,
    timestamp.substring(6, 8),
    timestamp.substring(8, 10),
    timestamp.substring(10, 12),
    timestamp.substring(12, 14)
  )
} else {
  newestMigrationTime = new Date()
}

knex('knex_migrations')
.whereNotIn('name', migrations)
.where('migration_time', '<', newestMigrationTime)
.del()
.then(n => console.info(`${n} rows affected.`))
.catch(console.error)
.finally(() => knex.destroy())
<|endoftext|>


<commit_before>/**
 * app.js
 */
(function (spiderOakApp, window, undefined) {
  "use strict";
  var console = window.console || {};
  console.log = console.log || function(){};
  var Backbone    = window.Backbone,
      _           = window._,
      $           = window.$;

  // Fix for lack of detach in Zepto...
  $.fn.detach = $.fn.remove;

  // Considering changing the template settings as the ERB defaults are annoying
  // _.templateSettings = {
  //   evaluate:    /\{\{#([\s\S]+?)=\}\}/g,          // {{# console.log("blah") }}
  //   interpolate: /\{\{[^#\{]([\s\S]+?)[^\}]\}\}/g, // {{ title }}
  //   escape:      /\{\{\{([\s\S]+?)\}\}\}/g         // {{{ title }}}
  // };

  _.extend(spiderOakApp, {
    initialize: function() {
      // Start listening for important app-level events
      document.addEventListener(
        "deviceready",
        this.onDeviceReady,
        false
      );
      document.addEventListener(
        "loginSuccess",
        this.onLoginSuccess,
        false
      );
      // Hax for Android 2.x not groking :active
      $(document).on("touchstart", "a", function(event) {
        var $this = $(this);
        $this.addClass("active");
      });
      $(document).on("touchend", "a", function(event) {
        var $this = $(this);
        $this.removeClass("active");
      });
      $(document).on("touchmove", "a", function(event) {
        var $this = $(this);
        $this.removeClass("active");
      });
      $(".splash").hide();
    },
    backDisabled: true,
    onDeviceReady: function() {
      document.addEventListener(
        "backbutton",
        spiderOakApp.onBackKeyDown,
        false
      );
      document.addEventListener(
        "menubutton",
        spiderOakApp.onMenuKeyDown,
        false
      );
      // @FIXME: This seems cludgey
      if (window.cssLoaded) navigator.splashscreen.hide();
      // @TODO: Instantiate any plugins
      spiderOakApp.fileViewer = window.cordova &&
        window.cordova.require("cordova/plugin/fileviewerplugin");
    },
    onLoginSuccess: function() {
      // Instantiate the menusheet and bind the spiderOakApp.accountModel
      // @TODO: refactor so menuSheetView can also be used without active login.
      spiderOakApp.menuSheetView = new spiderOakApp.MenuSheetView({
        model: spiderOakApp.accountModel
      }).render();
      // Instantiate the favorites and populate from localStorage
      var favorites = window.store.get(
        "favorites-" + spiderOakApp.accountModel.get("b32username")
      );
      favorites = favorites || [];
      spiderOakApp.favoritesCollection =
        new spiderOakApp.FavoritesCollection(favorites);

      // Fresh new recents collection
      spiderOakApp.recentsCollection = new spiderOakApp.RecentsCollection();
    },
    onBackKeyDown: function(event) {
      event.preventDefault();
      if ($(".modal").is(":visible")) {
        return;
      }
      // @FIXME: Extend this logic a bit... it's a bit simplistic
      if ($("#main").hasClass("open")) {
        spiderOakApp.mainView.closeMenu();
        return;
      }
      if ($(".nav .back-btn").is(":visible")) {
        spiderOakApp.navigator.popView(spiderOakApp.defaultEffect);
        return;
      }
      navigator.app.exitApp();
    },
    onMenuKeyDown: function(event) {
      if ($("#main").hasClass("open")) {
        spiderOakApp.mainView.closeMenu();
      }
      else {
        spiderOakApp.mainView.openMenu();
      }
    },
    downloader: new window.FileDownloadHelper(),
    navigator: new window.BackStack.StackNavigator({el:'#subviews'}),
    noEffect: new window.BackStack.NoEffect(),
    fadeEffect: new window.BackStack.FadeEffect(),
    defaultEffect: (($.os.android) ? new window.BackStack.NoEffect() : null),
    b32nibbler: new window.Nibbler({dataBits: 8,
                                    codeBits: 5,
                                    keyString:
                                      "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",
                                    pad: ""
                                   }),
    /** Maintain persistent local settings.
     *
     * - Values are maintained transparently using JSON.
     * - Use .get(name), .set(name, value), and .remove(name).
     * - .keys() returns an array of all stored keys.
     * - .length() returns the number of keys.
     */
    localVal: {
      get: function (name) {
        return JSON.parse(localStorage.getItem(name));
      },
      set: function (name, value) {
        localStorage.setItem(name, JSON.stringify(value));
      },
      remove: function (name) {
        localStorage.removeItem(name);
      },
      keys: function () {
        return Object.keys(localStorage);
      }
    }
  });
  // Implement spiderOakApp.local.length as a property, for iterability:
  Object.defineProperty(spiderOakApp.localVal, "length",
                        {get: function() { return localStorage.length; },
                         enumerable: true
                        });

  /*
   * How a model in our framework determines its' composite URL.
   *
   * The URL is a concatenation of model and collection url elements.  Any
   * prevailing elements that are functions are evaluated for their result.
   *
   * - A head part is taken in this order of precedence:
   *   - the model's collection's urlBase attribute, or
   *   - the model's collection's url attribute,
   * - The url part is taken from the model's .get("url").
   *
   * @this{model}
   */
  Backbone.Model.prototype.composedUrl = function() {
    var urlTail = this.get("url");
    var collection = this.collection;
    var urlHead = collection ? (collection.urlBase || collection.url) : "";
    if (typeof urlTail === "function") {
      urlTail = urlTail.call(this);
    }
    if (typeof urlHead === "function") {
      urlHead = urlHead.call(this.collection);
    }
    return urlHead + urlTail;
  };
  /**
   * Method to fetch model.url string and function versions identically.
   */
  Backbone.Model.prototype.urlResult = function() {
    return (typeof this.url === "function") ? this.url() : this.url;
  };

})(window.spiderOakApp = window.spiderOakApp || {}, window);

/* Function.bind polyfill */

if (!Function.prototype.bind) {
  Function.prototype.bind = function (oThis) {
    if (typeof this !== "function") {
      // closest thing possible to the ECMAScript 5 internal IsCallable function
      throw new TypeError("Function.prototype.bind - " +
        "what is trying to be bound is not callable");
    }

    var aArgs = Array.prototype.slice.call(arguments, 1),
        fToBind = this,
        FNOP = function () {},
        fBound = function () {
          return fToBind.apply(this instanceof FNOP && oThis ? this : oThis,
                          aArgs.concat(Array.prototype.slice.call(arguments)));
        };

    FNOP.prototype = this.prototype;
    fBound.prototype = new FNOP();

    return fBound;
  };
}
<commit_msg>Remove spiderOakApp.localVal - window.store (via store.js) is much better.<commit_after>/**
 * app.js
 */
(function (spiderOakApp, window, undefined) {
  "use strict";
  var console = window.console || {};
  console.log = console.log || function(){};
  var Backbone    = window.Backbone,
      _           = window._,
      $           = window.$;

  // Fix for lack of detach in Zepto...
  $.fn.detach = $.fn.remove;

  // Considering changing the template settings as the ERB defaults are annoying
  // _.templateSettings = {
  //   evaluate:    /\{\{#([\s\S]+?)=\}\}/g,          // {{# console.log("blah") }}
  //   interpolate: /\{\{[^#\{]([\s\S]+?)[^\}]\}\}/g, // {{ title }}
  //   escape:      /\{\{\{([\s\S]+?)\}\}\}/g         // {{{ title }}}
  // };

  _.extend(spiderOakApp, {
    initialize: function() {
      // Start listening for important app-level events
      document.addEventListener(
        "deviceready",
        this.onDeviceReady,
        false
      );
      document.addEventListener(
        "loginSuccess",
        this.onLoginSuccess,
        false
      );
      // Hax for Android 2.x not groking :active
      $(document).on("touchstart", "a", function(event) {
        var $this = $(this);
        $this.addClass("active");
      });
      $(document).on("touchend", "a", function(event) {
        var $this = $(this);
        $this.removeClass("active");
      });
      $(document).on("touchmove", "a", function(event) {
        var $this = $(this);
        $this.removeClass("active");
      });
      $(".splash").hide();
    },
    backDisabled: true,
    onDeviceReady: function() {
      document.addEventListener(
        "backbutton",
        spiderOakApp.onBackKeyDown,
        false
      );
      document.addEventListener(
        "menubutton",
        spiderOakApp.onMenuKeyDown,
        false
      );
      // @FIXME: This seems cludgey
      if (window.cssLoaded) navigator.splashscreen.hide();
      // @TODO: Instantiate any plugins
      spiderOakApp.fileViewer = window.cordova &&
        window.cordova.require("cordova/plugin/fileviewerplugin");
    },
    onLoginSuccess: function() {
      // Instantiate the menusheet and bind the spiderOakApp.accountModel
      // @TODO: refactor so menuSheetView can also be used without active login.
      spiderOakApp.menuSheetView = new spiderOakApp.MenuSheetView({
        model: spiderOakApp.accountModel
      }).render();
      // Instantiate the favorites and populate from localStorage
      var favorites = window.store.get(
        "favorites-" + spiderOakApp.accountModel.get("b32username")
      );
      favorites = favorites || [];
      spiderOakApp.favoritesCollection =
        new spiderOakApp.FavoritesCollection(favorites);

      // Fresh new recents collection
      spiderOakApp.recentsCollection = new spiderOakApp.RecentsCollection();
    },
    onBackKeyDown: function(event) {
      event.preventDefault();
      if ($(".modal").is(":visible")) {
        return;
      }
      // @FIXME: Extend this logic a bit... it's a bit simplistic
      if ($("#main").hasClass("open")) {
        spiderOakApp.mainView.closeMenu();
        return;
      }
      if ($(".nav .back-btn").is(":visible")) {
        spiderOakApp.navigator.popView(spiderOakApp.defaultEffect);
        return;
      }
      navigator.app.exitApp();
    },
    onMenuKeyDown: function(event) {
      if ($("#main").hasClass("open")) {
        spiderOakApp.mainView.closeMenu();
      }
      else {
        spiderOakApp.mainView.openMenu();
      }
    },
    downloader: new window.FileDownloadHelper(),
    navigator: new window.BackStack.StackNavigator({el:'#subviews'}),
    noEffect: new window.BackStack.NoEffect(),
    fadeEffect: new window.BackStack.FadeEffect(),
    defaultEffect: (($.os.android) ? new window.BackStack.NoEffect() : null),
    b32nibbler: new window.Nibbler({dataBits: 8,
                                    codeBits: 5,
                                    keyString:
                                      "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",
                                    pad: ""
                                   })
  });

  /*
   * How a model in our framework determines its' composite URL.
   *
   * The URL is a concatenation of model and collection url elements.  Any
   * prevailing elements that are functions are evaluated for their result.
   *
   * - A head part is taken in this order of precedence:
   *   - the model's collection's urlBase attribute, or
   *   - the model's collection's url attribute,
   * - The url part is taken from the model's .get("url").
   *
   * @this{model}
   */
  Backbone.Model.prototype.composedUrl = function() {
    var urlTail = this.get("url");
    var collection = this.collection;
    var urlHead = collection ? (collection.urlBase || collection.url) : "";
    if (typeof urlTail === "function") {
      urlTail = urlTail.call(this);
    }
    if (typeof urlHead === "function") {
      urlHead = urlHead.call(this.collection);
    }
    return urlHead + urlTail;
  };
  /**
   * Method to fetch model.url string and function versions identically.
   */
  Backbone.Model.prototype.urlResult = function() {
    return (typeof this.url === "function") ? this.url() : this.url;
  };

})(window.spiderOakApp = window.spiderOakApp || {}, window);

/* Function.bind polyfill */

if (!Function.prototype.bind) {
  Function.prototype.bind = function (oThis) {
    if (typeof this !== "function") {
      // closest thing possible to the ECMAScript 5 internal IsCallable function
      throw new TypeError("Function.prototype.bind - " +
        "what is trying to be bound is not callable");
    }

    var aArgs = Array.prototype.slice.call(arguments, 1),
        fToBind = this,
        FNOP = function () {},
        fBound = function () {
          return fToBind.apply(this instanceof FNOP && oThis ? this : oThis,
                          aArgs.concat(Array.prototype.slice.call(arguments)));
        };

    FNOP.prototype = this.prototype;
    fBound.prototype = new FNOP();

    return fBound;
  };
}
<|endoftext|>


<commit_before>'use strict';

const path = require('path');
const serveStatic = require('feathers').static;
const favicon = require('serve-favicon');
const compress = require('compression');
const cors = require('cors');
const feathers = require('feathers');
const configuration = require('feathers-configuration');
const hooks = require('feathers-hooks');
const rest = require('feathers-rest');
const bodyParser = require('body-parser');
const socketio = require('feathers-socketio');
const middleware = require('./middleware');
const services = require('./services');
const winston = require('winston');
const defaultHeaders = require('./middleware/defaultHeaders');
const setupSwagger = require('./swagger');

const app = feathers();

app.configure(configuration(path.join(__dirname, '..')));
setupSwagger(app);

app.use(compress())
	.options('*', cors())
	.use(cors())
	.use(favicon(path.join(app.get('public'), 'favicon.ico')))
	.use('/', serveStatic(app.get('public')))
	.use(bodyParser.json())
	.use(bodyParser.urlencoded({extended: true}))

	.use(defaultHeaders)
	.get('/system_info/haproxy', (req, res) => { res.send({ "timestamp":new Date().getTime() });})
	.get('/ping', (req, res) => { res.send({ "message":"pong","timestamp":new Date().getTime() });})

	.configure(hooks())
	.configure(rest())
	.configure(socketio())

	// auth is setup in /authentication/

	.configure(services)
	.configure(middleware);

winston.cli();	// optimize for cli, like using colors
winston.level = 'debug';
winston.info('test');

module.exports = app;
<commit_msg>No more 'test'!<commit_after>'use strict';

const path = require('path');
const serveStatic = require('feathers').static;
const favicon = require('serve-favicon');
const compress = require('compression');
const cors = require('cors');
const feathers = require('feathers');
const configuration = require('feathers-configuration');
const hooks = require('feathers-hooks');
const rest = require('feathers-rest');
const bodyParser = require('body-parser');
const socketio = require('feathers-socketio');
const middleware = require('./middleware');
const services = require('./services');
const winston = require('winston');
const defaultHeaders = require('./middleware/defaultHeaders');
const setupSwagger = require('./swagger');

const app = feathers();

app.configure(configuration(path.join(__dirname, '..')));
setupSwagger(app);

app.use(compress())
	.options('*', cors())
	.use(cors())
	.use(favicon(path.join(app.get('public'), 'favicon.ico')))
	.use('/', serveStatic(app.get('public')))
	.use(bodyParser.json())
	.use(bodyParser.urlencoded({extended: true}))

	.use(defaultHeaders)
	.get('/system_info/haproxy', (req, res) => { res.send({ "timestamp":new Date().getTime() });})
	.get('/ping', (req, res) => { res.send({ "message":"pong","timestamp":new Date().getTime() });})

	.configure(hooks())
	.configure(rest())
	.configure(socketio())

	// auth is setup in /authentication/

	.configure(services)
	.configure(middleware);

winston.cli();	// optimize for cli, like using colors
winston.level = 'debug';

module.exports = app;
<|endoftext|>


<commit_before>/*!
 * SVG.js Pan Zoom Plugin
 * ======================
 *
 * A JavaScript library for pan and zoom SVG things.
 * Created with <3 and JavaScript by the jillix developers.
 *
 * svg.pan-zoom.js 2.2.0
 * Licensed under the MIT license.
 * */
;(function() {

    var container = null
      , markers = null
      , mousewheel = "onwheel" in document.createElement("div")
      ? "wheel"
      : document.onmousewheel !== undefined
      ? "mousewheel"
      : "DOMMouseScroll"
      ;

    /**
     * panZoom
     * The pan-zoom contructor.
     *
     * @name panZoom
     * @function
     * @param {Object|undefined} opt_options An optional object containing the following fields:
     *
     *  - `zoom` (Array): An array of two float values: the minimum and maximum zoom values (default: `undefined`).
     *  - `zoomSpeed` (Number): The zoom speed (default: `-1`). By changing the sign the zoom is reversed.
     *
     * @return {PanZoom} The PanZoom object containing the following fields:
     *
     *  - `elm` (SVG): The selected element.
     *  - `pan` (Object): An object containing pan values.
     *  - `transform` (Object): An object containing the transform data (`scaleX`, `scaleY`, `x` and `y`).
     *
     */
    function panZoom(opt_options) {

        // Selected element
        var self = this;

        /**
         * setPosition
         * Sets the graph position programatically.
         *
         * @name setPosition
         * @function
         * @param {Number} x The relative position to the svg document (on x axis).
         * @param {Number} y The relative position to the svg document (on y axis).
         * @param {Number} z The zoom value which will be handled as `scale` internally.
         * @return {PanZoom} The `PanZoom` instance.
         */
        function setPosition(x, y, z) {
            pz.pan.iPos = pz.pan.fPos;
            pz.transform = self.transform();
            pz.transform.x = x;
            pz.transform.y = y;
            if (typeof z === "number") {
                pz.zoom(z);
            } else {
                updateMatrix();
            }
            return pz;
        }

        /**
         * zoom
         * Zooms in/out the graph programatically.
         *
         * @name zoom
         * @function
         * @param {Number} z The zoom value which will be handled as `scale` internally.
         * @return {PanZoom} The `PanZoom` instance.
         */
        function zoom(z) {
            if (typeof z === "number") {
                pz.transform = self.transform();
                pz.transform.scaleY = pz.transform.scaleX = z;
                updateMatrix();
                return pz;
            }

            pz.transform = self.transform();
            pz.transform.scaleY = pz.transform.scaleX = z;
            updateMatrix();
            return pz;
        }

        // Pan zoom object
        var pz = {
            pan: {}
          , elm: self
          , setPosition: setPosition
          , zoom: zoom
        };

        // Set options
        opt_options = Object(opt_options);
        opt_options.zoom = opt_options.zoom || [];
        opt_options.zoomSpeed = typeof opt_options.zoomSpeed === "number" ? opt_options.zoomSpeed : -1;

        // Get the svg document
        var svg = self;
        while ((svg = self.parent()).node.tagName.toUpperCase() !== "SVG") {}

        // Create the rectangle
        var rect = new SVG(document.createDocumentFragment()).rect().attr({
            width: svg.width()
          , height: svg.height()
          , fill: "none"
        }).style("pointer-events", "all");

        // Insert the rectangle
        self.parent().node.insertBefore(rect.node, self.node);

        /*!
         * updateMatrix
         * An internal function called to update the svg matrix.
         *
         * @name updateMatrix
         * @function
         * @return {undefined}
         */
        function updateMatrix() {
            self.attr("transform", "matrix(" + [
                pz.transform.scaleX
              , 0, 0
              , pz.transform.scaleY
              , pz.transform.x
              , pz.transform.y
            ].join(",")+ ")");
        }

        /*!
         * pan
         * The internal function called for panning.
         *
         * @name pan
         * @function
         * @param {Event} e The internal listener event.
         * @return {undefined}
         */
        function pan(e) {
            if (!pz.pan.mousedown) {
                return;
            }
            var tr = pz.transform = self.transform();
            var diffX = pz.pan.fPos.x - pz.pan.iPos.x;
            var diffY = pz.pan.fPos.y - pz.pan.iPos.y;
            pz.setPosition(tr.x + diffX, tr.y + diffY);
            self.node.dispatchEvent(new CustomEvent("pan", { detail: { e: e, tr: tr } }));
        }

        /*!
         * mousePos
         * Returns the mouse point coordinates.
         *
         * @name mousePos
         * @function
         * @param {Event} e The mouse event.
         * @param {Boolean} rel If `true`, the relative coordinates will be returned instead.
         * @return {Object} An object containing the relative coordinates.
         */
        function mousePos(e, rel) {
            var bbox = self.parent().node.getBoundingClientRect()
              , abs = {
                    x: e.clientX || e.touches[0].pageX
                  , y: e.clientY || e.touches[0].pageY
                }
              ;
            if (!rel) { return abs; }
            return {
                x: abs.x - bbox.left
              , y: abs.y - bbox.top
            };
        }

        /*!
         * zoom
         * The internal function called for zooming.
         *
         * @name zoom
         * @function
         * @param {Event} e The internal listener event.
         * @return {undefined}
         */
        function doZoom (e) {

            // Get the relative mouse point
            var rP = mousePos(e, true)
              , oX = rP.x
              , oY = rP.y
              ;

            e.deltaY = e.deltaY || e.wheelDeltaY;

            // Compute the new scale
            var d = opt_options.zoomSpeed * e.deltaY / 1000
              , tr = pz.transform = self.transform()
              , scale = tr.scaleX + (tr.scaleX * d)
              , scaleD = scale / tr.scaleX

                // Get the current x, y
              , currentX = tr.x
              , currentY = tr.y

                // Compute the final x, y
              , x = scaleD * (currentX - oX) + oX
              , y = scaleD * (currentY - oY) + oY
              ;

            // Handle zoom restrictions
            if (scale > opt_options.zoom[1]) {
                scale = opt_options.zoom[1];
                return;
            }

            if (scale < opt_options.zoom[0]) {
                scale = opt_options.zoom[0];
                return;
            }

            // Zoom
            tr.scaleY = tr.scaleX = scale;
            tr.x = x;
            tr.y = y;

            self.node.dispatchEvent(new CustomEvent("zoom", { detail: { e: e, tr: tr } }));
            updateMatrix();

            // Prevent the default browser behavior
            e.preventDefault();
        }

        // The event listeners
        var EventListeners = {
            mouse_down: function (e) {
                pz.pan.mousedown = true;
                pz.pan.iPos = mousePos(e);
            }
          , mouse_up: function (e) {
                pz.pan.mousedown = false;
                pz.pan.fPos = mousePos(e);
                pan();
            }
          , mouse_move: function (e) {
                if (!pz.pan.mousedown) { return; }
                pz.pan.fPos = mousePos(e);
                pan();
            }
          , mouse_leave: function (e) {
                pz.pan.mousedown = false;
            }
        };

        // Add event listeners
        rect
          .on(mousewheel, doZoom)
          .on("mousedown", EventListeners.mouse_down)
          .on("touchstart", EventListeners.mouse_down)
          .on("mousemove", EventListeners.mouse_move)
          .on("touchmove", EventListeners.mouse_move)
          .on("mouseup", EventListeners.mouse_up)
          .on("touchup", EventListeners.mouse_up)
          .on("mouseleave", EventListeners.mouse_leave)
          ;

        self.on(mousewheel, doZoom);
        return pz;
    }

    // Extend the SVG.Element with the new function
    SVG.extend(SVG.Element, {
        panZoom: panZoom
    });
}).call(this);
<commit_msg>Use the transform which is already there<commit_after>/*!
 * SVG.js Pan Zoom Plugin
 * ======================
 *
 * A JavaScript library for pan and zoom SVG things.
 * Created with <3 and JavaScript by the jillix developers.
 *
 * svg.pan-zoom.js 2.2.0
 * Licensed under the MIT license.
 * */
;(function() {

    var container = null
      , markers = null
      , mousewheel = "onwheel" in document.createElement("div")
      ? "wheel"
      : document.onmousewheel !== undefined
      ? "mousewheel"
      : "DOMMouseScroll"
      ;

    /**
     * panZoom
     * The pan-zoom contructor.
     *
     * @name panZoom
     * @function
     * @param {Object|undefined} opt_options An optional object containing the following fields:
     *
     *  - `zoom` (Array): An array of two float values: the minimum and maximum zoom values (default: `undefined`).
     *  - `zoomSpeed` (Number): The zoom speed (default: `-1`). By changing the sign the zoom is reversed.
     *
     * @return {PanZoom} The PanZoom object containing the following fields:
     *
     *  - `elm` (SVG): The selected element.
     *  - `pan` (Object): An object containing pan values.
     *  - `transform` (Object): An object containing the transform data (`scaleX`, `scaleY`, `x` and `y`).
     *
     */
    function panZoom(opt_options) {

        // Selected element
        var self = this;

        /**
         * setPosition
         * Sets the graph position programatically.
         *
         * @name setPosition
         * @function
         * @param {Number} x The relative position to the svg document (on x axis).
         * @param {Number} y The relative position to the svg document (on y axis).
         * @param {Number} z The zoom value which will be handled as `scale` internally.
         * @return {PanZoom} The `PanZoom` instance.
         */
        function setPosition(x, y, z) {
            pz.pan.iPos = pz.pan.fPos;
            pz.transform = self.transform();
            pz.transform.x = x;
            pz.transform.y = y;
            if (typeof z === "number") {
                pz.zoom(z);
            } else {
                updateMatrix();
            }
            return pz;
        }

        /**
         * zoom
         * Zooms in/out the graph programatically.
         *
         * @name zoom
         * @function
         * @param {Number} z The zoom value which will be handled as `scale` internally.
         * @return {PanZoom} The `PanZoom` instance.
         */
        function zoom(z) {
            if (typeof z === "number") {
                pz.transform = pz.transform || self.transform();
                pz.transform.scaleY = pz.transform.scaleX = z;
                updateMatrix();
                return pz;
            }

            pz.transform = self.transform();
            pz.transform.scaleY = pz.transform.scaleX = z;
            updateMatrix();
            return pz;
        }

        // Pan zoom object
        var pz = {
            pan: {}
          , elm: self
          , setPosition: setPosition
          , zoom: zoom
        };

        // Set options
        opt_options = Object(opt_options);
        opt_options.zoom = opt_options.zoom || [];
        opt_options.zoomSpeed = typeof opt_options.zoomSpeed === "number" ? opt_options.zoomSpeed : -1;

        // Get the svg document
        var svg = self;
        while ((svg = self.parent()).node.tagName.toUpperCase() !== "SVG") {}

        // Create the rectangle
        var rect = new SVG(document.createDocumentFragment()).rect().attr({
            width: svg.width()
          , height: svg.height()
          , fill: "none"
        }).style("pointer-events", "all");

        // Insert the rectangle
        self.parent().node.insertBefore(rect.node, self.node);

        /*!
         * updateMatrix
         * An internal function called to update the svg matrix.
         *
         * @name updateMatrix
         * @function
         * @return {undefined}
         */
        function updateMatrix() {
            self.attr("transform", "matrix(" + [
                pz.transform.scaleX
              , 0, 0
              , pz.transform.scaleY
              , pz.transform.x
              , pz.transform.y
            ].join(",")+ ")");
        }

        /*!
         * pan
         * The internal function called for panning.
         *
         * @name pan
         * @function
         * @param {Event} e The internal listener event.
         * @return {undefined}
         */
        function pan(e) {
            if (!pz.pan.mousedown) {
                return;
            }
            var tr = pz.transform = self.transform();
            var diffX = pz.pan.fPos.x - pz.pan.iPos.x;
            var diffY = pz.pan.fPos.y - pz.pan.iPos.y;
            pz.setPosition(tr.x + diffX, tr.y + diffY);
            self.node.dispatchEvent(new CustomEvent("pan", { detail: { e: e, tr: tr } }));
        }

        /*!
         * mousePos
         * Returns the mouse point coordinates.
         *
         * @name mousePos
         * @function
         * @param {Event} e The mouse event.
         * @param {Boolean} rel If `true`, the relative coordinates will be returned instead.
         * @return {Object} An object containing the relative coordinates.
         */
        function mousePos(e, rel) {
            var bbox = self.parent().node.getBoundingClientRect()
              , abs = {
                    x: e.clientX || e.touches[0].pageX
                  , y: e.clientY || e.touches[0].pageY
                }
              ;
            if (!rel) { return abs; }
            return {
                x: abs.x - bbox.left
              , y: abs.y - bbox.top
            };
        }

        /*!
         * zoom
         * The internal function called for zooming.
         *
         * @name zoom
         * @function
         * @param {Event} e The internal listener event.
         * @return {undefined}
         */
        function doZoom (e) {

            // Get the relative mouse point
            var rP = mousePos(e, true)
              , oX = rP.x
              , oY = rP.y
              ;

            e.deltaY = e.deltaY || e.wheelDeltaY;

            // Compute the new scale
            var d = opt_options.zoomSpeed * e.deltaY / 1000
              , tr = pz.transform = self.transform()
              , scale = tr.scaleX + (tr.scaleX * d)
              , scaleD = scale / tr.scaleX

                // Get the current x, y
              , currentX = tr.x
              , currentY = tr.y

                // Compute the final x, y
              , x = scaleD * (currentX - oX) + oX
              , y = scaleD * (currentY - oY) + oY
              ;

            // Handle zoom restrictions
            if (scale > opt_options.zoom[1]) {
                scale = opt_options.zoom[1];
                return;
            }

            if (scale < opt_options.zoom[0]) {
                scale = opt_options.zoom[0];
                return;
            }

            // Zoom
            tr.scaleY = tr.scaleX = scale;
            tr.x = x;
            tr.y = y;

            self.node.dispatchEvent(new CustomEvent("zoom", { detail: { e: e, tr: tr } }));
            updateMatrix();

            // Prevent the default browser behavior
            e.preventDefault();
        }

        // The event listeners
        var EventListeners = {
            mouse_down: function (e) {
                pz.pan.mousedown = true;
                pz.pan.iPos = mousePos(e);
            }
          , mouse_up: function (e) {
                pz.pan.mousedown = false;
                pz.pan.fPos = mousePos(e);
                pan();
            }
          , mouse_move: function (e) {
                if (!pz.pan.mousedown) { return; }
                pz.pan.fPos = mousePos(e);
                pan();
            }
          , mouse_leave: function (e) {
                pz.pan.mousedown = false;
            }
        };

        // Add event listeners
        rect
          .on(mousewheel, doZoom)
          .on("mousedown", EventListeners.mouse_down)
          .on("touchstart", EventListeners.mouse_down)
          .on("mousemove", EventListeners.mouse_move)
          .on("touchmove", EventListeners.mouse_move)
          .on("mouseup", EventListeners.mouse_up)
          .on("touchup", EventListeners.mouse_up)
          .on("mouseleave", EventListeners.mouse_leave)
          ;

        self.on(mousewheel, doZoom);
        return pz;
    }

    // Extend the SVG.Element with the new function
    SVG.extend(SVG.Element, {
        panZoom: panZoom
    });
}).call(this);
<|endoftext|>


<commit_before>var yaml = require("js-yaml");
var S = require("string");

var CONTENT_PATH_PREFIX = "content/";

// define the grunt function for cli
module.exports = function(grunt) {

    // define the actual lunr-index task for cli
    grunt.registerTask("lunr-index", function() {

        grunt.log.writeln("Build pages index");

        // makes an array of the names of all the files
        var indexPages = function() {
            grunt.log.writeln("Inside indexPages function");

            var pagesIndex = [];
            // go through the folders recursively
            grunt.file.recurse(CONTENT_PATH_PREFIX, function(abspath, rootdir, subdir, filename) {
                grunt.verbose.writeln("Parse file:",abspath);

                // push adds the processed file to the array of pages
                pagesIndex.push(processFile(abspath, filename));
            });
            return pagesIndex;
        };

        // call the appropriate process for if it's a content file (md) or html page
        var processFile = function(abspath, filename) {
            grunt.log.writeln("Inside processFile function");

            var pageIndex;
            if (S(filename).endsWith(".html")) {
                pageIndex = processHTMLFile(abspath, filename);
            } else {
                pageIndex = processMDFile(abspath, filename);
            }
            return pageIndex;
        };

        // process html
        var processHTMLFile = function(abspath, filename) {
            grunt.log.writeln("Inside processHTMLFile function");

            // read the file contents
            var content = grunt.file.read(abspath);
            // the page name will be the filename, minus html
            var pageName = S(filename).chompRight(".html").s;
            // create the path to the file, minus everything before the path prefix
            var href = "/" + S(abspath)
                .chompLeft(CONTENT_PATH_PREFIX).s;
            grunt.log.writeln("PageName (html)" + pageName);
            return {
                // return an object containing these values
                title: pageName,
                href: href,
                // remove any tags and punctuation from the page
                content: S(content).trim().stripTags().stripPunctuation().s
            };
        };

        // process md
        var processMDFile = function(abspath, filename) {
            grunt.log.writeln("Inside processMDFile function");

            // read the file contents
            var content = grunt.file.read(abspath);
            var pageIndex;
            // first separate the Front Matter from the content and parse it
            content = content.split("---");
            var frontMatter;
            try {
                frontMatter = yaml.load(content[1].trim());
            } catch (e) {
                grunt.log.writeln("Front matter failed: " + e.message);
            }

            // create the path to the file, minus everything before the path prefix
            var href = S(abspath).chompLeft(CONTENT_PATH_PREFIX).chompRight(".md").s;
            // href for index.md files stops at the folder name
            if (filename === "index.md") {
                href = S(abspath).chompLeft(CONTENT_PATH_PREFIX).chompRight(filename).s;
            }

            href = "/" + href

            grunt.log.writeln("PageName (html)" + frontMatter.title);

            // build Lunr index for this page
            pageIndex = {
                title: frontMatter.title,
                tags: frontMatter.tags,
                product: frontMatter.product,
                version: frontMatter.version,
                location: href,
                display_name: frontMatter.product + " " + frontMatter.version + ": " + frontMatter.title,
                content: S(content[2]).trim().stripTags().stripPunctuation().s
            };
            return pageIndex;
        };
        grunt.log.writeln("Index pages -> process file -> process based on type");
        grunt.file.write("static/js/lunr/PagesIndex.json", JSON.stringify(indexPages()));
        grunt.log.ok("Index built");
    });
};

<commit_msg>Gruntfile.js: processFile - only send .md files to processMDFile()<commit_after>var yaml = require("js-yaml");
var S = require("string");

var CONTENT_PATH_PREFIX = "content/";

// define the grunt function for cli
module.exports = function(grunt) {

    // define the actual lunr-index task for cli
    grunt.registerTask("lunr-index", function() {

        grunt.log.writeln("Build pages index");

        // makes an array of the names of all the files
        var indexPages = function() {
            grunt.log.writeln("Inside indexPages function");

            var pagesIndex = [];
            // go through the folders recursively
            grunt.file.recurse(CONTENT_PATH_PREFIX, function(abspath, rootdir, subdir, filename) {
                grunt.verbose.writeln("Parse file:",abspath);

                // push adds the processed file to the array of pages
                pagesIndex.push(processFile(abspath, filename));
            });
            return pagesIndex;
        };

        // call the appropriate process for if it's a content file (md) or html page
        var processFile = function(abspath, filename) {
            grunt.log.writeln("Inside processFile function");

            var pageIndex;
            if (S(filename).endsWith(".html")) {
                pageIndex = processHTMLFile(abspath, filename);
            } else if (S(filename).endsWith(".md")) {
                pageIndex = processMDFile(abspath, filename);
            }
            return pageIndex;
        };

        // process html
        var processHTMLFile = function(abspath, filename) {
            grunt.log.writeln("Inside processHTMLFile function");

            // read the file contents
            var content = grunt.file.read(abspath);
            // the page name will be the filename, minus html
            var pageName = S(filename).chompRight(".html").s;
            // create the path to the file, minus everything before the path prefix
            var href = "/" + S(abspath)
                .chompLeft(CONTENT_PATH_PREFIX).s;
            grunt.log.writeln("PageName (html)" + pageName);
            return {
                // return an object containing these values
                title: pageName,
                href: href,
                // remove any tags and punctuation from the page
                content: S(content).trim().stripTags().stripPunctuation().s
            };
        };

        // process md
        var processMDFile = function(abspath, filename) {
            grunt.log.writeln("Inside processMDFile function");

            // read the file contents
            var content = grunt.file.read(abspath);
            var pageIndex;
            // first separate the Front Matter from the content and parse it
            content = content.split("---");
            var frontMatter;
            try {
                frontMatter = yaml.load(content[1].trim());
            } catch (e) {
                grunt.log.writeln("Front matter failed: " + e.message);
            }

            // create the path to the file, minus everything before the path prefix
            var href = S(abspath).chompLeft(CONTENT_PATH_PREFIX).chompRight(".md").s;
            // href for index.md files stops at the folder name
            if (filename === "index.md") {
                href = S(abspath).chompLeft(CONTENT_PATH_PREFIX).chompRight(filename).s;
            }

            href = "/" + href

            grunt.log.writeln("PageName (html)" + frontMatter.title);

            // build Lunr index for this page
            pageIndex = {
                title: frontMatter.title,
                tags: frontMatter.tags,
                product: frontMatter.product,
                version: frontMatter.version,
                location: href,
                display_name: frontMatter.product + " " + frontMatter.version + ": " + frontMatter.title,
                content: S(content[2]).trim().stripTags().stripPunctuation().s
            };
            return pageIndex;
        };
        grunt.log.writeln("Index pages -> process file -> process based on type");
        grunt.file.write("static/js/lunr/PagesIndex.json", JSON.stringify(indexPages()));
        grunt.log.ok("Index built");
    });
};

<|endoftext|>


<commit_before>//initialize all of our variables
var app, base, concat, directory, gulp, gutil, hostname, path, refresh, sass, uglify, imagemin, cache, minifyCSS, clean, connect;

//load all of our dependencies
//add more here if you want to include more libraries
gulp        = require('gulp');
gutil       = require('gulp-util');
concat      = require('gulp-concat');
uglify      = require('gulp-uglify');
sass        = require('gulp-sass');
imagemin    = require('gulp-imagemin');
cache       = require('gulp-cache');
minifyCSS   = require('gulp-minify-css');
clean       = require('gulp-clean');
connect     = require('gulp-connect');

gulp.task('connect', function() {
  connect.server({
    root: 'app',
    livereload: true
  });
});

//compressing images & handle SVG files
gulp.task('images', function(tmp) {
    console.log(tmp);
    gulp.src(['app/images/*.jpg', 'app/images/*.png'])
        .pipe(imagemin({ optimizationLevel: 5, progressive: true, interlaced: true }));
});

//compressing images & handle SVG files
gulp.task('images-deploy', function() {
    gulp.src(['app/images/*'])
        .pipe(gulp.dest('dist/images'));
});

//compiling our Javascripts
gulp.task('scripts', function() {
    //this is where our dev JS scripts are
    return gulp.src('app/scripts/src/**/*.js')
                //this is the filename of the compressed version of our JS
               .pipe(concat('app.js'))
               //catch errors
               .on('error', gutil.log)
               //compress :D
               .pipe(uglify())
               //where we will store our finalized, compressed script
               .pipe(gulp.dest('app/scripts'))
               //notify LiveReload to refresh
               .pipe(connect.reload());
});

//compiling our Javascripts for deployment
gulp.task('scripts-deploy', function() {
    //this is where our dev JS scripts are
    return gulp.src('app/scripts/src/**/*.js')
                //this is the filename of the compressed version of our JS
               .pipe(concat('app.js'))
               //compress :D
               .pipe(uglify())
               //where we will store our finalized, compressed script
               .pipe(gulp.dest('dist/scripts'));
});

//compiling our SCSS files
gulp.task('styles', function() {
    //the initializer / master SCSS file, which will just be a file that imports everything
    return gulp.src('app/styles/scss/init.scss')
                //include SCSS and list every "include" folder
               .pipe(sass({
                      errLogToConsole: true,
                      includePaths: [
                          'app/styles/scss/'
                      ]
               }))
               //catch errors
               .on('error', gutil.log)
               //the final filename of our combined css file
               .pipe(concat('styles.css'))
               //where to save our final, compressed css file
               .pipe(gulp.dest('app/styles'))
               //notify LiveReload to refresh
               .pipe(connect.reload());
});

//compiling our SCSS files for deployment
gulp.task('styles-deploy', function() {
    //the initializer / master SCSS file, which will just be a file that imports everything
    return gulp.src('app/styles/scss/init.scss')
                //include SCSS includes folder
               .pipe(sass({
                      includePaths: [
                          'app/styles/scss',
                      ]
               }))
               //the final filename of our combined css file
               .pipe(concat('styles.css'))
               .pipe(minifyCSS())
               //where to save our final, compressed css file
               .pipe(gulp.dest('dist/styles'));
});

//basically just keeping an eye on all HTML files
gulp.task('html', function() {
    //watch any and all HTML files and refresh when something changes
    return gulp.src('app/*.html')
        .pipe(connect.reload())
       //catch errors
       .on('error', gutil.log);
});

//migrating over all HTML files for deployment
gulp.task('html-deploy', function() {
    //grab everything, which should include htaccess, robots, etc
    gulp.src('app/*')
        .pipe(gulp.dest('dist'));

    //grab any hidden files too
    gulp.src('app/.*')
        .pipe(gulp.dest('dist'));

    gulp.src('app/fonts/*')
        .pipe(gulp.dest('dist/fonts'));

    //grab all of the styles
    gulp.src(['app/styles/*.css', '!app/styles/styles.css'])
        .pipe(gulp.dest('dist/styles'));
});

//cleans our dist directory in case things got deleted
gulp.task('clean', function() {
  return gulp.src(['dist/*'], {read: false})
    .pipe(clean());
});

//this is our master task when you run `gulp` in CLI / Terminal
//this is the main watcher to use when in active development
//  this will:
//  startup the web server,
//  start up livereload
//  compress all scripts and SCSS files
gulp.task('default', ['connect', 'scripts', 'styles'], function() {
    //a list of watchers, so it will watch all of the following files waiting for changes
    gulp.watch('app/scripts/src/**', ['scripts']);
    gulp.watch('app/styles/scss/**', ['styles']);
    gulp.watch('app/images/**', ['images']);
    gulp.watch('app/*.html', ['html']);
});

//this is our deployment task, it will set everything for deployment-ready files
gulp.task('deploy', ['clean'], function () {
  gulp.start('scripts-deploy', 'styles-deploy', 'html-deploy', 'images-deploy');
});<commit_msg>Supports font families & nested images<commit_after>//initialize all of our variables
var app, base, concat, directory, gulp, gutil, hostname, path, refresh, sass, uglify, imagemin, cache, minifyCSS, clean, connect;

//load all of our dependencies
//add more here if you want to include more libraries
gulp        = require('gulp');
gutil       = require('gulp-util');
concat      = require('gulp-concat');
uglify      = require('gulp-uglify');
sass        = require('gulp-sass');
imagemin    = require('gulp-imagemin');
cache       = require('gulp-cache');
minifyCSS   = require('gulp-minify-css');
clean       = require('gulp-clean');
connect     = require('gulp-connect');

gulp.task('connect', function() {
  connect.server({
    root: 'app',
    livereload: true
  });
});

//compressing images & handle SVG files
gulp.task('images', function(tmp) {
    console.log(tmp);
    gulp.src(['app/images/*.jpg', 'app/images/*.png'])
        .pipe(imagemin({ optimizationLevel: 5, progressive: true, interlaced: true }));
});

//compressing images & handle SVG files
gulp.task('images-deploy', function() {
    gulp.src(['app/images/**/*'])
        .pipe(gulp.dest('dist/images'));
});

//compiling our Javascripts
gulp.task('scripts', function() {
    //this is where our dev JS scripts are
    return gulp.src('app/scripts/src/**/*.js')
                //this is the filename of the compressed version of our JS
               .pipe(concat('app.js'))
               //catch errors
               .on('error', gutil.log)
               //compress :D
               .pipe(uglify())
               //where we will store our finalized, compressed script
               .pipe(gulp.dest('app/scripts'))
               //notify LiveReload to refresh
               .pipe(connect.reload());
});

//compiling our Javascripts for deployment
gulp.task('scripts-deploy', function() {
    //this is where our dev JS scripts are
    return gulp.src('app/scripts/src/**/*.js')
                //this is the filename of the compressed version of our JS
               .pipe(concat('app.js'))
               //compress :D
               .pipe(uglify())
               //where we will store our finalized, compressed script
               .pipe(gulp.dest('dist/scripts'));
});

//compiling our SCSS files
gulp.task('styles', function() {
    //the initializer / master SCSS file, which will just be a file that imports everything
    return gulp.src('app/styles/scss/init.scss')
                //include SCSS and list every "include" folder
               .pipe(sass({
                      errLogToConsole: true,
                      includePaths: [
                          'app/styles/scss/'
                      ]
               }))
               //catch errors
               .on('error', gutil.log)
               //the final filename of our combined css file
               .pipe(concat('styles.css'))
               //where to save our final, compressed css file
               .pipe(gulp.dest('app/styles'))
               //notify LiveReload to refresh
               .pipe(connect.reload());
});

//compiling our SCSS files for deployment
gulp.task('styles-deploy', function() {
    //the initializer / master SCSS file, which will just be a file that imports everything
    return gulp.src('app/styles/scss/init.scss')
                //include SCSS includes folder
               .pipe(sass({
                      includePaths: [
                          'app/styles/scss',
                      ]
               }))
               //the final filename of our combined css file
               .pipe(concat('styles.css'))
               .pipe(minifyCSS())
               //where to save our final, compressed css file
               .pipe(gulp.dest('dist/styles'));
});

//basically just keeping an eye on all HTML files
gulp.task('html', function() {
    //watch any and all HTML files and refresh when something changes
    return gulp.src('app/*.html')
        .pipe(connect.reload())
       //catch errors
       .on('error', gutil.log);
});

//migrating over all HTML files for deployment
gulp.task('html-deploy', function() {
    //grab everything, which should include htaccess, robots, etc
    gulp.src('app/*')
        .pipe(gulp.dest('dist'));

    //grab any hidden files too
    gulp.src('app/.*')
        .pipe(gulp.dest('dist'));

    gulp.src('app/fonts/**/*')
        .pipe(gulp.dest('dist/fonts'));

    //grab all of the styles
    gulp.src(['app/styles/*.css', '!app/styles/styles.css'])
        .pipe(gulp.dest('dist/styles'));
});

//cleans our dist directory in case things got deleted
gulp.task('clean', function() {
  return gulp.src(['dist/*'], {read: false})
    .pipe(clean());
});

//this is our master task when you run `gulp` in CLI / Terminal
//this is the main watcher to use when in active development
//  this will:
//  startup the web server,
//  start up livereload
//  compress all scripts and SCSS files
gulp.task('default', ['connect', 'scripts', 'styles'], function() {
    //a list of watchers, so it will watch all of the following files waiting for changes
    gulp.watch('app/scripts/src/**', ['scripts']);
    gulp.watch('app/styles/scss/**', ['styles']);
    gulp.watch('app/images/**', ['images']);
    gulp.watch('app/*.html', ['html']);
});

//this is our deployment task, it will set everything for deployment-ready files
gulp.task('deploy', ['clean'], function () {
  gulp.start('scripts-deploy', 'styles-deploy', 'html-deploy', 'images-deploy');
});
<|endoftext|>


<commit_before>import { Editor, Preview } from './index';
import ReactDOM from 'react-dom';
import React from 'react';
import getMuiTheme from 'material-ui/styles/getMuiTheme';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
import injectTapEventPlugin from 'react-tap-event-plugin';

injectTapEventPlugin();

const handleImageFile = (file, callback) => {
    const reader = new FileReader();
    reader.onload = (e) => {
        callback(e.target.result);
    };
    reader.readAsDataURL(file);
};

const renderOutput = (rawContent) => {
    ReactDOM.render(<Preview rawContent={rawContent} />, document.getElementById('output'));
};

ReactDOM.render((
    <MuiThemeProvider muiTheme={getMuiTheme()}>
        <Editor handleImageFile={handleImageFile} onChange={renderOutput} />
    </MuiThemeProvider>
), document.getElementById('editor'));
<commit_msg>fixed import<commit_after>import { Editor, Preview } from '../index';
import ReactDOM from 'react-dom';
import React from 'react';
import getMuiTheme from 'material-ui/styles/getMuiTheme';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
import injectTapEventPlugin from 'react-tap-event-plugin';

injectTapEventPlugin();

const handleImageFile = (file, callback) => {
    const reader = new FileReader();
    reader.onload = (e) => {
        callback(e.target.result);
    };
    reader.readAsDataURL(file);
};

const renderOutput = (rawContent) => {
    ReactDOM.render(<Preview rawContent={rawContent} />, document.getElementById('output'));
};

ReactDOM.render((
    <MuiThemeProvider muiTheme={getMuiTheme()}>
        <Editor handleImageFile={handleImageFile} onChange={renderOutput} />
    </MuiThemeProvider>
), document.getElementById('editor'));
<|endoftext|>