Add support for grunt 0.4.0
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,2 +1,3 @@
|
|||||||
# Include your project-specific ignores in this file
|
# Include your project-specific ignores in this file
|
||||||
# Read about how to use .gitignore: https://help.github.com/articles/ignoring-files
|
# Read about how to use .gitignore: https://help.github.com/articles/ignoring-files
|
||||||
|
node_modules
|
||||||
|
|||||||
18
.jshintrc
Normal file
18
.jshintrc
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"bitwise": true,
|
||||||
|
"browser": true,
|
||||||
|
"curly": true,
|
||||||
|
"eqeqeq": true,
|
||||||
|
"eqnull": true,
|
||||||
|
"es5": true,
|
||||||
|
"esnext": true,
|
||||||
|
"immed": true,
|
||||||
|
"jquery": true,
|
||||||
|
"latedef": true,
|
||||||
|
"newcap": true,
|
||||||
|
"noarg": true,
|
||||||
|
"node": true,
|
||||||
|
"strict": false,
|
||||||
|
"trailing": true,
|
||||||
|
"undef": true
|
||||||
|
}
|
||||||
95
Gruntfile.js
Normal file
95
Gruntfile.js
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
'use strict';
|
||||||
|
module.exports = function(grunt) {
|
||||||
|
|
||||||
|
grunt.initConfig({
|
||||||
|
jshint: {
|
||||||
|
options: {
|
||||||
|
jshintrc: '.jshintrc'
|
||||||
|
},
|
||||||
|
all: [
|
||||||
|
'Gruntfile.js',
|
||||||
|
'assets/js/*.js',
|
||||||
|
'assets/js/plugins/*.js',
|
||||||
|
'!assets/js/scripts.min.js'
|
||||||
|
]
|
||||||
|
},
|
||||||
|
recess: {
|
||||||
|
dist: {
|
||||||
|
options: {
|
||||||
|
compile: true,
|
||||||
|
compress: true
|
||||||
|
},
|
||||||
|
files: {
|
||||||
|
'assets/css/main.min.css': [
|
||||||
|
'assets/css/less/bootstrap/bootstrap.less',
|
||||||
|
'assets/css/less/bootstrap/responsive.less',
|
||||||
|
'assets/css/less/app.less'
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
uglify: {
|
||||||
|
dist: {
|
||||||
|
files: {
|
||||||
|
'assets/js/scripts.min.js': [
|
||||||
|
'assets/js/plugins/bootstrap/bootstrap-transition.js',
|
||||||
|
'assets/js/plugins/bootstrap/bootstrap-alert.js',
|
||||||
|
'assets/js/plugins/bootstrap/bootstrap-button.js',
|
||||||
|
'assets/js/plugins/bootstrap/bootstrap-carousel.js',
|
||||||
|
'assets/js/plugins/bootstrap/bootstrap-collapse.js',
|
||||||
|
'assets/js/plugins/bootstrap/bootstrap-dropdown.js',
|
||||||
|
'assets/js/plugins/bootstrap/bootstrap-modla.js',
|
||||||
|
'assets/js/plugins/bootstrap/bootstrap-tooltip.js',
|
||||||
|
'assets/js/plugins/bootstrap/bootstrap-popover.js',
|
||||||
|
'assets/js/plugins/bootstrap/bootstrap-scrollspy.js',
|
||||||
|
'assets/js/plugins/bootstrap/bootstrap-tab.js',
|
||||||
|
'assets/js/plugins/bootstrap/bootstrap-typehead.js',
|
||||||
|
'assets/js/plugins/*.js',
|
||||||
|
'assets/js/_*.js'
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
less: {
|
||||||
|
files: [
|
||||||
|
'assets/css/less/*.less',
|
||||||
|
'assets/css/less/bootstrap/*.less'
|
||||||
|
],
|
||||||
|
tasks: ['recess']
|
||||||
|
},
|
||||||
|
js: {
|
||||||
|
files: [
|
||||||
|
'<%= jshint.all %>'
|
||||||
|
],
|
||||||
|
tasks: ['jshint']
|
||||||
|
}
|
||||||
|
},
|
||||||
|
clean: {
|
||||||
|
dist: [
|
||||||
|
'assets/css/main.min.css',
|
||||||
|
'assets/js/scripts.min.js'
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Load tasks
|
||||||
|
grunt.loadTasks('tasks');
|
||||||
|
grunt.loadNpmTasks('grunt-contrib-clean');
|
||||||
|
grunt.loadNpmTasks('grunt-contrib-jshint');
|
||||||
|
grunt.loadNpmTasks('grunt-contrib-uglify');
|
||||||
|
grunt.loadNpmTasks('grunt-contrib-watch');
|
||||||
|
grunt.loadNpmTasks('grunt-recess');
|
||||||
|
|
||||||
|
// Register tasks
|
||||||
|
grunt.registerTask('default', [
|
||||||
|
'clean',
|
||||||
|
'recess',
|
||||||
|
'uglify',
|
||||||
|
'version'
|
||||||
|
]);
|
||||||
|
grunt.registerTask('dev', [
|
||||||
|
'watch'
|
||||||
|
]);
|
||||||
|
|
||||||
|
};
|
||||||
7471
assets/css/main.css
7471
assets/css/main.css
File diff suppressed because it is too large
Load Diff
6
assets/css/main.min.css
vendored
6
assets/css/main.min.css
vendored
File diff suppressed because one or more lines are too long
@@ -1,7 +1,7 @@
|
|||||||
// Modified http://paulirish.com/2009/markup-based-unobtrusive-comprehensive-dom-ready-execution/
|
// Modified http://paulirish.com/2009/markup-based-unobtrusive-comprehensive-dom-ready-execution/
|
||||||
// Only fires on body class (working off strictly WordPress body_class)
|
// Only fires on body class (working off strictly WordPress body_class)
|
||||||
|
|
||||||
ExampleSite = {
|
var ExampleSite = {
|
||||||
// All pages
|
// All pages
|
||||||
common: {
|
common: {
|
||||||
init: function() {
|
init: function() {
|
||||||
@@ -23,7 +23,7 @@ ExampleSite = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
UTIL = {
|
var UTIL = {
|
||||||
fire: function(func, funcname, args) {
|
fire: function(func, funcname, args) {
|
||||||
var namespace = ExampleSite;
|
var namespace = ExampleSite;
|
||||||
funcname = (funcname === undefined) ? 'init' : funcname;
|
funcname = (funcname === undefined) ? 'init' : funcname;
|
||||||
@@ -43,4 +43,4 @@ UTIL = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$(document).ready(UTIL.loadEvents);
|
$(document).ready(UTIL.loadEvents);
|
||||||
|
|||||||
2209
assets/js/scripts.js
2209
assets/js/scripts.js
File diff suppressed because it is too large
Load Diff
3
assets/js/scripts.min.js
vendored
3
assets/js/scripts.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -1,42 +0,0 @@
|
|||||||
/**
|
|
||||||
* Task: enqueue_ver
|
|
||||||
* Description: Set the versions in scripts.php for CSS/JS
|
|
||||||
*/
|
|
||||||
|
|
||||||
module.exports = function(grunt) {
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var fs = require('fs');
|
|
||||||
var path = require('path');
|
|
||||||
var crypto = require('crypto');
|
|
||||||
|
|
||||||
grunt.registerTask('enqueue_ver', 'Set the versions in scripts.php for CSS/JS', function() {
|
|
||||||
var scriptsPhp = 'lib/scripts.php';
|
|
||||||
|
|
||||||
// Hash the CSS
|
|
||||||
var hashCss = grunt.helper('md5', 'assets/css/main.min.css');
|
|
||||||
|
|
||||||
// Hash the JS
|
|
||||||
var hashJs = grunt.helper('md5', 'assets/js/scripts.min.js');
|
|
||||||
|
|
||||||
// Update scripts.php to reference the new versions
|
|
||||||
var regexCss = /(wp_enqueue_style\('roots_main',(\s*[^,]+,){2})\s*[^\)]+\);/;
|
|
||||||
var regexJs = /(wp_register_script\('roots_scripts',(\s*[^,]+,){2})\s*[^,]+,\s*([^\)]+)\);/;
|
|
||||||
|
|
||||||
var content = grunt.file.read(scriptsPhp);
|
|
||||||
content = content.replace(regexCss, "\$1 '" + hashCss + "');");
|
|
||||||
content = content.replace(regexJs, "\$1 '" + hashJs + "', " + "\$3);");
|
|
||||||
grunt.file.write(scriptsPhp, content);
|
|
||||||
grunt.log.writeln('"' + scriptsPhp + '" updated with new CSS/JS versions.');
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The 'md5' helper is a basic wrapper around crypto.createHash
|
|
||||||
*/
|
|
||||||
grunt.registerHelper('md5', function(filepath) {
|
|
||||||
var hash = crypto.createHash('md5');
|
|
||||||
hash.update(fs.readFileSync(filepath));
|
|
||||||
grunt.log.write('Versioning ' + filepath + '...').ok();
|
|
||||||
return hash.digest('hex');
|
|
||||||
});
|
|
||||||
};
|
|
||||||
75
grunt.js
75
grunt.js
@@ -1,75 +0,0 @@
|
|||||||
module.exports = function(grunt) {
|
|
||||||
grunt.initConfig({
|
|
||||||
pkg: '<json:package.json>',
|
|
||||||
meta: {
|
|
||||||
banner: '/*! Roots <%= pkg.version %> - <%= pkg.homepage %> */'
|
|
||||||
},
|
|
||||||
lint: {
|
|
||||||
files: ['grunt.js', 'assets/js/_*.js']
|
|
||||||
},
|
|
||||||
recess: {
|
|
||||||
dist: {
|
|
||||||
src: [
|
|
||||||
'assets/css/less/bootstrap/bootstrap.less',
|
|
||||||
'assets/css/less/bootstrap/responsive.less',
|
|
||||||
'assets/css/less/app.less'
|
|
||||||
],
|
|
||||||
dest: 'assets/css/main.css',
|
|
||||||
options: {
|
|
||||||
compile: true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
concat: {
|
|
||||||
js: {
|
|
||||||
src: [
|
|
||||||
'assets/js/plugins/bootstrap/bootstrap-transition.js',
|
|
||||||
'assets/js/plugins/bootstrap/bootstrap-alert.js',
|
|
||||||
'assets/js/plugins/bootstrap/bootstrap-button.js',
|
|
||||||
'assets/js/plugins/bootstrap/bootstrap-carousel.js',
|
|
||||||
'assets/js/plugins/bootstrap/bootstrap-collapse.js',
|
|
||||||
'assets/js/plugins/bootstrap/bootstrap-dropdown.js',
|
|
||||||
'assets/js/plugins/bootstrap/bootstrap-modal.js',
|
|
||||||
'assets/js/plugins/bootstrap/bootstrap-tooltip.js',
|
|
||||||
'assets/js/plugins/bootstrap/bootstrap-popover.js',
|
|
||||||
'assets/js/plugins/bootstrap/bootstrap-scrollspy.js',
|
|
||||||
'assets/js/plugins/bootstrap/bootstrap-tab.js',
|
|
||||||
'assets/js/plugins/bootstrap/bootstrap-typeahead.js',
|
|
||||||
'assets/js/plugins/*.js',
|
|
||||||
'assets/js/_*.js'
|
|
||||||
],
|
|
||||||
dest: 'assets/js/scripts.js'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
min: {
|
|
||||||
dist: {
|
|
||||||
src: ['<banner>', 'assets/js/scripts.js'],
|
|
||||||
dest: 'assets/js/scripts.min.js'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mincss: {
|
|
||||||
compress: {
|
|
||||||
files: {
|
|
||||||
'assets/css/main.min.css': ['assets/css/main.css']
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
js: {
|
|
||||||
files: ['<config:lint.files>'],
|
|
||||||
tasks: 'js'
|
|
||||||
},
|
|
||||||
css: {
|
|
||||||
files: ['assets/css/less/**/*.less'],
|
|
||||||
tasks: 'css'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
grunt.loadTasks('build/tasks');
|
|
||||||
grunt.registerTask('default', 'lint recess concat min mincss enqueue_ver');
|
|
||||||
grunt.registerTask('js', 'lint concat min enqueue_ver');
|
|
||||||
grunt.registerTask('css', 'recess mincss enqueue_ver');
|
|
||||||
grunt.loadNpmTasks('grunt-contrib');
|
|
||||||
grunt.loadNpmTasks('grunt-recess');
|
|
||||||
};
|
|
||||||
@@ -4,11 +4,12 @@
|
|||||||
*
|
*
|
||||||
* Enqueue stylesheets in the following order:
|
* Enqueue stylesheets in the following order:
|
||||||
* 1. /theme/assets/css/main.min.css
|
* 1. /theme/assets/css/main.min.css
|
||||||
|
* 2. /child-theme/style.css (if a child theme is activated)
|
||||||
*
|
*
|
||||||
* Enqueue scripts in the following order:
|
* Enqueue scripts in the following order:
|
||||||
* 1. jquery-1.9.1.min.js via Google CDN
|
* 1. jquery-1.9.1.min.js via Google CDN
|
||||||
* 2. /theme/assets/js/vendor/modernizr-2.6.2.min.js
|
* 2. /theme/assets/js/vendor/modernizr-2.6.2.min.js
|
||||||
* 3. /theme/assets/js/scripts.min.js
|
* 3. /theme/assets/js/main.min.js (in footer)
|
||||||
*/
|
*/
|
||||||
function roots_scripts() {
|
function roots_scripts() {
|
||||||
wp_enqueue_style('roots_main', get_template_directory_uri() . '/assets/css/main.min.css', false, '99a8db779c85fab09c1780951893470f');
|
wp_enqueue_style('roots_main', get_template_directory_uri() . '/assets/css/main.min.css', false, '99a8db779c85fab09c1780951893470f');
|
||||||
|
|||||||
38
package.json
38
package.json
@@ -1,34 +1,28 @@
|
|||||||
{
|
{
|
||||||
"name": "roots",
|
"name": "roots",
|
||||||
"description": "A starting WordPress theme made for developers based on HTML5 Boilerplate & Bootstrap.",
|
|
||||||
"version": "6.3.0",
|
"version": "6.3.0",
|
||||||
"homepage": "http://www.rootstheme.com/",
|
|
||||||
"author": "Ben Word <ben@benword.com>",
|
"author": "Ben Word <ben@benword.com>",
|
||||||
"contributors": [
|
"homepage": "http://www.rootstheme.com",
|
||||||
{
|
|
||||||
"name": "Scott Walkinshaw",
|
|
||||||
"email": "scott.walkinshaw@gmail.com"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/retlehs/roots.git"
|
"url": "git://github.com/retlehs/roots.git"
|
||||||
},
|
},
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url" : "https://github.com/retlehs/roots/issues"
|
"url" : "https://github.com/retlehs/roots/issues"
|
||||||
},
|
},
|
||||||
"licenses": [
|
"licenses": [{
|
||||||
{
|
"type": "MIT",
|
||||||
"type": "MIT",
|
"url": "http://opensource.org/licenses/MIT"
|
||||||
"url": "https://github.com/retlehs/roots/blob/master/LICENSE.md"
|
}],
|
||||||
}
|
"engines": {
|
||||||
],
|
"node": ">= 0.8.0"
|
||||||
"dependencies": {
|
|
||||||
"grunt": "~0.3.15",
|
|
||||||
"grunt-contrib": "~0.2.0",
|
|
||||||
"grunt-recess": "~0.1.1",
|
|
||||||
"uglify-js": "~1.3.3",
|
|
||||||
"jshint": "~0.5.9"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {}
|
"devDependencies": {
|
||||||
|
"grunt": "~0.4.0",
|
||||||
|
"grunt-contrib-clean": "~0.4.0",
|
||||||
|
"grunt-contrib-jshint": "~0.1.1",
|
||||||
|
"grunt-contrib-uglify": "~0.1.1",
|
||||||
|
"grunt-contrib-watch": "~0.2.0",
|
||||||
|
"grunt-recess": "~0.3.0"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
42
tasks/version.js
Normal file
42
tasks/version.js
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
/**
|
||||||
|
* Task: version
|
||||||
|
* Set the versions in scripts.php for CSS/JS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var fs = require('fs'),
|
||||||
|
path = require('path'),
|
||||||
|
crypto = require('crypto');
|
||||||
|
|
||||||
|
module.exports = function(grunt) {
|
||||||
|
grunt.registerTask('version', 'Set the versions in scripts.php for CSS/JS', function() {
|
||||||
|
var scriptsPhp = 'lib/scripts.php';
|
||||||
|
|
||||||
|
// Hash the CSS
|
||||||
|
var hashCss = md5('assets/css/main.min.css');
|
||||||
|
|
||||||
|
// Hash the JS
|
||||||
|
var hashJs = md5('assets/js/scripts.min.js');
|
||||||
|
|
||||||
|
// Update scripts.php to reference the new versions
|
||||||
|
var regexCss = /(wp_enqueue_style\('roots_css',(\s*[^,]+,){2})\s*[^\)]+\);/;
|
||||||
|
var regexJs = /(wp_register_script\('roots_js',(\s*[^,]+,){2})\s*[^,]+,\s*([^\)]+)\);/;
|
||||||
|
|
||||||
|
var content = grunt.file.read(scriptsPhp);
|
||||||
|
content = content.replace(regexCss, "\$1 '" + hashCss + "');");
|
||||||
|
content = content.replace(regexJs, "\$1 '" + hashJs + "', " + "\$3);");
|
||||||
|
grunt.file.write(scriptsPhp, content);
|
||||||
|
grunt.log.writeln('"' + scriptsPhp + '" updated with new CSS/JS versions.');
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 'md5' is a basic wrapper around crypto.createHash
|
||||||
|
*/
|
||||||
|
var md5 = function(filepath) {
|
||||||
|
var hash = crypto.createHash('md5');
|
||||||
|
hash.update(fs.readFileSync(filepath));
|
||||||
|
grunt.log.write('Versioning ' + filepath + '...').ok();
|
||||||
|
return hash.digest('hex');
|
||||||
|
};
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user