Skip to content

Commit df69696

Browse files
committed
Added pages from live WordPress site: Types and extending-ajax
1 parent 9744cb5 commit df69696

File tree

3 files changed

+897
-2
lines changed

3 files changed

+897
-2
lines changed

grunt.js

+38-2
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ var // modules
88
spawn = require( "child_process" ).spawn,
99

1010
// files
11+
pageFiles = grunt.file.expandFiles( "pages/*.html" ),
1112
entryFiles = grunt.file.expandFiles( "entries/*.xml" ),
1213
categoryFiles = grunt.file.expandFiles( "categories/*.xml" ),
1314
resourceFiles = grunt.file.expandFiles( "resources/*" ),
1415

15-
xmlFiles = [].concat( entryFiles, categoryFiles );
16+
xmlFiles = [].concat( entryFiles, categoryFiles, "cat2tax.xsl", "categories.xml", "entries2html.xsl", "xml2json.xsl" );
1617

1718
function pathSlug( fileName ) {
1819
return path.basename( fileName, path.extname( fileName ) );
@@ -65,6 +66,41 @@ grunt.registerTask( "xmllint", function() {
6566
});
6667
});
6768

69+
grunt.registerTask( "build-pages", function() {
70+
var task = this,
71+
taskDone = task.async(),
72+
targetDir = grunt.config( "wordpress.dir" ) + "/posts/page/";
73+
74+
grunt.file.mkdir( targetDir );
75+
76+
grunt.utils.async.forEachSeries( pageFiles, function( fileName, fileDone ) {
77+
var targetFileName = targetDir + path.basename( fileName );
78+
grunt.verbose.write( "Reading " + fileName + "..." );
79+
grunt.verbose.write( "Pygmentizing " + targetFileName + "..." );
80+
pygmentize.file( fileName, function( error, data ) {
81+
if ( error ) {
82+
grunt.verbose.error();
83+
grunt.log.error( error );
84+
fileDone();
85+
return;
86+
}
87+
grunt.verbose.ok();
88+
89+
grunt.file.write( targetFileName, data );
90+
91+
fileDone();
92+
});
93+
}, function() {
94+
if ( task.errorCount ) {
95+
grunt.warn( "Task \"" + task.name + "\" failed." );
96+
taskDone();
97+
return;
98+
}
99+
grunt.log.writeln( "Built " + pageFiles.length + " pages." );
100+
taskDone();
101+
});
102+
});
103+
68104
grunt.registerTask( "build-entries", function() {
69105
var task = this,
70106
taskDone = task.async(),
@@ -173,7 +209,7 @@ grunt.registerTask( "build-resources", function() {
173209
});
174210

175211
grunt.registerTask( "default", "build-wordpress" );
176-
grunt.registerTask( "build-wordpress", "clean lint xmllint build-entries build-categories build-resources" );
212+
grunt.registerTask( "build-wordpress", "clean lint xmllint build-pages build-entries build-categories build-resources" );
177213
grunt.registerTask( "deploy", "wordpress-deploy" );
178214

179215
};

0 commit comments

Comments
 (0)