Skip to content

Commit ce5bc8b

Browse files
committed
update docs
1 parent 595b093 commit ce5bc8b

22 files changed

+181
-250
lines changed

grunt.js Gruntfile.js

+61-26
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@
44
//
55
module.exports = function(grunt) {
66

7-
grunt.loadNpmTasks('grunt-contrib');
7+
grunt.loadNpmTasks('grunt-contrib-clean');
8+
grunt.loadNpmTasks('grunt-contrib-jade');
9+
grunt.loadNpmTasks('grunt-contrib-cssmin');
10+
grunt.loadNpmTasks('grunt-contrib-watch');
11+
grunt.loadNpmTasks('grunt-contrib-copy');
12+
813
grunt.loadTasks("buildtasks");
914

1015
grunt.initConfig({
@@ -63,12 +68,29 @@ module.exports = function(grunt) {
6368
},
6469

6570
jade: {
66-
"./": [
67-
"src/jade/index.jade"
68-
],
69-
"pages": [
70-
"src/jade/pages/**/*.jade"
71-
]
71+
dynamic_mappings: {
72+
// Grunt will search for "**/*.jade" under "client/app/modules/" when the "jade" task
73+
// runs and build the appropriate src-dest file mappings then, so you
74+
// don't need to update the Gruntfile when files are added or removed.
75+
files: [
76+
{
77+
expand: true, // Enable dynamic expansion.
78+
cwd: './', // Src matches are relative to this path.
79+
src: ['src/jade/index.jade'], // Actual pattern(s) to match.
80+
dest: './', // Destination path prefix.
81+
ext: '.html', // Dest filepaths will have this extension.
82+
flatten: true // Remove all path parts from generated destination paths.
83+
},
84+
{
85+
expand: true, // Enable dynamic expansion.
86+
cwd: './', // Src matches are relative to this path.
87+
src: ['src/jade/pages/**/*.jade'], // Actual pattern(s) to match.
88+
dest: 'pages', // Destination path prefix.
89+
ext: '.html', // Dest filepaths will have this extension.
90+
flatten: true // Remove all path parts from generated destination paths.
91+
}
92+
]
93+
}
7294
},
7395

7496
prettify: {
@@ -79,12 +101,21 @@ module.exports = function(grunt) {
79101
},
80102

81103
copy: {
82-
dist: {
83-
options: {
84-
basePath: "public/test/locales"
85-
},
104+
// js: {
105+
// options: { basePath: "client/assets/js/libs" },
106+
// files: {
107+
// "client/dist/release/": ["client/assets/js/libs/raphael.js", "client/assets/js/libs/infoviz.js"]
108+
// }
109+
// },
110+
// css: {
111+
// files: [
112+
// { expand: true, cwd: 'client/assets/css', src: ['client/assets/css/font-awesome-ie7-2.0.css'], dest: 'client/dist/release/' }
113+
// ]
114+
// }
115+
css: {
116+
options: { basePath: "public/test/locales" },
86117
files: {
87-
"pages/locales/": "public/test/locales/**/*"
118+
"pages/locales/": ["public/test/locales/**/*"]
88119
}
89120
}
90121
},
@@ -111,14 +142,18 @@ module.exports = function(grunt) {
111142
// order and concatenate them into a single CSS file named index.css. It
112143
// also minifies all the CSS as well. This is named index.css, because we
113144
// only want to load one stylesheet in index.html.
114-
mincss: {
115-
"public/css/index.css": [
116-
"public/css/bootstrap-2.0.2.css",
117-
"public/css/bootstrap-responsive-2.0.2.css",
118-
"public/css/font-awesome-2.0.css",
119-
"public/css/prettify.css",
120-
"public/css/main.css"
121-
]
145+
cssmin: {
146+
compress: {
147+
files: {
148+
"public/css/index.css": [
149+
"public/css/bootstrap-2.0.2.css",
150+
"public/css/bootstrap-responsive-2.0.2.css",
151+
"public/css/font-awesome-2.0.css",
152+
"public/css/prettify.css",
153+
"public/css/main.css"
154+
]
155+
}
156+
}
122157
},
123158

124159
// Takes the built require.js file and minifies it for filesize benefits.
@@ -193,13 +228,13 @@ module.exports = function(grunt) {
193228

194229
watch: {
195230
jade: {
196-
files: "src/jade/**/*.jade",
197-
tasks: "build"
231+
files: ["src/jade/**/*.jade"],
232+
tasks: ["build"]
198233
},
199234

200235
stylus: {
201-
files: "src/stylus/**/*.styl",
202-
tasks: "build"
236+
files: ["src/stylus/**/*.styl"],
237+
tasks: ["build"]
203238
}
204239
}
205240

@@ -210,14 +245,14 @@ module.exports = function(grunt) {
210245
// dist/debug/templates.js, compile all the application code into
211246
// dist/debug/require.js, and then concatenate the require/define shim
212247
// almond.js and dist/debug/templates.js into the require.js file.
213-
grunt.registerTask("default", "clean jade prettify stylus copy");
248+
grunt.registerTask("default", ["clean", "jade", "prettify", "stylus", "copy"]);
214249

215250
// The debug task is simply an alias to default to remain consistent with
216251
// debug/release.
217252
//grunt.registerTask("debug", "default");
218253

219254
// The release task will run the debug tasks and then minify the
220255
// dist/debug/require.js file and CSS files.
221-
grunt.registerTask("build", "default mincss");
256+
grunt.registerTask("build", ["default", "cssmin"]);
222257

223258
};

buildtasks/handlebars.js

-69
This file was deleted.

buildtasks/jade.js

-52
This file was deleted.

buildtasks/prettify.js

+14-14
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,26 @@
99
*/
1010
var prettify = require('./lib/prettify')
1111
, path = require('path')
12-
, _ = require('underscore');
12+
, _ = require('lodash');
1313

1414
module.exports = function(grunt) {
1515

1616
var config = grunt.config;
1717
var file = grunt.file;
1818
var log = grunt.log;
1919

20+
function exePrettify(src, options) {
21+
var prettifyFn = function(scr, options) {
22+
return src.replace(/<pre><code>[^<]+<\/code><\/pre>/g,
23+
function applyHighlight(code) {
24+
code = code.match(/<code>([\s\S]+)<\/code>/)[1];
25+
code = prettify.prettyPrintOne(code);
26+
return "<pre><code>" + code + "</code></pre>";
27+
});
28+
};
29+
return prettifyFn();
30+
}
31+
2032
// Compiles Jade templates into HTML. Each input file is renamed with a '.html'
2133
// extension. The task name specifies the output directory. Options are
2234
// specified via 'jadeopts'.
@@ -31,24 +43,12 @@ module.exports = function(grunt) {
3143

3244
files.forEach(function (filepath) {
3345
var opts = _.extend(options, {filename: filepath}); console.log(filepath);
34-
var html = grunt.helper('prettify', file.read(filepath), opts);
46+
var html = exePrettify(file.read(filepath), opts);
3547

3648
file.write(filepath, html);
3749

3850
log.writeln('File prittified"' + filepath + '" created.');
3951
});
4052
});
4153

42-
grunt.registerHelper('prettify', function(src, options) {
43-
var prettifyFn = function(scr, options) {
44-
return src.replace(/<pre><code>[^<]+<\/code><\/pre>/g,
45-
function applyHighlight(code) {
46-
code = code.match(/<code>([\s\S]+)<\/code>/)[1];
47-
code = prettify.prettyPrintOne(code);
48-
return "<pre><code>" + code + "</code></pre>";
49-
});
50-
};
51-
return prettifyFn();
52-
});
53-
5454
};

0 commit comments

Comments
 (0)