Permalink
Browse files

Update to 2.1.0

  • Loading branch information...
1 parent 1425e10 commit 48d30bca2771491412eb7a48ece1823cce5a6e93 @RobLoach RobLoach committed Dec 13, 2013
View
5 .gitignore
@@ -1,8 +1,9 @@
-# v1.3.5 October 31, 2013
+# v1.3.10 December 10, 2013
# https://github.com/bevry/base
# Temp Files
**/*.log
+**/.docpad.db
# Build Files
build/
@@ -14,4 +15,4 @@ out/
# =====================================
# CUSTOM MODIFICATIONS
-test/.docpad.db
+# None
View
3 .npmignore
@@ -1,8 +1,9 @@
-# v1.3.3 October 26, 2013
+# v1.3.10 December 10, 2013
# https://github.com/bevry/base
# Temp Files
**/*.log
+**/.docpad.db
# Build Files
build/
View
5 .travis.yml
@@ -5,8 +5,11 @@ install: "npm install; ./node_modules/.bin/cake install"
before_script: "./node_modules/.bin/cake compile"
script: "npm test"
node_js:
+ - "0.8"
- "0.10"
notifications:
irc:
- "irc.freenode.org#bevry-dev"
- email: false
+ email:
+ recipients:
+ - travisci@bevry.me
View
66 CONTRIBUTING.md
@@ -1,12 +1,19 @@
<!--
-v1.3.9 November 17, 2013
+v1.3.10 December 10, 2013
https://github.com/bevry/base
-->
# Contribute
+## Resources
+
+- [Coding Standards](http://bevry.me/bevry/coding-standards)
+- [Documentation Guidelines](http://bevry.me/bevry/documentation-guidelines)
+- [Support Guidelines](http://bevry.me/bevry/support-guidelines)
+
+
## Development
For developers and contributors
@@ -15,31 +22,31 @@ For developers and contributors
2. Install global dependencies
- ``` bash
- npm install -g coffee-script
- ```
+ ``` bash
+ npm install -g coffee-script
+ ```
3. Install local dependencies
- ``` bash
- cake install
- ```
+ ``` bash
+ cake install
+ ```
4. Compile project
- ``` bash
- # Only once
- cake compile
+ ``` bash
+ # Only once
+ cake compile
- # On every change
- cake watch
- ```
+ # On every change
+ cake watch
+ ```
5. Run tests
- ``` bash
- cake test
- ```
+ ``` bash
+ cake test
+ ```
## Publishing
@@ -48,27 +55,28 @@ For project maintainers
1. Update meta files with latest information
- ``` bash
- cake prepublish
- ```
+ ``` bash
+ cake prepublish
+ ```
2. Add a changelog entry to `HISTORY.md` with change information
- ```
- v2.0.0 April 17, 2013
- - Something that changes
- ```
+ ```
+ v2.0.0 April 17, 2013
+ - Something that changes
+ ```
3. Update `version` entry in `package.json` with new version number
4. Commit changes
- ``` bash
- git commit -a -m "A message about what changed"
- ```
+ ``` bash
+ git commit -a -m "A message about what changed"
+ ```
5. Publish new version
+
+ ``` bash
+ cake publish
+ ```
- ``` bash
- cake publish
- ```
View
213 Cakefile
@@ -1,4 +1,4 @@
-# v1.3.8 November 7, 2013
+# v1.3.12 December 13, 2013
# https://github.com/bevry/base
@@ -12,32 +12,45 @@ pathUtil = require('path')
# =====================================
# Variables
-WINDOWS = process.platform.indexOf('win') is 0
-NODE = process.execPath
-NPM = (if WINDOWS then process.execPath.replace('node.exe', 'npm.cmd') else 'npm')
-EXT = (if WINDOWS then '.cmd' else '')
-APP_DIR = process.cwd()
-PACKAGE_PATH = pathUtil.join(APP_DIR, "package.json")
-PACKAGE_DATA = require(PACKAGE_PATH)
-DOCS_DIR = pathUtil.join(APP_DIR, "docs")
-DOCS_INPUT = pathUtil.join(APP_DIR, "src", "lib", "*")
-SRC_DIR = pathUtil.join(APP_DIR, "src")
-OUT_DIR = pathUtil.join(APP_DIR, "out")
-TEST_DIR = pathUtil.join(APP_DIR, "test")
-MODULES_DIR = pathUtil.join(APP_DIR, "node_modules")
-DOCPAD_DIR = pathUtil.join(MODULES_DIR, "docpad")
-BIN_DIR = pathUtil.join(MODULES_DIR, ".bin")
-GIT = "git"
-CAKE = pathUtil.join(BIN_DIR, "cake#{EXT}")
-COFFEE = pathUtil.join(BIN_DIR, "coffee#{EXT}")
-PROJECTZ = pathUtil.join(BIN_DIR, "projectz#{EXT}")
-DOCCO = pathUtil.join(BIN_DIR, "docco#{EXT}")
+WINDOWS = process.platform.indexOf('win') is 0
+NODE = process.execPath
+NPM = (if WINDOWS then process.execPath.replace('node.exe', 'npm.cmd') else 'npm')
+EXT = (if WINDOWS then '.cmd' else '')
+GIT = "git"
+
+APP_PATH = process.cwd()
+PACKAGE_PATH = pathUtil.join(APP_PATH, "package.json")
+PACKAGE_DATA = require(PACKAGE_PATH)
+
+MODULES_PATH = pathUtil.join(APP_PATH, "node_modules")
+DOCPAD_PATH = pathUtil.join(MODULES_PATH, "docpad")
+BIN_PATH = pathUtil.join(MODULES_PATH, ".bin")
+CAKE = pathUtil.join(BIN_PATH, "cake" + EXT)
+COFFEE = pathUtil.join(BIN_PATH, "coffee" + EXT)
+PROJECTZ = pathUtil.join(BIN_PATH, "projectz" + EXT)
+DOCCO = pathUtil.join(BIN_PATH, "docco" + EXT)
+DOCPAD = pathUtil.join(BIN_PATH, "docpad" + EXT)
+
+config = {}
+config.TEST_PATH = "test"
+config.DOCCO_SRC_PATH = null
+config.DOCCO_OUT_PATH = "docs"
+config.COFFEE_SRC_PATH = "src" # eventually we'll set this to null, right now it isn't for b/c compat
+config.COFFEE_OUT_PATH = "out"
+config.DOCPAD_SRC_PATH = null
+config.DOCPAD_OUT_PATH = "out"
+
+for own key,value of (PACKAGE_DATA.cakeConfiguration or {})
+ config[key] = value
+
+for own key,value of config
+ config[key] = pathUtil.resolve(APP_PATH, value) if value
# =====================================
# Generic
-{exec,spawn} = require('child_process')
+{spawn, exec} = require('child_process')
safe = (next,fn) ->
fn ?= next # support only one argument
return (err) ->
@@ -65,9 +78,14 @@ finish = (err) ->
actions =
clean: (opts,next) ->
+ # Prepare
(next = opts; opts = {}) unless next?
- args = ['-Rf', OUT_DIR]
- for path in [APP_DIR, TEST_DIR]
+
+ # Add compilation paths
+ args = ['-Rf', config.COFFEE_OUT_PATH, config.DOCPAD_OUT_PATH, config.DOCCO_OUT_PATH]
+
+ # Add common ignore paths
+ for path in [APP_PATH, config.TEST_PATH]
args.push(
pathUtil.join(path, 'build')
pathUtil.join(path, 'components')
@@ -76,79 +94,138 @@ actions =
pathUtil.join(path, '*out')
pathUtil.join(path, '*log')
)
+
# rm
- spawn('rm', args, {stdio:'inherit', cwd:APP_DIR}).on('close', safe next)
+ console.log('clean')
+ spawn('rm', args, {stdio:'inherit', cwd:APP_PATH}).on('close', safe next)
install: (opts,next) ->
+ # Prepare
(next = opts; opts = {}) unless next?
+
+ # Steps
step1 = ->
- # npm install (for app)
- spawn(NPM, ['install'], {stdio:'inherit', cwd:APP_DIR}).on('close', safe next, step2)
+ console.log('npm install (for app)')
+ spawn(NPM, ['install'], {stdio:'inherit', cwd:APP_PATH}).on('close', safe next, step2)
step2 = ->
- fsUtil.exists TEST_DIR, (exists) ->
- return next() unless exists
- # npm install (for test)
- spawn(NPM, ['install'], {stdio:'inherit', cwd:TEST_DIR}).on('close', safe next, step3)
+ return step3() if !config.TEST_PATH or !fsUtil.existsSync(config.TEST_PATH)
+ console.log('npm install (for test)')
+ spawn(NPM, ['install'], {stdio:'inherit', cwd:config.TEST_PATH}).on('close', safe next, step3)
step3 = ->
- fsUtil.exists DOCPAD_DIR, (exists) ->
- return next() unless exists
- # npm install (for test)
- spawn(NPM, ['install'], {stdio:'inherit', cwd:DOCPAD_DIR}).on('close', safe next)
+ return step4() if !fsUtil.existsSync(DOCPAD_PATH)
+ console.log('npm install (for docpad tests)')
+ spawn(NPM, ['install'], {stdio:'inherit', cwd:DOCPAD_PATH}).on('close', safe next, step4)
+ step4 = next
+
+ # Start
step1()
compile: (opts,next) ->
+ # Prepare
(next = opts; opts = {}) unless next?
- # cake install
- actions.install opts, safe next, ->
- # coffee compile
- spawn(COFFEE, ['-co', OUT_DIR, SRC_DIR], {stdio:'inherit', cwd:APP_DIR}).on('close', safe next)
+
+ # Steps
+ step1 = ->
+ console.log('cake install')
+ actions.install(opts, safe next, step2)
+ step2 = ->
+ return step3() if !config.COFFEE_SRC_PATH or !fsUtil.existsSync(COFFEE)
+ console.log('coffee compile')
+ spawn(COFFEE, ['-co', config.COFFEE_OUT_PATH, config.COFFEE_SRC_PATH], {stdio:'inherit', cwd:APP_PATH}).on('close', safe next, step3)
+ step3 = ->
+ return step4() if !config.DOCPAD_SRC_PATH or !fsUtil.existsSync(DOCPAD)
+ console.log('docpad generate')
+ spawn(DOCPAD, ['generate'], {stdio:'inherit', cwd:APP_PATH}).on('close', safe next, step4)
+ step4 = next
+
+ # Start
+ step1()
watch: (opts,next) ->
+ # Prepare
(next = opts; opts = {}) unless next?
- # cake install
- actions.install opts, safe next, ->
- # coffee watch
- spawn(COFFEE, ['-wco', OUT_DIR, SRC_DIR], {stdio:'inherit', cwd:APP_DIR}).on('close', safe next)
+
+ # Steps
+ step1 = ->
+ console.log('cake install')
+ actions.install(opts, safe next, step2)
+ step2 = ->
+ return step3() if !config.COFFEE_SRC_PATH or !fsUtil.existsSync(COFFEE)
+ console.log('coffee watch')
+ spawn(COFFEE, ['-wco', config.COFFEE_OUT_PATH, config.COFFEE_SRC_PATH], {stdio:'inherit', cwd:APP_PATH}).on('close', safe next, step3)
+ step3 = ->
+ return step4() if !config.DOCPAD_SRC_PATH or !fsUtil.existsSync(DOCPAD)
+ console.log('docpad run')
+ spawn(DOCPAD, ['run'], {stdio:'inherit', cwd:APP_PATH}).on('close', safe next, step4)
+ step4 = next
+
+ # Start
+ step1()
test: (opts,next) ->
+ # Prepare
(next = opts; opts = {}) unless next?
- # cake compile
- actions.compile opts, safe next, ->
- # npm test
- spawn(NPM, ['test'], {stdio:'inherit', cwd:APP_DIR}).on('close', safe next)
+
+ # Steps
+ step1 = ->
+ console.log('cake compile')
+ actions.compile(opts, safe next, step2)
+ step2 = ->
+ console.log('npm test')
+ spawn(NPM, ['test'], {stdio:'inherit', cwd:APP_PATH}).on('close', safe next, step3)
+ step3 = next
+
+ # Start
+ step1()
prepublish: (opts,next) ->
+ # Prepare
(next = opts; opts = {}) unless next?
+
+ # Steps
step1 = ->
- # cake compile
+ console.log('cake compile')
actions.compile(opts, safe next, step2)
step2 = ->
- # project compile
- fsUtil.exists PROJECTZ, (exists) ->
- return step3() unless exists
- spawn(PROJECTZ, ['compile'], {stdio:'inherit', cwd:APP_DIR}).on('close', safe next, step3)
+ return step3() if !fsUtil.existsSync(PROJECTZ)
+ console.log('projectz compile')
+ spawn(PROJECTZ, ['compile'], {stdio:'inherit', cwd:APP_PATH}).on('close', safe next, step3)
step3 = ->
- # docco compile
- fsUtil.exists DOCCO, (exists) ->
- return step4() unless exists
- exec("#{DOCCO} -o #{DOCS_DIR} #{DOCS_INPUT}", {stdio:'inherit', cwd:APP_DIR}, safe next, step4)
+ return step4() if !config.DOCCO_SRC_PATH or !fsUtil.existsSync(DOCCO)
+ console.log('docco compile')
+ exec("#{DOCCO} -o #{config.DOCCO_OUT_PATH} #{config.DOCCO_SRC_PATH}", {stdio:'inherit', cwd:APP_PATH}, safe next, step4)
step4 = ->
- # npm test
- actions.test(opts, safe next)
+ console.log('cake test')
+ actions.test(opts, safe next, step5)
+ step5 = next
+
+ # Start
step1()
publish: (opts,next) ->
+ # Prepare
(next = opts; opts = {}) unless next?
- # cake prepublish
- actions.prepublish opts, safe next, ->
- # npm publish
- spawn(NPM, ['publish'], {stdio:'inherit', cwd:APP_DIR}).on 'close', safe next, ->
- # git tag
- spawn(GIT, ['tag', 'v'+PACKAGE_DATA.version, '-a'], {stdio:'inherit', cwd:APP_DIR}).on 'close', safe next, ->
- # git push origin master
- spawn(GIT, ['push', 'origin', 'master'], {stdio:'inherit', cwd:APP_DIR}).on 'close', safe next, ->
- # git push tags
- spawn(GIT, ['push', 'origin', '--tags'], {stdio:'inherit', cwd:APP_DIR}).on('close', safe next)
+
+ # Steps
+ step1 = ->
+ console.log('cake prepublish')
+ actions.prepublish(opts, safe next, step2)
+ step2 = ->
+ console.log('npm publish')
+ spawn(NPM, ['publish'], {stdio:'inherit', cwd:APP_PATH}).on('close', safe next, step3)
+ step3 = ->
+ console.log('git tag')
+ spawn(GIT, ['tag', 'v'+PACKAGE_DATA.version, '-a'], {stdio:'inherit', cwd:APP_PATH}).on('close', safe next, step4)
+ step4 = ->
+ console.log('git push origin master')
+ spawn(GIT, ['push', 'origin', 'master'], {stdio:'inherit', cwd:APP_PATH}).on('close', safe next, step5)
+ step5 = ->
+ console.log('git push tags')
+ spawn(GIT, ['push', 'origin', '--tags'], {stdio:'inherit', cwd:APP_PATH}).on('close', safe next, step6)
+ step6 = next
+
+ # Start
+ step1()
# =====================================
View
4 HISTORY.md
@@ -1,7 +1,9 @@
# History
-- v2.0.1 <date>
+- v2.1.0 December 13th, 2013
- Updated documentation
+ - Updated to latest Base
+ - Acts on all .css documents
- v2.0.0 December 6th, 2013
- First release
View
2 LICENSE.md
@@ -1,3 +1,5 @@
+<!-- LICENSEFILE -->
+
LICENSE
=======
View
13 README.md
@@ -5,10 +5,10 @@
[![Gittip button](http://img.shields.io/gittip/RobLoach.png)](https://www.gittip.com/RobLoach/ "Support this project using Gittip")
[![Flattr button](http://img.shields.io/flattr/donate.png?color=yellow)](http://flattr.com/thing/2257574/RobLoach "Support this project using Flattr")
-Allows minification of CSS, using [clean-css](http://github.com/GoalSmashers/clean-css),
-from within [DocPad](https://docpad.org).
+Allows minification of CSS from within [DocPad](https://docpad.org), using
+[clean-css](http://github.com/GoalSmashers/clean-css).
-Convention: `.css.cssmin.anything`
+Convention: `.css.anything`
## Install
@@ -55,7 +55,8 @@ plugins:
### Template Configuration
-It is possible to override the default configuration on a per-template basis:
+It is possible to override the default configuration on a per-template basis. In
+this example, we are acting on `src/documents/style.css`:
``` css
---
@@ -64,9 +65,9 @@ cssmin:
---
/**
- * The style.css file will be imported directly into this document.
+ * The import.css file will be imported directly into this document.
*/
-@import 'style.css';
+@import 'import.css';
```
View
20 cyclic.js
@@ -1,13 +1,13 @@
// v1.3.7 November 1, 2013
// https://github.com/bevry/base
(function(){
- var fsUtil = require('fs'),
- name = require('./package.json').name;
- if ( fsUtil.existsSync('.git') === true && fsUtil.existsSync('./node_modules/'+name) === false ) {
- require('child_process').spawn(
- process.platform.indexOf('win') === 0 ? process.execPath.replace('node.exe', 'npm.cmd') : 'npm',
- ['install', '--force', name],
- {env:process.env, cwd:process.cwd(), stdio:'inherit'}
- ).on('error', console.log).on('close', console.log);
- }
-})()
+ var fsUtil = require('fs'),
+ name = require('./package.json').name;
+ if ( fsUtil.existsSync('.git') === true && fsUtil.existsSync('./node_modules/'+name) === false ) {
+ require('child_process').spawn(
+ process.platform.indexOf('win') === 0 ? process.execPath.replace('node.exe', 'npm.cmd') : 'npm',
+ ['install', '--force', name],
+ {env:process.env, cwd:process.cwd(), stdio:'inherit'}
+ ).on('error', console.log).on('close', console.log);
+ }
+})()
View
3 package.json
@@ -1,6 +1,7 @@
{
"name": "docpad-plugin-cssmin",
- "version": "2.0.1",
+ "title": "CSS-Minifier Plugin for DocPad",
+ "version": "2.1.0",
"description": "Adds support to minify CSS in DocPad.",
"license": "MIT",
"homepage": "http://github.com/robloach/docpad-plugin-cssmin",
View
19 src/cssmin.plugin.coffee
@@ -26,26 +26,31 @@ module.exports = (BasePlugin) ->
# Chain
@
- render: (opts,next) ->
+ renderDocument: (opts,next) ->
# Prepare.
- {inExtension,outExtension,templateData, file} = opts
+ {extension, templateData, file, content} = opts
- # Ensure we are minifying the CSS.
- if inExtension in ['cssmin'] and outExtension in ['css', null]
+ # Ensure we are acting on a Stylesheet document.
+ if extension == 'css' and file.type == 'document'
# Prepare
config = @getConfig()
+ cssminOptions = {}
+
+ # Allow use of global config options.
+ for own key, value of config
+ cssminOptions[key] = value
# Allow overriding using the document options
if templateData.document.cssmin or false
for own key, value of templateData.document.cssmin
- config[key] = value
+ cssminOptions[key] = value
# Add in any more needed CleanCSS options.
- config.relativeTo = file.attributes.fullDirPath
+ cssminOptions.relativeTo = file.attributes.fullDirPath
# Render
try
- opts.content = new @CleanCSS(config).minify(opts.content)
+ opts.content = new @CleanCSS(cssminOptions).minify(opts.content)
catch err
return next(err)
View
4 test/out-expected/defaults.css
@@ -1,3 +1,5 @@
/*!
+ * defaults.css
+ *
* This special comment is kept in the CSS due to docpad.cson.
- */h1{color:red}@import "no-cssmin.css";
+ */h1{color:red}@import "processImport.css";
View
1 test/out-expected/import.css
@@ -1 +0,0 @@
-h2{color:#ff0}h3{color:#00f}
View
6 test/out-expected/no-cssmin.css
@@ -1,6 +0,0 @@
-/**
- * This CSS file is not minified.
- */
- h3 {
- color: blue;
-}
View
3 test/out-expected/processImport-import.css
@@ -0,0 +1,3 @@
+/*!
+ * processImport-import.css
+ */h3{color:#00f}
View
3 test/out-expected/processImport.css
@@ -0,0 +1,3 @@
+/*!
+ * processImport.css
+ */h2{color:#ff0}h3{color:#00f}
View
4 test/src/documents/defaults.css.cssmin → test/src/documents/defaults.css
@@ -1,4 +1,6 @@
/*!
+ * defaults.css
+ *
* This special comment is kept in the CSS due to docpad.cson.
*/
@@ -16,4 +18,4 @@ h1 {
/**
* This import should stay as just a @import.
*/
-@import "no-cssmin.css";
+@import "processImport.css";
View
6 test/src/documents/no-cssmin.css
@@ -1,6 +0,0 @@
-/**
- * This CSS file is not minified.
- */
- h3 {
- color: blue;
-}
View
10 test/src/documents/processImport-import.css
@@ -0,0 +1,10 @@
+/*!
+ * processImport-import.css
+ */
+
+/**
+ * This CSS file is imported.
+ */
+h3 {
+ color: blue;
+}
View
6 test/src/documents/import.css.cssmin → test/src/documents/processImport.css
@@ -3,6 +3,10 @@ cssmin:
processImport: true
---
+/*!
+ * processImport.css
+ */
+
/**
* Standard CSS to see where the document is.
*/
@@ -13,4 +17,4 @@ h2 {
/**
* This import is brought into the actual document.
*/
-@import "no-cssmin.css";
+@import "processImport-import.css";

0 comments on commit 48d30bc

Please sign in to comment.