-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
192 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,16 @@ | ||
# http://editorconfig.org | ||
root = true | ||
|
||
[*] | ||
indent_style = tab | ||
indent_size = 4 | ||
indent_size = 2 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false | ||
[package.json] | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[test/fixtures/*] | ||
insert_final_newline = false | ||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
* text=auto | ||
* text=auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
node_modules | ||
.DS_Store | ||
node_modules/ | ||
temp/ | ||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,14 @@ | ||
{ | ||
"node": true, | ||
"esnext": true, | ||
"bitwise": true, | ||
"camelcase": true, | ||
"curly": true, | ||
"eqeqeq": true, | ||
"immed": true, | ||
"indent": 4, | ||
"latedef": true, | ||
"newcap": true, | ||
"noarg": true, | ||
"quotmark": "double", | ||
"regexp": true, | ||
"undef": true, | ||
"unused": true, | ||
"strict": true, | ||
"trailing": true, | ||
"smarttabs": true, | ||
"white": true | ||
"node": true, | ||
"esnext": true, | ||
"bitwise": true, | ||
"camelcase": true, | ||
"curly": true, | ||
"immed": true, | ||
"newcap": true, | ||
"noarg": true, | ||
"undef": true, | ||
"unused": "vars", | ||
"strict": true, | ||
"mocha": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
sudo: false | ||
language: node_js | ||
node_js: | ||
- '0.8' | ||
- 'iojs' | ||
- '0.12' | ||
- '0.10' | ||
after_script: | ||
- npm run coveralls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,21 @@ | ||
Copyright 2014 Raúl | ||
The MIT License (MIT) | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
Copyright (c) raulghm <[email protected]> | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
'use strict'; | ||
|
||
var gulp = require('gulp'); | ||
var runSequence = require('run-sequence'); | ||
var wpRev = require('gulp-wp-rev'); | ||
|
||
gulp.task('rev', function () { | ||
gulp.src('./wp-content/themes/raulghm-theme/lib/scripts.php') | ||
.pipe(wpRev({ | ||
css: 'src/styles/styles.css', | ||
cssHandle: 'my_assets', | ||
js: 'src/scripts/scripts.js', | ||
jsHandle: 'my_assets' | ||
})) | ||
.pipe(gulp.dest('./wp-content/themes/raulghm-theme/lib')); | ||
}); | ||
|
||
gulp.task('build', function (callback) { | ||
runSequence( | ||
'rev', | ||
function (error) { | ||
if (error) { | ||
console.log(error.message); | ||
} else { | ||
console.log('Build finished successfully :)'); | ||
} | ||
callback(error); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "example", | ||
"version": "1.0.0", | ||
"description": "example", | ||
"main": "gulpfile.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"build": "gulp build" | ||
}, | ||
"author": "raulghm", | ||
"license": "MIT", | ||
"devDependencies": { | ||
"gulp": "^3.9.0", | ||
"gulp-wp-rev": "0.0.1", | ||
"run-sequence": "^1.1.5" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log('Más vale código en mano que líneas volando'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
body { | ||
background: #bbb; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
|
||
|
||
<?php | ||
/** | ||
* Enqueue scripts and stylesheets | ||
* | ||
* Simple example | ||
*/ | ||
|
||
function my_assets_function() { | ||
wp_enqueue_style('my_assets', get_template_directory_uri() . '/assets/styles/styles.css', false, '99751aae501b70d8edb1be6d827adefd'); | ||
wp_register_script('my_assets', get_template_directory_uri() . '/assets/scripts/scripts.js', array(), '892354e5fc462fba85da60adb9b87ce7'); | ||
wp_enqueue_script('my_assets'); | ||
} | ||
|
||
add_action('wp_enqueue_scripts', 'my_assets_function', 10); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,48 @@ | ||
var through = require("through2"), | ||
gutil = require("gulp-util"); | ||
fs = require('fs'); | ||
crypto = require('crypto'); | ||
|
||
'use strict'; | ||
var gutil = require('gulp-util'); | ||
var through = require('through2'); | ||
var fs = require('fs'); | ||
var crypto = require('crypto'); | ||
var md5 = function(str) { | ||
var hash = crypto.createHash('md5'); | ||
hash.update(fs.readFileSync(str)); | ||
return hash.digest('hex'); | ||
}; | ||
|
||
module.exports = function(options) { | ||
"use strict"; | ||
|
||
var o = options || {}; | ||
|
||
function foo(file, enc, callback) { | ||
module.exports = function (options) { | ||
options = options || {}; | ||
|
||
// Do nothing if no contents | ||
return through.obj(function (file, enc, cb) { | ||
if (file.isNull()) { | ||
this.push(file); | ||
return callback(); | ||
cb(null, file); | ||
return; | ||
} | ||
|
||
if (file.isStream()) { | ||
// accepting streams is optional | ||
this.emit("error", | ||
new gutil.PluginError("gulp-foo", "Stream content is not supported")); | ||
return callback(); | ||
cb(new gutil.PluginError('gulp-wp-rev', 'Streaming not supported')); | ||
return; | ||
} | ||
|
||
// check if file.contents is a `Buffer` | ||
if (file.isBuffer()) { | ||
|
||
file.contents = new Buffer(String(file.contents)); | ||
if (o.css && o.cssHandle) { | ||
var regexCss = new RegExp("(wp_enqueue_style\\('" + o.cssHandle + "',(\\s*[^,]+,){2})\\s*[^\\)]+\\);"); | ||
var hashCss = md5(o.css); | ||
file.contents = new Buffer(String(file.contents)); | ||
|
||
if (options.css && options.cssHandle) { | ||
var regexCss = new RegExp("(wp_enqueue_style\\('" + options.cssHandle + "',(\\s*[^,]+,){2})\\s*[^\\)]+\\);"); | ||
var hashCss = md5(options.css); | ||
file.contents = new Buffer(String(file.contents).replace(regexCss, "$1 '" + hashCss + "');")); | ||
} | ||
|
||
if (o.js && o.jsHandle) { | ||
var regexJs = new RegExp("(wp_register_script\\('" + o.jsHandle + "',(\\s*[^,]+,){2})\\s*[^\\)]+\\);"); | ||
var hashJs = md5(o.js); | ||
if (options.js && options.jsHandle) { | ||
var regexJs = new RegExp("(wp_register_script\\('" + options.jsHandle + "',(\\s*[^,]+,){2})\\s*[^\\)]+\\);"); | ||
var hashJs = md5(options.js); | ||
file.contents = new Buffer(String(file.contents).replace(regexJs, "$1 '" + hashJs + "');")); | ||
} | ||
} | ||
|
||
this.push(file); | ||
} | ||
return callback(); | ||
} | ||
|
||
return through.obj(foo); | ||
cb(); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,23 @@ | ||
{ | ||
"name": "gulp-wp-rev", | ||
"version": "0.1.0", | ||
"description": "Revisioning JS and CSS to scripts.php file on wordpress assets", | ||
"version": "0.2.0", | ||
"description": "Revisioning CSS/JS appending a hash in you assets of wordpress theme", | ||
"license": "MIT", | ||
"repository": "raulghm/gulp-wp-rev", | ||
"author": { | ||
"name": "raulghm", | ||
"email": "[email protected]", | ||
"url": "https://github.com/raulghm" | ||
}, | ||
"engines": { | ||
"node": ">=0.10.0" | ||
}, | ||
"scripts": { | ||
"test": "mocha" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"gulpplugin", | ||
"wordpress" | ||
|
@@ -14,32 +30,13 @@ | |
"cache", | ||
"expire", | ||
"static", | ||
"asset", | ||
"assets" | ||
], | ||
"homepage": "https://github.com/raulghm/gulp-wp-rev", | ||
"bugs": "https://github.com/raulghm/gulp-wp-rev/issues", | ||
"author": { | ||
"name": "Raul Hernandez", | ||
"email": "[email protected]", | ||
"url": "https://github.com/raulghm" | ||
}, | ||
"main": "./index.js", | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/raulghm/gulp-wp-rev.git" | ||
}, | ||
"dependencies": { | ||
"through2": "*", | ||
"gulp-util": "~2.2.0" | ||
}, | ||
"engines": { | ||
"node": ">=0.8.0", | ||
"npm": ">=1.2.10" | ||
"gulp-util": "^3.0.1", | ||
"through2": "^0.6.3" | ||
}, | ||
"licenses": [ | ||
{ | ||
"type": "MIT" | ||
} | ||
] | ||
"devDependencies": { | ||
"mocha": "*" | ||
} | ||
} |
Oops, something went wrong.