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
0 parents
commit e321d31
Showing
13 changed files
with
312 additions
and
0 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
* 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 |
---|---|---|
@@ -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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"indent" : 2, | ||
"latedef" : true, | ||
"newcap" : true, | ||
"nonew" : true, | ||
"plusplus" : true, | ||
"quotmark" : "single", | ||
|
||
"node": true, | ||
|
||
"globals": { "hexo": 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,2 @@ | ||
test/ | ||
.jshintrc |
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,4 @@ | ||
# Changelog | ||
|
||
## 0.1.0 (July 19, 2015) | ||
* Initial version. |
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,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2015 Mark van Seventer | ||
|
||
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# more-css plugin for [Hexo](https://hexo.io) | ||
> Compress CSS with [more-css](https://www.npmjs.com/package/more-css). | ||
## Install | ||
```bash | ||
$ npm install hexo-more-css --save | ||
``` | ||
|
||
## Options | ||
You can configure this plugin in `_config.yml`. | ||
|
||
```yaml | ||
more_css: | ||
enabled : true | ||
exclude : *.min.css | ||
radical : true | ||
``` | ||
|
||
- **enabled** - Enable the plugin. Defaults to `true`. | ||
- **exclude** - Exclude files. | ||
- **radical** - Apply further minimization. Defaults to `true`. | ||
|
||
## Changelog | ||
See the [Changelog](./CHANGELOG.md) for a list of changes. | ||
|
||
## License | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2015 Mark van Seventer | ||
|
||
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* The MIT License (MIT) | ||
* | ||
* Copyright (c) 2015 Mark van Seventer | ||
* | ||
* 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 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. | ||
**/ | ||
|
||
// Strict mode. | ||
'use strict'; | ||
|
||
// Package modules. | ||
var assign = require('object-assign'); | ||
|
||
// Local modules. | ||
var filter = require('./lib/filter.js'); | ||
|
||
// Configure. | ||
hexo.config.more_css = assign({ | ||
enabled : true, | ||
exclude : [ '*.min.css' ], | ||
radical : true | ||
}, hexo.config.more_css); | ||
|
||
// Register the filter. | ||
hexo.extend.filter.register('after_render:css', filter); |
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,58 @@ | ||
/** | ||
* The MIT License (MIT) | ||
* | ||
* Copyright (c) 2015 Mark van Seventer | ||
* | ||
* 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 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. | ||
**/ | ||
|
||
// Strict mode. | ||
'use strict'; | ||
|
||
// Package modules. | ||
var minimatch = require('minimatch'), | ||
moreCss = require('more-css'); | ||
|
||
// Exports. | ||
module.exports = function(str, locals) { | ||
// Init. | ||
var hexo = this, | ||
config = hexo.config.more_css, | ||
exclude = config.exclude; | ||
|
||
// Return original if disabled. | ||
if(false === config.enabled) { | ||
return str; | ||
} | ||
|
||
// Format exclusion patterns. | ||
if(!Array.isArray(exclude)) { | ||
exclude = [ exclude ]; | ||
} | ||
|
||
// Return original if the file was excluded. | ||
for(var i = 0; i < exclude.length; i += 1) { | ||
if(minimatch(locals.path, exclude[i])) { | ||
return str; | ||
} | ||
} | ||
|
||
// Return the result. | ||
return moreCss.compress(str, config.radical); | ||
}; |
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,27 @@ | ||
{ | ||
"name" : "hexo-more-css", | ||
"version" : "0.1.0-dev", | ||
"description" : "more-css plugin for Hexo.", | ||
"keywords" : [ "hexo", "more-css", "plugin" ], | ||
"homepage" : "https://github.com/vseventer/hexo-more-css", | ||
"bugs" : "https://github.com/vseventer/hexo-more-css/issues", | ||
"license" : "MIT", | ||
"author" : "Mark van Seventer <mark@vseventer.com>", | ||
"repository" : { "type": "git", "url": "vseventer/hexo-more-css" }, | ||
"main" : "./index.js", | ||
"scripts" : { | ||
"pretest" : "./node_modules/.bin/jshint --reporter=./node_modules/jshint-stylish lib/ test/ *.js", | ||
"test" : "./node_modules/.bin/mocha test/" | ||
}, | ||
"dependencies": { | ||
"minimatch" : "2.0.x", | ||
"more-css" : "0.12.x", | ||
"object-assign" : "3.0.x" | ||
}, | ||
"devDependencies": { | ||
"jshint" : "2.8.x", | ||
"jshint-stylish": "2.0.x", | ||
"mocha" : "2.2.x" | ||
}, | ||
"engines": { "node" : ">=0.10.x" } | ||
} |
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,16 @@ | ||
{ | ||
"indent" : 2, | ||
"latedef" : true, | ||
"newcap" : true, | ||
"nonew" : true, | ||
"plusplus" : true, | ||
"quotmark" : "single", | ||
|
||
"node": true, | ||
|
||
"globals": { | ||
"describe" : true, | ||
"expect" : true, | ||
"it" : 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,76 @@ | ||
/** | ||
* The MIT License (MIT) | ||
* | ||
* Copyright (c) 2015 Mark van Seventer | ||
* | ||
* 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 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. | ||
**/ | ||
|
||
// Strict mode. | ||
'use strict'; | ||
|
||
// Local modules. | ||
var subject = require('../lib/filter.js'); | ||
|
||
// Test suite. | ||
describe('hexo-more-css', function() { | ||
// Tests. | ||
it('should compress CSS.', function() { | ||
// Configure. | ||
var data = 'div { color: black }'; | ||
var hexo = { | ||
config: { | ||
more_css: { exclude: [ ] } | ||
} | ||
}; | ||
|
||
// Filter and test. | ||
var result = subject.call(hexo, data, { path: '123' }); | ||
var expected = 'div{color:#000}'; | ||
console.assert(result === expected); | ||
}); | ||
|
||
it('should exclude files.', function() { | ||
// Configure. | ||
var data = 'div { color: black }'; | ||
var hexo = { | ||
config: { | ||
more_css: { exclude: '**' } | ||
} | ||
}; | ||
|
||
// Filter and test. | ||
var result = subject.call(hexo, data, { path: '123' }); | ||
console.assert(result === data); | ||
}); | ||
|
||
it('should do nothing if disabled.', function() { | ||
// Configure. | ||
var data = 'div { color: black }'; | ||
var hexo = { | ||
config: { | ||
more_css: { enabled: false, exclude: [ ] } | ||
} | ||
}; | ||
|
||
// Filter and test. | ||
var result = subject.call(hexo, data, { path: '123' }); | ||
console.assert(result === data); | ||
}); | ||
}); |
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,5 @@ | ||
--check-leaks | ||
--no-exit | ||
--reporter spec | ||
--timeout 100 | ||
--ui bdd |