Comparing version 0.0.1 to 0.0.2
115
Gruntfile.js
@@ -5,6 +5,14 @@ module.exports = function(grunt) { | ||
grunt.initConfig({ | ||
// manifest file | ||
/** | ||
* Manifest file | ||
*/ | ||
pkg : grunt.file.readJSON('package.json'), | ||
/** | ||
* Engine configuration file | ||
*/ | ||
engines : grunt.file.readJSON('config/engines.json'), | ||
/** | ||
* The path of the assets source files | ||
@@ -24,3 +32,3 @@ * | ||
/** | ||
* Choose the CSS preprocessor (stylus, sass, scss) | ||
* Choose the CSS preprocessor (css, stylus, sass, scss) | ||
* | ||
@@ -32,2 +40,24 @@ * @var string | ||
/** | ||
* Choose the CSS preprocessor (js, coffee) | ||
* | ||
* @var string | ||
*/ | ||
jsPreprocessor : 'coffee', | ||
/** | ||
* Compiles the stylesheets source directory to the stylesheets public directory | ||
* | ||
* @task cssmin | ||
*/ | ||
cssmin : { | ||
build : { | ||
expand : true, | ||
cwd : '<%= srcPath %>/stylesheets/', | ||
src : '**/*.css', | ||
dest : '<%= publicPath %>/css/', | ||
ext : '.min.css' | ||
} | ||
}, | ||
/** | ||
* Clean folders | ||
@@ -44,2 +74,32 @@ * | ||
/** | ||
* Compiles the javascript source directory and outputs the files to javascripts public directory | ||
* | ||
* @task coffee | ||
*/ | ||
coffee : { | ||
options : { | ||
join : true | ||
}, | ||
build : { | ||
src : ['<%= srcPath %>/javascripts/**/*.coffee'], | ||
dest : '<%= publicPath %>/js/site.js' | ||
} | ||
}, | ||
/** | ||
* Copies files from the source directory to the public directory | ||
* | ||
* @task copy | ||
*/ | ||
copy : { | ||
js : { | ||
expand : true, | ||
cwd : '<%= srcPath %>/javascripts/', | ||
src : '**/*.js', | ||
dest : '<%= publicPath %>/js/', | ||
ext : '.js' | ||
} | ||
}, | ||
/** | ||
* Minifies image files form the source directory to the public directory | ||
@@ -66,5 +126,2 @@ * | ||
stylus : { | ||
options : { | ||
compress : true | ||
}, | ||
build : { | ||
@@ -98,17 +155,2 @@ expand : true, | ||
/** | ||
* Compiles the javascript source directory and outputs the files to javascripts public directory | ||
* | ||
* @task coffee | ||
*/ | ||
coffee : { | ||
options : { | ||
join : true | ||
}, | ||
build : { | ||
src : ['<%= srcPath %>/javascripts/**/*.coffee'], | ||
dest : '<%= publicPath %>/js/site.js' | ||
} | ||
}, | ||
/** | ||
* Uglifies the javascript source directory and outputs the files to javascripts public directory | ||
@@ -136,3 +178,3 @@ * | ||
src : { | ||
files : ['<%= srcPath %>/js/**/*.js', '<%= srcPath %>/stylesheets/**/*.{styl,sass,scss}'], | ||
files : ['<%= srcPath %>/javascripts/**/*.{js,coffee}', '<%= srcPath %>/stylesheets/**/*.{css,styl,sass,scss}'], | ||
tasks : ['default'] | ||
@@ -147,2 +189,4 @@ } | ||
grunt.loadNpmTasks('grunt-contrib-coffee'); | ||
grunt.loadNpmTasks('grunt-contrib-copy'); | ||
grunt.loadNpmTasks('grunt-contrib-cssmin'); | ||
grunt.loadNpmTasks('grunt-contrib-imagemin'); | ||
@@ -154,12 +198,31 @@ grunt.loadNpmTasks('grunt-contrib-sass'); | ||
// An array of tasks to run | ||
var tasks = ['clean', 'imagemin']; | ||
// Set the JS preprocessor | ||
jsPreprocessor = grunt.config.get('engines').js || grunt.config.get('jsPreprocessor'); | ||
switch(jsPreprocessor) { | ||
case 'js': | ||
tasks.push('copy:js'); | ||
break; | ||
case 'coffee': | ||
default: | ||
tasks.push('coffee'); | ||
break; | ||
} | ||
tasks.push('uglify'); | ||
// Set the CSS preprocessor | ||
cssPreprocessor = 'stylus'; | ||
switch(grunt.config.get('cssPreprocessor')) { | ||
cssPreprocessor = grunt.config.get('engines').css || grunt.config.get('cssPreprocessor'); | ||
switch(cssPreprocessor) { | ||
case 'sass': | ||
case 'scss': | ||
cssPreprocessor = 'sass'; | ||
tasks.push('sass'); | ||
break; | ||
case 'css': | ||
tasks.push('cssmin'); | ||
break; | ||
case 'stylus': | ||
default: | ||
cssPreprocessor = 'stylus'; | ||
tasks.push('stylus'); | ||
break; | ||
@@ -169,4 +232,4 @@ } | ||
// Register the default task | ||
grunt.registerTask('default', ['clean', 'imagemin', 'coffee', 'uglify', cssPreprocessor]); | ||
grunt.registerTask('default', tasks); | ||
}; |
{ | ||
"name": "cafesuada", | ||
"description": "A CoffeeScript-based MVC framework built on top of ExpressJS.", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"homepage": "https://github.com/vutran/cafesuada", | ||
@@ -22,3 +22,5 @@ "repository": { | ||
"grunt-contrib-coffee": "~0.7.0", | ||
"grunt-contrib-uglify": "~0.2.7" | ||
"grunt-contrib-uglify": "~0.2.7", | ||
"grunt-contrib-copy": "~0.4.1", | ||
"grunt-contrib-cssmin": "~0.7.0" | ||
}, | ||
@@ -30,2 +32,2 @@ "engines": { | ||
"license": "MIT" | ||
} | ||
} |
/* | ||
Misc. JS module | ||
# Misc. JS module | ||
*/ | ||
@@ -14,3 +14,3 @@ | ||
/* | ||
The main site object | ||
# The main site object | ||
*/ | ||
@@ -17,0 +17,0 @@ |
# Cafe Sua Da | ||
A CoffeeScript-based MVC framework built on top of ExpressJS. | ||
A CoffeeScript-based MVC framework built on top of the Express framework and Grunt. | ||
@@ -14,3 +14,3 @@ # Features | ||
`foreman start` or `node app.js` | ||
`foreman start` or `coffee app.coffee` | ||
@@ -27,6 +27,56 @@ ## Default Local URL | ||
## `engines.json` | ||
Speciy a compiler to use for your application's assets and view renderer | ||
### Options | ||
#### html | ||
Type: `String` Default: `ejs` | ||
This is used to define the view rendering engine for the application. | ||
***Currently Supports:*** | ||
* `ejs` | ||
#### css | ||
Type: `String` Default: `stylus` | ||
This is used to define the CSS framework to use for handling your CSS assets with Grunt. | ||
***Currently Supports:*** | ||
* `css` | ||
* `stylus` | ||
* `scss` | ||
* `sass` | ||
#### js | ||
Type: `String` Default: `coffee` | ||
This is used to define the JS framework to use for handling your JS assets with Grunt. | ||
***Currently Supports:*** | ||
* `js` | ||
* `coffee` | ||
### Sample `engines.json` | ||
{ | ||
"html" : "ejs", | ||
"css" : "stylus", | ||
"js" : "coffee" | ||
} | ||
## `paths.js` | ||
You can customize the app folder names here otherwise, leave it as is. | ||
You can customize the app folder names here. | ||
99.99% of the time, you will never ever need to change this. | ||
## `routes.json` | ||
@@ -38,2 +88,10 @@ | ||
| Method | Request URI | Routes File To Be Loaded | | ||
|:---|:---|:---| | ||
| GET | / | /app/routes/index.js | | ||
| GET | /news | /app/routes/news/archive.js | | ||
| GET | /news/:postid/ | /app/routes/news/single | | ||
| POST | /news/:postid/ | /app/routes/news/post.js | | ||
| DELETE | /news/:postid/ | /app/routes/news/delete.js | | ||
### Sample `routes.json` | ||
@@ -49,10 +107,2 @@ | ||
| Method | Request URI | Routes File To Be Loaded | | ||
|:---|:---|:---| | ||
| GET | / | /app/routes/index.js | | ||
| GET | /news | /app/routes/news/archive.js | | ||
| GET | /news/:postid/ | /app/routes/news/single | | ||
| POST | /news/:postid/ | /app/routes/news/post.js | | ||
| DELETE | /news/:postid/ | /app/routes/news/delete.js | | ||
# Building Assets | ||
@@ -64,5 +114,16 @@ | ||
# CHANGELOG | ||
## 0.0.2 | ||
* Fixed `grunt` for JS files | ||
* Added the ability to switch compilers for handling CSS and JS assets | ||
* Cleaned up code/docblocks | ||
## 0.0.1 | ||
* Initial development | ||
# TODOS | ||
* Add support for more views engine | ||
* Better documentation | ||
* Better documentation | ||
* Convert `Gruntfile` to coffeescript |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
14652
24
227
124
10