From d680d473e705a6120f2e1200c44f2556d7f91e08 Mon Sep 17 00:00:00 2001 From: kalenjohnson Date: Fri, 15 Aug 2014 01:46:35 -0700 Subject: [PATCH 001/143] Gruntfile reduced to only grunt-only "version" plugin. Gulpfile set up. package.json updated with gulp dependencies --- Gruntfile.js | 152 +-------------------------------------------------- gulpfile.js | 110 +++++++++++++++++++++++++++++++++++++ package.json | 27 +++++---- 3 files changed, 126 insertions(+), 163 deletions(-) create mode 100644 gulpfile.js diff --git a/Gruntfile.js b/Gruntfile.js index 75da245..22e8e67 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,112 +1,9 @@ 'use strict'; module.exports = function(grunt) { - // Load all tasks - require('load-grunt-tasks')(grunt); - // Show elapsed time - require('time-grunt')(grunt); - var jsFileList = [ - 'assets/vendor/bootstrap/js/transition.js', - 'assets/vendor/bootstrap/js/alert.js', - 'assets/vendor/bootstrap/js/button.js', - 'assets/vendor/bootstrap/js/carousel.js', - 'assets/vendor/bootstrap/js/collapse.js', - 'assets/vendor/bootstrap/js/dropdown.js', - 'assets/vendor/bootstrap/js/modal.js', - 'assets/vendor/bootstrap/js/tooltip.js', - 'assets/vendor/bootstrap/js/popover.js', - 'assets/vendor/bootstrap/js/scrollspy.js', - 'assets/vendor/bootstrap/js/tab.js', - 'assets/vendor/bootstrap/js/affix.js', - 'assets/js/plugins/*.js', - 'assets/js/_*.js' - ]; + grunt.loadNpmTasks('grunt-wp-assets'); grunt.initConfig({ - jshint: { - options: { - jshintrc: '.jshintrc' - }, - all: [ - 'Gruntfile.js', - 'assets/js/*.js', - '!assets/js/scripts.js', - '!assets/**/*.min.*' - ] - }, - less: { - dev: { - files: { - 'assets/css/main.css': [ - 'assets/less/main.less' - ] - }, - options: { - compress: false, - // LESS source map - // To enable, set sourceMap to true and update sourceMapRootpath based on your install - sourceMap: true, - sourceMapFilename: 'assets/css/main.css.map', - sourceMapRootpath: '/app/themes/roots/' - } - }, - build: { - files: { - 'assets/css/main.min.css': [ - 'assets/less/main.less' - ] - }, - options: { - compress: true - } - } - }, - concat: { - options: { - separator: ';', - }, - dist: { - src: [jsFileList], - dest: 'assets/js/scripts.js', - }, - }, - uglify: { - dist: { - files: { - 'assets/js/scripts.min.js': [jsFileList] - } - } - }, - autoprefixer: { - options: { - browsers: ['last 2 versions', 'ie 8', 'ie 9', 'android 2.3', 'android 4', 'opera 12'] - }, - dev: { - options: { - map: { - prev: 'assets/css/' - } - }, - src: 'assets/css/main.css' - }, - build: { - src: 'assets/css/main.min.css' - } - }, - modernizr: { - build: { - devFile: 'assets/vendor/modernizr/modernizr.js', - outputFile: 'assets/js/vendor/modernizr.min.js', - files: { - 'src': [ - ['assets/js/scripts.min.js'], - ['assets/css/main.min.css'] - ] - }, - uglify: true, - parseFiles: true - } - }, version: { default: { options: { @@ -122,54 +19,7 @@ module.exports = function(grunt) { 'lib/scripts.php': 'assets/{css,js}/{main,scripts}.min.{css,js}' } } - }, - watch: { - less: { - files: [ - 'assets/less/*.less', - 'assets/less/**/*.less' - ], - tasks: ['less:dev', 'autoprefixer:dev'] - }, - js: { - files: [ - jsFileList, - '<%= jshint.all %>' - ], - tasks: ['jshint', 'concat'] - }, - livereload: { - // Browser live reloading - // https://github.com/gruntjs/grunt-contrib-watch#live-reloading - options: { - livereload: false - }, - files: [ - 'assets/css/main.css', - 'assets/js/scripts.js', - 'templates/*.php', - '*.php' - ] - } } }); - // Register tasks - grunt.registerTask('default', [ - 'dev' - ]); - grunt.registerTask('dev', [ - 'jshint', - 'less:dev', - 'autoprefixer:dev', - 'concat' - ]); - grunt.registerTask('build', [ - 'jshint', - 'less:build', - 'autoprefixer:build', - 'uglify', - 'modernizr', - 'version' - ]); }; diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000..e7761de --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,110 @@ +var gulp = require('gulp'), + less = require('gulp-less'), + autoprefix = require('gulp-autoprefixer'), + sourcemaps = require('gulp-sourcemaps'), + rename = require('gulp-rename'), + concat = require('gulp-concat'), + minifyCSS = require('gulp-minify-css'), + jshint = require('gulp-jshint'), + uglify = require('gulp-uglify'), + livereload = require('gulp-livereload'), + stylish = require('jshint-stylish'), + modernizr = require('gulp-modernizr'); + +// add all the gruntfile tasks to gulp +require('gulp-grunt')(gulp); + +var paths = { + scripts: [ + 'assets/vendor/bootstrap/js/transition.js', + 'assets/vendor/bootstrap/js/alert.js', + 'assets/vendor/bootstrap/js/button.js', + 'assets/vendor/bootstrap/js/carousel.js', + 'assets/vendor/bootstrap/js/collapse.js', + 'assets/vendor/bootstrap/js/dropdown.js', + 'assets/vendor/bootstrap/js/modal.js', + 'assets/vendor/bootstrap/js/tooltip.js', + 'assets/vendor/bootstrap/js/popover.js', + 'assets/vendor/bootstrap/js/scrollspy.js', + 'assets/vendor/bootstrap/js/tab.js', + 'assets/vendor/bootstrap/js/affix.js', + 'assets/js/plugins/*.js', + 'assets/js/_*.js' + ], + jshint: [ + 'gulpfile.js', + 'assets/js/*.js', + '!assets/js/scripts.js', + '!assets/**/*.min.*' + ], + less: 'assets/less/main.less' +}; + +var destination = { + css: 'assets/css', + scripts: 'assets/js', + modernizr: 'assets/vendor/modernizr', + vendor: 'assets/vendor' +}; + + +gulp.task('less', function () { + return gulp.src(paths.less) + .pipe(sourcemaps.init()) + .pipe(less()).on('error', function(err){ + console.warn(err.message); + }) + .pipe(autoprefix('last 2 versions', 'ie 8', 'ie 9', 'android 2.3', 'android 4', 'opera 12')) + .pipe(rename('./main.css')) + .pipe(sourcemaps.write()) + .pipe(gulp.dest(destination.css)) + .pipe(minifyCSS()) + .pipe(rename('./main.min.css')) + .pipe(gulp.dest(destination.css)); +}); + +gulp.task('jshint', function() { + return gulp.src(paths.jshint) + .pipe(jshint()) + .pipe(jshint.reporter(stylish)); +}); + +gulp.task('js', ['jshint'], function() { + return gulp.src(paths.scripts) + .pipe(concat('./scripts.js')) + .pipe(gulp.dest(destination.scripts)) + .pipe(uglify()) + .pipe(rename('./scripts.min.js')) + .pipe(gulp.dest(destination.scripts)); +}); + +gulp.task('modernizr', function() { + return gulp.src( + ['assets/js/scripts.min.js'], + ['assets/css/main.min.css'] + ) + .pipe(modernizr()) + .pipe(gulp.dest(destination.modernizr)) + .pipe(uglify()) + .pipe(rename('./modernizr.min.js')) + .pipe(gulp.dest(destination.vendor)); +}); + +gulp.task('version', function() { + gulp.run('grunt-version'); +}); + +gulp.task('watch', function() { + livereload.listen(); + + gulp.watch('assets/less/**/*.less', ['less']).on('change', livereload.changed); + gulp.watch('assets/js/**/*.js', ['jshint', 'js']).on('change', livereload.changed); + gulp.watch('**/*.php').on('change', function(file) { + livereload.changed(file.path); + }); + +}); + +gulp.task('default', ['less', 'jshint', 'js', 'modernizr']); +gulp.task('dev', ['default']); +gulp.task('build', ['less', 'jshint', 'js', 'modernizr', 'version']); \ No newline at end of file diff --git a/package.json b/package.json index 07c2ae3..3613b7f 100644 --- a/package.json +++ b/package.json @@ -17,23 +17,26 @@ } ], "scripts": { - "postinstall": "node node_modules/bower/bin/bower install && grunt dev" + "postinstall": "node node_modules/bower/bin/bower install && gulp dev" }, "engines": { "node": ">= 0.10.0" }, "devDependencies": { "bower": ">=1.3.9", - "grunt": "~0.4.5", - "grunt-autoprefixer": "~0.8.1", - "grunt-contrib-concat": "~0.4.0", - "grunt-contrib-jshint": "~0.10.0", - "grunt-contrib-less": "~0.11.3", - "grunt-contrib-uglify": "~0.5.0", - "grunt-contrib-watch": "~0.6.1", - "grunt-modernizr": "~0.5.2", - "grunt-wp-assets": "~0.2.6", - "load-grunt-tasks": "~0.6.0", - "time-grunt": "~0.3.2" + "grunt": "^0.4.5", + "grunt-wp-assets": "^0.2.6", + "gulp": "^3.8.7", + "gulp-autoprefixer": "0.0.8", + "gulp-concat": "^2.3.4", + "gulp-grunt": "^0.5.2", + "gulp-jshint": "^1.8.4", + "gulp-less": "^1.3.3", + "gulp-livereload": "^2.1.0", + "gulp-minify-css": "^0.3.7", + "gulp-modernizr": "https://github.com/doctyper/gulp-modernizr/tarball/develop", + "gulp-rename": "^1.2.0", + "gulp-sourcemaps": "^1.1.1", + "gulp-uglify": "^0.3.1" } } From ed7a0d75c66b0de7f28492da28d1c0a1e16548b3 Mon Sep 17 00:00:00 2001 From: Ben Word Date: Sun, 24 Aug 2014 16:45:06 -0500 Subject: [PATCH 002/143] Remove Grunt completely, add gulp-rev --- Gruntfile.js | 25 ------------------------- package.json | 6 +++--- 2 files changed, 3 insertions(+), 28 deletions(-) delete mode 100644 Gruntfile.js diff --git a/Gruntfile.js b/Gruntfile.js deleted file mode 100644 index 22e8e67..0000000 --- a/Gruntfile.js +++ /dev/null @@ -1,25 +0,0 @@ -'use strict'; -module.exports = function(grunt) { - - grunt.loadNpmTasks('grunt-wp-assets'); - - grunt.initConfig({ - version: { - default: { - options: { - format: true, - length: 32, - manifest: 'assets/manifest.json', - querystring: { - style: 'roots_css', - script: 'roots_js' - } - }, - files: { - 'lib/scripts.php': 'assets/{css,js}/{main,scripts}.min.{css,js}' - } - } - } - }); - -}; diff --git a/package.json b/package.json index 8eace7c..aea817a 100644 --- a/package.json +++ b/package.json @@ -24,19 +24,19 @@ }, "devDependencies": { "bower": ">=1.3.9", - "grunt": "^0.4.5", - "grunt-wp-assets": "^0.2.6", "gulp": "^3.8.7", "gulp-autoprefixer": "0.0.8", "gulp-concat": "^2.3.4", "gulp-grunt": "^0.5.2", "gulp-jshint": "^1.8.4", + "jshint-stylish": "^0.4.0", "gulp-less": "^1.3.3", "gulp-livereload": "^2.1.0", "gulp-minify-css": "^0.3.7", "gulp-modernizr": "https://github.com/doctyper/gulp-modernizr/tarball/develop", "gulp-rename": "^1.2.0", "gulp-sourcemaps": "^1.1.1", - "gulp-uglify": "^0.3.1" + "gulp-uglify": "^0.3.1", + "gulp-rev": "^1.1.0" } } From 534fef326265c0f762e700c6aede9e93f6a1a4f7 Mon Sep 17 00:00:00 2001 From: Ben Word Date: Sun, 24 Aug 2014 16:51:08 -0500 Subject: [PATCH 003/143] Use gulp-rev for versioning CSS and JS --- .gitignore | 4 ++-- gulpfile.js | 17 +++++++++-------- lib/scripts.php | 8 ++++---- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index 95cee23..1a360a8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,9 @@ # Include your project-specific ignores in this file # Read about how to use .gitignore: https://help.github.com/articles/ignoring-files node_modules -assets/vendor/* +assets/vendor assets/css/main.css.map assets/css/*main*.css assets/js/*scripts*.js assets/js/vendor/modernizr.min.js -assets/manifest.json +assets/rev-manifest.json diff --git a/gulpfile.js b/gulpfile.js index e7761de..7b4692c 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -9,11 +9,9 @@ var gulp = require('gulp'), uglify = require('gulp-uglify'), livereload = require('gulp-livereload'), stylish = require('jshint-stylish'), + rev = require('gulp-rev'); modernizr = require('gulp-modernizr'); -// add all the gruntfile tasks to gulp -require('gulp-grunt')(gulp); - var paths = { scripts: [ 'assets/vendor/bootstrap/js/transition.js', @@ -35,7 +33,7 @@ var paths = { 'gulpfile.js', 'assets/js/*.js', '!assets/js/scripts.js', - '!assets/**/*.min.*' + '!assets/**/*.min-*' ], less: 'assets/less/main.less' }; @@ -44,10 +42,9 @@ var destination = { css: 'assets/css', scripts: 'assets/js', modernizr: 'assets/vendor/modernizr', - vendor: 'assets/vendor' + vendor: 'assets/js/vendor' }; - gulp.task('less', function () { return gulp.src(paths.less) .pipe(sourcemaps.init()) @@ -91,7 +88,11 @@ gulp.task('modernizr', function() { }); gulp.task('version', function() { - gulp.run('grunt-version'); + return gulp.src(['assets/css/main.min.css', 'assets/js/scripts.min.js'], { base: 'assets' }) + .pipe(rev()) + .pipe(gulp.dest('assets')) + .pipe(rev.manifest()) + .pipe(gulp.dest('assets')); }); gulp.task('watch', function() { @@ -107,4 +108,4 @@ gulp.task('watch', function() { gulp.task('default', ['less', 'jshint', 'js', 'modernizr']); gulp.task('dev', ['default']); -gulp.task('build', ['less', 'jshint', 'js', 'modernizr', 'version']); \ No newline at end of file +gulp.task('build', ['less', 'jshint', 'js', 'modernizr', 'version']); diff --git a/lib/scripts.php b/lib/scripts.php index ac3f22f..0ce15eb 100644 --- a/lib/scripts.php +++ b/lib/scripts.php @@ -27,11 +27,11 @@ function roots_scripts() { 'jquery' => '//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.js' ); } else { - $get_assets = file_get_contents(get_template_directory() . '/assets/manifest.json'); + $get_assets = file_get_contents(get_template_directory() . '/assets/rev-manifest.json'); $assets = json_decode($get_assets, true); $assets = array( - 'css' => '/assets/css/main.min.css?' . $assets['assets/css/main.min.css']['hash'], - 'js' => '/assets/js/scripts.min.js?' . $assets['assets/js/scripts.min.js']['hash'], + 'css' => '/assets/' . $assets[get_template_directory() . '/assets/css/main.min.css'], + 'js' => '/assets/' . $assets[get_template_directory() . '/assets/js/scripts.min.js'], 'modernizr' => '/assets/js/vendor/modernizr.min.js', 'jquery' => '//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js' ); @@ -79,7 +79,7 @@ add_action('wp_head', 'roots_jquery_local_fallback'); /** * Google Analytics snippet from HTML5 Boilerplate - * + * * Cookie domain is 'auto' configured. See: http://goo.gl/VUCHKM */ function roots_google_analytics() { ?> From 7d422d7f5cbb9ac69e97f7c83b51be8c665c233f Mon Sep 17 00:00:00 2001 From: Ben Word Date: Sun, 24 Aug 2014 16:57:09 -0500 Subject: [PATCH 004/143] Update README for switch to Gulp --- README.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 8fa6f8c..97dbdca 100644 --- a/README.md +++ b/README.md @@ -12,11 +12,11 @@ Roots is a WordPress starter theme based on [HTML5 Boilerplate](http://html5boil ## Features -* [Grunt](http://roots.io/using-grunt-for-wordpress-theme-development/) for compiling LESS to CSS, checking for JS errors, live reloading, concatenating and minifying files, versioning assets, and generating lean Modernizr builds +* [Gulp](http://gulpjs.com/) for compiling LESS to CSS, checking for JS errors, live reloading, concatenating and minifying files, versioning assets, and generating lean Modernizr builds * [Bower](http://bower.io/) for front-end package management * [HTML5 Boilerplate](http://html5boilerplate.com/) * The latest [jQuery](http://jquery.com/) via Google CDN, with a local fallback - * The latest [Modernizr](http://modernizr.com/) build for feature detection, with lean builds with Grunt + * The latest [Modernizr](http://modernizr.com/) build for feature detection, with lean builds with Gulp * An optimized Google Analytics snippet * [Bootstrap](http://getbootstrap.com/) * Organized file and template structure @@ -57,32 +57,32 @@ Edit `lib/init.php` to setup navigation menus, post thumbnail sizes, post format ## Theme development -Roots uses [Grunt](http://gruntjs.com/) for compiling LESS to CSS, checking for JS errors, live reloading, concatenating and minifying files, versioning assets, and generating lean Modernizr builds. +Roots uses [Gulp](http://gulpjs.com/) for compiling LESS to CSS, checking for JS errors, live reloading, concatenating and minifying files, versioning assets, and generating lean Modernizr builds. If you'd like to use Bootstrap Sass, look at the [Roots Sass](https://github.com/roots/roots-sass) fork. -### Install Grunt +### Install Gulp **Unfamiliar with npm? Don't have node installed?** [Download and install node.js](http://nodejs.org/download/) before proceeding. From the command line: -1. Install `grunt-cli` globally with `npm install -g grunt-cli`. +1. Install `gulp` globally with `npm install -g gulp`. 2. Navigate to the theme directory, then run `npm install`. npm will look at `package.json` and automatically install the necessary dependencies. It will also automatically run `bower install`, which installs front-end packages defined in `bower.json`. -When completed, you'll be able to run the various Grunt commands provided from the command line. +When completed, you'll be able to run the various Gulp commands provided from the command line. -### Available Grunt commands +### Available Gulp commands -* `grunt dev` — Compile LESS to CSS, concatenate and validate JS -* `grunt watch` — Compile assets when file changes are made -* `grunt build` — Create minified assets that are used on non-development environments +* `gulp dev` — Compile LESS to CSS, concatenate and validate JS +* `gulp watch` — Compile assets when file changes are made +* `gulp build` — Create minified assets that are used on non-development environments ## Documentation * [Roots 101](http://roots.io/roots-101/) — A guide to installing Roots, the files, and theme organization * [Theme Wrapper](http://roots.io/an-introduction-to-the-roots-theme-wrapper/) — Learn all about the theme wrapper -* [Build Script](http://roots.io/using-grunt-for-wordpress-theme-development/) — A look into how Roots uses Grunt +* [Build Script](http://roots.io/using-gulp-for-wordpress-theme-development/) — A look into how Roots uses Gulp * [Roots Sidebar](http://roots.io/the-roots-sidebar/) — Understand how to display or hide the sidebar in Roots ## Contributing From 3021b182fe317fe432bb9598448787b3651e6dba Mon Sep 17 00:00:00 2001 From: Ben Word Date: Sun, 24 Aug 2014 17:01:28 -0500 Subject: [PATCH 005/143] Also ignore minified JS --- gulpfile.js | 1 + 1 file changed, 1 insertion(+) diff --git a/gulpfile.js b/gulpfile.js index 7b4692c..af653e3 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -33,6 +33,7 @@ var paths = { 'gulpfile.js', 'assets/js/*.js', '!assets/js/scripts.js', + '!assets/js/scripts.min.js', '!assets/**/*.min-*' ], less: 'assets/less/main.less' From f1844b6a149ff84cf0b536557b9ad23135e1d9b7 Mon Sep 17 00:00:00 2001 From: Ben Word Date: Sun, 24 Aug 2014 17:41:17 -0500 Subject: [PATCH 006/143] Formatting fixes --- gulpfile.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index af653e3..adfffb8 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -46,10 +46,10 @@ var destination = { vendor: 'assets/js/vendor' }; -gulp.task('less', function () { +gulp.task('less', function() { return gulp.src(paths.less) .pipe(sourcemaps.init()) - .pipe(less()).on('error', function(err){ + .pipe(less()).on('error', function(err) { console.warn(err.message); }) .pipe(autoprefix('last 2 versions', 'ie 8', 'ie 9', 'android 2.3', 'android 4', 'opera 12')) @@ -98,13 +98,11 @@ gulp.task('version', function() { gulp.task('watch', function() { livereload.listen(); - gulp.watch('assets/less/**/*.less', ['less']).on('change', livereload.changed); gulp.watch('assets/js/**/*.js', ['jshint', 'js']).on('change', livereload.changed); gulp.watch('**/*.php').on('change', function(file) { livereload.changed(file.path); }); - }); gulp.task('default', ['less', 'jshint', 'js', 'modernizr']); From 21f653c1b1a7efb052de1725dfa7aefb1fa23269 Mon Sep 17 00:00:00 2001 From: kalenjohnson Date: Thu, 4 Sep 2014 22:03:54 -0700 Subject: [PATCH 007/143] Set up livereload to refresh after LESS/JS compiling --- gulpfile.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index adfffb8..5b36c79 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -58,7 +58,8 @@ gulp.task('less', function() { .pipe(gulp.dest(destination.css)) .pipe(minifyCSS()) .pipe(rename('./main.min.css')) - .pipe(gulp.dest(destination.css)); + .pipe(gulp.dest(destination.css)) + .pipe(livereload({ auto: false })); }); gulp.task('jshint', function() { @@ -73,7 +74,8 @@ gulp.task('js', ['jshint'], function() { .pipe(gulp.dest(destination.scripts)) .pipe(uglify()) .pipe(rename('./scripts.min.js')) - .pipe(gulp.dest(destination.scripts)); + .pipe(gulp.dest(destination.scripts)) + .pipe(livereload({ auto: false })); }); gulp.task('modernizr', function() { @@ -98,8 +100,8 @@ gulp.task('version', function() { gulp.task('watch', function() { livereload.listen(); - gulp.watch('assets/less/**/*.less', ['less']).on('change', livereload.changed); - gulp.watch('assets/js/**/*.js', ['jshint', 'js']).on('change', livereload.changed); + gulp.watch('assets/less/**/*.less', ['less']); + gulp.watch('assets/js/**/*.js', ['jshint', 'js']); gulp.watch('**/*.php').on('change', function(file) { livereload.changed(file.path); }); From 45a00cec0e96e8546239ad9e39fb84438830e204 Mon Sep 17 00:00:00 2001 From: Austin Pray Date: Thu, 11 Sep 2014 22:15:45 -0500 Subject: [PATCH 008/143] Use gulp-load-plugins https://www.npmjs.org/package/gulp-load-plugins --- gulpfile.js | 59 ++++++++++++++++++++++------------------------------ package.json | 7 ++++--- 2 files changed, 29 insertions(+), 37 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 5b36c79..9f5dd1d 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,16 +1,6 @@ -var gulp = require('gulp'), - less = require('gulp-less'), - autoprefix = require('gulp-autoprefixer'), - sourcemaps = require('gulp-sourcemaps'), - rename = require('gulp-rename'), - concat = require('gulp-concat'), - minifyCSS = require('gulp-minify-css'), - jshint = require('gulp-jshint'), - uglify = require('gulp-uglify'), - livereload = require('gulp-livereload'), - stylish = require('jshint-stylish'), - rev = require('gulp-rev'); - modernizr = require('gulp-modernizr'); +/*global $:true*/ +var gulp = require('gulp'); +var $ = require('gulp-load-plugins')(); var paths = { scripts: [ @@ -48,34 +38,35 @@ var destination = { gulp.task('less', function() { return gulp.src(paths.less) - .pipe(sourcemaps.init()) - .pipe(less()).on('error', function(err) { + .pipe($.sourcemaps.init()) + .pipe($.less()).on('error', function(err) { console.warn(err.message); }) - .pipe(autoprefix('last 2 versions', 'ie 8', 'ie 9', 'android 2.3', 'android 4', 'opera 12')) - .pipe(rename('./main.css')) - .pipe(sourcemaps.write()) + .pipe($.autoprefixer('last 2 versions', 'ie 8', 'ie 9', 'android 2.3', 'android 4', 'opera 12')) + .pipe($.rename('./main.css')) + .pipe($.sourcemaps.write()) .pipe(gulp.dest(destination.css)) - .pipe(minifyCSS()) - .pipe(rename('./main.min.css')) + .pipe($.minifyCss()) + .pipe($.rename('./main.min.css')) .pipe(gulp.dest(destination.css)) - .pipe(livereload({ auto: false })); + .pipe($.livereload({ auto: false })); }); gulp.task('jshint', function() { return gulp.src(paths.jshint) - .pipe(jshint()) - .pipe(jshint.reporter(stylish)); + .pipe($.jshint()) + .pipe($.jshint.reporter('jshint-stylish')) + .pipe($.jshint.reporter('fail')); }); gulp.task('js', ['jshint'], function() { return gulp.src(paths.scripts) - .pipe(concat('./scripts.js')) + .pipe($.concat('./scripts.js')) .pipe(gulp.dest(destination.scripts)) - .pipe(uglify()) - .pipe(rename('./scripts.min.js')) + .pipe($.uglify()) + .pipe($.rename('./scripts.min.js')) .pipe(gulp.dest(destination.scripts)) - .pipe(livereload({ auto: false })); + .pipe($.livereload({ auto: false })); }); gulp.task('modernizr', function() { @@ -83,27 +74,27 @@ gulp.task('modernizr', function() { ['assets/js/scripts.min.js'], ['assets/css/main.min.css'] ) - .pipe(modernizr()) + .pipe($.modernizr()) .pipe(gulp.dest(destination.modernizr)) - .pipe(uglify()) - .pipe(rename('./modernizr.min.js')) + .pipe($.uglify()) + .pipe($.rename('./modernizr.min.js')) .pipe(gulp.dest(destination.vendor)); }); gulp.task('version', function() { return gulp.src(['assets/css/main.min.css', 'assets/js/scripts.min.js'], { base: 'assets' }) - .pipe(rev()) + .pipe($.rev()) .pipe(gulp.dest('assets')) - .pipe(rev.manifest()) + .pipe($.rev.manifest()) .pipe(gulp.dest('assets')); }); gulp.task('watch', function() { - livereload.listen(); + $.livereload.listen(); gulp.watch('assets/less/**/*.less', ['less']); gulp.watch('assets/js/**/*.js', ['jshint', 'js']); gulp.watch('**/*.php').on('change', function(file) { - livereload.changed(file.path); + $.livereload.changed(file.path); }); }); diff --git a/package.json b/package.json index aea817a..a819593 100644 --- a/package.json +++ b/package.json @@ -25,18 +25,19 @@ "devDependencies": { "bower": ">=1.3.9", "gulp": "^3.8.7", - "gulp-autoprefixer": "0.0.8", + "gulp-autoprefixer": "^0.0.7", "gulp-concat": "^2.3.4", "gulp-grunt": "^0.5.2", "gulp-jshint": "^1.8.4", - "jshint-stylish": "^0.4.0", "gulp-less": "^1.3.3", "gulp-livereload": "^2.1.0", + "gulp-load-plugins": "^0.5.0", "gulp-minify-css": "^0.3.7", "gulp-modernizr": "https://github.com/doctyper/gulp-modernizr/tarball/develop", "gulp-rename": "^1.2.0", + "gulp-rev": "^1.1.0", "gulp-sourcemaps": "^1.1.1", "gulp-uglify": "^0.3.1", - "gulp-rev": "^1.1.0" + "jshint-stylish": "^0.4.0" } } From 6e0e036ae70ac83f91a27169b93adf088f087b9d Mon Sep 17 00:00:00 2001 From: Austin Pray Date: Thu, 11 Sep 2014 23:04:29 -0500 Subject: [PATCH 009/143] Enhance Gulp dependency compilation Gulp automatically grabs all of the dependencies listed as main files in `bower.json` except for jQuery and modernizr Deletes plugin directory, bad development pattern. Doesn't make sense with the existence of `vendor` directory anyway. Concat all of the js in the js directory except vendor and compiled files --- assets/js/plugins/.gitkeep | 0 bower.json | 18 ++++++++++++++++++ gulpfile.js | 25 +++++++++---------------- package.json | 5 ++++- 4 files changed, 31 insertions(+), 17 deletions(-) delete mode 100644 assets/js/plugins/.gitkeep diff --git a/assets/js/plugins/.gitkeep b/assets/js/plugins/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/bower.json b/bower.json index 0d8195d..3dde4cf 100644 --- a/bower.json +++ b/bower.json @@ -17,5 +17,23 @@ "jquery": "1.11.1", "bootstrap": "3.2.0", "respond": "1.4.2" + }, + "overrides": { + "bootstrap": { + "main": [ + "./js/transition.js", + "./js/alert.js", + "./js/button.js", + "./js/carousel.js", + "./js/collapse.js", + "./js/dropdown.js", + "./js/modal.js", + "./js/tooltip.js", + "./js/popover.js", + "./js/scrollspy.js", + "./js/tab.js", + "./js/affix.js" + ] + } } } diff --git a/gulpfile.js b/gulpfile.js index 9f5dd1d..920c6b2 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,23 +1,13 @@ /*global $:true*/ var gulp = require('gulp'); var $ = require('gulp-load-plugins')(); +var mainBowerFiles = require('main-bower-files'); var paths = { scripts: [ - 'assets/vendor/bootstrap/js/transition.js', - 'assets/vendor/bootstrap/js/alert.js', - 'assets/vendor/bootstrap/js/button.js', - 'assets/vendor/bootstrap/js/carousel.js', - 'assets/vendor/bootstrap/js/collapse.js', - 'assets/vendor/bootstrap/js/dropdown.js', - 'assets/vendor/bootstrap/js/modal.js', - 'assets/vendor/bootstrap/js/tooltip.js', - 'assets/vendor/bootstrap/js/popover.js', - 'assets/vendor/bootstrap/js/scrollspy.js', - 'assets/vendor/bootstrap/js/tab.js', - 'assets/vendor/bootstrap/js/affix.js', - 'assets/js/plugins/*.js', - 'assets/js/_*.js' + 'assets/js/**/*.js', + '!assets/js/vendor/**/*', + '!assets/js/scripts*.js' ], jshint: [ 'gulpfile.js', @@ -26,7 +16,8 @@ var paths = { '!assets/js/scripts.min.js', '!assets/**/*.min-*' ], - less: 'assets/less/main.less' + less: 'assets/less/main.less', + bower: mainBowerFiles() }; var destination = { @@ -38,6 +29,7 @@ var destination = { gulp.task('less', function() { return gulp.src(paths.less) + .pipe($.plumber()) .pipe($.sourcemaps.init()) .pipe($.less()).on('error', function(err) { console.warn(err.message); @@ -60,7 +52,8 @@ gulp.task('jshint', function() { }); gulp.task('js', ['jshint'], function() { - return gulp.src(paths.scripts) + return gulp.src(paths.bower.concat(paths.scripts)) + .pipe($.filter(['**/*.js', '!jquery.js', '!modernizr.js'])) .pipe($.concat('./scripts.js')) .pipe(gulp.dest(destination.scripts)) .pipe($.uglify()) diff --git a/package.json b/package.json index a819593..969fd49 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "gulp": "^3.8.7", "gulp-autoprefixer": "^0.0.7", "gulp-concat": "^2.3.4", + "gulp-filter": "^0.5.0", "gulp-grunt": "^0.5.2", "gulp-jshint": "^1.8.4", "gulp-less": "^1.3.3", @@ -34,10 +35,12 @@ "gulp-load-plugins": "^0.5.0", "gulp-minify-css": "^0.3.7", "gulp-modernizr": "https://github.com/doctyper/gulp-modernizr/tarball/develop", + "gulp-plumber": "^0.6.3", "gulp-rename": "^1.2.0", "gulp-rev": "^1.1.0", "gulp-sourcemaps": "^1.1.1", "gulp-uglify": "^0.3.1", - "jshint-stylish": "^0.4.0" + "jshint-stylish": "^0.4.0", + "main-bower-files": "^1.0.1" } } From 79fdfcb21c412aa9913ba6ea7310903d0d7dfff9 Mon Sep 17 00:00:00 2001 From: Austin Pray Date: Thu, 11 Sep 2014 23:29:41 -0500 Subject: [PATCH 010/143] Adds `gulp images` Lossless image optimization including pngcrush(1) --- README.md | 1 + gulpfile.js | 16 ++++++++++++++++ package.json | 2 ++ 3 files changed, 19 insertions(+) diff --git a/README.md b/README.md index 97dbdca..93eafff 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,7 @@ When completed, you'll be able to run the various Gulp commands provided from th * `gulp dev` — Compile LESS to CSS, concatenate and validate JS * `gulp watch` — Compile assets when file changes are made * `gulp build` — Create minified assets that are used on non-development environments +* `gulp images` — Lossless compression of PNG, JPEG, GIF and SVG images ## Documentation diff --git a/gulpfile.js b/gulpfile.js index 920c6b2..6ea429c 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,6 +1,7 @@ /*global $:true*/ var gulp = require('gulp'); var $ = require('gulp-load-plugins')(); +var pngcrush = require('imagemin-pngcrush'); var mainBowerFiles = require('main-bower-files'); var paths = { @@ -14,6 +15,7 @@ var paths = { 'assets/js/*.js', '!assets/js/scripts.js', '!assets/js/scripts.min.js', + '!assets/js/vendor/**/*', '!assets/**/*.min-*' ], less: 'assets/less/main.less', @@ -74,6 +76,20 @@ gulp.task('modernizr', function() { .pipe(gulp.dest(destination.vendor)); }); +gulp.task('images', function () { + return gulp.src('assets/img/**/*') + .pipe($.imagemin({ + progressive: true, + interlaced: true, + use: [pngcrush()] + })) + .pipe(gulp.dest('assets/img')); +}); + +gulp.task('bust', function () { + $.cache.clearAll(); +}); + gulp.task('version', function() { return gulp.src(['assets/css/main.min.css', 'assets/js/scripts.min.js'], { base: 'assets' }) .pipe($.rev()) diff --git a/package.json b/package.json index 969fd49..3f08142 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "gulp-concat": "^2.3.4", "gulp-filter": "^0.5.0", "gulp-grunt": "^0.5.2", + "gulp-imagemin": "^0.6.0", "gulp-jshint": "^1.8.4", "gulp-less": "^1.3.3", "gulp-livereload": "^2.1.0", @@ -40,6 +41,7 @@ "gulp-rev": "^1.1.0", "gulp-sourcemaps": "^1.1.1", "gulp-uglify": "^0.3.1", + "imagemin-pngcrush": "^1.0.0", "jshint-stylish": "^0.4.0", "main-bower-files": "^1.0.1" } From 34b297a33902c74c24a83dbce0f323407b326678 Mon Sep 17 00:00:00 2001 From: Casey Zumwalt Date: Fri, 19 Sep 2014 01:47:44 -0700 Subject: [PATCH 011/143] Removed errant semicolon in gulpfile.js --- gulpfile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gulpfile.js b/gulpfile.js index 5b36c79..4317299 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -9,7 +9,7 @@ var gulp = require('gulp'), uglify = require('gulp-uglify'), livereload = require('gulp-livereload'), stylish = require('jshint-stylish'), - rev = require('gulp-rev'); + rev = require('gulp-rev'), modernizr = require('gulp-modernizr'); var paths = { From e3266279e60e2070c8087e19df0c06be26834b56 Mon Sep 17 00:00:00 2001 From: Ben Word Date: Fri, 24 Oct 2014 18:04:29 -0500 Subject: [PATCH 012/143] Remove custom Bower directory --- .bowerrc | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 .bowerrc diff --git a/.bowerrc b/.bowerrc deleted file mode 100644 index cc48978..0000000 --- a/.bowerrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "directory": "assets/vendor" -} From 5b22f0bd9d5325a6e560f87a68ebab4dcd98e0cd Mon Sep 17 00:00:00 2001 From: Ben Word Date: Mon, 27 Oct 2014 10:01:17 -0500 Subject: [PATCH 013/143] Introduce src/ and dist/ folders Separate minifying/renaming of files to prod-only tasks Add tasks for copying jQuery and fonts Ref #1138, #1070, #1155 --- .gitignore | 9 +- assets/less/_bootstrap.less | 92 ---------------- assets/{ => src}/fonts/.gitkeep | 0 assets/{img/.gitignore => src/img/.gitkeep} | 0 assets/{js/_main.js => src/js/main.js} | 0 assets/src/less/_bootstrap.less | 92 ++++++++++++++++ assets/{ => src}/less/_global.less | 0 assets/{ => src}/less/_variables.less | 0 .../{ => src}/less/components/_buttons.less | 0 assets/{ => src}/less/components/_forms.less | 0 assets/{ => src}/less/components/_media.less | 0 .../less/components/_wp-classes.less | 0 .../less/editor-style.less} | 0 assets/{ => src}/less/layouts/_footer.less | 0 assets/{ => src}/less/layouts/_general.less | 0 assets/{ => src}/less/layouts/_header.less | 0 assets/{ => src}/less/layouts/_pages.less | 0 assets/{ => src}/less/layouts/_posts.less | 0 assets/{ => src}/less/layouts/_sidebar.less | 0 .../{ => src}/less/layouts/pages/_home.less | 0 assets/{ => src}/less/main.less | 2 +- gulpfile.js | 101 ++++++++++-------- lib/scripts.php | 20 ++-- package.json | 5 +- 24 files changed, 164 insertions(+), 157 deletions(-) delete mode 100644 assets/less/_bootstrap.less rename assets/{ => src}/fonts/.gitkeep (100%) rename assets/{img/.gitignore => src/img/.gitkeep} (100%) rename assets/{js/_main.js => src/js/main.js} (100%) create mode 100644 assets/src/less/_bootstrap.less rename assets/{ => src}/less/_global.less (100%) rename assets/{ => src}/less/_variables.less (100%) rename assets/{ => src}/less/components/_buttons.less (100%) rename assets/{ => src}/less/components/_forms.less (100%) rename assets/{ => src}/less/components/_media.less (100%) rename assets/{ => src}/less/components/_wp-classes.less (100%) rename assets/{css/editor-style.css => src/less/editor-style.less} (100%) rename assets/{ => src}/less/layouts/_footer.less (100%) rename assets/{ => src}/less/layouts/_general.less (100%) rename assets/{ => src}/less/layouts/_header.less (100%) rename assets/{ => src}/less/layouts/_pages.less (100%) rename assets/{ => src}/less/layouts/_posts.less (100%) rename assets/{ => src}/less/layouts/_sidebar.less (100%) rename assets/{ => src}/less/layouts/pages/_home.less (100%) rename assets/{ => src}/less/main.less (97%) diff --git a/.gitignore b/.gitignore index 1a360a8..ba97a2a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,6 @@ # Include your project-specific ignores in this file # Read about how to use .gitignore: https://help.github.com/articles/ignoring-files -node_modules -assets/vendor -assets/css/main.css.map -assets/css/*main*.css -assets/js/*scripts*.js -assets/js/vendor/modernizr.min.js +assets/dist assets/rev-manifest.json +bower_components +node_modules diff --git a/assets/less/_bootstrap.less b/assets/less/_bootstrap.less deleted file mode 100644 index 425658e..0000000 --- a/assets/less/_bootstrap.less +++ /dev/null @@ -1,92 +0,0 @@ -// -// Bootstrap -// -// Comment out any unused components -// -------------------------------------------------- - -// Variables -@import "../vendor/bootstrap/less/variables"; - -// Mixins: Utilities -@import "../vendor/bootstrap/less/mixins/hide-text"; -@import "../vendor/bootstrap/less/mixins/opacity"; -@import "../vendor/bootstrap/less/mixins/image"; -@import "../vendor/bootstrap/less/mixins/labels"; -@import "../vendor/bootstrap/less/mixins/reset-filter"; -@import "../vendor/bootstrap/less/mixins/resize"; -@import "../vendor/bootstrap/less/mixins/responsive-visibility"; -@import "../vendor/bootstrap/less/mixins/size"; -@import "../vendor/bootstrap/less/mixins/tab-focus"; -@import "../vendor/bootstrap/less/mixins/text-emphasis"; -@import "../vendor/bootstrap/less/mixins/text-overflow"; -@import "../vendor/bootstrap/less/mixins/vendor-prefixes"; - -// Mixins: Components -@import "../vendor/bootstrap/less/mixins/alerts"; -@import "../vendor/bootstrap/less/mixins/buttons"; -@import "../vendor/bootstrap/less/mixins/panels"; -@import "../vendor/bootstrap/less/mixins/pagination"; -@import "../vendor/bootstrap/less/mixins/list-group"; -@import "../vendor/bootstrap/less/mixins/nav-divider"; -@import "../vendor/bootstrap/less/mixins/forms"; -@import "../vendor/bootstrap/less/mixins/progress-bar"; -@import "../vendor/bootstrap/less/mixins/table-row"; - -// Mixins: Skins -@import "../vendor/bootstrap/less/mixins/background-variant"; -@import "../vendor/bootstrap/less/mixins/border-radius"; -@import "../vendor/bootstrap/less/mixins/gradients"; - -// Mixins: Layout -@import "../vendor/bootstrap/less/mixins/clearfix"; -@import "../vendor/bootstrap/less/mixins/center-block"; -@import "../vendor/bootstrap/less/mixins/nav-vertical-align"; -@import "../vendor/bootstrap/less/mixins/grid-framework"; -@import "../vendor/bootstrap/less/mixins/grid"; - -// Reset -@import "../vendor/bootstrap/less/normalize"; -@import "../vendor/bootstrap/less/print"; -@import "../vendor/bootstrap/less/glyphicons"; - -// Core CSS -@import "../vendor/bootstrap/less/scaffolding"; -@import "../vendor/bootstrap/less/type"; -@import "../vendor/bootstrap/less/code"; -@import "../vendor/bootstrap/less/grid"; -@import "../vendor/bootstrap/less/tables"; -@import "../vendor/bootstrap/less/forms"; -@import "../vendor/bootstrap/less/buttons"; - -// Components -@import "../vendor/bootstrap/less/component-animations"; -@import "../vendor/bootstrap/less/dropdowns"; -@import "../vendor/bootstrap/less/button-groups"; -@import "../vendor/bootstrap/less/input-groups"; -@import "../vendor/bootstrap/less/navs"; -@import "../vendor/bootstrap/less/navbar"; -@import "../vendor/bootstrap/less/breadcrumbs"; -@import "../vendor/bootstrap/less/pagination"; -@import "../vendor/bootstrap/less/pager"; -@import "../vendor/bootstrap/less/labels"; -@import "../vendor/bootstrap/less/badges"; -@import "../vendor/bootstrap/less/jumbotron"; -@import "../vendor/bootstrap/less/thumbnails"; -@import "../vendor/bootstrap/less/alerts"; -@import "../vendor/bootstrap/less/progress-bars"; -@import "../vendor/bootstrap/less/media"; -@import "../vendor/bootstrap/less/list-group"; -@import "../vendor/bootstrap/less/panels"; -@import "../vendor/bootstrap/less/responsive-embed"; -@import "../vendor/bootstrap/less/wells"; -@import "../vendor/bootstrap/less/close"; - -// Components w/ JavaScript -@import "../vendor/bootstrap/less/modals"; -@import "../vendor/bootstrap/less/tooltip"; -@import "../vendor/bootstrap/less/popovers"; -@import "../vendor/bootstrap/less/carousel"; - -// Utility classes -@import "../vendor/bootstrap/less/utilities"; -@import "../vendor/bootstrap/less/responsive-utilities"; diff --git a/assets/fonts/.gitkeep b/assets/src/fonts/.gitkeep similarity index 100% rename from assets/fonts/.gitkeep rename to assets/src/fonts/.gitkeep diff --git a/assets/img/.gitignore b/assets/src/img/.gitkeep similarity index 100% rename from assets/img/.gitignore rename to assets/src/img/.gitkeep diff --git a/assets/js/_main.js b/assets/src/js/main.js similarity index 100% rename from assets/js/_main.js rename to assets/src/js/main.js diff --git a/assets/src/less/_bootstrap.less b/assets/src/less/_bootstrap.less new file mode 100644 index 0000000..6825f08 --- /dev/null +++ b/assets/src/less/_bootstrap.less @@ -0,0 +1,92 @@ +// +// Bootstrap +// +// Comment out any unused components +// -------------------------------------------------- + +// Variables +@import "../../../bower_components/bootstrap/less/variables"; + +// Mixins: Utilities +@import "../../../bower_components/bootstrap/less/mixins/hide-text"; +@import "../../../bower_components/bootstrap/less/mixins/opacity"; +@import "../../../bower_components/bootstrap/less/mixins/image"; +@import "../../../bower_components/bootstrap/less/mixins/labels"; +@import "../../../bower_components/bootstrap/less/mixins/reset-filter"; +@import "../../../bower_components/bootstrap/less/mixins/resize"; +@import "../../../bower_components/bootstrap/less/mixins/responsive-visibility"; +@import "../../../bower_components/bootstrap/less/mixins/size"; +@import "../../../bower_components/bootstrap/less/mixins/tab-focus"; +@import "../../../bower_components/bootstrap/less/mixins/text-emphasis"; +@import "../../../bower_components/bootstrap/less/mixins/text-overflow"; +@import "../../../bower_components/bootstrap/less/mixins/vendor-prefixes"; + +// Mixins: Components +@import "../../../bower_components/bootstrap/less/mixins/alerts"; +@import "../../../bower_components/bootstrap/less/mixins/buttons"; +@import "../../../bower_components/bootstrap/less/mixins/panels"; +@import "../../../bower_components/bootstrap/less/mixins/pagination"; +@import "../../../bower_components/bootstrap/less/mixins/list-group"; +@import "../../../bower_components/bootstrap/less/mixins/nav-divider"; +@import "../../../bower_components/bootstrap/less/mixins/forms"; +@import "../../../bower_components/bootstrap/less/mixins/progress-bar"; +@import "../../../bower_components/bootstrap/less/mixins/table-row"; + +// Mixins: Skins +@import "../../../bower_components/bootstrap/less/mixins/background-variant"; +@import "../../../bower_components/bootstrap/less/mixins/border-radius"; +@import "../../../bower_components/bootstrap/less/mixins/gradients"; + +// Mixins: Layout +@import "../../../bower_components/bootstrap/less/mixins/clearfix"; +@import "../../../bower_components/bootstrap/less/mixins/center-block"; +@import "../../../bower_components/bootstrap/less/mixins/nav-vertical-align"; +@import "../../../bower_components/bootstrap/less/mixins/grid-framework"; +@import "../../../bower_components/bootstrap/less/mixins/grid"; + +// Reset +@import "../../../bower_components/bootstrap/less/normalize"; +@import "../../../bower_components/bootstrap/less/print"; +@import "../../../bower_components/bootstrap/less/glyphicons"; + +// Core CSS +@import "../../../bower_components/bootstrap/less/scaffolding"; +@import "../../../bower_components/bootstrap/less/type"; +@import "../../../bower_components/bootstrap/less/code"; +@import "../../../bower_components/bootstrap/less/grid"; +@import "../../../bower_components/bootstrap/less/tables"; +@import "../../../bower_components/bootstrap/less/forms"; +@import "../../../bower_components/bootstrap/less/buttons"; + +// Components +@import "../../../bower_components/bootstrap/less/component-animations"; +@import "../../../bower_components/bootstrap/less/dropdowns"; +@import "../../../bower_components/bootstrap/less/button-groups"; +@import "../../../bower_components/bootstrap/less/input-groups"; +@import "../../../bower_components/bootstrap/less/navs"; +@import "../../../bower_components/bootstrap/less/navbar"; +@import "../../../bower_components/bootstrap/less/breadcrumbs"; +@import "../../../bower_components/bootstrap/less/pagination"; +@import "../../../bower_components/bootstrap/less/pager"; +@import "../../../bower_components/bootstrap/less/labels"; +@import "../../../bower_components/bootstrap/less/badges"; +@import "../../../bower_components/bootstrap/less/jumbotron"; +@import "../../../bower_components/bootstrap/less/thumbnails"; +@import "../../../bower_components/bootstrap/less/alerts"; +@import "../../../bower_components/bootstrap/less/progress-bars"; +@import "../../../bower_components/bootstrap/less/media"; +@import "../../../bower_components/bootstrap/less/list-group"; +@import "../../../bower_components/bootstrap/less/panels"; +@import "../../../bower_components/bootstrap/less/responsive-embed"; +@import "../../../bower_components/bootstrap/less/wells"; +@import "../../../bower_components/bootstrap/less/close"; + +// Components w/ JavaScript +@import "../../../bower_components/bootstrap/less/modals"; +@import "../../../bower_components/bootstrap/less/tooltip"; +@import "../../../bower_components/bootstrap/less/popovers"; +@import "../../../bower_components/bootstrap/less/carousel"; + +// Utility classes +@import "../../../bower_components/bootstrap/less/utilities"; +@import "../../../bower_components/bootstrap/less/responsive-utilities"; diff --git a/assets/less/_global.less b/assets/src/less/_global.less similarity index 100% rename from assets/less/_global.less rename to assets/src/less/_global.less diff --git a/assets/less/_variables.less b/assets/src/less/_variables.less similarity index 100% rename from assets/less/_variables.less rename to assets/src/less/_variables.less diff --git a/assets/less/components/_buttons.less b/assets/src/less/components/_buttons.less similarity index 100% rename from assets/less/components/_buttons.less rename to assets/src/less/components/_buttons.less diff --git a/assets/less/components/_forms.less b/assets/src/less/components/_forms.less similarity index 100% rename from assets/less/components/_forms.less rename to assets/src/less/components/_forms.less diff --git a/assets/less/components/_media.less b/assets/src/less/components/_media.less similarity index 100% rename from assets/less/components/_media.less rename to assets/src/less/components/_media.less diff --git a/assets/less/components/_wp-classes.less b/assets/src/less/components/_wp-classes.less similarity index 100% rename from assets/less/components/_wp-classes.less rename to assets/src/less/components/_wp-classes.less diff --git a/assets/css/editor-style.css b/assets/src/less/editor-style.less similarity index 100% rename from assets/css/editor-style.css rename to assets/src/less/editor-style.less diff --git a/assets/less/layouts/_footer.less b/assets/src/less/layouts/_footer.less similarity index 100% rename from assets/less/layouts/_footer.less rename to assets/src/less/layouts/_footer.less diff --git a/assets/less/layouts/_general.less b/assets/src/less/layouts/_general.less similarity index 100% rename from assets/less/layouts/_general.less rename to assets/src/less/layouts/_general.less diff --git a/assets/less/layouts/_header.less b/assets/src/less/layouts/_header.less similarity index 100% rename from assets/less/layouts/_header.less rename to assets/src/less/layouts/_header.less diff --git a/assets/less/layouts/_pages.less b/assets/src/less/layouts/_pages.less similarity index 100% rename from assets/less/layouts/_pages.less rename to assets/src/less/layouts/_pages.less diff --git a/assets/less/layouts/_posts.less b/assets/src/less/layouts/_posts.less similarity index 100% rename from assets/less/layouts/_posts.less rename to assets/src/less/layouts/_posts.less diff --git a/assets/less/layouts/_sidebar.less b/assets/src/less/layouts/_sidebar.less similarity index 100% rename from assets/less/layouts/_sidebar.less rename to assets/src/less/layouts/_sidebar.less diff --git a/assets/less/layouts/pages/_home.less b/assets/src/less/layouts/pages/_home.less similarity index 100% rename from assets/less/layouts/pages/_home.less rename to assets/src/less/layouts/pages/_home.less diff --git a/assets/less/main.less b/assets/src/less/main.less similarity index 97% rename from assets/less/main.less rename to assets/src/less/main.less index 5affb9f..aec9850 100644 --- a/assets/less/main.less +++ b/assets/src/less/main.less @@ -2,7 +2,7 @@ @import "_bootstrap"; // Variable overrides and custom variables -@import "_variables"; +@import "_variables"; // Roots @import "_global"; // Base styling & custom mixins diff --git a/gulpfile.js b/gulpfile.js index 6ea429c..8601a78 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,35 +1,27 @@ /*global $:true*/ var gulp = require('gulp'); var $ = require('gulp-load-plugins')(); +var plugins = require('gulp-load-plugins')(); + var pngcrush = require('imagemin-pngcrush'); + var mainBowerFiles = require('main-bower-files'); +var pkg = require('./package.json'); + var paths = { scripts: [ - 'assets/js/**/*.js', - '!assets/js/vendor/**/*', - '!assets/js/scripts*.js' + 'assets/src/js/**/*' ], jshint: [ 'gulpfile.js', - 'assets/js/*.js', - '!assets/js/scripts.js', - '!assets/js/scripts.min.js', - '!assets/js/vendor/**/*', - '!assets/**/*.min-*' + 'assets/src/js/**/*' ], - less: 'assets/less/main.less', + less: 'assets/src/less/main.less', bower: mainBowerFiles() }; -var destination = { - css: 'assets/css', - scripts: 'assets/js', - modernizr: 'assets/vendor/modernizr', - vendor: 'assets/js/vendor' -}; - -gulp.task('less', function() { +gulp.task('less:dev', function() { return gulp.src(paths.less) .pipe($.plumber()) .pipe($.sourcemaps.init()) @@ -38,14 +30,23 @@ gulp.task('less', function() { }) .pipe($.autoprefixer('last 2 versions', 'ie 8', 'ie 9', 'android 2.3', 'android 4', 'opera 12')) .pipe($.rename('./main.css')) + .pipe(gulp.dest('assets/dist/css')) .pipe($.sourcemaps.write()) - .pipe(gulp.dest(destination.css)) - .pipe($.minifyCss()) - .pipe($.rename('./main.min.css')) - .pipe(gulp.dest(destination.css)) .pipe($.livereload({ auto: false })); }); +gulp.task('less:build', function() { + return gulp.src(paths.less) + .pipe($.plumber()) + .pipe($.less()).on('error', function(err) { + console.warn(err.message); + }) + .pipe($.autoprefixer('last 2 versions', 'ie 9', 'android 2.3', 'android 4', 'opera 12')) + .pipe($.rename('./main.min.css')) + .pipe(gulp.dest('assets/dist/css')) + .pipe($.minifyCss()); +}); + gulp.task('jshint', function() { return gulp.src(paths.jshint) .pipe($.jshint()) @@ -53,45 +54,53 @@ gulp.task('jshint', function() { .pipe($.jshint.reporter('fail')); }); -gulp.task('js', ['jshint'], function() { +gulp.task('js:dev', ['jshint'], function() { return gulp.src(paths.bower.concat(paths.scripts)) - .pipe($.filter(['**/*.js', '!jquery.js', '!modernizr.js'])) .pipe($.concat('./scripts.js')) - .pipe(gulp.dest(destination.scripts)) - .pipe($.uglify()) - .pipe($.rename('./scripts.min.js')) - .pipe(gulp.dest(destination.scripts)) + .pipe(gulp.dest('assets/dist/js')) .pipe($.livereload({ auto: false })); }); -gulp.task('modernizr', function() { - return gulp.src( - ['assets/js/scripts.min.js'], - ['assets/css/main.min.css'] - ) - .pipe($.modernizr()) - .pipe(gulp.dest(destination.modernizr)) +gulp.task('js:build', ['jshint'], function() { + return gulp.src(paths.bower.concat(paths.scripts)) + .pipe($.concat('./scripts.min.js')) .pipe($.uglify()) - .pipe($.rename('./modernizr.min.js')) - .pipe(gulp.dest(destination.vendor)); + .pipe(gulp.dest('assets/dist/js')); }); -gulp.task('images', function () { - return gulp.src('assets/img/**/*') +gulp.task('copy:fonts', function() { + return gulp.src(['bower_components/bootstrap/fonts/*', 'assets/src/fonts/*']) + .pipe(gulp.dest('assets/dist/fonts')); +}); + +gulp.task('copy:jquery', function() { + return gulp.src(['bower_components/jquery/dist/jquery.min.js']) + .pipe($.rename('jquery-' + pkg.devDependencies.jquery + '.min.js')) + .pipe(gulp.dest('assets/dist/js')); +}); + +gulp.task('images', function() { + return gulp.src('assets/src/img/**/*') .pipe($.imagemin({ progressive: true, interlaced: true, use: [pngcrush()] })) - .pipe(gulp.dest('assets/img')); + .pipe(gulp.dest('assets/dist/img')); }); -gulp.task('bust', function () { - $.cache.clearAll(); +gulp.task('modernizr', function() { + return gulp.src( + ['assets/dist/js/scripts.min.js'], + ['assets/dist/css/main.min.css'] + ) + .pipe($.modernizr('modernizr.min.js')) + .pipe($.uglify()) + .pipe(gulp.dest('assets/dist/js')); }); gulp.task('version', function() { - return gulp.src(['assets/css/main.min.css', 'assets/js/scripts.min.js'], { base: 'assets' }) + return gulp.src(['assets/dist/css/main.min.css', 'assets/dist/js/scripts.min.js'], { base: 'assets' }) .pipe($.rev()) .pipe(gulp.dest('assets')) .pipe($.rev.manifest()) @@ -100,13 +109,13 @@ gulp.task('version', function() { gulp.task('watch', function() { $.livereload.listen(); - gulp.watch('assets/less/**/*.less', ['less']); - gulp.watch('assets/js/**/*.js', ['jshint', 'js']); + gulp.watch('assets/src/less/**/*', ['less:dev']); + gulp.watch('assets/src/js/**/*', ['jshint', 'js:dev']); gulp.watch('**/*.php').on('change', function(file) { $.livereload.changed(file.path); }); }); -gulp.task('default', ['less', 'jshint', 'js', 'modernizr']); +gulp.task('default', ['less:dev', 'jshint', 'js:dev']); gulp.task('dev', ['default']); -gulp.task('build', ['less', 'jshint', 'js', 'modernizr', 'version']); +gulp.task('build', ['less:build', 'js:build', 'copy:fonts', 'copy:jquery', 'images', 'modernizr', 'version']); diff --git a/lib/scripts.php b/lib/scripts.php index d84eaec..6854c8b 100644 --- a/lib/scripts.php +++ b/lib/scripts.php @@ -3,12 +3,12 @@ * Scripts and stylesheets * * Enqueue stylesheets in the following order: - * 1. /theme/assets/css/main.css + * 1. /theme/assets/dist/css/main.css * * Enqueue scripts in the following order: * 1. jquery-1.11.1.min.js via Google CDN - * 2. /theme/assets/js/vendor/modernizr.min.js - * 3. /theme/assets/js/scripts.js + * 2. /theme/assets/dist/js/modernizr.min.js + * 3. /theme/assets/dist/js/scripts.js * * Google Analytics is loaded after enqueued scripts if: * - An ID has been defined in config.php @@ -21,18 +21,18 @@ function roots_scripts() { */ if (WP_ENV === 'development') { $assets = array( - 'css' => '/assets/css/main.css', - 'js' => '/assets/js/scripts.js', - 'modernizr' => '/assets/vendor/modernizr/modernizr.js', + 'css' => '/assets/dist/css/main.css', + 'js' => '/assets/dist/js/scripts.js', + 'modernizr' => '/assets/dist/js/modernizr.min.js', 'jquery' => '//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.js' ); } else { $get_assets = file_get_contents(get_template_directory() . '/assets/rev-manifest.json'); $assets = json_decode($get_assets, true); $assets = array( - 'css' => '/assets/' . $assets[get_template_directory() . '/assets/css/main.min.css'], - 'js' => '/assets/' . $assets[get_template_directory() . '/assets/js/scripts.min.js'], - 'modernizr' => '/assets/js/vendor/modernizr.min.js', + 'css' => '/assets/' . $assets[get_template_directory() . '/assets/dist/css/main.min.css'], + 'js' => '/assets/' . $assets[get_template_directory() . '/assets/dist/js/scripts.min.js'], + 'modernizr' => '/assets/dist/js/modernizr.min.js', 'jquery' => '//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js' ); } @@ -65,7 +65,7 @@ function roots_jquery_local_fallback($src, $handle = null) { static $add_jquery_fallback = false; if ($add_jquery_fallback) { - echo '' . "\n"; + echo '' . "\n"; $add_jquery_fallback = false; } diff --git a/package.json b/package.json index 5be6590..3cf7835 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,6 @@ "gulp": "^3.8.7", "gulp-autoprefixer": "^0.0.7", "gulp-concat": "^2.3.4", - "gulp-filter": "^0.5.0", "gulp-grunt": "^0.5.2", "gulp-imagemin": "^0.6.0", "gulp-jshint": "^1.8.4", @@ -38,11 +37,13 @@ "gulp-modernizr": "https://github.com/doctyper/gulp-modernizr/tarball/develop", "gulp-plumber": "^0.6.3", "gulp-rename": "^1.2.0", - "gulp-rev": "^1.1.0", + "gulp-rev": "^2.0.1", "gulp-sourcemaps": "^1.1.1", "gulp-uglify": "^0.3.1", "imagemin-pngcrush": "^1.0.0", "jshint-stylish": "^0.4.0", + "jquery": "1.11.1", + "lodash": "^2.4.1", "main-bower-files": "^1.0.1" } } From 7636ddaa4c76e99e59a873ce5e33af5c1efbec19 Mon Sep 17 00:00:00 2001 From: Ben Word Date: Mon, 27 Oct 2014 12:24:43 -0500 Subject: [PATCH 014/143] Fix sourcemaps --- gulpfile.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 8601a78..acfb254 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -29,9 +29,9 @@ gulp.task('less:dev', function() { console.warn(err.message); }) .pipe($.autoprefixer('last 2 versions', 'ie 8', 'ie 9', 'android 2.3', 'android 4', 'opera 12')) - .pipe($.rename('./main.css')) - .pipe(gulp.dest('assets/dist/css')) .pipe($.sourcemaps.write()) + .pipe($.rename('./main.css')) + .pipe(gulp.dest('assets/dist/css')) .pipe($.livereload({ auto: false })); }); From 5389bd63c31de0203939d8332e35fca2602d0885 Mon Sep 17 00:00:00 2001 From: Ben Word Date: Mon, 27 Oct 2014 12:43:29 -0500 Subject: [PATCH 015/143] Don't use gulp-modernizr --- gulpfile.js | 19 ++++++++----------- lib/scripts.php | 2 +- package.json | 1 - 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index acfb254..d6e39f5 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -79,6 +79,13 @@ gulp.task('copy:jquery', function() { .pipe(gulp.dest('assets/dist/js')); }); +gulp.task('copy:modernizr', function() { + return gulp.src(['bower_components/modernizr/modernizr.js']) + .pipe($.uglify()) + .pipe($.rename('modernizr.min.js')) + .pipe(gulp.dest('assets/dist/js')); +}); + gulp.task('images', function() { return gulp.src('assets/src/img/**/*') .pipe($.imagemin({ @@ -89,16 +96,6 @@ gulp.task('images', function() { .pipe(gulp.dest('assets/dist/img')); }); -gulp.task('modernizr', function() { - return gulp.src( - ['assets/dist/js/scripts.min.js'], - ['assets/dist/css/main.min.css'] - ) - .pipe($.modernizr('modernizr.min.js')) - .pipe($.uglify()) - .pipe(gulp.dest('assets/dist/js')); -}); - gulp.task('version', function() { return gulp.src(['assets/dist/css/main.min.css', 'assets/dist/js/scripts.min.js'], { base: 'assets' }) .pipe($.rev()) @@ -118,4 +115,4 @@ gulp.task('watch', function() { gulp.task('default', ['less:dev', 'jshint', 'js:dev']); gulp.task('dev', ['default']); -gulp.task('build', ['less:build', 'js:build', 'copy:fonts', 'copy:jquery', 'images', 'modernizr', 'version']); +gulp.task('build', ['less:build', 'js:build', 'copy:fonts', 'copy:jquery', 'copy:modernizr', 'images', 'version']); diff --git a/lib/scripts.php b/lib/scripts.php index 6854c8b..05ce3ce 100644 --- a/lib/scripts.php +++ b/lib/scripts.php @@ -23,7 +23,7 @@ function roots_scripts() { $assets = array( 'css' => '/assets/dist/css/main.css', 'js' => '/assets/dist/js/scripts.js', - 'modernizr' => '/assets/dist/js/modernizr.min.js', + 'modernizr' => '/bower_components/modernizr/modernizr.js', 'jquery' => '//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.js' ); } else { diff --git a/package.json b/package.json index 3cf7835..77c9e35 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,6 @@ "gulp-livereload": "^2.1.0", "gulp-load-plugins": "^0.5.0", "gulp-minify-css": "^0.3.7", - "gulp-modernizr": "https://github.com/doctyper/gulp-modernizr/tarball/develop", "gulp-plumber": "^0.6.3", "gulp-rename": "^1.2.0", "gulp-rev": "^2.0.1", From e8822a2d670a1bd2d69b0031a360f65d94fde7b9 Mon Sep 17 00:00:00 2001 From: Ben Word Date: Mon, 27 Oct 2014 18:45:35 -0500 Subject: [PATCH 016/143] Asset improvements (gulp) Ref #1149 & https://github.com/roots/roots/blob/assets-improvements/lib/assets.php --- .gitignore | 1 - functions.php | 2 +- gulpfile.js | 7 +++-- lib/{scripts.php => assets.php} | 52 +++++++++++++++++---------------- 4 files changed, 32 insertions(+), 30 deletions(-) rename lib/{scripts.php => assets.php} (64%) diff --git a/.gitignore b/.gitignore index ba97a2a..34cb1dd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ # Include your project-specific ignores in this file # Read about how to use .gitignore: https://help.github.com/articles/ignoring-files assets/dist -assets/rev-manifest.json bower_components node_modules diff --git a/functions.php b/functions.php index a93b5e1..119939b 100644 --- a/functions.php +++ b/functions.php @@ -15,11 +15,11 @@ $roots_includes = array( 'lib/wrapper.php', // Theme wrapper class 'lib/sidebar.php', // Sidebar class 'lib/config.php', // Configuration + 'lib/assets.php', // Scripts and stylesheets 'lib/activation.php', // Theme activation 'lib/titles.php', // Page titles 'lib/nav.php', // Custom nav modifications 'lib/gallery.php', // Custom [gallery] modifications - 'lib/scripts.php', // Scripts and stylesheets 'lib/extras.php', // Custom functions ); diff --git a/gulpfile.js b/gulpfile.js index d6e39f5..a602101 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -97,11 +97,12 @@ gulp.task('images', function() { }); gulp.task('version', function() { - return gulp.src(['assets/dist/css/main.min.css', 'assets/dist/js/scripts.min.js'], { base: 'assets' }) + return gulp.src(['assets/dist/css/main.min.css', 'assets/dist/js/scripts.min.js'], { base: 'assets/dist' }) + .pipe(gulp.dest('assets/dist')) .pipe($.rev()) - .pipe(gulp.dest('assets')) + .pipe(gulp.dest('assets/dist')) .pipe($.rev.manifest()) - .pipe(gulp.dest('assets')); + .pipe(gulp.dest('assets/dist')); }); gulp.task('watch', function() { diff --git a/lib/scripts.php b/lib/assets.php similarity index 64% rename from lib/scripts.php rename to lib/assets.php index 05ce3ce..25cb8b2 100644 --- a/lib/scripts.php +++ b/lib/assets.php @@ -14,30 +14,26 @@ * - An ID has been defined in config.php * - You're not logged in as an administrator */ -function roots_scripts() { - /** - * The build task in Grunt renames production assets with a hash - * Read the asset names from assets-manifest.json - */ +function roots_asset_path($filename_dev, $filename) { if (WP_ENV === 'development') { - $assets = array( - 'css' => '/assets/dist/css/main.css', - 'js' => '/assets/dist/js/scripts.js', - 'modernizr' => '/bower_components/modernizr/modernizr.js', - 'jquery' => '//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.js' - ); - } else { - $get_assets = file_get_contents(get_template_directory() . '/assets/rev-manifest.json'); - $assets = json_decode($get_assets, true); - $assets = array( - 'css' => '/assets/' . $assets[get_template_directory() . '/assets/dist/css/main.min.css'], - 'js' => '/assets/' . $assets[get_template_directory() . '/assets/dist/js/scripts.min.js'], - 'modernizr' => '/assets/dist/js/modernizr.min.js', - 'jquery' => '//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js' - ); + return get_template_directory_uri() . '/assets/dist/' . $filename_dev; } - wp_enqueue_style('roots_css', get_template_directory_uri() . $assets['css'], false, null); + $manifest_path = get_template_directory() . '/assets/dist/rev-manifest.json'; + + if (file_exists($manifest_path)) { + $manifest = json_decode(file_get_contents($manifest_path), true); + } else { + $manifest = []; + } + + if (array_key_exists($filename, $manifest)) { + return get_template_directory_uri() . '/assets/dist/' . $manifest[$filename]; + } +} + +function roots_assets() { + wp_enqueue_style('roots_css', roots_asset_path('css/main.css', 'css/main.min.css'), false, null); /** * jQuery is loaded using the same method from HTML5 Boilerplate: @@ -46,7 +42,13 @@ function roots_scripts() { */ if (!is_admin() && current_theme_supports('jquery-cdn')) { wp_deregister_script('jquery'); - wp_register_script('jquery', $assets['jquery'], array(), null, true); + + if (WP_ENV === 'development') { + wp_register_script('jquery', '//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.js', array(), null, true); + } else { + wp_register_script('jquery', '//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js', array(), null, true); + } + add_filter('script_loader_src', 'roots_jquery_local_fallback', 10, 2); } @@ -54,11 +56,11 @@ function roots_scripts() { wp_enqueue_script('comment-reply'); } - wp_enqueue_script('modernizr', get_template_directory_uri() . $assets['modernizr'], array(), null, true); + wp_enqueue_script('modernizr', roots_asset_path('../../bower_components/modernizr/modernizr.js', 'js/modernizr.min.js'), array(), null, true); wp_enqueue_script('jquery'); - wp_enqueue_script('roots_js', get_template_directory_uri() . $assets['js'], array(), null, true); + wp_enqueue_script('roots_js', roots_asset_path('js/scripts.js', 'js/scripts.min.js'), array(), null, true); } -add_action('wp_enqueue_scripts', 'roots_scripts', 100); +add_action('wp_enqueue_scripts', 'roots_assets', 100); // http://wordpress.stackexchange.com/a/12450 function roots_jquery_local_fallback($src, $handle = null) { From a89283df321a7a12205a1abd7b1715e0d981d366 Mon Sep 17 00:00:00 2001 From: Kalen Johnson Date: Fri, 31 Oct 2014 11:21:57 -0700 Subject: [PATCH 017/143] CSS must be minified before saving it to dist --- gulpfile.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index a602101..bc195c4 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -43,8 +43,8 @@ gulp.task('less:build', function() { }) .pipe($.autoprefixer('last 2 versions', 'ie 9', 'android 2.3', 'android 4', 'opera 12')) .pipe($.rename('./main.min.css')) - .pipe(gulp.dest('assets/dist/css')) - .pipe($.minifyCss()); + .pipe($.minifyCss()) + .pipe(gulp.dest('assets/dist/css')); }); gulp.task('jshint', function() { From 52cd504c279d890c1bb4c3df67923f125780ddc0 Mon Sep 17 00:00:00 2001 From: Kalen Johnson Date: Fri, 31 Oct 2014 12:24:57 -0700 Subject: [PATCH 018/143] Added editor-style build to dev and build tasks --- gulpfile.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index bc195c4..717bb75 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -18,6 +18,7 @@ var paths = { 'assets/src/js/**/*' ], less: 'assets/src/less/main.less', + editorStyle: 'assets/src/less/editor-style.less', bower: mainBowerFiles() }; @@ -47,6 +48,17 @@ gulp.task('less:build', function() { .pipe(gulp.dest('assets/dist/css')); }); +gulp.task('less:editorStyle', function() { + return gulp.src(paths.editorStyle) + .pipe($.plumber()) + .pipe($.less()).on('error', function(err) { + console.warn(err.message); + }) + .pipe($.autoprefixer('last 2 versions', 'ie 9', 'android 2.3', 'android 4', 'opera 12')) + .pipe($.rename('./editor-style.css')) + .pipe(gulp.dest('assets/dist/css')); +}); + gulp.task('jshint', function() { return gulp.src(paths.jshint) .pipe($.jshint()) @@ -114,6 +126,6 @@ gulp.task('watch', function() { }); }); -gulp.task('default', ['less:dev', 'jshint', 'js:dev']); +gulp.task('default', ['less:dev', 'less:editorStyle', 'jshint', 'js:dev']); gulp.task('dev', ['default']); -gulp.task('build', ['less:build', 'js:build', 'copy:fonts', 'copy:jquery', 'copy:modernizr', 'images', 'version']); +gulp.task('build', ['less:build', 'less:editorStyle', 'js:build', 'copy:fonts', 'copy:jquery', 'copy:modernizr', 'images', 'version']); From 329102d630174d54a578eed72356d70485150f43 Mon Sep 17 00:00:00 2001 From: Kalen Johnson Date: Fri, 31 Oct 2014 12:29:34 -0700 Subject: [PATCH 019/143] Added correct path to editor-styles.css --- lib/init.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/init.php b/lib/init.php index a2ba3b1..c836824 100644 --- a/lib/init.php +++ b/lib/init.php @@ -28,7 +28,7 @@ function roots_setup() { add_theme_support('html5', array('caption', 'comment-form', 'comment-list')); // Tell the TinyMCE editor to use a custom stylesheet - add_editor_style('/assets/css/editor-style.css'); + add_editor_style('/assets/dist/css/editor-style.css'); } add_action('after_setup_theme', 'roots_setup'); From 1c591f9243fd8c2942b3dedbfdb9efe603650f2c Mon Sep 17 00:00:00 2001 From: Ben Word Date: Tue, 11 Nov 2014 12:14:35 -0600 Subject: [PATCH 020/143] Fix Glyphicons path --- assets/src/less/_variables.less | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/src/less/_variables.less b/assets/src/less/_variables.less index 1fa2be8..b46f50e 100644 --- a/assets/src/less/_variables.less +++ b/assets/src/less/_variables.less @@ -14,4 +14,4 @@ // Glyphicons path // ------------------------- -@icon-font-path: "../vendor/bootstrap/fonts/"; +@icon-font-path: "../fonts/"; From 337f64d99c59cceaf67ea30a071fb1e532a8d6f1 Mon Sep 17 00:00:00 2001 From: Ben Word Date: Tue, 11 Nov 2014 12:17:51 -0600 Subject: [PATCH 021/143] Add fonts and images tasks to dev --- gulpfile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gulpfile.js b/gulpfile.js index 717bb75..f0a0832 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -126,6 +126,6 @@ gulp.task('watch', function() { }); }); -gulp.task('default', ['less:dev', 'less:editorStyle', 'jshint', 'js:dev']); +gulp.task('default', ['less:dev', 'less:editorStyle', 'jshint', 'js:dev', 'copy:fonts', 'images']); gulp.task('dev', ['default']); gulp.task('build', ['less:build', 'less:editorStyle', 'js:build', 'copy:fonts', 'copy:jquery', 'copy:modernizr', 'images', 'version']); From 087fd5878a5b9a0d47384ff25f5e2b24b7a314a3 Mon Sep 17 00:00:00 2001 From: Michael Silber Date: Thu, 13 Nov 2014 15:27:19 -0500 Subject: [PATCH 022/143] Watch bower.json for override changes, installs, and uninstalls --- gulpfile.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index f0a0832..e5ed4db 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -14,12 +14,12 @@ var paths = { 'assets/src/js/**/*' ], jshint: [ + 'bower.json', 'gulpfile.js', 'assets/src/js/**/*' ], less: 'assets/src/less/main.less', - editorStyle: 'assets/src/less/editor-style.less', - bower: mainBowerFiles() + editorStyle: 'assets/src/less/editor-style.less' }; gulp.task('less:dev', function() { @@ -67,14 +67,14 @@ gulp.task('jshint', function() { }); gulp.task('js:dev', ['jshint'], function() { - return gulp.src(paths.bower.concat(paths.scripts)) + return gulp.src(mainBowerFiles().concat(paths.scripts)) .pipe($.concat('./scripts.js')) .pipe(gulp.dest('assets/dist/js')) .pipe($.livereload({ auto: false })); }); gulp.task('js:build', ['jshint'], function() { - return gulp.src(paths.bower.concat(paths.scripts)) + return gulp.src(mainBowerFiles().concat(paths.scripts)) .pipe($.concat('./scripts.min.js')) .pipe($.uglify()) .pipe(gulp.dest('assets/dist/js')); @@ -119,8 +119,8 @@ gulp.task('version', function() { gulp.task('watch', function() { $.livereload.listen(); - gulp.watch('assets/src/less/**/*', ['less:dev']); - gulp.watch('assets/src/js/**/*', ['jshint', 'js:dev']); + gulp.watch(['assets/src/less/**/*', 'bower.json'], ['less:dev']); + gulp.watch(['assets/src/js/**/*', 'bower.json'], ['jshint', 'js:dev']); gulp.watch('**/*.php').on('change', function(file) { $.livereload.changed(file.path); }); From 3d9db730d896196e206562298cc2dfbb58f0f152 Mon Sep 17 00:00:00 2001 From: Ben Word Date: Fri, 14 Nov 2014 18:43:04 -0600 Subject: [PATCH 023/143] Update Bootstrap (and remove Respond) --- bower.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bower.json b/bower.json index d556cd2..a5a5b73 100644 --- a/bower.json +++ b/bower.json @@ -15,8 +15,7 @@ "dependencies": { "modernizr": "2.8.2", "jquery": "1.11.1", - "bootstrap": "3.2.0", - "respond": "1.4.2" + "bootstrap": "3.3.1" }, "overrides": { "bootstrap": { From c3379fabd8cb0d89386b6fc8175aed4b013dbb8a Mon Sep 17 00:00:00 2001 From: Ben Word Date: Fri, 14 Nov 2014 18:58:19 -0600 Subject: [PATCH 024/143] Add gulp-clean --- gulpfile.js | 7 ++++++- package.json | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/gulpfile.js b/gulpfile.js index e5ed4db..2bd031d 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -117,6 +117,11 @@ gulp.task('version', function() { .pipe(gulp.dest('assets/dist')); }); +gulp.task('clean', function() { + return gulp.src(['assets/dist/css/main.min*', 'assets/dist/js/scripts.min*'], { read: false }) + .pipe($.clean()); +}); + gulp.task('watch', function() { $.livereload.listen(); gulp.watch(['assets/src/less/**/*', 'bower.json'], ['less:dev']); @@ -128,4 +133,4 @@ gulp.task('watch', function() { gulp.task('default', ['less:dev', 'less:editorStyle', 'jshint', 'js:dev', 'copy:fonts', 'images']); gulp.task('dev', ['default']); -gulp.task('build', ['less:build', 'less:editorStyle', 'js:build', 'copy:fonts', 'copy:jquery', 'copy:modernizr', 'images', 'version']); +gulp.task('build', ['clean', 'less:build', 'less:editorStyle', 'js:build', 'copy:fonts', 'copy:jquery', 'copy:modernizr', 'images', 'version']); diff --git a/package.json b/package.json index 77c9e35..2cecc3e 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "bower": ">=1.3.9", "gulp": "^3.8.7", "gulp-autoprefixer": "^0.0.7", + "gulp-clean": "^0.3.1", "gulp-concat": "^2.3.4", "gulp-grunt": "^0.5.2", "gulp-imagemin": "^0.6.0", From c866f4532d16672e938be1d09835006c48bc12d3 Mon Sep 17 00:00:00 2001 From: Ben Word Date: Fri, 14 Nov 2014 23:41:38 -0600 Subject: [PATCH 025/143] Use main-bower-files to copy fonts --- bower.json | 6 +++++- gulpfile.js | 22 +++++++++------------- package.json | 1 + 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/bower.json b/bower.json index a5a5b73..3c6c50c 100644 --- a/bower.json +++ b/bower.json @@ -31,7 +31,11 @@ "./js/popover.js", "./js/scrollspy.js", "./js/tab.js", - "./js/affix.js" + "./js/affix.js", + "./fonts/glyphicons-halflings-regular.eot", + "./fonts/glyphicons-halflings-regular.svg", + "./fonts/glyphicons-halflings-regular.ttf", + "./fonts/glyphicons-halflings-regular.woff" ] } } diff --git a/gulpfile.js b/gulpfile.js index 2bd031d..6592574 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,13 +1,7 @@ /*global $:true*/ var gulp = require('gulp'); + var $ = require('gulp-load-plugins')(); -var plugins = require('gulp-load-plugins')(); - -var pngcrush = require('imagemin-pngcrush'); - -var mainBowerFiles = require('main-bower-files'); - -var pkg = require('./package.json'); var paths = { scripts: [ @@ -67,27 +61,30 @@ gulp.task('jshint', function() { }); gulp.task('js:dev', ['jshint'], function() { - return gulp.src(mainBowerFiles().concat(paths.scripts)) + return gulp.src(require('main-bower-files')().concat(paths.scripts)) + .pipe($.filter('**/*.js')) .pipe($.concat('./scripts.js')) .pipe(gulp.dest('assets/dist/js')) .pipe($.livereload({ auto: false })); }); gulp.task('js:build', ['jshint'], function() { - return gulp.src(mainBowerFiles().concat(paths.scripts)) + return gulp.src(require('main-bower-files')().concat(paths.scripts)) + .pipe($.filter('**/*.js')) .pipe($.concat('./scripts.min.js')) .pipe($.uglify()) .pipe(gulp.dest('assets/dist/js')); }); gulp.task('copy:fonts', function() { - return gulp.src(['bower_components/bootstrap/fonts/*', 'assets/src/fonts/*']) + return gulp.src(require('main-bower-files')().concat('asset/src/fonts/**/*')) + .pipe($.filter('**/*.{eot,svg,ttf,woff}')) .pipe(gulp.dest('assets/dist/fonts')); }); gulp.task('copy:jquery', function() { return gulp.src(['bower_components/jquery/dist/jquery.min.js']) - .pipe($.rename('jquery-' + pkg.devDependencies.jquery + '.min.js')) + .pipe($.rename('jquery-1.11.1.min.js')) .pipe(gulp.dest('assets/dist/js')); }); @@ -102,8 +99,7 @@ gulp.task('images', function() { return gulp.src('assets/src/img/**/*') .pipe($.imagemin({ progressive: true, - interlaced: true, - use: [pngcrush()] + interlaced: true })) .pipe(gulp.dest('assets/dist/img')); }); diff --git a/package.json b/package.json index 2cecc3e..d4f9e78 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "gulp-autoprefixer": "^0.0.7", "gulp-clean": "^0.3.1", "gulp-concat": "^2.3.4", + "gulp-filter": "^0.4.1", "gulp-grunt": "^0.5.2", "gulp-imagemin": "^0.6.0", "gulp-jshint": "^1.8.4", From 3a4ae77b1e1c10e7678ba4bc8889fc4099cbfe05 Mon Sep 17 00:00:00 2001 From: Austin Pray Date: Sat, 22 Nov 2014 19:28:38 -0600 Subject: [PATCH 026/143] Reorganizes asset file structure Separates assets into - Source assets: `assets` - Compiled assets: `dist` Edits assets.php to reflect changes Removes '.min' from filenames Fixes: - removes 'clean' from build step. --- .gitignore | 2 +- assets/{src => }/fonts/.gitkeep | 0 assets/{src/img => images}/.gitkeep | 0 assets/{src/js => scripts}/main.js | 0 assets/src/less/_bootstrap.less | 92 ------------------- assets/styles/_bootstrap.less | 92 +++++++++++++++++++ assets/{src/less => styles}/_global.less | 0 assets/{src/less => styles}/_variables.less | 0 .../less => styles}/components/_buttons.less | 0 .../less => styles}/components/_forms.less | 0 .../less => styles}/components/_media.less | 0 .../components/_wp-classes.less | 0 assets/{src/less => styles}/editor-style.less | 0 .../{src/less => styles}/layouts/_footer.less | 0 .../less => styles}/layouts/_general.less | 0 .../{src/less => styles}/layouts/_header.less | 0 .../{src/less => styles}/layouts/_pages.less | 0 .../{src/less => styles}/layouts/_posts.less | 0 .../less => styles}/layouts/_sidebar.less | 0 .../less => styles}/layouts/pages/_home.less | 0 assets/{src/less => styles}/main.less | 0 gulpfile.js | 83 +++++++++-------- lib/assets.php | 24 ++--- lib/init.php | 2 +- 24 files changed, 150 insertions(+), 145 deletions(-) rename assets/{src => }/fonts/.gitkeep (100%) rename assets/{src/img => images}/.gitkeep (100%) rename assets/{src/js => scripts}/main.js (100%) delete mode 100644 assets/src/less/_bootstrap.less create mode 100644 assets/styles/_bootstrap.less rename assets/{src/less => styles}/_global.less (100%) rename assets/{src/less => styles}/_variables.less (100%) rename assets/{src/less => styles}/components/_buttons.less (100%) rename assets/{src/less => styles}/components/_forms.less (100%) rename assets/{src/less => styles}/components/_media.less (100%) rename assets/{src/less => styles}/components/_wp-classes.less (100%) rename assets/{src/less => styles}/editor-style.less (100%) rename assets/{src/less => styles}/layouts/_footer.less (100%) rename assets/{src/less => styles}/layouts/_general.less (100%) rename assets/{src/less => styles}/layouts/_header.less (100%) rename assets/{src/less => styles}/layouts/_pages.less (100%) rename assets/{src/less => styles}/layouts/_posts.less (100%) rename assets/{src/less => styles}/layouts/_sidebar.less (100%) rename assets/{src/less => styles}/layouts/pages/_home.less (100%) rename assets/{src/less => styles}/main.less (100%) diff --git a/.gitignore b/.gitignore index 34cb1dd..9eddf7e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ # Include your project-specific ignores in this file # Read about how to use .gitignore: https://help.github.com/articles/ignoring-files -assets/dist +dist bower_components node_modules diff --git a/assets/src/fonts/.gitkeep b/assets/fonts/.gitkeep similarity index 100% rename from assets/src/fonts/.gitkeep rename to assets/fonts/.gitkeep diff --git a/assets/src/img/.gitkeep b/assets/images/.gitkeep similarity index 100% rename from assets/src/img/.gitkeep rename to assets/images/.gitkeep diff --git a/assets/src/js/main.js b/assets/scripts/main.js similarity index 100% rename from assets/src/js/main.js rename to assets/scripts/main.js diff --git a/assets/src/less/_bootstrap.less b/assets/src/less/_bootstrap.less deleted file mode 100644 index 6825f08..0000000 --- a/assets/src/less/_bootstrap.less +++ /dev/null @@ -1,92 +0,0 @@ -// -// Bootstrap -// -// Comment out any unused components -// -------------------------------------------------- - -// Variables -@import "../../../bower_components/bootstrap/less/variables"; - -// Mixins: Utilities -@import "../../../bower_components/bootstrap/less/mixins/hide-text"; -@import "../../../bower_components/bootstrap/less/mixins/opacity"; -@import "../../../bower_components/bootstrap/less/mixins/image"; -@import "../../../bower_components/bootstrap/less/mixins/labels"; -@import "../../../bower_components/bootstrap/less/mixins/reset-filter"; -@import "../../../bower_components/bootstrap/less/mixins/resize"; -@import "../../../bower_components/bootstrap/less/mixins/responsive-visibility"; -@import "../../../bower_components/bootstrap/less/mixins/size"; -@import "../../../bower_components/bootstrap/less/mixins/tab-focus"; -@import "../../../bower_components/bootstrap/less/mixins/text-emphasis"; -@import "../../../bower_components/bootstrap/less/mixins/text-overflow"; -@import "../../../bower_components/bootstrap/less/mixins/vendor-prefixes"; - -// Mixins: Components -@import "../../../bower_components/bootstrap/less/mixins/alerts"; -@import "../../../bower_components/bootstrap/less/mixins/buttons"; -@import "../../../bower_components/bootstrap/less/mixins/panels"; -@import "../../../bower_components/bootstrap/less/mixins/pagination"; -@import "../../../bower_components/bootstrap/less/mixins/list-group"; -@import "../../../bower_components/bootstrap/less/mixins/nav-divider"; -@import "../../../bower_components/bootstrap/less/mixins/forms"; -@import "../../../bower_components/bootstrap/less/mixins/progress-bar"; -@import "../../../bower_components/bootstrap/less/mixins/table-row"; - -// Mixins: Skins -@import "../../../bower_components/bootstrap/less/mixins/background-variant"; -@import "../../../bower_components/bootstrap/less/mixins/border-radius"; -@import "../../../bower_components/bootstrap/less/mixins/gradients"; - -// Mixins: Layout -@import "../../../bower_components/bootstrap/less/mixins/clearfix"; -@import "../../../bower_components/bootstrap/less/mixins/center-block"; -@import "../../../bower_components/bootstrap/less/mixins/nav-vertical-align"; -@import "../../../bower_components/bootstrap/less/mixins/grid-framework"; -@import "../../../bower_components/bootstrap/less/mixins/grid"; - -// Reset -@import "../../../bower_components/bootstrap/less/normalize"; -@import "../../../bower_components/bootstrap/less/print"; -@import "../../../bower_components/bootstrap/less/glyphicons"; - -// Core CSS -@import "../../../bower_components/bootstrap/less/scaffolding"; -@import "../../../bower_components/bootstrap/less/type"; -@import "../../../bower_components/bootstrap/less/code"; -@import "../../../bower_components/bootstrap/less/grid"; -@import "../../../bower_components/bootstrap/less/tables"; -@import "../../../bower_components/bootstrap/less/forms"; -@import "../../../bower_components/bootstrap/less/buttons"; - -// Components -@import "../../../bower_components/bootstrap/less/component-animations"; -@import "../../../bower_components/bootstrap/less/dropdowns"; -@import "../../../bower_components/bootstrap/less/button-groups"; -@import "../../../bower_components/bootstrap/less/input-groups"; -@import "../../../bower_components/bootstrap/less/navs"; -@import "../../../bower_components/bootstrap/less/navbar"; -@import "../../../bower_components/bootstrap/less/breadcrumbs"; -@import "../../../bower_components/bootstrap/less/pagination"; -@import "../../../bower_components/bootstrap/less/pager"; -@import "../../../bower_components/bootstrap/less/labels"; -@import "../../../bower_components/bootstrap/less/badges"; -@import "../../../bower_components/bootstrap/less/jumbotron"; -@import "../../../bower_components/bootstrap/less/thumbnails"; -@import "../../../bower_components/bootstrap/less/alerts"; -@import "../../../bower_components/bootstrap/less/progress-bars"; -@import "../../../bower_components/bootstrap/less/media"; -@import "../../../bower_components/bootstrap/less/list-group"; -@import "../../../bower_components/bootstrap/less/panels"; -@import "../../../bower_components/bootstrap/less/responsive-embed"; -@import "../../../bower_components/bootstrap/less/wells"; -@import "../../../bower_components/bootstrap/less/close"; - -// Components w/ JavaScript -@import "../../../bower_components/bootstrap/less/modals"; -@import "../../../bower_components/bootstrap/less/tooltip"; -@import "../../../bower_components/bootstrap/less/popovers"; -@import "../../../bower_components/bootstrap/less/carousel"; - -// Utility classes -@import "../../../bower_components/bootstrap/less/utilities"; -@import "../../../bower_components/bootstrap/less/responsive-utilities"; diff --git a/assets/styles/_bootstrap.less b/assets/styles/_bootstrap.less new file mode 100644 index 0000000..d592f99 --- /dev/null +++ b/assets/styles/_bootstrap.less @@ -0,0 +1,92 @@ +// +// Bootstrap +// +// Comment out any unused components +// -------------------------------------------------- + +// Variables +@import "../../bower_components/bootstrap/less/variables"; + +// Mixins: Utilities +@import "../../bower_components/bootstrap/less/mixins/hide-text"; +@import "../../bower_components/bootstrap/less/mixins/opacity"; +@import "../../bower_components/bootstrap/less/mixins/image"; +@import "../../bower_components/bootstrap/less/mixins/labels"; +@import "../../bower_components/bootstrap/less/mixins/reset-filter"; +@import "../../bower_components/bootstrap/less/mixins/resize"; +@import "../../bower_components/bootstrap/less/mixins/responsive-visibility"; +@import "../../bower_components/bootstrap/less/mixins/size"; +@import "../../bower_components/bootstrap/less/mixins/tab-focus"; +@import "../../bower_components/bootstrap/less/mixins/text-emphasis"; +@import "../../bower_components/bootstrap/less/mixins/text-overflow"; +@import "../../bower_components/bootstrap/less/mixins/vendor-prefixes"; + +// Mixins: Components +@import "../../bower_components/bootstrap/less/mixins/alerts"; +@import "../../bower_components/bootstrap/less/mixins/buttons"; +@import "../../bower_components/bootstrap/less/mixins/panels"; +@import "../../bower_components/bootstrap/less/mixins/pagination"; +@import "../../bower_components/bootstrap/less/mixins/list-group"; +@import "../../bower_components/bootstrap/less/mixins/nav-divider"; +@import "../../bower_components/bootstrap/less/mixins/forms"; +@import "../../bower_components/bootstrap/less/mixins/progress-bar"; +@import "../../bower_components/bootstrap/less/mixins/table-row"; + +// Mixins: Skins +@import "../../bower_components/bootstrap/less/mixins/background-variant"; +@import "../../bower_components/bootstrap/less/mixins/border-radius"; +@import "../../bower_components/bootstrap/less/mixins/gradients"; + +// Mixins: Layout +@import "../../bower_components/bootstrap/less/mixins/clearfix"; +@import "../../bower_components/bootstrap/less/mixins/center-block"; +@import "../../bower_components/bootstrap/less/mixins/nav-vertical-align"; +@import "../../bower_components/bootstrap/less/mixins/grid-framework"; +@import "../../bower_components/bootstrap/less/mixins/grid"; + +// Reset +@import "../../bower_components/bootstrap/less/normalize"; +@import "../../bower_components/bootstrap/less/print"; +@import "../../bower_components/bootstrap/less/glyphicons"; + +// Core CSS +@import "../../bower_components/bootstrap/less/scaffolding"; +@import "../../bower_components/bootstrap/less/type"; +@import "../../bower_components/bootstrap/less/code"; +@import "../../bower_components/bootstrap/less/grid"; +@import "../../bower_components/bootstrap/less/tables"; +@import "../../bower_components/bootstrap/less/forms"; +@import "../../bower_components/bootstrap/less/buttons"; + +// Components +@import "../../bower_components/bootstrap/less/component-animations"; +@import "../../bower_components/bootstrap/less/dropdowns"; +@import "../../bower_components/bootstrap/less/button-groups"; +@import "../../bower_components/bootstrap/less/input-groups"; +@import "../../bower_components/bootstrap/less/navs"; +@import "../../bower_components/bootstrap/less/navbar"; +@import "../../bower_components/bootstrap/less/breadcrumbs"; +@import "../../bower_components/bootstrap/less/pagination"; +@import "../../bower_components/bootstrap/less/pager"; +@import "../../bower_components/bootstrap/less/labels"; +@import "../../bower_components/bootstrap/less/badges"; +@import "../../bower_components/bootstrap/less/jumbotron"; +@import "../../bower_components/bootstrap/less/thumbnails"; +@import "../../bower_components/bootstrap/less/alerts"; +@import "../../bower_components/bootstrap/less/progress-bars"; +@import "../../bower_components/bootstrap/less/media"; +@import "../../bower_components/bootstrap/less/list-group"; +@import "../../bower_components/bootstrap/less/panels"; +@import "../../bower_components/bootstrap/less/responsive-embed"; +@import "../../bower_components/bootstrap/less/wells"; +@import "../../bower_components/bootstrap/less/close"; + +// Components w/ JavaScript +@import "../../bower_components/bootstrap/less/modals"; +@import "../../bower_components/bootstrap/less/tooltip"; +@import "../../bower_components/bootstrap/less/popovers"; +@import "../../bower_components/bootstrap/less/carousel"; + +// Utility classes +@import "../../bower_components/bootstrap/less/utilities"; +@import "../../bower_components/bootstrap/less/responsive-utilities"; diff --git a/assets/src/less/_global.less b/assets/styles/_global.less similarity index 100% rename from assets/src/less/_global.less rename to assets/styles/_global.less diff --git a/assets/src/less/_variables.less b/assets/styles/_variables.less similarity index 100% rename from assets/src/less/_variables.less rename to assets/styles/_variables.less diff --git a/assets/src/less/components/_buttons.less b/assets/styles/components/_buttons.less similarity index 100% rename from assets/src/less/components/_buttons.less rename to assets/styles/components/_buttons.less diff --git a/assets/src/less/components/_forms.less b/assets/styles/components/_forms.less similarity index 100% rename from assets/src/less/components/_forms.less rename to assets/styles/components/_forms.less diff --git a/assets/src/less/components/_media.less b/assets/styles/components/_media.less similarity index 100% rename from assets/src/less/components/_media.less rename to assets/styles/components/_media.less diff --git a/assets/src/less/components/_wp-classes.less b/assets/styles/components/_wp-classes.less similarity index 100% rename from assets/src/less/components/_wp-classes.less rename to assets/styles/components/_wp-classes.less diff --git a/assets/src/less/editor-style.less b/assets/styles/editor-style.less similarity index 100% rename from assets/src/less/editor-style.less rename to assets/styles/editor-style.less diff --git a/assets/src/less/layouts/_footer.less b/assets/styles/layouts/_footer.less similarity index 100% rename from assets/src/less/layouts/_footer.less rename to assets/styles/layouts/_footer.less diff --git a/assets/src/less/layouts/_general.less b/assets/styles/layouts/_general.less similarity index 100% rename from assets/src/less/layouts/_general.less rename to assets/styles/layouts/_general.less diff --git a/assets/src/less/layouts/_header.less b/assets/styles/layouts/_header.less similarity index 100% rename from assets/src/less/layouts/_header.less rename to assets/styles/layouts/_header.less diff --git a/assets/src/less/layouts/_pages.less b/assets/styles/layouts/_pages.less similarity index 100% rename from assets/src/less/layouts/_pages.less rename to assets/styles/layouts/_pages.less diff --git a/assets/src/less/layouts/_posts.less b/assets/styles/layouts/_posts.less similarity index 100% rename from assets/src/less/layouts/_posts.less rename to assets/styles/layouts/_posts.less diff --git a/assets/src/less/layouts/_sidebar.less b/assets/styles/layouts/_sidebar.less similarity index 100% rename from assets/src/less/layouts/_sidebar.less rename to assets/styles/layouts/_sidebar.less diff --git a/assets/src/less/layouts/pages/_home.less b/assets/styles/layouts/pages/_home.less similarity index 100% rename from assets/src/less/layouts/pages/_home.less rename to assets/styles/layouts/pages/_home.less diff --git a/assets/src/less/main.less b/assets/styles/main.less similarity index 100% rename from assets/src/less/main.less rename to assets/styles/main.less diff --git a/gulpfile.js b/gulpfile.js index 6592574..5891138 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -3,21 +3,26 @@ var gulp = require('gulp'); var $ = require('gulp-load-plugins')(); +var build = { + src: 'assets/', + dist: 'dist/' +}; + var paths = { scripts: [ - 'assets/src/js/**/*' + build.src + 'scripts/**/*' ], jshint: [ 'bower.json', 'gulpfile.js', - 'assets/src/js/**/*' + build.src + 'scripts/**/*' ], - less: 'assets/src/less/main.less', - editorStyle: 'assets/src/less/editor-style.less' + styles: build.src + 'styles/main.less', + editorStyle: build.src + 'styles/editor-style.less' }; -gulp.task('less:dev', function() { - return gulp.src(paths.less) +gulp.task('styles:dev', function() { + return gulp.src(paths.styles) .pipe($.plumber()) .pipe($.sourcemaps.init()) .pipe($.less()).on('error', function(err) { @@ -25,32 +30,32 @@ gulp.task('less:dev', function() { }) .pipe($.autoprefixer('last 2 versions', 'ie 8', 'ie 9', 'android 2.3', 'android 4', 'opera 12')) .pipe($.sourcemaps.write()) - .pipe($.rename('./main.css')) - .pipe(gulp.dest('assets/dist/css')) + .pipe($.rename('main.css')) + .pipe(gulp.dest(build.dist + 'styles')) .pipe($.livereload({ auto: false })); }); -gulp.task('less:build', function() { - return gulp.src(paths.less) +gulp.task('styles:build', function() { + return gulp.src(paths.styles) .pipe($.plumber()) .pipe($.less()).on('error', function(err) { console.warn(err.message); }) .pipe($.autoprefixer('last 2 versions', 'ie 9', 'android 2.3', 'android 4', 'opera 12')) - .pipe($.rename('./main.min.css')) + .pipe($.rename('main.css')) .pipe($.minifyCss()) - .pipe(gulp.dest('assets/dist/css')); + .pipe(gulp.dest(build.dist + 'styles')); }); -gulp.task('less:editorStyle', function() { +gulp.task('styles:editorStyle', function() { return gulp.src(paths.editorStyle) .pipe($.plumber()) .pipe($.less()).on('error', function(err) { console.warn(err.message); }) .pipe($.autoprefixer('last 2 versions', 'ie 9', 'android 2.3', 'android 4', 'opera 12')) - .pipe($.rename('./editor-style.css')) - .pipe(gulp.dest('assets/dist/css')); + .pipe($.rename('editor-style.css')) + .pipe(gulp.dest(build.dist + 'styles')); }); gulp.task('jshint', function() { @@ -60,73 +65,73 @@ gulp.task('jshint', function() { .pipe($.jshint.reporter('fail')); }); -gulp.task('js:dev', ['jshint'], function() { +gulp.task('scripts:dev', ['jshint'], function() { return gulp.src(require('main-bower-files')().concat(paths.scripts)) .pipe($.filter('**/*.js')) - .pipe($.concat('./scripts.js')) - .pipe(gulp.dest('assets/dist/js')) + .pipe($.concat('scripts.js')) + .pipe(gulp.dest(build.dist + 'scripts')) .pipe($.livereload({ auto: false })); }); -gulp.task('js:build', ['jshint'], function() { +gulp.task('scripts:build', ['jshint'], function() { return gulp.src(require('main-bower-files')().concat(paths.scripts)) .pipe($.filter('**/*.js')) - .pipe($.concat('./scripts.min.js')) + .pipe($.concat('scripts.js')) .pipe($.uglify()) - .pipe(gulp.dest('assets/dist/js')); + .pipe(gulp.dest(build.dist + 'scripts')); }); gulp.task('copy:fonts', function() { - return gulp.src(require('main-bower-files')().concat('asset/src/fonts/**/*')) + return gulp.src(require('main-bower-files')().concat(build.src + 'fonts/**/*')) .pipe($.filter('**/*.{eot,svg,ttf,woff}')) - .pipe(gulp.dest('assets/dist/fonts')); + .pipe(gulp.dest(build.dist + 'fonts')); }); gulp.task('copy:jquery', function() { - return gulp.src(['bower_components/jquery/dist/jquery.min.js']) - .pipe($.rename('jquery-1.11.1.min.js')) - .pipe(gulp.dest('assets/dist/js')); + return gulp.src(['bower_components/jquery/dist/jquery.js']) + .pipe($.rename('jquery.js')) + .pipe(gulp.dest(build.dist + 'scripts')); }); gulp.task('copy:modernizr', function() { return gulp.src(['bower_components/modernizr/modernizr.js']) .pipe($.uglify()) - .pipe($.rename('modernizr.min.js')) - .pipe(gulp.dest('assets/dist/js')); + .pipe($.rename('modernizr.js')) + .pipe(gulp.dest(build.dist + 'scripts')); }); gulp.task('images', function() { - return gulp.src('assets/src/img/**/*') + return gulp.src(build.src + 'src/images/**/*') .pipe($.imagemin({ progressive: true, interlaced: true })) - .pipe(gulp.dest('assets/dist/img')); + .pipe(gulp.dest(build.dist + 'images')); }); gulp.task('version', function() { - return gulp.src(['assets/dist/css/main.min.css', 'assets/dist/js/scripts.min.js'], { base: 'assets/dist' }) - .pipe(gulp.dest('assets/dist')) + return gulp.src([build.dist + 'styles/main.css', build.dist + 'js/scripts.js'], { base: build.dist }) + .pipe(gulp.dest(build.dist)) .pipe($.rev()) - .pipe(gulp.dest('assets/dist')) + .pipe(gulp.dest(build.dist)) .pipe($.rev.manifest()) - .pipe(gulp.dest('assets/dist')); + .pipe(gulp.dest(build.dist)); }); gulp.task('clean', function() { - return gulp.src(['assets/dist/css/main.min*', 'assets/dist/js/scripts.min*'], { read: false }) + return gulp.src(build.dist, { read: false }) .pipe($.clean()); }); gulp.task('watch', function() { $.livereload.listen(); - gulp.watch(['assets/src/less/**/*', 'bower.json'], ['less:dev']); - gulp.watch(['assets/src/js/**/*', 'bower.json'], ['jshint', 'js:dev']); + gulp.watch([build.src + 'styles/**/*', 'bower.json'], ['styles:dev']); + gulp.watch([build.src + 'scripts/**/*', 'bower.json'], ['jshint', 'scripts:dev']); gulp.watch('**/*.php').on('change', function(file) { $.livereload.changed(file.path); }); }); -gulp.task('default', ['less:dev', 'less:editorStyle', 'jshint', 'js:dev', 'copy:fonts', 'images']); +gulp.task('default', ['styles:dev', 'styles:editorStyle', 'jshint', 'scripts:dev', 'copy:fonts', 'images']); gulp.task('dev', ['default']); -gulp.task('build', ['clean', 'less:build', 'less:editorStyle', 'js:build', 'copy:fonts', 'copy:jquery', 'copy:modernizr', 'images', 'version']); +gulp.task('build', ['styles:build', 'styles:editorStyle', 'scripts:build', 'copy:fonts', 'copy:jquery', 'copy:modernizr', 'images', 'version']); diff --git a/lib/assets.php b/lib/assets.php index 25cb8b2..67b7952 100644 --- a/lib/assets.php +++ b/lib/assets.php @@ -3,12 +3,12 @@ * Scripts and stylesheets * * Enqueue stylesheets in the following order: - * 1. /theme/assets/dist/css/main.css + * 1. /theme/dist/styles/main.css * * Enqueue scripts in the following order: - * 1. jquery-1.11.1.min.js via Google CDN - * 2. /theme/assets/dist/js/modernizr.min.js - * 3. /theme/assets/dist/js/scripts.js + * 1. jquery-1.11.1.js via Google CDN + * 2. /theme/dist/scripts/modernizr.js + * 3. /theme/dist/scripts/scripts.js * * Google Analytics is loaded after enqueued scripts if: * - An ID has been defined in config.php @@ -16,10 +16,10 @@ */ function roots_asset_path($filename_dev, $filename) { if (WP_ENV === 'development') { - return get_template_directory_uri() . '/assets/dist/' . $filename_dev; + return get_template_directory_uri() . '/dist/' . $filename_dev; } - $manifest_path = get_template_directory() . '/assets/dist/rev-manifest.json'; + $manifest_path = get_template_directory() . '/dist/rev-manifest.json'; if (file_exists($manifest_path)) { $manifest = json_decode(file_get_contents($manifest_path), true); @@ -28,12 +28,12 @@ function roots_asset_path($filename_dev, $filename) { } if (array_key_exists($filename, $manifest)) { - return get_template_directory_uri() . '/assets/dist/' . $manifest[$filename]; + return get_template_directory_uri() . '/dist/' . $manifest[$filename]; } } function roots_assets() { - wp_enqueue_style('roots_css', roots_asset_path('css/main.css', 'css/main.min.css'), false, null); + wp_enqueue_style('roots_css', roots_asset_path('styles/main.css', 'styles/main.css'), false, null); /** * jQuery is loaded using the same method from HTML5 Boilerplate: @@ -46,7 +46,7 @@ function roots_assets() { if (WP_ENV === 'development') { wp_register_script('jquery', '//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.js', array(), null, true); } else { - wp_register_script('jquery', '//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js', array(), null, true); + wp_register_script('jquery', '//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.js', array(), null, true); } add_filter('script_loader_src', 'roots_jquery_local_fallback', 10, 2); @@ -56,9 +56,9 @@ function roots_assets() { wp_enqueue_script('comment-reply'); } - wp_enqueue_script('modernizr', roots_asset_path('../../bower_components/modernizr/modernizr.js', 'js/modernizr.min.js'), array(), null, true); + wp_enqueue_script('modernizr', roots_asset_path('scripts/modernizr.js', 'scripts/modernizr.js'), array(), null, true); wp_enqueue_script('jquery'); - wp_enqueue_script('roots_js', roots_asset_path('js/scripts.js', 'js/scripts.min.js'), array(), null, true); + wp_enqueue_script('roots_js', roots_asset_path('scripts/scripts.js', 'scripts/scripts.js'), array(), null, true); } add_action('wp_enqueue_scripts', 'roots_assets', 100); @@ -67,7 +67,7 @@ function roots_jquery_local_fallback($src, $handle = null) { static $add_jquery_fallback = false; if ($add_jquery_fallback) { - echo '' . "\n"; + echo '' . "\n"; $add_jquery_fallback = false; } diff --git a/lib/init.php b/lib/init.php index c836824..e9f6f28 100644 --- a/lib/init.php +++ b/lib/init.php @@ -28,7 +28,7 @@ function roots_setup() { add_theme_support('html5', array('caption', 'comment-form', 'comment-list')); // Tell the TinyMCE editor to use a custom stylesheet - add_editor_style('/assets/dist/css/editor-style.css'); + add_editor_style('/dist/css/editor-style.css'); } add_action('after_setup_theme', 'roots_setup'); From 75db78a9a1be9370ea9763103d4415476722d69f Mon Sep 17 00:00:00 2001 From: Austin Pray Date: Sun, 23 Nov 2014 00:16:07 -0600 Subject: [PATCH 027/143] Remove disparity between dev and prod gulp tasks removes `gulp dev` in favor of `gulp` adds `gulp --rev` to produce revved asset manifest adds `gulp --tasks` to the readme removes postinstall script removes bower dep --- README.md | 4 ++-- gulpfile.js | 45 ++++++++++++++------------------------------- lib/assets.php | 16 ++++++---------- package.json | 9 +++------ 4 files changed, 25 insertions(+), 49 deletions(-) diff --git a/README.md b/README.md index 93eafff..1ed30df 100644 --- a/README.md +++ b/README.md @@ -74,10 +74,10 @@ When completed, you'll be able to run the various Gulp commands provided from th ### Available Gulp commands -* `gulp dev` — Compile LESS to CSS, concatenate and validate JS +* `gulp` — Compile LESS to CSS, concatenate and validate JS * `gulp watch` — Compile assets when file changes are made -* `gulp build` — Create minified assets that are used on non-development environments * `gulp images` — Lossless compression of PNG, JPEG, GIF and SVG images +* `gulp --tasks` - Lists all the available tasks and what they do ## Documentation diff --git a/gulpfile.js b/gulpfile.js index 5891138..90598b1 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,7 +1,6 @@ /*global $:true*/ var gulp = require('gulp'); - -var $ = require('gulp-load-plugins')(); +var $ = require('gulp-load-plugins')(); var build = { src: 'assets/', @@ -21,7 +20,7 @@ var paths = { editorStyle: build.src + 'styles/editor-style.less' }; -gulp.task('styles:dev', function() { +gulp.task('styles', function() { return gulp.src(paths.styles) .pipe($.plumber()) .pipe($.sourcemaps.init()) @@ -29,21 +28,9 @@ gulp.task('styles:dev', function() { console.warn(err.message); }) .pipe($.autoprefixer('last 2 versions', 'ie 8', 'ie 9', 'android 2.3', 'android 4', 'opera 12')) + .pipe($.minifyCss()) .pipe($.sourcemaps.write()) .pipe($.rename('main.css')) - .pipe(gulp.dest(build.dist + 'styles')) - .pipe($.livereload({ auto: false })); -}); - -gulp.task('styles:build', function() { - return gulp.src(paths.styles) - .pipe($.plumber()) - .pipe($.less()).on('error', function(err) { - console.warn(err.message); - }) - .pipe($.autoprefixer('last 2 versions', 'ie 9', 'android 2.3', 'android 4', 'opera 12')) - .pipe($.rename('main.css')) - .pipe($.minifyCss()) .pipe(gulp.dest(build.dist + 'styles')); }); @@ -65,15 +52,7 @@ gulp.task('jshint', function() { .pipe($.jshint.reporter('fail')); }); -gulp.task('scripts:dev', ['jshint'], function() { - return gulp.src(require('main-bower-files')().concat(paths.scripts)) - .pipe($.filter('**/*.js')) - .pipe($.concat('scripts.js')) - .pipe(gulp.dest(build.dist + 'scripts')) - .pipe($.livereload({ auto: false })); -}); - -gulp.task('scripts:build', ['jshint'], function() { +gulp.task('scripts', ['jshint'], function() { return gulp.src(require('main-bower-files')().concat(paths.scripts)) .pipe($.filter('**/*.js')) .pipe($.concat('scripts.js')) @@ -110,7 +89,7 @@ gulp.task('images', function() { }); gulp.task('version', function() { - return gulp.src([build.dist + 'styles/main.css', build.dist + 'js/scripts.js'], { base: build.dist }) + return gulp.src([build.dist + 'styles/main.css', build.dist + 'scripts/scripts.js'], { base: build.dist }) .pipe(gulp.dest(build.dist)) .pipe($.rev()) .pipe(gulp.dest(build.dist)) @@ -125,13 +104,17 @@ gulp.task('clean', function() { gulp.task('watch', function() { $.livereload.listen(); - gulp.watch([build.src + 'styles/**/*', 'bower.json'], ['styles:dev']); - gulp.watch([build.src + 'scripts/**/*', 'bower.json'], ['jshint', 'scripts:dev']); + gulp.watch([build.src + 'styles/**/*', 'bower.json'], ['styles']); + gulp.watch([build.src + 'scripts/**/*', 'bower.json'], ['jshint', 'scripts']); gulp.watch('**/*.php').on('change', function(file) { $.livereload.changed(file.path); }); }); -gulp.task('default', ['styles:dev', 'styles:editorStyle', 'jshint', 'scripts:dev', 'copy:fonts', 'images']); -gulp.task('dev', ['default']); -gulp.task('build', ['styles:build', 'styles:editorStyle', 'scripts:build', 'copy:fonts', 'copy:jquery', 'copy:modernizr', 'images', 'version']); +gulp.task('build', ['styles', 'styles:editorStyle', 'scripts', 'copy:fonts', 'copy:jquery', 'copy:modernizr', 'images'], function () { + gulp.start('version'); +}); + +gulp.task('default', ['clean'], function () { + gulp.start('build'); +}); diff --git a/lib/assets.php b/lib/assets.php index 67b7952..c668ed2 100644 --- a/lib/assets.php +++ b/lib/assets.php @@ -14,9 +14,9 @@ * - An ID has been defined in config.php * - You're not logged in as an administrator */ -function roots_asset_path($filename_dev, $filename) { +function roots_asset_path($filename) { if (WP_ENV === 'development') { - return get_template_directory_uri() . '/dist/' . $filename_dev; + return get_template_directory_uri() . '/dist/' . $filename; } $manifest_path = get_template_directory() . '/dist/rev-manifest.json'; @@ -33,7 +33,7 @@ function roots_asset_path($filename_dev, $filename) { } function roots_assets() { - wp_enqueue_style('roots_css', roots_asset_path('styles/main.css', 'styles/main.css'), false, null); + wp_enqueue_style('roots_css', roots_asset_path('styles/main.css'), false, null); /** * jQuery is loaded using the same method from HTML5 Boilerplate: @@ -43,11 +43,7 @@ function roots_assets() { if (!is_admin() && current_theme_supports('jquery-cdn')) { wp_deregister_script('jquery'); - if (WP_ENV === 'development') { - wp_register_script('jquery', '//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.js', array(), null, true); - } else { - wp_register_script('jquery', '//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.js', array(), null, true); - } + wp_register_script('jquery', '//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.js', array(), null, true); add_filter('script_loader_src', 'roots_jquery_local_fallback', 10, 2); } @@ -56,9 +52,9 @@ function roots_assets() { wp_enqueue_script('comment-reply'); } - wp_enqueue_script('modernizr', roots_asset_path('scripts/modernizr.js', 'scripts/modernizr.js'), array(), null, true); + wp_enqueue_script(roots_asset_path('scripts/modernizr.js'), array(), null, true); wp_enqueue_script('jquery'); - wp_enqueue_script('roots_js', roots_asset_path('scripts/scripts.js', 'scripts/scripts.js'), array(), null, true); + wp_enqueue_script('roots_js', roots_asset_path('scripts/scripts.js'), array(), null, true); } add_action('wp_enqueue_scripts', 'roots_assets', 100); diff --git a/package.json b/package.json index d4f9e78..60ef200 100644 --- a/package.json +++ b/package.json @@ -16,15 +16,12 @@ "url": "http://opensource.org/licenses/MIT" } ], - "scripts": { - "postinstall": "node node_modules/bower/bin/bower install && gulp dev" - }, + "scripts": {}, "engines": { "node": ">= 0.10.0" }, "devDependencies": { - "bower": ">=1.3.9", - "gulp": "^3.8.7", + "gulp": "^3.8.10", "gulp-autoprefixer": "^0.0.7", "gulp-clean": "^0.3.1", "gulp-concat": "^2.3.4", @@ -42,8 +39,8 @@ "gulp-sourcemaps": "^1.1.1", "gulp-uglify": "^0.3.1", "imagemin-pngcrush": "^1.0.0", - "jshint-stylish": "^0.4.0", "jquery": "1.11.1", + "jshint-stylish": "^0.4.0", "lodash": "^2.4.1", "main-bower-files": "^1.0.1" } From e2091ef88065881ca3b5afa99b15c9f04e8cc7ec Mon Sep 17 00:00:00 2001 From: Austin Pray Date: Sun, 23 Nov 2014 21:53:18 -0600 Subject: [PATCH 028/143] Implement JSON file based asset pipeline Adds manifest.json which contains all of the mappings for the assets ref: https://github.com/roots/roots/pull/1138#issuecomment-62593715 Prune and update NPM deps --- README.md | 3 +- assets/manifest.json | 22 +++++ gulpfile.js | 211 ++++++++++++++++++++++++++++--------------- lib/assets.php | 4 +- package.json | 27 +++--- 5 files changed, 179 insertions(+), 88 deletions(-) create mode 100644 assets/manifest.json diff --git a/README.md b/README.md index 1ed30df..469a1bd 100644 --- a/README.md +++ b/README.md @@ -74,9 +74,8 @@ When completed, you'll be able to run the various Gulp commands provided from th ### Available Gulp commands -* `gulp` — Compile LESS to CSS, concatenate and validate JS +* `gulp` — Compile and optimize the files in your assets directory * `gulp watch` — Compile assets when file changes are made -* `gulp images` — Lossless compression of PNG, JPEG, GIF and SVG images * `gulp --tasks` - Lists all the available tasks and what they do ## Documentation diff --git a/assets/manifest.json b/assets/manifest.json new file mode 100644 index 0000000..26ed346 --- /dev/null +++ b/assets/manifest.json @@ -0,0 +1,22 @@ +{ + "dependencies": { + "theme": { + "scripts": [ + "scripts/**/*", + "scripts/main.js" + ], + "styles": "styles/main.less", + "editorStyle": "styles/editor-style.less" + }, + "vendor": { + "scripts": [], + "styles": [] + } + }, + "ignoreDependencies": { + "bower": [ + "jquery", + "modernizr" + ] + } +} diff --git a/gulpfile.js b/gulpfile.js index 90598b1..7733173 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,117 +1,184 @@ /*global $:true*/ -var gulp = require('gulp'); -var $ = require('gulp-load-plugins')(); +var $ = require('gulp-load-plugins')(); +var _ = require('lodash'); +var gulp = require('gulp'); +var lazypipe = require('lazypipe'); +var mainBowerFiles = require('main-bower-files'); +var obj = require('object-path'); +var traverse = require('traverse'); +var util = require('util'); -var build = { - src: 'assets/', - dist: 'dist/' -}; +function getManifest(path) { + var m = require(path); + var defaults = { + buildPaths: { + appendSrc: ['theme'], + src: 'assets/', + dist: 'dist/' + } + }; + var err = function (msg) { + msg = msg || 'file seems to be malformed'; + console.error('Manifest File Error: %s: %s', path, msg); + process.exit(1); + }; + var required = ['dependencies', 'buildPaths']; -var paths = { - scripts: [ - build.src + 'scripts/**/*' - ], - jshint: [ - 'bower.json', - 'gulpfile.js', - build.src + 'scripts/**/*' - ], - styles: build.src + 'styles/main.less', - editorStyle: build.src + 'styles/editor-style.less' -}; + if(_.isPlainObject(m)) { + m = _.defaults(m, defaults); -gulp.task('styles', function() { - return gulp.src(paths.styles) - .pipe($.plumber()) - .pipe($.sourcemaps.init()) - .pipe($.less()).on('error', function(err) { - console.warn(err.message); + _.forEach(required, function (req) { + if(!obj.has(m, req)) { + err('missing "'+req+'" property'); + } + }); + + traverse(m.dependencies).forEach(function (node) { + if(this.isLeaf && !_.isArray(node) && !_.isArray(this.parent.node)) { + this.update([node]); + } + }); + + if(m.buildPaths.appendSrc) { + _.forOwn(m.dependencies, function (dependency, name) { + if(m.buildPaths.appendSrc.indexOf(name) >= 0) { + traverse(m.dependencies[name]).forEach(function (node) { + if(this.isLeaf) { + this.update(m.buildPaths.src + node); + } + }); + } + }); + } + + return m; + } else { + err(); + } +} + +var manifest = getManifest('./assets/manifest.json'); + +var path = manifest.buildPaths; + +var bower = require('wiredep')({ + exclude: obj.get(manifest, 'ignoreDependencies.bower') +}); + +var globs = (function buildGlobs() { + return { + scripts: (bower.js || []) + .concat(obj.get(manifest, 'dependencies.vendor.scripts', [])) + .concat(obj.get(manifest, 'dependencies.theme.scripts', [])), + scriptsIgnored: _.reduce(obj.get(manifest, 'ignoreDependencies.bower', []), + function (paths, depName) { + return paths.concat(obj.get(bower, 'packages.'+depName+'.main', [])); + }, []), + styles: (bower.css || []) + .concat(obj.get(manifest, 'dependencies.vendor.styles', [])) + .concat(obj.get(manifest, 'dependencies.theme.styles', [])), + editorStyle: obj.get(manifest, 'dependencies.theme.editorStyle', []), + fonts: mainBowerFiles({ filter: /\.(eot|svg|ttf|woff)$/i }) + .concat(manifest.buildPaths.src + 'fonts/**/*.{eot,svg,ttf,woff}'), + images: path.src + 'images/**/*' + }; +})(); + +var cssTasks = function(filename) { + return lazypipe() + .pipe($.plumber) + .pipe($.sourcemaps.init) + .pipe(function () { + return $.if('*.less', $.less().on('error', function(err) { + console.warn(err.message); + })); }) - .pipe($.autoprefixer('last 2 versions', 'ie 8', 'ie 9', 'android 2.3', 'android 4', 'opera 12')) - .pipe($.minifyCss()) - .pipe($.sourcemaps.write()) - .pipe($.rename('main.css')) - .pipe(gulp.dest(build.dist + 'styles')); + .pipe(function () { + return $.if('*.scss', $.sass()); + }) + .pipe($.autoprefixer, 'last 2 versions', 'ie 8', 'ie 9', 'android 2.3', 'android 4', 'opera 12') + .pipe($.concat, filename) + .pipe($.sourcemaps.write, '.') + .pipe(gulp.dest, path.dist + 'styles')(); +}; + +gulp.task('styles', ['styles:editorStyle'], function() { + return gulp.src(globs.styles) + .pipe(cssTasks('main.css')); }); gulp.task('styles:editorStyle', function() { - return gulp.src(paths.editorStyle) - .pipe($.plumber()) - .pipe($.less()).on('error', function(err) { - console.warn(err.message); - }) - .pipe($.autoprefixer('last 2 versions', 'ie 9', 'android 2.3', 'android 4', 'opera 12')) - .pipe($.rename('editor-style.css')) - .pipe(gulp.dest(build.dist + 'styles')); + return gulp.src(globs.editorStyle) + .pipe(cssTasks('editor-style.css')); }); gulp.task('jshint', function() { - return gulp.src(paths.jshint) + return gulp.src([ + 'bower.json', 'gulpfile.js' + ].concat(obj.get(manifest, 'dependencies.theme.scripts', []))) .pipe($.jshint()) .pipe($.jshint.reporter('jshint-stylish')) .pipe($.jshint.reporter('fail')); }); -gulp.task('scripts', ['jshint'], function() { - return gulp.src(require('main-bower-files')().concat(paths.scripts)) - .pipe($.filter('**/*.js')) - .pipe($.concat('scripts.js')) - .pipe($.uglify()) - .pipe(gulp.dest(build.dist + 'scripts')); +var jsTasks = function(filename) { + var fn = filename; + return lazypipe() + .pipe($.sourcemaps.init) + .pipe(function () { + return $.if(!!fn, $.concat(fn || 'all.js')); + }) + .pipe($.uglify) + .pipe($.sourcemaps.write, '.') + .pipe(gulp.dest, path.dist + 'scripts')(); +}; + +gulp.task('scripts', ['jshint', 'scripts:ignored'], function() { + return gulp.src(globs.scripts) + .pipe(jsTasks('app.js')); }); -gulp.task('copy:fonts', function() { - return gulp.src(require('main-bower-files')().concat(build.src + 'fonts/**/*')) - .pipe($.filter('**/*.{eot,svg,ttf,woff}')) - .pipe(gulp.dest(build.dist + 'fonts')); +gulp.task('scripts:ignored', function () { + return gulp.src(globs.scriptsIgnored) + .pipe(jsTasks()); }); -gulp.task('copy:jquery', function() { - return gulp.src(['bower_components/jquery/dist/jquery.js']) - .pipe($.rename('jquery.js')) - .pipe(gulp.dest(build.dist + 'scripts')); -}); - -gulp.task('copy:modernizr', function() { - return gulp.src(['bower_components/modernizr/modernizr.js']) - .pipe($.uglify()) - .pipe($.rename('modernizr.js')) - .pipe(gulp.dest(build.dist + 'scripts')); +gulp.task('fonts', function() { + return gulp.src(globs.fonts) + .pipe($.flatten()) + .pipe(gulp.dest(path.dist + 'fonts')); }); gulp.task('images', function() { - return gulp.src(build.src + 'src/images/**/*') + return gulp.src(globs.images) .pipe($.imagemin({ progressive: true, interlaced: true })) - .pipe(gulp.dest(build.dist + 'images')); + .pipe(gulp.dest(path.dist + 'images')); }); gulp.task('version', function() { - return gulp.src([build.dist + 'styles/main.css', build.dist + 'scripts/scripts.js'], { base: build.dist }) - .pipe(gulp.dest(build.dist)) + return gulp.src([path.dist + '**/*.{js,css}'], { base: path.dist }) + .pipe(gulp.dest(path.dist)) .pipe($.rev()) - .pipe(gulp.dest(build.dist)) + .pipe(gulp.dest(path.dist)) .pipe($.rev.manifest()) - .pipe(gulp.dest(build.dist)); + .pipe(gulp.dest(path.dist)); }); -gulp.task('clean', function() { - return gulp.src(build.dist, { read: false }) - .pipe($.clean()); -}); +gulp.task('clean', require('del').bind(null, [path.dist])); gulp.task('watch', function() { $.livereload.listen(); - gulp.watch([build.src + 'styles/**/*', 'bower.json'], ['styles']); - gulp.watch([build.src + 'scripts/**/*', 'bower.json'], ['jshint', 'scripts']); + gulp.watch([path.src + 'styles/**/*', 'bower.json'], ['styles']); + gulp.watch([path.src + 'scripts/**/*', 'bower.json'], ['jshint', 'scripts']); gulp.watch('**/*.php').on('change', function(file) { $.livereload.changed(file.path); }); }); -gulp.task('build', ['styles', 'styles:editorStyle', 'scripts', 'copy:fonts', 'copy:jquery', 'copy:modernizr', 'images'], function () { +gulp.task('build', ['styles', 'scripts', 'fonts', 'images'], function () { gulp.start('version'); }); diff --git a/lib/assets.php b/lib/assets.php index c668ed2..a670be2 100644 --- a/lib/assets.php +++ b/lib/assets.php @@ -8,7 +8,7 @@ * Enqueue scripts in the following order: * 1. jquery-1.11.1.js via Google CDN * 2. /theme/dist/scripts/modernizr.js - * 3. /theme/dist/scripts/scripts.js + * 3. /theme/dist/scripts/app.js * * Google Analytics is loaded after enqueued scripts if: * - An ID has been defined in config.php @@ -54,7 +54,7 @@ function roots_assets() { wp_enqueue_script(roots_asset_path('scripts/modernizr.js'), array(), null, true); wp_enqueue_script('jquery'); - wp_enqueue_script('roots_js', roots_asset_path('scripts/scripts.js'), array(), null, true); + wp_enqueue_script('roots_js', roots_asset_path('scripts/app.js'), array(), null, true); } add_action('wp_enqueue_scripts', 'roots_assets', 100); diff --git a/package.json b/package.json index 60ef200..a91d162 100644 --- a/package.json +++ b/package.json @@ -21,27 +21,30 @@ "node": ">= 0.10.0" }, "devDependencies": { + "del": "^0.1.3", "gulp": "^3.8.10", - "gulp-autoprefixer": "^0.0.7", - "gulp-clean": "^0.3.1", + "gulp-autoprefixer": "^2.0.0", "gulp-concat": "^2.3.4", - "gulp-filter": "^0.4.1", - "gulp-grunt": "^0.5.2", - "gulp-imagemin": "^0.6.0", + "gulp-flatten": "0.0.4", + "gulp-if": "^1.2.5", + "gulp-imagemin": "^2.0.0", "gulp-jshint": "^1.8.4", "gulp-less": "^1.3.3", "gulp-livereload": "^2.1.0", - "gulp-load-plugins": "^0.5.0", - "gulp-minify-css": "^0.3.7", + "gulp-load-plugins": "^0.7.1", "gulp-plumber": "^0.6.3", "gulp-rename": "^1.2.0", "gulp-rev": "^2.0.1", + "gulp-sass": "^1.1.0", "gulp-sourcemaps": "^1.1.1", - "gulp-uglify": "^0.3.1", - "imagemin-pngcrush": "^1.0.0", - "jquery": "1.11.1", - "jshint-stylish": "^0.4.0", + "gulp-uglify": "^1.0.1", + "imagemin-pngcrush": "^4.0.0", + "jshint-stylish": "^1.0.0", + "lazypipe": "^0.2.2", "lodash": "^2.4.1", - "main-bower-files": "^1.0.1" + "main-bower-files": "^2.4.0", + "object-path": "^0.8.0", + "traverse": "^0.6.6", + "wiredep": "^2.1.0" } } From df004917b7c674bdc33c68a40a438276162e704c Mon Sep 17 00:00:00 2001 From: Austin Pray Date: Sun, 23 Nov 2014 22:23:36 -0600 Subject: [PATCH 029/143] Use wiredep for sass and less injection https://github.com/taptapship/wiredep all third-party deps are injected via wiredep rather than manually managed --- assets/styles/_bootstrap.less | 92 ----------------------------------- assets/styles/main.less | 5 +- bower.json | 1 + gulpfile.js | 10 +++- 4 files changed, 13 insertions(+), 95 deletions(-) delete mode 100644 assets/styles/_bootstrap.less diff --git a/assets/styles/_bootstrap.less b/assets/styles/_bootstrap.less deleted file mode 100644 index d592f99..0000000 --- a/assets/styles/_bootstrap.less +++ /dev/null @@ -1,92 +0,0 @@ -// -// Bootstrap -// -// Comment out any unused components -// -------------------------------------------------- - -// Variables -@import "../../bower_components/bootstrap/less/variables"; - -// Mixins: Utilities -@import "../../bower_components/bootstrap/less/mixins/hide-text"; -@import "../../bower_components/bootstrap/less/mixins/opacity"; -@import "../../bower_components/bootstrap/less/mixins/image"; -@import "../../bower_components/bootstrap/less/mixins/labels"; -@import "../../bower_components/bootstrap/less/mixins/reset-filter"; -@import "../../bower_components/bootstrap/less/mixins/resize"; -@import "../../bower_components/bootstrap/less/mixins/responsive-visibility"; -@import "../../bower_components/bootstrap/less/mixins/size"; -@import "../../bower_components/bootstrap/less/mixins/tab-focus"; -@import "../../bower_components/bootstrap/less/mixins/text-emphasis"; -@import "../../bower_components/bootstrap/less/mixins/text-overflow"; -@import "../../bower_components/bootstrap/less/mixins/vendor-prefixes"; - -// Mixins: Components -@import "../../bower_components/bootstrap/less/mixins/alerts"; -@import "../../bower_components/bootstrap/less/mixins/buttons"; -@import "../../bower_components/bootstrap/less/mixins/panels"; -@import "../../bower_components/bootstrap/less/mixins/pagination"; -@import "../../bower_components/bootstrap/less/mixins/list-group"; -@import "../../bower_components/bootstrap/less/mixins/nav-divider"; -@import "../../bower_components/bootstrap/less/mixins/forms"; -@import "../../bower_components/bootstrap/less/mixins/progress-bar"; -@import "../../bower_components/bootstrap/less/mixins/table-row"; - -// Mixins: Skins -@import "../../bower_components/bootstrap/less/mixins/background-variant"; -@import "../../bower_components/bootstrap/less/mixins/border-radius"; -@import "../../bower_components/bootstrap/less/mixins/gradients"; - -// Mixins: Layout -@import "../../bower_components/bootstrap/less/mixins/clearfix"; -@import "../../bower_components/bootstrap/less/mixins/center-block"; -@import "../../bower_components/bootstrap/less/mixins/nav-vertical-align"; -@import "../../bower_components/bootstrap/less/mixins/grid-framework"; -@import "../../bower_components/bootstrap/less/mixins/grid"; - -// Reset -@import "../../bower_components/bootstrap/less/normalize"; -@import "../../bower_components/bootstrap/less/print"; -@import "../../bower_components/bootstrap/less/glyphicons"; - -// Core CSS -@import "../../bower_components/bootstrap/less/scaffolding"; -@import "../../bower_components/bootstrap/less/type"; -@import "../../bower_components/bootstrap/less/code"; -@import "../../bower_components/bootstrap/less/grid"; -@import "../../bower_components/bootstrap/less/tables"; -@import "../../bower_components/bootstrap/less/forms"; -@import "../../bower_components/bootstrap/less/buttons"; - -// Components -@import "../../bower_components/bootstrap/less/component-animations"; -@import "../../bower_components/bootstrap/less/dropdowns"; -@import "../../bower_components/bootstrap/less/button-groups"; -@import "../../bower_components/bootstrap/less/input-groups"; -@import "../../bower_components/bootstrap/less/navs"; -@import "../../bower_components/bootstrap/less/navbar"; -@import "../../bower_components/bootstrap/less/breadcrumbs"; -@import "../../bower_components/bootstrap/less/pagination"; -@import "../../bower_components/bootstrap/less/pager"; -@import "../../bower_components/bootstrap/less/labels"; -@import "../../bower_components/bootstrap/less/badges"; -@import "../../bower_components/bootstrap/less/jumbotron"; -@import "../../bower_components/bootstrap/less/thumbnails"; -@import "../../bower_components/bootstrap/less/alerts"; -@import "../../bower_components/bootstrap/less/progress-bars"; -@import "../../bower_components/bootstrap/less/media"; -@import "../../bower_components/bootstrap/less/list-group"; -@import "../../bower_components/bootstrap/less/panels"; -@import "../../bower_components/bootstrap/less/responsive-embed"; -@import "../../bower_components/bootstrap/less/wells"; -@import "../../bower_components/bootstrap/less/close"; - -// Components w/ JavaScript -@import "../../bower_components/bootstrap/less/modals"; -@import "../../bower_components/bootstrap/less/tooltip"; -@import "../../bower_components/bootstrap/less/popovers"; -@import "../../bower_components/bootstrap/less/carousel"; - -// Utility classes -@import "../../bower_components/bootstrap/less/utilities"; -@import "../../bower_components/bootstrap/less/responsive-utilities"; diff --git a/assets/styles/main.less b/assets/styles/main.less index aec9850..49f61a5 100644 --- a/assets/styles/main.less +++ b/assets/styles/main.less @@ -1,5 +1,6 @@ -// Bootstrap -@import "_bootstrap"; +// bower:less +@import "../../bower_components/bootstrap/less/bootstrap.less"; +// endbower // Variable overrides and custom variables @import "_variables"; diff --git a/bower.json b/bower.json index 3c6c50c..1d2d767 100644 --- a/bower.json +++ b/bower.json @@ -20,6 +20,7 @@ "overrides": { "bootstrap": { "main": [ + "./less/bootstrap.less", "./js/transition.js", "./js/alert.js", "./js/button.js", diff --git a/gulpfile.js b/gulpfile.js index 7733173..3f08b44 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -102,7 +102,7 @@ var cssTasks = function(filename) { .pipe(gulp.dest, path.dist + 'styles')(); }; -gulp.task('styles', ['styles:editorStyle'], function() { +gulp.task('styles', ['wiredep', 'styles:editorStyle'], function() { return gulp.src(globs.styles) .pipe(cssTasks('main.css')); }); @@ -173,6 +173,7 @@ gulp.task('watch', function() { $.livereload.listen(); gulp.watch([path.src + 'styles/**/*', 'bower.json'], ['styles']); gulp.watch([path.src + 'scripts/**/*', 'bower.json'], ['jshint', 'scripts']); + gulp.watch(['bower.json'], ['wiredep']); gulp.watch('**/*.php').on('change', function(file) { $.livereload.changed(file.path); }); @@ -182,6 +183,13 @@ gulp.task('build', ['styles', 'scripts', 'fonts', 'images'], function () { gulp.start('version'); }); +gulp.task('wiredep', function () { + var wiredep = require('wiredep').stream; + gulp.src(obj.get(manifest, 'dependencies.theme.styles')) + .pipe(wiredep()) + .pipe(gulp.dest(manifest.buildPaths.src + 'styles/')); +}); + gulp.task('default', ['clean'], function () { gulp.start('build'); }); From 063a77d1490c08e681ef3c5975b7344860dbfa7f Mon Sep 17 00:00:00 2001 From: Austin Pray Date: Mon, 24 Nov 2014 11:33:32 -0600 Subject: [PATCH 030/143] Refactor: remove manifest file concerns https://github.com/austinpray/asset-builder Moves all manifest parsing concerns to separate node module --- gulpfile.js | 77 ++-------------------------------------------------- package.json | 1 + 2 files changed, 3 insertions(+), 75 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 3f08b44..97f0f36 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -5,84 +5,11 @@ var gulp = require('gulp'); var lazypipe = require('lazypipe'); var mainBowerFiles = require('main-bower-files'); var obj = require('object-path'); -var traverse = require('traverse'); -var util = require('util'); -function getManifest(path) { - var m = require(path); - var defaults = { - buildPaths: { - appendSrc: ['theme'], - src: 'assets/', - dist: 'dist/' - } - }; - var err = function (msg) { - msg = msg || 'file seems to be malformed'; - console.error('Manifest File Error: %s: %s', path, msg); - process.exit(1); - }; - var required = ['dependencies', 'buildPaths']; - - if(_.isPlainObject(m)) { - m = _.defaults(m, defaults); - - _.forEach(required, function (req) { - if(!obj.has(m, req)) { - err('missing "'+req+'" property'); - } - }); - - traverse(m.dependencies).forEach(function (node) { - if(this.isLeaf && !_.isArray(node) && !_.isArray(this.parent.node)) { - this.update([node]); - } - }); - - if(m.buildPaths.appendSrc) { - _.forOwn(m.dependencies, function (dependency, name) { - if(m.buildPaths.appendSrc.indexOf(name) >= 0) { - traverse(m.dependencies[name]).forEach(function (node) { - if(this.isLeaf) { - this.update(m.buildPaths.src + node); - } - }); - } - }); - } - - return m; - } else { - err(); - } -} - -var manifest = getManifest('./assets/manifest.json'); +var manifest = require('asset-builder')('./assets/manifest.json'); var path = manifest.buildPaths; - -var bower = require('wiredep')({ - exclude: obj.get(manifest, 'ignoreDependencies.bower') -}); - -var globs = (function buildGlobs() { - return { - scripts: (bower.js || []) - .concat(obj.get(manifest, 'dependencies.vendor.scripts', [])) - .concat(obj.get(manifest, 'dependencies.theme.scripts', [])), - scriptsIgnored: _.reduce(obj.get(manifest, 'ignoreDependencies.bower', []), - function (paths, depName) { - return paths.concat(obj.get(bower, 'packages.'+depName+'.main', [])); - }, []), - styles: (bower.css || []) - .concat(obj.get(manifest, 'dependencies.vendor.styles', [])) - .concat(obj.get(manifest, 'dependencies.theme.styles', [])), - editorStyle: obj.get(manifest, 'dependencies.theme.editorStyle', []), - fonts: mainBowerFiles({ filter: /\.(eot|svg|ttf|woff)$/i }) - .concat(manifest.buildPaths.src + 'fonts/**/*.{eot,svg,ttf,woff}'), - images: path.src + 'images/**/*' - }; -})(); +var globs = manifest.globs; var cssTasks = function(filename) { return lazypipe() diff --git a/package.json b/package.json index a91d162..6e6884e 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "node": ">= 0.10.0" }, "devDependencies": { + "asset-builder": "0.0.1", "del": "^0.1.3", "gulp": "^3.8.10", "gulp-autoprefixer": "^2.0.0", From f13d52d38a57150126695c4fb2e08da25c083e7c Mon Sep 17 00:00:00 2001 From: Scott Walkinshaw Date: Wed, 3 Dec 2014 18:44:59 -0500 Subject: [PATCH 031/143] Use csswring and autoprefixer via postcss csswring supports minification and sourcemaps --- gulpfile.js | 9 ++++++++- package.json | 4 +++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 97f0f36..3baf1cb 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,6 +1,8 @@ /*global $:true*/ var $ = require('gulp-load-plugins')(); var _ = require('lodash'); +var autoprefixer = require('autoprefixer-core'); +var csswring = require('csswring'); var gulp = require('gulp'); var lazypipe = require('lazypipe'); var mainBowerFiles = require('main-bower-files'); @@ -12,6 +14,11 @@ var path = manifest.buildPaths; var globs = manifest.globs; var cssTasks = function(filename) { + var processors = [ + autoprefixer({browsers: ['last 2 versions', 'ie 8', 'ie 9', 'android 2.3', 'android 4', 'opera 12']}), + csswring + ]; + return lazypipe() .pipe($.plumber) .pipe($.sourcemaps.init) @@ -23,8 +30,8 @@ var cssTasks = function(filename) { .pipe(function () { return $.if('*.scss', $.sass()); }) - .pipe($.autoprefixer, 'last 2 versions', 'ie 8', 'ie 9', 'android 2.3', 'android 4', 'opera 12') .pipe($.concat, filename) + .pipe($.postcss, processors) .pipe($.sourcemaps.write, '.') .pipe(gulp.dest, path.dist + 'styles')(); }; diff --git a/package.json b/package.json index 6e6884e..1aa552f 100644 --- a/package.json +++ b/package.json @@ -22,9 +22,10 @@ }, "devDependencies": { "asset-builder": "0.0.1", + "autoprefixer-core": "4.0.1", + "csswring": "^2.0.0", "del": "^0.1.3", "gulp": "^3.8.10", - "gulp-autoprefixer": "^2.0.0", "gulp-concat": "^2.3.4", "gulp-flatten": "0.0.4", "gulp-if": "^1.2.5", @@ -34,6 +35,7 @@ "gulp-livereload": "^2.1.0", "gulp-load-plugins": "^0.7.1", "gulp-plumber": "^0.6.3", + "gulp-postcss": "^3.0.0", "gulp-rename": "^1.2.0", "gulp-rev": "^2.0.1", "gulp-sass": "^1.1.0", From 44f69cf0a53d1bfad7ebdfd444227b14fad91cb1 Mon Sep 17 00:00:00 2001 From: Austin Pray Date: Fri, 5 Dec 2014 01:00:07 -0600 Subject: [PATCH 032/143] Fixes modernizr not being enqueued https://github.com/roots/roots/issues/1223 https://github.com/roots/roots/issues/1223#issuecomment-65754009 --- lib/assets.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/assets.php b/lib/assets.php index a670be2..b0545c8 100644 --- a/lib/assets.php +++ b/lib/assets.php @@ -52,7 +52,7 @@ function roots_assets() { wp_enqueue_script('comment-reply'); } - wp_enqueue_script(roots_asset_path('scripts/modernizr.js'), array(), null, true); + wp_enqueue_script('modernizr', roots_asset_path('scripts/modernizr.js'), array(), null, true); wp_enqueue_script('jquery'); wp_enqueue_script('roots_js', roots_asset_path('scripts/app.js'), array(), null, true); } From 41e9f3ea68dd7d31ca3631d1b3513e23e6a9fd18 Mon Sep 17 00:00:00 2001 From: Joe Fletcher Date: Fri, 5 Dec 2014 14:28:39 -0800 Subject: [PATCH 033/143] update comments now that jQuery & Modernizr load in the footer --- lib/assets.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/assets.php b/lib/assets.php index b0545c8..5817999 100644 --- a/lib/assets.php +++ b/lib/assets.php @@ -36,9 +36,10 @@ function roots_assets() { wp_enqueue_style('roots_css', roots_asset_path('styles/main.css'), false, null); /** - * jQuery is loaded using the same method from HTML5 Boilerplate: * Grab Google CDN's latest jQuery with a protocol relative URL; fallback to local if offline - * It's kept in the header instead of footer to avoid conflicts with plugins. + * jQuery & Modernizr load in the footer per HTML5 Boilerplate's recommendation: http://goo.gl/nMGR7P + * If a plugin enqueues jQuery-dependent scripts in the head, jQuery will load in the head to meet the plugin's dependencies + * To explicitly load jQuery in the head, change the last wp_enqueue_script parameter to false */ if (!is_admin() && current_theme_supports('jquery-cdn')) { wp_deregister_script('jquery'); From 63a2be27bf3625d1380d2624f274ba636303f361 Mon Sep 17 00:00:00 2001 From: Ben Word Date: Sat, 6 Dec 2014 22:34:25 -0600 Subject: [PATCH 034/143] Be consistent --- gulpfile.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 3baf1cb..9a97b0d 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -22,12 +22,12 @@ var cssTasks = function(filename) { return lazypipe() .pipe($.plumber) .pipe($.sourcemaps.init) - .pipe(function () { + .pipe(function() { return $.if('*.less', $.less().on('error', function(err) { console.warn(err.message); })); }) - .pipe(function () { + .pipe(function() { return $.if('*.scss', $.sass()); }) .pipe($.concat, filename) @@ -59,7 +59,7 @@ var jsTasks = function(filename) { var fn = filename; return lazypipe() .pipe($.sourcemaps.init) - .pipe(function () { + .pipe(function() { return $.if(!!fn, $.concat(fn || 'all.js')); }) .pipe($.uglify) @@ -72,7 +72,7 @@ gulp.task('scripts', ['jshint', 'scripts:ignored'], function() { .pipe(jsTasks('app.js')); }); -gulp.task('scripts:ignored', function () { +gulp.task('scripts:ignored', function() { return gulp.src(globs.scriptsIgnored) .pipe(jsTasks()); }); @@ -113,17 +113,17 @@ gulp.task('watch', function() { }); }); -gulp.task('build', ['styles', 'scripts', 'fonts', 'images'], function () { +gulp.task('build', ['styles', 'scripts', 'fonts', 'images'], function() { gulp.start('version'); }); -gulp.task('wiredep', function () { +gulp.task('wiredep', function() { var wiredep = require('wiredep').stream; gulp.src(obj.get(manifest, 'dependencies.theme.styles')) .pipe(wiredep()) .pipe(gulp.dest(manifest.buildPaths.src + 'styles/')); }); -gulp.task('default', ['clean'], function () { +gulp.task('default', ['clean'], function() { gulp.start('build'); }); From fd4dbccf86d5e32381d77158756a0d39676aa079 Mon Sep 17 00:00:00 2001 From: Austin Pray Date: Wed, 10 Dec 2014 14:11:12 -0600 Subject: [PATCH 035/143] Adds a bowerrc Related: https://github.com/roots/roots/issues/1226 http://bower.io/docs/config/#placement--order --- .bowerrc | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .bowerrc diff --git a/.bowerrc b/.bowerrc new file mode 100644 index 0000000..69fad35 --- /dev/null +++ b/.bowerrc @@ -0,0 +1,3 @@ +{ + "directory": "bower_components" +} From fc627d43ac205f48971c4e4ece6231156d0c48ab Mon Sep 17 00:00:00 2001 From: Austin Pray Date: Wed, 24 Dec 2014 17:12:32 -0600 Subject: [PATCH 036/143] Adds travis --- .gitignore | 1 + .travis.yml | 11 +++++++++++ README.md | 1 + package.json | 5 ++++- 4 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 .travis.yml diff --git a/.gitignore b/.gitignore index 9eddf7e..8596abe 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ dist bower_components node_modules +npm-debug.log diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..88353cd --- /dev/null +++ b/.travis.yml @@ -0,0 +1,11 @@ +sudo: false +language: php +php: +- '5.5' +- '5.4' +before_install: + - npm install -g bower + - npm install +script: + - npm run build + - npm run jshint diff --git a/README.md b/README.md index 469a1bd..482eef1 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # [Roots Starter Theme](http://roots.io/) +[![Build Status](https://travis-ci.org/roots/roots.svg)](https://travis-ci.org/roots/roots) [![devDependency Status](https://david-dm.org/roots/roots/dev-status.svg)](https://david-dm.org/roots/roots#info=devDependencies) Roots is a WordPress starter theme based on [HTML5 Boilerplate](http://html5boilerplate.com/) & [Bootstrap](http://getbootstrap.com/) that will help you make better themes. diff --git a/package.json b/package.json index 1aa552f..0ea6de5 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,10 @@ "url": "http://opensource.org/licenses/MIT" } ], - "scripts": {}, + "scripts": { + "build": "bower install && gulp", + "jshint": "gulp jshint" + }, "engines": { "node": ">= 0.10.0" }, From ba1aee86bfff0c6878df60459f092f22073ce28b Mon Sep 17 00:00:00 2001 From: Austin Pray Date: Wed, 24 Dec 2014 18:01:25 -0600 Subject: [PATCH 037/143] Update and tidy README Removes references to defunct modernizr build generator Removes repetition Gulp -> gulp https://github.com/gulpjs/gulp/blob/master/docs/FAQ.md#is-it-gulp-or-gulp Removes references to Sass fork, it is dead Removes "Organized file and template structure" as a feature Some opinionated usage changes in the Contributing section Adds my twitter to Readme so I can be reached for gulp stuff Pimps bedrock --- README.md | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 469a1bd..307e0a3 100644 --- a/README.md +++ b/README.md @@ -6,20 +6,19 @@ Roots is a WordPress starter theme based on [HTML5 Boilerplate](http://html5boil * Source: [https://github.com/roots/roots](https://github.com/roots/roots) * Homepage: [http://roots.io/](http://roots.io/) * Documentation: [http://roots.io/docs/](http://roots.io/docs/) -* Twitter: [@rootswp](https://twitter.com/rootswp), [@retlehs](https://twitter.com/retlehs), [@swalkinshaw](https://twitter.com/swalkinshaw), [@Foxaii](https://twitter.com/Foxaii), [@c2foryou](https://twitter.com/c2foryou) +* Twitter: [@rootswp](https://twitter.com/rootswp), [@retlehs](https://twitter.com/retlehs), [@swalkinshaw](https://twitter.com/swalkinshaw), [@Foxaii](https://twitter.com/Foxaii), [@c2foryou](https://twitter.com/c2foryou) [@austinpray](https://twitter.com/austinpray) * Newsletter: [Subscribe](http://roots.io/subscribe/) * Forum: [http://discourse.roots.io/](http://discourse.roots.io/) ## Features -* [Gulp](http://gulpjs.com/) for compiling LESS to CSS, checking for JS errors, live reloading, concatenating and minifying files, versioning assets, and generating lean Modernizr builds +* [gulp](http://gulpjs.com/) for compiling Sass and LESS, checking for JavaScript errors, live reloading, concatenating and minifying files, and versioning assets * [Bower](http://bower.io/) for front-end package management * [HTML5 Boilerplate](http://html5boilerplate.com/) * The latest [jQuery](http://jquery.com/) via Google CDN, with a local fallback - * The latest [Modernizr](http://modernizr.com/) build for feature detection, with lean builds with Gulp + * The latest [Modernizr](http://modernizr.com/) build for feature detection * An optimized Google Analytics snippet * [Bootstrap](http://getbootstrap.com/) -* Organized file and template structure * ARIA roles and microformats * [Theme activation](http://roots.io/roots-101/#theme-activation) * [Theme wrapper](http://roots.io/an-introduction-to-the-roots-theme-wrapper/) @@ -27,14 +26,22 @@ Roots is a WordPress starter theme based on [HTML5 Boilerplate](http://html5boil * Posts use the [hNews](http://microformats.org/wiki/hnews) microformat * [Multilingual ready](http://roots.io/wpml/) and over 30 available [community translations](https://github.com/roots/roots-translations) -### Additional features +### Go further with Roots +#### Clean up WordPress Install the [Soil](https://github.com/roots/soil) plugin to enable additional features: * Root relative URLs * Nice search (`/search/query/`) * Cleaner output of `wp_head` and enqueued assets markup +#### Modernize your WordPress stack +[Bedrock](https://github.com/roots/bedrock) gets you started with the best development tools, practices, and project structure. + +* Dependency management with Composer +* Automated deployments with Capistrano +* Easy environment specific configuration + ## Installation Clone the git repo - `git clone git://github.com/roots/roots.git` - or [download it](https://github.com/roots/roots/zipball/master) and then rename the directory to the name of your theme or website. @@ -57,43 +64,40 @@ Edit `lib/init.php` to setup navigation menus, post thumbnail sizes, post format ## Theme development -Roots uses [Gulp](http://gulpjs.com/) for compiling LESS to CSS, checking for JS errors, live reloading, concatenating and minifying files, versioning assets, and generating lean Modernizr builds. +Roots uses [gulp](http://gulpjs.com/) as its build system. -If you'd like to use Bootstrap Sass, look at the [Roots Sass](https://github.com/roots/roots-sass) fork. - -### Install Gulp +### Install gulp **Unfamiliar with npm? Don't have node installed?** [Download and install node.js](http://nodejs.org/download/) before proceeding. From the command line: -1. Install `gulp` globally with `npm install -g gulp`. -2. Navigate to the theme directory, then run `npm install`. npm will look at `package.json` and automatically install the necessary dependencies. It will also automatically run `bower install`, which installs front-end packages defined in `bower.json`. +1. Install [gulp](http://gulpjs.com) and [bower](http://bower.io) globally with `npm install -g gulp bower`. +2. Navigate to the theme directory, then run `npm install`. -When completed, you'll be able to run the various Gulp commands provided from the command line. +You now have all the necessary dependencies to run the build process. -### Available Gulp commands +### Available gulp commands * `gulp` — Compile and optimize the files in your assets directory * `gulp watch` — Compile assets when file changes are made -* `gulp --tasks` - Lists all the available tasks and what they do +* `gulp --tasks` — Lists all the available tasks and what they do ## Documentation * [Roots 101](http://roots.io/roots-101/) — A guide to installing Roots, the files, and theme organization * [Theme Wrapper](http://roots.io/an-introduction-to-the-roots-theme-wrapper/) — Learn all about the theme wrapper -* [Build Script](http://roots.io/using-gulp-for-wordpress-theme-development/) — A look into how Roots uses Gulp +* [Build Script](http://roots.io/using-gulp-for-wordpress-theme-development/) — A look into how Roots uses gulp * [Roots Sidebar](http://roots.io/the-roots-sidebar/) — Understand how to display or hide the sidebar in Roots ## Contributing -Everyone is welcome to help [contribute](CONTRIBUTING.md) and improve this project. There are several ways you can contribute: +Contributions are welcome from everyone. We have [contributing guidelines](CONTRIBUTING.md) to help you get started. You can help out by: -* Reporting issues (please read [issue guidelines](https://github.com/necolas/issue-guidelines)) -* Suggesting new features -* Writing or refactoring code +* Reporting issues (please follow the [issue guidelines](https://github.com/necolas/issue-guidelines)) * Fixing [issues](https://github.com/roots/roots/issues) -* Replying to questions on the [forum](http://discourse.roots.io/) +* Suggesting new features +* Answering questions on the [forum](http://discourse.roots.io/) ## Support From 870a14168ce5aa1d90b75dcd22d18b1aa99fbf50 Mon Sep 17 00:00:00 2001 From: Scott Walkinshaw Date: Wed, 31 Dec 2014 17:29:32 -0500 Subject: [PATCH 038/143] Update .travis.yml with npm cache and php 5.6 --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 88353cd..2228c1a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,8 @@ sudo: false language: php +cache: npm php: +- '5.6' - '5.5' - '5.4' before_install: From 6a7764f2eeab3decfd71f1b8f151cf3df7a0c5b4 Mon Sep 17 00:00:00 2001 From: Ben Word Date: Sat, 3 Jan 2015 01:22:27 -0600 Subject: [PATCH 039/143] README tweaks --- README.md | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 9297268..ee64572 100644 --- a/README.md +++ b/README.md @@ -2,12 +2,12 @@ [![Build Status](https://travis-ci.org/roots/roots.svg)](https://travis-ci.org/roots/roots) [![devDependency Status](https://david-dm.org/roots/roots/dev-status.svg)](https://david-dm.org/roots/roots#info=devDependencies) -Roots is a WordPress starter theme based on [HTML5 Boilerplate](http://html5boilerplate.com/) & [Bootstrap](http://getbootstrap.com/) that will help you make better themes. +Roots is a WordPress starter theme based on [HTML5 Boilerplate](http://html5boilerplate.com/) that will help you make better themes. * Source: [https://github.com/roots/roots](https://github.com/roots/roots) * Homepage: [http://roots.io/](http://roots.io/) * Documentation: [http://roots.io/docs/](http://roots.io/docs/) -* Twitter: [@rootswp](https://twitter.com/rootswp), [@retlehs](https://twitter.com/retlehs), [@swalkinshaw](https://twitter.com/swalkinshaw), [@Foxaii](https://twitter.com/Foxaii), [@c2foryou](https://twitter.com/c2foryou) [@austinpray](https://twitter.com/austinpray) +* Twitter: [@rootswp](https://twitter.com/rootswp), [@retlehs](https://twitter.com/retlehs), [@swalkinshaw](https://twitter.com/swalkinshaw), [@Foxaii](https://twitter.com/Foxaii), [@c2foryou](https://twitter.com/c2foryou), [@austinpray](https://twitter.com/austinpray) * Newsletter: [Subscribe](http://roots.io/subscribe/) * Forum: [http://discourse.roots.io/](http://discourse.roots.io/) @@ -32,12 +32,12 @@ Roots is a WordPress starter theme based on [HTML5 Boilerplate](http://html5boil #### Clean up WordPress Install the [Soil](https://github.com/roots/soil) plugin to enable additional features: +* Cleaner output of `wp_head` and enqueued assets * Root relative URLs * Nice search (`/search/query/`) -* Cleaner output of `wp_head` and enqueued assets markup #### Modernize your WordPress stack -[Bedrock](https://github.com/roots/bedrock) gets you started with the best development tools, practices, and project structure. +[Bedrock](https://github.com/roots/bedrock) gets you started with the best development tools, practices, and project structure: * Dependency management with Composer * Automated deployments with Capistrano @@ -45,7 +45,7 @@ Install the [Soil](https://github.com/roots/soil) plugin to enable additional fe ## Installation -Clone the git repo - `git clone git://github.com/roots/roots.git` - or [download it](https://github.com/roots/roots/zipball/master) and then rename the directory to the name of your theme or website. +Clone the git repo - `git clone https://github.com/roots/roots.git` - or [download it](https://github.com/roots/roots/zipball/master) and then rename the directory to the name of your theme or website. If you don't use [Bedrock](https://github.com/roots/bedrock), you'll need to add the following to your `wp-config.php` on your development installation: @@ -73,8 +73,8 @@ Roots uses [gulp](http://gulpjs.com/) as its build system. From the command line: -1. Install [gulp](http://gulpjs.com) and [bower](http://bower.io) globally with `npm install -g gulp bower`. -2. Navigate to the theme directory, then run `npm install`. +1. Install [gulp](http://gulpjs.com) and [Bower](http://bower.io) globally with `npm install -g gulp bower` +2. Navigate to the theme directory, then run `npm install` You now have all the necessary dependencies to run the build process. @@ -86,20 +86,16 @@ You now have all the necessary dependencies to run the build process. ## Documentation -* [Roots 101](http://roots.io/roots-101/) — A guide to installing Roots, the files, and theme organization -* [Theme Wrapper](http://roots.io/an-introduction-to-the-roots-theme-wrapper/) — Learn all about the theme wrapper -* [Build Script](http://roots.io/using-gulp-for-wordpress-theme-development/) — A look into how Roots uses gulp -* [Roots Sidebar](http://roots.io/the-roots-sidebar/) — Understand how to display or hide the sidebar in Roots +Roots documentation is available at [http://roots.io/docs/](http://roots.io/docs/). ## Contributing -Contributions are welcome from everyone. We have [contributing guidelines](CONTRIBUTING.md) to help you get started. You can help out by: +Contributions are welcome from everyone. We have [contributing guidelines](CONTRIBUTING.md) to help you get started. -* Reporting issues (please follow the [issue guidelines](https://github.com/necolas/issue-guidelines)) -* Fixing [issues](https://github.com/roots/roots/issues) -* Suggesting new features -* Answering questions on the [forum](http://discourse.roots.io/) +## Community -## Support +Keep track of development and community news. -Use the [Roots Discourse](http://discourse.roots.io/) to ask questions and get support. +* Participate on the [Roots Discourse](http://discourse.roots.io/) +* Follow [@rootswp on Twitter](https://twitter.com/rootswp) +* Read and subscribe to the [Roots Blog](http://roots.io/blog/) From b9722e93b5ef711488fd1b9598a08e10620984cc Mon Sep 17 00:00:00 2001 From: Austin Pray Date: Sun, 4 Jan 2015 20:04:07 -0600 Subject: [PATCH 040/143] fixes wiredep task --- gulpfile.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 9a97b0d..62bfcc9 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -119,9 +119,9 @@ gulp.task('build', ['styles', 'scripts', 'fonts', 'images'], function() { gulp.task('wiredep', function() { var wiredep = require('wiredep').stream; - gulp.src(obj.get(manifest, 'dependencies.theme.styles')) + gulp.src(globs.styles) .pipe(wiredep()) - .pipe(gulp.dest(manifest.buildPaths.src + 'styles/')); + .pipe(gulp.dest(path.dist + 'styles')); }); gulp.task('default', ['clean'], function() { From d87854d931fd74a607f7e0a44fdce830ebacaa34 Mon Sep 17 00:00:00 2001 From: Ben Word Date: Tue, 6 Jan 2015 11:53:32 -0600 Subject: [PATCH 041/143] Not needed --- bower.json | 5 ----- 1 file changed, 5 deletions(-) diff --git a/bower.json b/bower.json index 1d2d767..9f31974 100644 --- a/bower.json +++ b/bower.json @@ -7,11 +7,6 @@ ], "license": "MIT", "private": true, - "ignore": [ - "**/.*", - "node_modules", - "assets/vendor" - ], "dependencies": { "modernizr": "2.8.2", "jquery": "1.11.1", From fcc685f9df0d75930a9a9206f9ce075b91908a53 Mon Sep 17 00:00:00 2001 From: Ben Word Date: Tue, 6 Jan 2015 11:54:18 -0600 Subject: [PATCH 042/143] Update to jQuery 1.11.2 --- bower.json | 2 +- lib/assets.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bower.json b/bower.json index 9f31974..24f05f1 100644 --- a/bower.json +++ b/bower.json @@ -9,7 +9,7 @@ "private": true, "dependencies": { "modernizr": "2.8.2", - "jquery": "1.11.1", + "jquery": "1.11.2", "bootstrap": "3.3.1" }, "overrides": { diff --git a/lib/assets.php b/lib/assets.php index 5817999..d90862b 100644 --- a/lib/assets.php +++ b/lib/assets.php @@ -6,7 +6,7 @@ * 1. /theme/dist/styles/main.css * * Enqueue scripts in the following order: - * 1. jquery-1.11.1.js via Google CDN + * 1. jquery-1.11.2.js via Google CDN * 2. /theme/dist/scripts/modernizr.js * 3. /theme/dist/scripts/app.js * @@ -44,7 +44,7 @@ function roots_assets() { if (!is_admin() && current_theme_supports('jquery-cdn')) { wp_deregister_script('jquery'); - wp_register_script('jquery', '//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.js', array(), null, true); + wp_register_script('jquery', '//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.js', array(), null, true); add_filter('script_loader_src', 'roots_jquery_local_fallback', 10, 2); } From ebc18f724c9fb679688cf50e4e415ffb433555bb Mon Sep 17 00:00:00 2001 From: Ben Word Date: Fri, 9 Jan 2015 17:50:12 -0600 Subject: [PATCH 043/143] Add example of how to use bootstrap-sass --- assets/styles/main.scss.example | 12 ++++++++++++ bower.json | 21 +++++++++++++++++++++ package.json | 2 +- 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 assets/styles/main.scss.example diff --git a/assets/styles/main.scss.example b/assets/styles/main.scss.example new file mode 100644 index 0000000..5a3a5d6 --- /dev/null +++ b/assets/styles/main.scss.example @@ -0,0 +1,12 @@ +// How to get started using Bootstrap Sass: +// +// 1. Run `bower install bootstrap-sass-official --save` +// 2. Rename this file to `main.scss` and remove `main.less` +// 3. Update the `assets/manifest.json` styles dependenies to change `main.less` to `main.scss` +// +// Feel free to remove this file if you're using LESS + + +// bower:sass +@import "../../bower_components/bootstrap-sass-official/assets/stylesheets/_bootstrap.scss"; +// endbower diff --git a/bower.json b/bower.json index 24f05f1..69539c0 100644 --- a/bower.json +++ b/bower.json @@ -33,6 +33,27 @@ "./fonts/glyphicons-halflings-regular.ttf", "./fonts/glyphicons-halflings-regular.woff" ] + }, + "bootstrap-sass-official": { + "main": [ + "./assets/stylesheets/_bootstrap.scss", + "./assets/javascripts/transition.js", + "./assets/javascripts/alert.js", + "./assets/javascripts/button.js", + "./assets/javascripts/carousel.js", + "./assets/javascripts/collapse.js", + "./assets/javascripts/dropdown.js", + "./assets/javascripts/modal.js", + "./assets/javascripts/tooltip.js", + "./assets/javascripts/popover.js", + "./assets/javascripts/scrollspy.js", + "./assets/javascripts/tab.js", + "./assets/javascripts/affix.js", + "./assets/fonts/glyphicons-halflings-regular.eot", + "./assets/fonts/glyphicons-halflings-regular.svg", + "./assets/fonts/glyphicons-halflings-regular.ttf", + "./assets/fonts/glyphicons-halflings-regular.woff" + ] } } } diff --git a/package.json b/package.json index 0ea6de5..2d4e926 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "gulp-postcss": "^3.0.0", "gulp-rename": "^1.2.0", "gulp-rev": "^2.0.1", - "gulp-sass": "^1.1.0", + "gulp-sass": "^1.2.4", "gulp-sourcemaps": "^1.1.1", "gulp-uglify": "^1.0.1", "imagemin-pngcrush": "^4.0.0", From 2ac5a1e0d422192edc88371abb86e6657ef57eac Mon Sep 17 00:00:00 2001 From: Ben Word Date: Fri, 9 Jan 2015 18:41:51 -0600 Subject: [PATCH 044/143] README tweaks --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ee64572..0bf62e2 100644 --- a/README.md +++ b/README.md @@ -65,15 +65,15 @@ Edit `lib/init.php` to setup navigation menus, post thumbnail sizes, post format ## Theme development -Roots uses [gulp](http://gulpjs.com/) as its build system. +Roots uses [gulp](http://gulpjs.com/) as its build system and [Bower](http://bower.io/) to manage front-end packages. -### Install gulp +### Install gulp and Bower **Unfamiliar with npm? Don't have node installed?** [Download and install node.js](http://nodejs.org/download/) before proceeding. From the command line: -1. Install [gulp](http://gulpjs.com) and [Bower](http://bower.io) globally with `npm install -g gulp bower` +1. Install [gulp](http://gulpjs.com) and [Bower](http://bower.io/) globally with `npm install -g gulp bower` 2. Navigate to the theme directory, then run `npm install` You now have all the necessary dependencies to run the build process. From eaf4d7b73bd1382e3a07771fd19c25cadb2ab91e Mon Sep 17 00:00:00 2001 From: Ben Word Date: Fri, 9 Jan 2015 19:15:24 -0600 Subject: [PATCH 045/143] Fix error after master merge because of new assets directory structure --- assets/{less => styles}/components/_comments.less | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename assets/{less => styles}/components/_comments.less (100%) diff --git a/assets/less/components/_comments.less b/assets/styles/components/_comments.less similarity index 100% rename from assets/less/components/_comments.less rename to assets/styles/components/_comments.less From 030c084134d28a93ab1fe7dbcb83717e3e1e33a0 Mon Sep 17 00:00:00 2001 From: Ben Word Date: Fri, 9 Jan 2015 20:48:11 -0600 Subject: [PATCH 046/143] Rename to Sage --- 404.php | 8 +-- CONTRIBUTING.md | 12 ++-- README.md | 24 +++---- assets/scripts/main.js | 8 +-- assets/styles/main.less | 5 +- base.php | 8 +-- bower.json | 6 +- functions.php | 12 ++-- index.php | 6 +- lang/{roots.pot => sage.pot} | 0 lib/activation.php | 136 +++++++++++++++++------------------ lib/assets.php | 22 +++--- lib/config.php | 14 ++-- lib/extras.php | 6 +- lib/gallery.php | 8 +-- lib/init.php | 20 +++--- lib/nav.php | 26 +++---- lib/sidebar.php | 4 +- lib/titles.php | 8 +-- lib/utils.php | 8 +-- lib/wrapper.php | 18 ++--- package.json | 10 +-- style.css | 8 +-- templates/comments.php | 8 +-- templates/content-single.php | 2 +- templates/entry-meta.php | 2 +- templates/header.php | 2 +- templates/page-header.php | 2 +- templates/searchform.php | 6 +- 29 files changed, 198 insertions(+), 201 deletions(-) rename lang/{roots.pot => sage.pot} (100%) diff --git a/404.php b/404.php index 51f0483..48ff9d2 100644 --- a/404.php +++ b/404.php @@ -1,13 +1,13 @@
- +
-

+

    -
  • -
  • +
  • +
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 84bf86c..2ff8401 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,4 +1,4 @@ -# Contributing to Roots Theme +# Contributing to Sage Please take a moment to review this document in order to make the contribution process easy and effective for everyone involved. @@ -36,7 +36,7 @@ Guidelines for bug reports: 2. **Check if the issue has been fixed** — try to reproduce it using the latest `master` or development branch in the repository. -3. **Isolate the problem to Roots** — make sure that the code in the Roots +3. **Isolate the problem to Sage** — make sure that the code in the Sage repository is _definitely_ responsible for the issue. Switch to a core WordPress theme (such as Twenty Thirteen) to confirm problems before reporting an issue. Make sure you have reproduced the bug with all plugins disabled. Any issues @@ -51,7 +51,7 @@ information. Please try to be as detailed as possible in your report. ## Feature requests Feature requests are welcome. But take a moment to find out whether your idea -fits with the scope and aims of Roots. It's up to *you* to make a strong +fits with the scope and aims of Sage. It's up to *you* to make a strong case to convince the Roots developers of the merits of this feature. Please provide as much detail and context as possible. @@ -65,15 +65,15 @@ commits. **Please ask first** before embarking on any significant pull request (e.g. implementing features, refactoring code), otherwise you risk spending a lot of -time working on something that the developers might not want to merge into Roots. +time working on something that the developers might not want to merge into Sage. Please adhere to the coding conventions used throughout the project (indentation, comments, etc.). Adhering to the following this process is the best way to get your work -included in Roots: +included in Sage: -1. [Fork](http://help.github.com/fork-a-repo/) Roots, clone your fork, +1. [Fork](http://help.github.com/fork-a-repo/) Sage, clone your fork, and configure the remotes: ```bash diff --git a/README.md b/README.md index 0bf62e2..1385741 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ -# [Roots Starter Theme](http://roots.io/) +# [Sage Starter Theme](http://roots.io/sage/) [![Build Status](https://travis-ci.org/roots/roots.svg)](https://travis-ci.org/roots/roots) [![devDependency Status](https://david-dm.org/roots/roots/dev-status.svg)](https://david-dm.org/roots/roots#info=devDependencies) -Roots is a WordPress starter theme based on [HTML5 Boilerplate](http://html5boilerplate.com/) that will help you make better themes. +Sage is a WordPress starter theme based on [HTML5 Boilerplate](http://html5boilerplate.com/) that will help you make better themes. -* Source: [https://github.com/roots/roots](https://github.com/roots/roots) -* Homepage: [http://roots.io/](http://roots.io/) -* Documentation: [http://roots.io/docs/](http://roots.io/docs/) +* Source: [https://github.com/roots/sage](https://github.com/roots/sage) +* Homepage: [http://roots.io/sage/](http://roots.io/sage/) +* Documentation: [http://roots.io/sage/getting-started/](http://roots.io/sage/getting-started/) * Twitter: [@rootswp](https://twitter.com/rootswp), [@retlehs](https://twitter.com/retlehs), [@swalkinshaw](https://twitter.com/swalkinshaw), [@Foxaii](https://twitter.com/Foxaii), [@c2foryou](https://twitter.com/c2foryou), [@austinpray](https://twitter.com/austinpray) * Newsletter: [Subscribe](http://roots.io/subscribe/) * Forum: [http://discourse.roots.io/](http://discourse.roots.io/) @@ -22,12 +22,12 @@ Roots is a WordPress starter theme based on [HTML5 Boilerplate](http://html5boil * [Bootstrap](http://getbootstrap.com/) * ARIA roles and microformats * [Theme activation](http://roots.io/roots-101/#theme-activation) -* [Theme wrapper](http://roots.io/an-introduction-to-the-roots-theme-wrapper/) +* [Theme wrapper](http://roots.io/sage/getting-started/theme-wrapper/) * Cleaner HTML output of navigation menus * Posts use the [hNews](http://microformats.org/wiki/hnews) microformat -* [Multilingual ready](http://roots.io/wpml/) and over 30 available [community translations](https://github.com/roots/roots-translations) +* [Multilingual ready](http://roots.io/wpml/) and over 30 available [community translations](https://github.com/roots/sage-translations) -### Go further with Roots +### Go further with Sage #### Clean up WordPress Install the [Soil](https://github.com/roots/soil) plugin to enable additional features: @@ -45,7 +45,7 @@ Install the [Soil](https://github.com/roots/soil) plugin to enable additional fe ## Installation -Clone the git repo - `git clone https://github.com/roots/roots.git` - or [download it](https://github.com/roots/roots/zipball/master) and then rename the directory to the name of your theme or website. +Clone the git repo - `git clone https://github.com/roots/sage.git` and then rename the directory to the name of your theme or website. If you don't use [Bedrock](https://github.com/roots/bedrock), you'll need to add the following to your `wp-config.php` on your development installation: @@ -55,7 +55,7 @@ define('WP_ENV', 'development'); ## Theme activation -Reference the [theme activation](http://roots.io/roots-101/#theme-activation) documentation to understand everything that happens once you activate Roots. +Reference the [theme activation](http://roots.io/roots-101/#theme-activation) documentation to understand everything that happens once you activate Sage. ## Configuration @@ -65,7 +65,7 @@ Edit `lib/init.php` to setup navigation menus, post thumbnail sizes, post format ## Theme development -Roots uses [gulp](http://gulpjs.com/) as its build system and [Bower](http://bower.io/) to manage front-end packages. +Sage uses [gulp](http://gulpjs.com/) as its build system and [Bower](http://bower.io/) to manage front-end packages. ### Install gulp and Bower @@ -86,7 +86,7 @@ You now have all the necessary dependencies to run the build process. ## Documentation -Roots documentation is available at [http://roots.io/docs/](http://roots.io/docs/). +Sage documentation is available at [http://roots.io/sage/getting-started/](http://roots.io/sage/getting-started/). ## Contributing diff --git a/assets/scripts/main.js b/assets/scripts/main.js index a0ad193..846502e 100644 --- a/assets/scripts/main.js +++ b/assets/scripts/main.js @@ -6,7 +6,7 @@ * replace the dash with an underscore when adding it to the object below. * * .noConflict() - * The routing is enclosed within an anonymous function so that you can + * The routing is enclosed within an anonymous function so that you can * always reference jQuery with $, even when in .noConflict() mode. * * Google CDN, Latest jQuery @@ -16,9 +16,9 @@ (function($) { -// Use this variable to set up the common and page specific functions. If you +// Use this variable to set up the common and page specific functions. If you // rename this variable, you will also need to rename the namespace below. -var Roots = { +var Sage = { // All pages common: { init: function() { @@ -43,7 +43,7 @@ var Roots = { // Add additional events for more control over timing e.g. a finalize event var UTIL = { fire: function(func, funcname, args) { - var namespace = Roots; + var namespace = Sage; funcname = (funcname === undefined) ? 'init' : funcname; if (func !== '' && namespace[func] && typeof namespace[func][funcname] === 'function') { namespace[func][funcname](args); diff --git a/assets/styles/main.less b/assets/styles/main.less index 544da42..08ec483 100644 --- a/assets/styles/main.less +++ b/assets/styles/main.less @@ -2,10 +2,7 @@ @import "../../bower_components/bootstrap/less/bootstrap.less"; // endbower -// Variable overrides and custom variables -@import "_variables"; - -// Roots +@import "_variables"; // Variable overrides and custom variables @import "_global"; // Base styling & custom mixins @import "components/_buttons"; // Button tweaks @import "components/_comments"; // Comment styling diff --git a/base.php b/base.php index 9828b4c..7f8f1e9 100644 --- a/base.php +++ b/base.php @@ -3,7 +3,7 @@ @@ -15,11 +15,11 @@
- +
- +
diff --git a/bower.json b/bower.json index 322883d..4745feb 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { - "name": "roots", - "version": "7.0.3", - "homepage": "http://roots.io", + "name": "sage", + "version": "8.0.0", + "homepage": "http://roots.io/sage/", "authors": [ "Ben Word " ], diff --git a/functions.php b/functions.php index 119939b..6cdbb1a 100644 --- a/functions.php +++ b/functions.php @@ -1,15 +1,15 @@
- +
@@ -14,8 +14,8 @@ max_num_pages > 1) : ?> diff --git a/lang/roots.pot b/lang/sage.pot similarity index 100% rename from lang/roots.pot rename to lang/sage.pot diff --git a/lib/activation.php b/lib/activation.php index fef50f7..01f10e5 100644 --- a/lib/activation.php +++ b/lib/activation.php @@ -7,29 +7,29 @@ if (is_admin() && isset($_GET['activated']) && 'themes.php' == $GLOBALS['pagenow exit; } -function roots_theme_activation_options_init() { +function sage_theme_activation_options_init() { register_setting( - 'roots_activation_options', - 'roots_theme_activation_options' + 'sage_activation_options', + 'sage_theme_activation_options' ); } -add_action('admin_init', 'roots_theme_activation_options_init'); +add_action('admin_init', 'sage_theme_activation_options_init'); -function roots_activation_options_page_capability() { +function sage_activation_options_page_capability() { return 'edit_theme_options'; } -add_filter('option_page_capability_roots_activation_options', 'roots_activation_options_page_capability'); +add_filter('option_page_capability_sage_activation_options', 'sage_activation_options_page_capability'); -function roots_theme_activation_options_add_page() { - $roots_activation_options = roots_get_theme_activation_options(); +function sage_theme_activation_options_add_page() { + $sage_activation_options = sage_get_theme_activation_options(); - if (!$roots_activation_options) { + if (!$sage_activation_options) { add_theme_page( - __('Theme Activation', 'roots'), - __('Theme Activation', 'roots'), + __('Theme Activation', 'sage'), + __('Theme Activation', 'sage'), 'edit_theme_options', 'theme_activation_options', - 'roots_theme_activation_options_render_page' + 'sage_theme_activation_options_render_page' ); } else { if (is_admin() && isset($_GET['page']) && $_GET['page'] === 'theme_activation_options') { @@ -39,68 +39,68 @@ function roots_theme_activation_options_add_page() { } } } -add_action('admin_menu', 'roots_theme_activation_options_add_page', 50); +add_action('admin_menu', 'sage_theme_activation_options_add_page', 50); -function roots_get_theme_activation_options() { - return get_option('roots_theme_activation_options'); +function sage_get_theme_activation_options() { + return get_option('sage_theme_activation_options'); } -function roots_theme_activation_options_render_page() { ?> +function sage_theme_activation_options_render_page() { ?>
-

+

- +
- + - + - + - + - + @@ -111,8 +111,8 @@ function roots_theme_activation_options_render_page() { ?> ID); @@ -155,8 +155,8 @@ function roots_theme_activation_action() { wp_update_post($home_menu_order); } - if ($roots_theme_activation_options['change_permalink_structure'] === 'true') { - $roots_theme_activation_options['change_permalink_structure'] = false; + if ($sage_theme_activation_options['change_permalink_structure'] === 'true') { + $sage_theme_activation_options['change_permalink_structure'] = false; if (get_option('permalink_structure') !== '/%postname%/') { global $wp_rewrite; @@ -165,29 +165,29 @@ function roots_theme_activation_action() { } } - if ($roots_theme_activation_options['create_navigation_menus'] === 'true') { - $roots_theme_activation_options['create_navigation_menus'] = false; + if ($sage_theme_activation_options['create_navigation_menus'] === 'true') { + $sage_theme_activation_options['create_navigation_menus'] = false; - $roots_nav_theme_mod = false; + $sage_nav_theme_mod = false; - $primary_nav = wp_get_nav_menu_object(__('Primary Navigation', 'roots')); + $primary_nav = wp_get_nav_menu_object(__('Primary Navigation', 'sage')); if (!$primary_nav) { - $primary_nav_id = wp_create_nav_menu(__('Primary Navigation', 'roots'), array('slug' => 'primary_navigation')); - $roots_nav_theme_mod['primary_navigation'] = $primary_nav_id; + $primary_nav_id = wp_create_nav_menu(__('Primary Navigation', 'sage'), array('slug' => 'primary_navigation')); + $sage_nav_theme_mod['primary_navigation'] = $primary_nav_id; } else { - $roots_nav_theme_mod['primary_navigation'] = $primary_nav->term_id; + $sage_nav_theme_mod['primary_navigation'] = $primary_nav->term_id; } - if ($roots_nav_theme_mod) { - set_theme_mod('nav_menu_locations', $roots_nav_theme_mod); + if ($sage_nav_theme_mod) { + set_theme_mod('nav_menu_locations', $sage_nav_theme_mod); } } - if ($roots_theme_activation_options['add_pages_to_primary_navigation'] === 'true') { - $roots_theme_activation_options['add_pages_to_primary_navigation'] = false; + if ($sage_theme_activation_options['add_pages_to_primary_navigation'] === 'true') { + $sage_theme_activation_options['add_pages_to_primary_navigation'] = false; - $primary_nav = wp_get_nav_menu_object(__('Primary Navigation', 'roots')); + $primary_nav = wp_get_nav_menu_object(__('Primary Navigation', 'sage')); $primary_nav_term_id = (int) $primary_nav->term_id; $menu_items= wp_get_nav_menu_items($primary_nav_term_id); @@ -205,11 +205,11 @@ function roots_theme_activation_action() { } } - update_option('roots_theme_activation_options', $roots_theme_activation_options); + update_option('sage_theme_activation_options', $sage_theme_activation_options); } -add_action('admin_init','roots_theme_activation_action'); +add_action('admin_init','sage_theme_activation_action'); -function roots_deactivation() { - delete_option('roots_theme_activation_options'); +function sage_deactivation() { + delete_option('sage_theme_activation_options'); } -add_action('switch_theme', 'roots_deactivation'); +add_action('switch_theme', 'sage_deactivation'); diff --git a/lib/assets.php b/lib/assets.php index d90862b..307bc4e 100644 --- a/lib/assets.php +++ b/lib/assets.php @@ -14,7 +14,7 @@ * - An ID has been defined in config.php * - You're not logged in as an administrator */ -function roots_asset_path($filename) { +function sage_asset_path($filename) { if (WP_ENV === 'development') { return get_template_directory_uri() . '/dist/' . $filename; } @@ -32,8 +32,8 @@ function roots_asset_path($filename) { } } -function roots_assets() { - wp_enqueue_style('roots_css', roots_asset_path('styles/main.css'), false, null); +function sage_assets() { + wp_enqueue_style('sage_css', sage_asset_path('styles/main.css'), false, null); /** * Grab Google CDN's latest jQuery with a protocol relative URL; fallback to local if offline @@ -46,21 +46,21 @@ function roots_assets() { wp_register_script('jquery', '//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.js', array(), null, true); - add_filter('script_loader_src', 'roots_jquery_local_fallback', 10, 2); + add_filter('script_loader_src', 'sage_jquery_local_fallback', 10, 2); } if (is_single() && comments_open() && get_option('thread_comments')) { wp_enqueue_script('comment-reply'); } - wp_enqueue_script('modernizr', roots_asset_path('scripts/modernizr.js'), array(), null, true); + wp_enqueue_script('modernizr', sage_asset_path('scripts/modernizr.js'), array(), null, true); wp_enqueue_script('jquery'); - wp_enqueue_script('roots_js', roots_asset_path('scripts/app.js'), array(), null, true); + wp_enqueue_script('sage_js', sage_asset_path('scripts/app.js'), array(), null, true); } -add_action('wp_enqueue_scripts', 'roots_assets', 100); +add_action('wp_enqueue_scripts', 'sage_assets', 100); // http://wordpress.stackexchange.com/a/12450 -function roots_jquery_local_fallback($src, $handle = null) { +function sage_jquery_local_fallback($src, $handle = null) { static $add_jquery_fallback = false; if ($add_jquery_fallback) { @@ -74,14 +74,14 @@ function roots_jquery_local_fallback($src, $handle = null) { return $src; } -add_action('wp_head', 'roots_jquery_local_fallback'); +add_action('wp_head', 'sage_jquery_local_fallback'); /** * Google Analytics snippet from HTML5 Boilerplate * * Cookie domain is 'auto' configured. See: http://goo.gl/VUCHKM */ -function roots_google_analytics() { ?> +function sage_google_analytics() { ?> "> - + + diff --git a/templates/head.php b/templates/head.php index d081d0c..f36abe6 100644 --- a/templates/head.php +++ b/templates/head.php @@ -5,7 +5,7 @@ - + diff --git a/templates/header.php b/templates/header.php index 6656578..56995f1 100644 --- a/templates/header.php +++ b/templates/header.php @@ -9,7 +9,7 @@ - +
- - + + -

+

- - + + -

+

- - + + -

+

- - + + -

+